/** * Constructs a new <code>ConfigurableCaret</code>. * * @param style The style to use when painting the caret. If this is * invalid, then {@link CaretStyle#THICK_VERTICAL_LINE_STYLE} is * used. */ public ConfigurableCaret(CaretStyle style) { seg = new Segment(); setStyle(style); selectionPainter = new ChangeableHighlightPainter(); pasteOnMiddleMouseClick = true; }
if (getAlpha()<1.0f) { originalComposite = g2d.getComposite(); g2d.setComposite(getAlphaComposite()); Rectangle p0 = mapper.modelToView(c, offs0); Rectangle p1 = mapper.modelToView(c, offs1); Paint paint = getPaint(); if (paint==null) { g2d.setColor(c.getSelectionColor()); } finally { if (getAlpha()<1.0f) { g2d.setComposite(originalComposite);
/** * Returns whether this caret's selection uses rounded edges. * * @return Whether this caret's edges are rounded. * @see #setRoundedSelectionEdges */ public boolean getRoundedSelectionEdges() { return ((ChangeableHighlightPainter)getSelectionPainter()). getRoundedEdges(); }
/** * Creates a new highlight painter. * * @param paint The <code>Paint</code> (usually a * <code>java.awt.Color</code>) with which to paint the * highlights. * @param rounded Whether to use rounded edges on the highlights. * @param alpha The alpha value to use when painting highlights. This * value should be in the range <code>0.0f</code> (completely * transparent) through <code>1.0f</code> (opaque). */ public ChangeableHighlightPainter(Paint paint, boolean rounded, float alpha) { setPaint(paint); setRoundedEdges(rounded); setAlpha(alpha); }
/** * Sets the color used for "mark all." This fires a property change of * type {@link #MARK_ALL_COLOR_PROPERTY}. * * @param color The color to use for "mark all." * @see #getMarkAllHighlightColor() */ public void setMarkAllHighlightColor(Color color) { Color old = (Color)markAllHighlightPainter.getPaint(); if (old!=null && !old.equals(color)) { markAllHighlightPainter.setPaint(color); if (markedWord!=null) repaint(); // Repaint if words are highlighted. firePropertyChange(MARK_ALL_COLOR_PROPERTY, old, color); } }
/** * Sets whether this caret's selection should have rounded edges. * * @param rounded Whether it should have rounded edges. * @see #getRoundedSelectionEdges() */ public void setRoundedSelectionEdges(boolean rounded) { ((ChangeableHighlightPainter)getSelectionPainter()). setRoundedEdges(rounded); }
/** * {@inheritDoc} */ @Override public void setPaint(Paint paint) { super.setPaint(paint); if (paint instanceof Color) { borderColor = ((Color)paint).darker(); } }
/** * Returns the color used in "mark all." * * @return The color. * @see #setMarkAllHighlightColor(Color) */ public Color getMarkAllHighlightColor() { return (Color)markAllHighlightPainter.getPaint(); }
/** * Creates a new highlight painter. * * @param paint The <code>Paint</code> (usually a * <code>java.awt.Color</code>) with which to paint the * highlights. * @param rounded Whether to use rounded edges on the highlights. * @param alpha The alpha value to use when painting highlights. This * value should be in the range <code>0.0f</code> (completely * transparent) through <code>1.0f</code> (opaque). */ public ChangeableHighlightPainter(Paint paint, boolean rounded, float alpha) { setPaint(paint); setRoundedEdges(rounded); setAlpha(alpha); }
/** * Sets the color used for "mark all." This fires a property change of * type {@link #MARK_ALL_COLOR_PROPERTY}. * * @param color The color to use for "mark all." * @see #getMarkAllHighlightColor() */ public void setMarkAllHighlightColor(Color color) { Color old = (Color)markAllHighlightPainter.getPaint(); if (old!=null && !old.equals(color)) { markAllHighlightPainter.setPaint(color); if (markedWord!=null) repaint(); // Repaint if words are highlighted. firePropertyChange(MARK_ALL_COLOR_PROPERTY, old, color); } }
/** * Sets whether this caret's selection should have rounded edges. * * @param rounded Whether it should have rounded edges. * @see #getRoundedSelectionEdges() */ public void setRoundedSelectionEdges(boolean rounded) { ((ChangeableHighlightPainter)getSelectionPainter()). setRoundedEdges(rounded); }
/** * {@inheritDoc} */ @Override public void paintLayeredHighlights(Graphics g, int p0, int p1, Shape viewBounds, JTextComponent editor, View view) { int start = getStartOffset(); int end = getEndOffset(); end++; // Workaround for Java highlight issues // Restrict the region to what we represent p0 = Math.max(start, p0); p1 = Math.min(end, p1); if (getColor()!=null && getPainter() instanceof ChangeableHighlightPainter) { ((ChangeableHighlightPainter)getPainter()).setPaint(getColor()); } // Paint the appropriate region using the painter and union // the effected region with our bounds. union(((LayeredHighlighter.LayerPainter)getPainter()).paintLayer( g, p0, p1, viewBounds, editor, view)); }
/** * Returns the color used in "mark all." * * @return The color. * @see #setMarkAllHighlightColor(Color) */ public Color getMarkAllHighlightColor() { return (Color)markAllHighlightPainter.getPaint(); }
if (getAlpha()<1.0f) { originalComposite = g2d.getComposite(); g2d.setComposite(getAlphaComposite()); Paint paint = getPaint(); if (paint==null) { g2d.setColor(c.getSelectionColor()); if (getAlpha()<1.0f) { g2d.setComposite(originalComposite); if (getAlpha()<1.0f) { g2d.setComposite(originalComposite); } finally { if (getAlpha()<1.0f) { g2d.setComposite(originalComposite);
/** * Creates a new highlight painter. * * @param paint The <code>Paint</code> (usually a * <code>java.awt.Color</code>) with which to paint the * highlights. * @param rounded Whether to use rounded edges on the highlights. * @param alpha The alpha value to use when painting highlights. This * value should be in the range <code>0.0f</code> (completely * transparent) through <code>1.0f</code> (opaque). */ public ChangeableHighlightPainter(Paint paint, boolean rounded, float alpha) { setPaint(paint); setRoundedEdges(rounded); setAlpha(alpha); }
/** * Constructs a new <code>ConfigurableCaret</code>. * * @param style The style to use when painting the caret. If this is * invalid, then {@link #VERTICAL_LINE_STYLE} is used. */ public ConfigurableCaret(int style) { seg = new Segment(); setStyle(style); selectionPainter = new ChangeableHighlightPainter(); }
/** * Sets whether this caret's selection should have rounded edges. * * @param rounded Whether it should have rounded edges. * @see #getRoundedSelectionEdges() */ public void setRoundedSelectionEdges(boolean rounded) { ((ChangeableHighlightPainter)getSelectionPainter()). setRoundedEdges(rounded); }
/** * {@inheritDoc} */ @Override public void setPaint(Paint paint) { super.setPaint(paint); if (paint instanceof Color) { borderColor = ((Color)paint).darker(); } }
/** * Returns whether this caret's selection uses rounded edges. * * @return Whether this caret's edges are rounded. * @see #setRoundedSelectionEdges */ public boolean getRoundedSelectionEdges() { return ((ChangeableHighlightPainter)getSelectionPainter()). getRoundedEdges(); }
if (getAlpha()<1.0f) { originalComposite = g2d.getComposite(); g2d.setComposite(getAlphaComposite()); Rectangle p0 = mapper.modelToView(c, offs0); Rectangle p1 = mapper.modelToView(c, offs1); Paint paint = getPaint(); if (paint==null) g2d.setColor(c.getSelectionColor()); } finally { if (getAlpha()<1.0f) g2d.setComposite(originalComposite);