Package diva.canvas.toolbox
Class BasicHighlighter
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.canvas.AbstractFigureContainer
-
- diva.canvas.FigureDecorator
-
- diva.canvas.toolbox.BasicHighlighter
-
- All Implemented Interfaces:
CanvasComponent,Figure,FigureContainer,FigureSet,VisibleComponent,UserObjectContainer
- Direct Known Subclasses:
ShadowHighlighter
public class BasicHighlighter extends FigureDecorator
A decorator figure that displays a highlight behind the figure. The highlighter has several options to control the color, transparency, and "halo." Currently, this just displays a rectangle on the figure's bounding box, but this may be changed to take notice of the figure's shape in the future.- Version:
- $Id$
- Author:
- John Reekie
-
-
Constructor Summary
Constructors Constructor Description BasicHighlighter()Create a new highlighter with a default paint and "halo"BasicHighlighter(java.awt.Paint paint, float halo)Create a new highlighter with the given paint and "halo"BasicHighlighter(java.awt.Paint paint, float halo, java.awt.Composite composite)Create a new highlighter with the given paint, "halo," and compositing operation.BasicHighlighter(java.awt.Paint paint, float halo, java.awt.Composite composite, java.awt.Stroke stroke)Create a new highlighter with the given paint, "halo," compositing operation, and stroke.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.geom.Rectangle2DgetBounds()Get the bounds.java.awt.CompositegetComposite()Get the composite.floatgetHalo()Get the halo.java.awt.PaintgetPaint()Get the paint.java.awt.StrokegetStroke()Get the stroke.booleanhit(java.awt.geom.Rectangle2D region)Return false.FigureDecoratornewInstance(Figure f)Create a new instance of this highlighter.voidpaint(java.awt.Graphics2D g)Paint the figure.voidrepaint()Request a repaint of the figure and highlight.voidrepaint(DamageRegion d)Receive repaint notification.-
Methods inherited from class diva.canvas.FigureDecorator
add, contains, figures, figuresFromBack, figuresFromFront, getChild, getContainer, getDecoratedFigure, getFigureCount, getShape, remove, replaceChild, setChild, transform, translate
-
Methods inherited from class diva.canvas.AbstractFigureContainer
decorate, pick, pick, undecorate
-
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, intersects, isVisible, paint, setInteractor, setParent, setToolTipText, setUserObject, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface diva.canvas.CanvasComponent
getTransformContext
-
Methods inherited from interface diva.canvas.VisibleComponent
isVisible, paint, setVisible
-
-
-
-
Constructor Detail
-
BasicHighlighter
public BasicHighlighter()
Create a new highlighter with a default paint and "halo"
-
BasicHighlighter
public BasicHighlighter(java.awt.Paint paint, float halo)Create a new highlighter with the given paint and "halo"
-
BasicHighlighter
public BasicHighlighter(java.awt.Paint paint, float halo, java.awt.Composite composite)Create a new highlighter with the given paint, "halo," and compositing operation.
-
BasicHighlighter
public BasicHighlighter(java.awt.Paint paint, float halo, java.awt.Composite composite, java.awt.Stroke stroke)Create a new highlighter with the given paint, "halo," compositing operation, and stroke. This highlighter draws an outline only and does not fill it.
-
-
Method Detail
-
getComposite
public java.awt.Composite getComposite()
Get the composite.
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Get the bounds. This is the child's bounding box stretched by the "halo."- Specified by:
getBoundsin interfaceFigure- Overrides:
getBoundsin classFigureDecorator- Returns:
- the bounding box of this figure.
-
getHalo
public float getHalo()
Get the halo.
-
getPaint
public java.awt.Paint getPaint()
Get the paint.
-
getStroke
public java.awt.Stroke getStroke()
Get the stroke.
-
hit
public boolean hit(java.awt.geom.Rectangle2D region)
Return false. This method always returns false, as it is meaningless (and dangerous!) to be able to hit a highlight.- Specified by:
hitin interfaceFigure- Overrides:
hitin classFigureDecorator- Parameters:
region- The rectangle to be checked.- Returns:
- true if the figure is hit by the given rectangle.
-
newInstance
public FigureDecorator newInstance(Figure f)
Create a new instance of this highlighter. The new instance will have the same paint, halo, and composite as this one.- Specified by:
newInstancein classFigureDecorator- Parameters:
f- The figure- Returns:
- The new instance of the figure decorator.
-
paint
public void paint(java.awt.Graphics2D g)
Paint the figure. This method first paints the highlight over the contained figure's bounding box stretched by the halo. It then paints the contained figure.- Specified by:
paintin interfaceVisibleComponent- Overrides:
paintin classFigureDecorator- Parameters:
g- The Graphics context
-
repaint
public void repaint(DamageRegion d)
Receive repaint notification. This method generates another repaint() call, with a larger region, in order to ensure that the highlight is repainted.- Specified by:
repaintin interfaceCanvasComponent- Overrides:
repaintin classAbstractFigureContainer- Parameters:
d- The region where a repaint has occurred.
-
repaint
public void repaint()
Request a repaint of the figure and highlight. This method reads the bounding box of the highlighted figure, and requests a repaint of that box stretched in each direction by the halo.- Specified by:
repaintin interfaceCanvasComponent- Overrides:
repaintin classAbstractFigure
-
-