Package jpicedt.graphic.view
Class DefaultHighlighterFactory.DefaultHighlighter
- java.lang.Object
-
- jpicedt.graphic.view.DefaultHighlighterFactory.DefaultHighlighter
-
- All Implemented Interfaces:
Highlighter
- Direct Known Subclasses:
DefaultHighlighterFactory.AbstractCurveHighlighter,DefaultHighlighterFactory.CircleHighlighter,DefaultHighlighterFactory.CompositeHighlighter,DefaultHighlighterFactory.EllipseHighlighter,DefaultHighlighterFactory.PsCurveHighlighter,DefaultHighlighterFactory.SmoothPolygonHighlighter,DefaultHighlighterFactory.TextHighlighter
- Enclosing class:
- DefaultHighlighterFactory
public class DefaultHighlighterFactory.DefaultHighlighter extends java.lang.Object implements Highlighter
Default implementation of the Highlighter interface.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.geom.Rectangle2D.Doubleboundscache for highlighter boundsprotected Elementelementhighlighted Elementprotected PointIndexIteratorpointIndexIteratoriterator over visible control-pointsprotected PicPointptBufferbuffer used by paint only ; may be safely used by subclasses as wellprotected java.awt.geom.Rectangle2DrectBufferbuffer used by paint only ; may be safely used by subclasses as wellprotected java.awt.Shapeshapehighlighter shape ; should be null if N/A in subclass
-
Constructor Summary
Constructors Constructor Description DefaultHighlighter(Element element)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangedUpdate(DrawingEvent.EventType eventType, double scale)Give notification from the model that a change occured for an element's highlighting this highlighter is responsible for rendering.java.awt.geom.Rectangle2DgetBounds()protected PointIndexIteratorgetControlPointsIterator()Returns an iterator over control-points that should be displayed by the hightligher.ElementgetElement()returns the higlighted ElementHighlighterFactorygetHighlighterFactory()Fetches the HighlighterFactory implementation that is feeding the view hierarchy.HitInfohitTest(PEMouseEvent e)Current implementation returns a HitInfo.Point if a click occured on one of the controlled-point indices returned bygetControlPointsIterator(); return null otherwise.voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)Render the Highlighter to the given graphic context.
Current implementation paints end-points by delegating to aDefaultPointIndexIterator, using the highlighter color if the given allocation intersects the bounds of this view, then iterates over theshapesarray, and paints any non-null element.protected voidsyncBounds(double scale)Synchronizes the highlighter's bounding rectangle (aka clip) with the model ; "bounds" is first computed from the set of visible control-points, then its size gets increased by BARBELL_SIZE.protected voidsyncShape(double scale)Synchronize the shape needed to paint this highlighter, with the model ; This implementation does nothing.
-
-
-
Field Detail
-
element
protected Element element
highlighted Element
-
pointIndexIterator
protected PointIndexIterator pointIndexIterator
iterator over visible control-points
-
shape
protected java.awt.Shape shape
highlighter shape ; should be null if N/A in subclass
-
bounds
protected java.awt.geom.Rectangle2D.Double bounds
cache for highlighter bounds
-
rectBuffer
protected java.awt.geom.Rectangle2D rectBuffer
buffer used by paint only ; may be safely used by subclasses as well
-
ptBuffer
protected PicPoint ptBuffer
buffer used by paint only ; may be safely used by subclasses as well
-
-
Constructor Detail
-
DefaultHighlighter
public DefaultHighlighter(Element element)
- Parameters:
element- the Element to be highlighted
-
-
Method Detail
-
getElement
public Element getElement()
returns the higlighted Element
-
getHighlighterFactory
public HighlighterFactory getHighlighterFactory()
Fetches the HighlighterFactory implementation that is feeding the view hierarchy.- Specified by:
getHighlighterFactoryin interfaceHighlighter- Returns:
- the factory, null if none
-
changedUpdate
public void changedUpdate(DrawingEvent.EventType eventType, double scale)
Give notification from the model that a change occured for an element's highlighting this highlighter is responsible for rendering. To reduce the burden for subclasses, this implemention dispatches to the following methods, in that order, depending on the value of "eventType" :-
syncShape()if it's a DrawingEvent.GEOMETRY_CHANGE -
syncBounds()if it's a DrawingEvent.GEOMETRY_CHANGE
- Specified by:
changedUpdatein interfaceHighlighter
-
-
syncBounds
protected void syncBounds(double scale)
Synchronizes the highlighter's bounding rectangle (aka clip) with the model ; "bounds" is first computed from the set of visible control-points, then its size gets increased by BARBELL_SIZE. Finally, is shape is not null, its gets added to the bounding rectangle.- Parameters:
scale- The current scale factor from-model-to-screen for the Graphics2D context ; this may be used to scale down line thickess, etc... so that e.g. barbells appear with the same size on the screen whatever the scale factor being set to the graphic context.
-
syncShape
protected void syncShape(double scale)
Synchronize the shape needed to paint this highlighter, with the model ; This implementation does nothing.- Parameters:
scale- The current scale factor from-model-to-screen for the Graphics2D context ; this may be used to scale down line thickess, etc... so that e.g. barbells appear with the same size on the screen whatever the scale factor being set to the graphic context.
-
paint
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)Render the Highlighter to the given graphic context.
Current implementation paints end-points by delegating to aDefaultPointIndexIterator, using the highlighter color if the given allocation intersects the bounds of this view, then iterates over theshapesarray, and paints any non-null element.- Specified by:
paintin interfaceHighlighter- Parameters:
scale- The current scale factor from-model-to-screen for the Graphics2D context ; this may be used to scale down line thickess, etc... so that e.g. barbells appear with the same size on the screen whatever the scale factor being set to the graphic context.allocation- current clipping
-
getControlPointsIterator
protected PointIndexIterator getControlPointsIterator()
Returns an iterator over control-points that should be displayed by the hightligher. This default implementation iterates over all control-points.
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
- Specified by:
getBoundsin interfaceHighlighter- Returns:
- the bounds of this Highlighter
This will determine the clipping rectangle passed as a parameter to repaint in the hosting view
-
hitTest
public HitInfo hitTest(PEMouseEvent e)
Current implementation returns a HitInfo.Point if a click occured on one of the controlled-point indices returned bygetControlPointsIterator(); return null otherwise.- Specified by:
hitTestin interfaceHighlighter- Returns:
- a HitInfo corresponding to the given mouse-event
-
-