public ResultsTableCellRenderer() { RSyntaxTextArea area = CodeArea.getDefaultArea(mainWindow); this.font = area.getFont(); this.codeSelectedColor = area.getSelectionColor(); this.codeBackground = area.getBackground(); }
private byte[] getTextAsRtf(int start, int end) { // Create the RTF selection. RtfGenerator gen = new RtfGenerator(getBackground()); Token tokenList = getTokenListFor(start, end); for (Token t = tokenList; t != null; t = t.getNextToken()) { if (t.isPaintable()) { if (t.length() == 1 && t.charAt(0) == '\n') { gen.appendNewline(); } else { Font font = getFontForTokenType(t.getType()); Color bg = getBackgroundForToken(t); boolean underline = getUnderlineForToken(t); // Small optimization - don't print fg color if this // is a whitespace color. Saves on RTF size. if (t.isWhitespace()) { gen.appendToDocNoFG(t.getLexeme(), font, bg, underline); } else { Color fg = getForegroundForToken(t); gen.appendToDoc(t.getLexeme(), font, fg, bg, underline); } } } } // RTF text is 7-bit ASCII so this should cover us return gen.getRtf().getBytes(StandardCharsets.UTF_8); }
public static String getTextAsHtml(RSyntaxTextArea textArea, int start, int end) { // Create the selection as HTML StringBuilder sb = new StringBuilder("<pre style='") .append("font-family: \"").append(textArea.getFont().getFamily()).append("\", courier;"); if (textArea.getBackground() != null) { // May be null if it is an image sb.append(" background: ") .append(HtmlUtil.getHexString(textArea.getBackground())) .append("'>"); } Token token = textArea.getTokenListFor(start, end); for (Token t = token; t != null; t = t.getNextToken()) { if (t.isPaintable()) { if (t.isSingleChar('\n')) { sb.append("<br>"); } else { sb.append(TokenUtils.tokenToHtml(textArea, t)); } } } sb.append("</pre>"); return sb.toString(); } }
private byte[] getTextAsRtf(int start, int end) { // Create the RTF selection. RtfGenerator gen = new RtfGenerator(getBackground()); Token tokenList = getTokenListFor(start, end); for (Token t = tokenList; t != null; t = t.getNextToken()) { if (t.isPaintable()) { if (t.length() == 1 && t.charAt(0) == '\n') { gen.appendNewline(); } else { Font font = getFontForTokenType(t.getType()); Color bg = getBackgroundForToken(t); boolean underline = getUnderlineForToken(t); // Small optimization - don't print fg color if this // is a whitespace color. Saves on RTF size. if (t.isWhitespace()) { gen.appendToDocNoFG(t.getLexeme(), font, bg, underline); } else { Color fg = getForegroundForToken(t); gen.appendToDoc(t.getLexeme(), font, fg, bg, underline); } } } } // RTF text is 7-bit ASCII so this should cover us return gen.getRtf().getBytes(StandardCharsets.UTF_8); }
bgColor = textArea.getBackground(); caretColor = textArea.getCaretColor(); useSelctionFG = textArea.getUseSelectedTextColor();
public static String getTextAsHtml(RSyntaxTextArea textArea, int start, int end) { // Create the selection as HTML StringBuilder sb = new StringBuilder("<pre style='") .append("font-family: \"").append(textArea.getFont().getFamily()).append("\", courier;"); if (textArea.getBackground() != null) { // May be null if it is an image sb.append(" background: ") .append(HtmlUtil.getHexString(textArea.getBackground())) .append("'>"); } Token token = textArea.getTokenListFor(start, end); for (Token t = token; t != null; t = t.getNextToken()) { if (t.isPaintable()) { if (t.isSingleChar('\n')) { sb.append("<br>"); } else { sb.append(TokenUtils.tokenToHtml(textArea, t)); } } } sb.append("</pre>"); return sb.toString(); } }
/** * Paints the background of a token. * * @param x The x-coordinate of the token. * @param y The y-coordinate of the token. * @param width The width of the token (actually, the width of the part of * the token to paint). * @param height The height of the token. * @param g The graphics context with which to paint. * @param fontAscent The ascent of the token's font. * @param host The text area. * @param color The color with which to paint. */ protected void paintBackground(float x, float y, float width, float height, Graphics2D g, int fontAscent, RSyntaxTextArea host, Color color) { // RSyntaxTextArea's bg can be null, so we must check for this. Color temp = host.getBackground(); g.setXORMode(temp!=null ? temp : Color.WHITE); g.setColor(color); bgRect.setRect(x,y-fontAscent, width,height); g.fill(bgRect); g.setPaintMode(); }
/** * Paints the background of a token. * * @param x The x-coordinate of the token. * @param y The y-coordinate of the token. * @param width The width of the token (actually, the width of the part of * the token to paint). * @param height The height of the token. * @param g The graphics context with which to paint. * @param fontAscent The ascent of the token's font. * @param host The text area. * @param color The color with which to paint. */ protected void paintBackground(float x, float y, float width, float height, Graphics2D g, int fontAscent, RSyntaxTextArea host, Color color) { // RSyntaxTextArea's bg can be null, so we must check for this. Color temp = host.getBackground(); g.setXORMode(temp!=null ? temp : Color.WHITE); g.setColor(color); bgRect.setRect(x,y-fontAscent, width,height); g.fill(bgRect); g.setPaintMode(); }
public static RSyntaxTextArea propertiesTextArea(Theme theme) { final RSyntaxTextArea editorPane = new RSyntaxTextArea(); editorPane.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE); SyntaxScheme scheme = editorPane.getSyntaxScheme(); scheme.getStyle(Token.RESERVED_WORD).foreground = theme.getColor(ThemeKey.LOG_DETAILS_PROPERTY_KEY); scheme.getStyle(Token.OPERATOR).foreground = theme.getColor(ThemeKey.LOG_DETAILS_PROPERTY_KEY); scheme.getStyle(Token.VARIABLE).foreground = theme.getColor(ThemeKey.LOG_DETAILS_PROPERTY_VALUE); scheme.getStyle(Token.LITERAL_STRING_DOUBLE_QUOTE).foreground = theme.getColor(ThemeKey.LOG_DETAILS_PROPERTY_VALUE); scheme.getStyle(Token.COMMENT_EOL).foreground = theme.getColor(ThemeKey.LOG_DETAILS_STACKTRACE_COMMENT); editorPane.setBackground(new JTextArea().getBackground()); Color highlightColor; if (theme.themeType().equals(Theme.Type.Light)){ highlightColor = editorPane.getBackground().darker(); } else { highlightColor = editorPane.getBackground().brighter(); } editorPane.setCurrentLineHighlightColor(highlightColor); editorPane.revalidate(); return editorPane; } }
Gutter gutter) { Assert.assertEquals(Color.red, textArea.getBackground()); Assert.assertEquals(Color.red, textArea.getCaretColor()); Assert.assertEquals(false, textArea.getUseSelectedTextColor());
Assert.assertEquals(textArea1.getBackground(), textArea2.getBackground()); Assert.assertEquals(textArea1.getCaretColor(), textArea2.getCaretColor()); Assert.assertEquals(textArea1.getUseSelectedTextColor(), textArea2.getUseSelectedTextColor());
Assert.assertNotEquals(textArea1.getBackground(), textArea2.getBackground()); Assert.assertNotEquals(textArea1.getCaretColor(), textArea2.getCaretColor()); Assert.assertNotEquals(textArea1.getUseSelectedTextColor(), textArea2.getUseSelectedTextColor());
bgColor = textArea.getBackground(); caretColor = textArea.getCaretColor(); useSelctionFG = textArea.getUseSelectedTextColor();