private AttributeSet getAttributeSet(String tag) { MutableAttributeSet attr = new SimpleAttributeSet(); Color color = tagToColorMap.get(tag); StyleConstants.setBackground(attr, color); StyleConstants.setForeground(attr, Color.WHITE); return attr; }
private AttributeSet getAttributeSet(String tag) { MutableAttributeSet attr = new SimpleAttributeSet(); Color color = tagToColorMap.get(tag); StyleConstants.setBackground(attr, color); StyleConstants.setForeground(attr, Color.WHITE); return attr; }
@Override public String doInBackground() { if (openfired != null) { // Get the input stream and read from it try (InputStream in = openfired.getErrorStream()) { int c; while ((c = in.read()) != -1) { try { StyleConstants.setForeground(styles, Color.red); pane.getDocument().insertString(pane.getDocument().getLength(), "" + (char)c, styles); } catch (BadLocationException e) { // Ignore. } } } catch (IOException e) { e.printStackTrace(); } } return "ok"; } };
private void removeTags() { if (editorPane.getContentType().equals("text/html")) { editorPane.setText(htmlContents); editorPane.revalidate(); editorPane.repaint(); } else { DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument(); SimpleAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.BLACK); StyleConstants.setBackground(attr, Color.WHITE); doc.setCharacterAttributes(0, doc.getLength(), attr, false); } saveTaggedAs.setEnabled(false); }
private void removeTags() { if (editorPane.getContentType().equals("text/html")) { if (htmlContents != null) { editorPane.setText(htmlContents); } editorPane.revalidate(); editorPane.repaint(); } else { DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument(); SimpleAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.BLACK); StyleConstants.setBackground(attr, Color.WHITE); doc.setCharacterAttributes(0, doc.getLength(), attr, false); } saveTaggedAs.setEnabled(false); }
protected void addStylesToDocument(JTextPane outputArea) { StyledDocument doc = outputArea.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "Monospaced"); promptStyle = doc.addStyle("prompt", regular); StyleConstants.setForeground(promptStyle, Color.BLUE); commandStyle = doc.addStyle("command", regular); StyleConstants.setForeground(commandStyle, Color.MAGENTA); outputStyle = doc.addStyle("output", regular); StyleConstants.setBold(outputStyle, true); }
/** * Write a line to the Log section of the GUI * * @param text the string to log * @param color the color of the line */ private void appendLog(final String text, final Color color) { SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setForeground(sas, color); StyledDocument sd = logText.getStyledDocument(); try { synchronized (this) { sd.insertString(sd.getLength(), text + "\n", sas); } } catch (BadLocationException e) { } logText.setCaretPosition(sd.getLength()); }
StyleConstants.setForeground(comment, COMMENT_COLOR); StyleConstants.setItalic(comment, true); StyleConstants.setForeground(quotes, Color.MAGENTA.darker().darker()); StyleConstants.setForeground(charQuotes, Color.GREEN.darker().darker()); StyleConstants.setForeground(slashyQuotes, Color.ORANGE.darker()); StyleConstants.setForeground(digit, Color.RED.darker()); StyleConstants.setForeground(reservedWords, Color.BLUE.darker().darker());
StyleConstants.setForeground(alertStyle, Color.red);
/** * Create adapter for java console. * @param tabName Default text */ public JavaConsoleAdapter(String tabName, String placeholder) { super(tabName, placeholder); StyleConstants.setForeground(this.attributeTimestamp, Color.RED); }
/** * Create adapter for console. * @param tabName Default text */ public SimpleConsoleAdapter(String tabName, String placeholder) { super(tabName, placeholder); StyleConstants.setForeground(this.attributeTimestamp, new Color(75, 143, 211)); }
/** * Add a colored string to the textpane, measure prompt at the same time. * @param string Text to append * @param color Color of text * @param isAddingPrompt Should we measure prompt length? */ private void appendPrompt(String string, Color color, boolean isAddingPrompt) { try { StyleConstants.setForeground(this.style, color); this.styledDocument.insertString(this.styledDocument.getLength(), string, this.style); if (isAddingPrompt) { this.prompt += string; } } catch (BadLocationException e) { LOGGER.error(e.getMessage(), e); } }
StyleConstants.setForeground(levelStyle, Color.WHITE); StyleConstants.setBackground(levelStyle, Color.BLACK); fatalCount++; case "error": levelText = "Error"; StyleConstants.setForeground(levelStyle, new Color(0xFF291F)); StyleConstants.setBackground(levelStyle, new Color(0xFFF0F0)); errorCount++; case "warn": levelText = "Warning"; StyleConstants.setForeground(levelStyle, new Color(0x614201)); StyleConstants.setBackground(levelStyle, new Color(0xFFFCE5)); warnCount++; case "info": levelText = "Info"; StyleConstants.setForeground(levelStyle, new Color(0x203261)); StyleConstants.setBackground(levelStyle, new Color(0xE2E8FF)); otherCount++; case "debug": levelText = "Debug"; StyleConstants.setForeground(levelStyle, new Color(0x32612E)); StyleConstants.setBackground(levelStyle, new Color(0xF4FFEC)); otherCount++; case "trace":
SimpleAttributeSet set = new SimpleAttributeSet(); StyleConstants.setForeground(set, new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256))); StyleConstants.setFontSize(set, random.nextInt(12) + 12); StyleConstants.setBold(set, random.nextBoolean());
private static void addStyle(String name, Color bg, Color fg, boolean bold, boolean italic) { SimpleAttributeSet style = new SimpleAttributeSet(); StyleConstants.setFontFamily(style, HelperUi.FONT_UBUNTU_MONO.getFontName()); StyleConstants.setFontSize(style, HelperUi.FONT_UBUNTU_MONO.getSize()); StyleConstants.setBackground(style, bg); StyleConstants.setForeground(style, fg); StyleConstants.setBold(style, bold); StyleConstants.setItalic(style, italic); styles.put(name, style); }
private void setForeground(Style style, Color defaultColor, Map<String, Color> overriden) { Color foreground = overriden.get(style.getName()); if (foreground == null) { foreground = defaultColor; } StyleConstants.setForeground(style, foreground == null ? StyleConstants.getForeground( doc.getStyle(StyleContext.DEFAULT_STYLE)) : foreground); }
private void createStyles() { for (Color color : owlEditorKit.getWorkspace().getKeyWordColorMap().values()) { Style style = getStyledDocument().addStyle(color.toString(), null); StyleConstants.setForeground(style, color); StyleConstants.setBold(style, true); } StyleConstants.setForeground(getStyledDocument().addStyle(Color.BLACK.toString(), null), Color.BLACK); }
protected void addStylesToDocument(JTextPane outputArea) { StyledDocument doc = outputArea.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "Monospaced"); promptStyle = doc.addStyle("prompt", regular); StyleConstants.setForeground(promptStyle, Color.BLUE); commandStyle = doc.addStyle("command", regular); StyleConstants.setForeground(commandStyle, Color.MAGENTA); outputStyle = doc.addStyle("output", regular); StyleConstants.setBold(outputStyle, true); }
protected MutableAttributeSet getPrefixStyle() { final MutableAttributeSet style = new SimpleAttributeSet(); StyleConstants.setFontFamily( style, "Dialog" ); StyleConstants.setFontSize( style, SettingsManager.getLocalPreferences().getChatRoomFontSize() ); StyleConstants.setForeground( style, prefixColor ); StyleConstants.setBackground( style, backgroundColor ); return style; }
protected AttributeSet getStyle() { final MutableAttributeSet style = new SimpleAttributeSet(); StyleConstants.setFontFamily( style, "Dialog" ); StyleConstants.setFontSize( style, SettingsManager.getLocalPreferences().getChatRoomFontSize() ); StyleConstants.setForeground( style, textColor ); StyleConstants.setBold( style, bold ); StyleConstants.setItalic( style, italic ); StyleConstants.setUnderline( style, underline ); StyleConstants.setStrikeThrough( style, strikeThrough ); return style; }