private void paintBackground(Graphics2D g, Color color, float x, int y, float width) { if (width <= 0 || color == null || color.equals(myEditor.getColorsScheme().getDefaultBackground()) || color.equals(myEditor.getBackgroundColor())) return; g.setColor(color); g.fillRect((int) x, y, (int) width, myView.getLineHeight()); }
private void merge(TextAttributes attributes) { Color myBackground = myMergedAttributes.getBackgroundColor(); if (myBackground == null || myDefaultBackground.equals(myBackground)) { myMergedAttributes.setBackgroundColor(attributes.getBackgroundColor()); } Color myForeground = myMergedAttributes.getForegroundColor(); if (myForeground == null || myDefaultForeground.equals(myForeground)) { myMergedAttributes.setForegroundColor(attributes.getForegroundColor()); } if (myMergedAttributes.getFontType() == Font.PLAIN) { myMergedAttributes.setFontType(attributes.getFontType()); } }
private void processBackground(int startOffset, Color background) { if (myBackground == null && background != null && !myDefaultBackground.equals(background)) { addTextIfPossible(startOffset); myBackground = background; builder.addBackground(background); } else if (myBackground != null) { Color c = background == null ? myDefaultBackground : background; if (!myBackground.equals(c)) { addTextIfPossible(startOffset); builder.addBackground(c); myBackground = c; } } }
private void findNextSuitableRange() { myNextAttributes = null; while (myIterator.hasNext()) { RangeHighlighterEx highlighter = myIterator.next(); if (highlighter == null || !highlighter.isValid() || !isInterestedInLayer(highlighter.getLayer())) { continue; } // LINES_IN_RANGE highlighters are not supported currently myNextStart = Math.max(highlighter.getStartOffset(), myStartOffset); myNextEnd = Math.min(highlighter.getEndOffset(), myEndOffset); if (myNextStart >= myEndOffset) { break; } if (myNextStart < myCurrentEnd) { continue; // overlapping ranges withing document markup model are not supported currently } TextAttributes attributes = null; Object tooltip = highlighter.getErrorStripeTooltip(); if (tooltip instanceof HighlightInfo) { HighlightInfo info = (HighlightInfo) tooltip; TextAttributesKey key = info.forcedTextAttributesKey; if (key == null) { HighlightInfoType type = info.type; key = type.getAttributesKey(); } if (key != null) { attributes = myColorsScheme.getAttributes(key); } } if (attributes == null) { continue; } Color foreground = attributes.getForegroundColor(); Color background = attributes.getBackgroundColor(); if ((foreground == null || myDefaultForeground.equals(foreground)) && (background == null || myDefaultBackground.equals(background)) && attributes.getFontType() == Font.PLAIN) { continue; } myNextAttributes = attributes; break; } }
private void processForeground(int startOffset, Color foreground) { if (myForeground == null && foreground != null) { addTextIfPossible(startOffset); myForeground = foreground; builder.addForeground(foreground); } else if (myForeground != null) { Color c = foreground == null ? myDefaultForeground : foreground; if (!myForeground.equals(c)) { addTextIfPossible(startOffset); builder.addForeground(c); myForeground = c; } } }
private void drawSpot( Graphics g, int width, boolean thinErrorStripeMark, int yStart, int yEnd, Color color, boolean drawTopDecoration, boolean drawBottomDecoration) { int x = isMirrored() ? 3 : 5; int paintWidth = width; if (thinErrorStripeMark) { paintWidth /= 2; paintWidth += 1; x = isMirrored() ? width + 2 : 0; } if (color == null) return; g.setColor(color); g.fillRect(x + 1, yStart, paintWidth - 2, yEnd - yStart + 1); Color brighter = color.brighter(); g.setColor(brighter); // left decoration UIUtil.drawLine(g, x, yStart, x, yEnd /* - 1*/); if (drawTopDecoration) { // top decoration UIUtil.drawLine(g, x + 1, yStart, x + paintWidth - 2, yStart); } Color darker = ColorUtil.shift(color, 0.75); g.setColor(darker); if (drawBottomDecoration) { // bottom decoration UIUtil.drawLine( g, x + 1, yEnd /* - 1*/, x + paintWidth - 2, yEnd /* - 1*/); // large bottom to let overwrite by hl below } // right decoration UIUtil.drawLine(g, x + paintWidth - 2, yStart, x + paintWidth - 2, yEnd /* - 1*/); }