http://www.jpicedt.org

jpicedt.graphic.view
Class DefaultHighlighterFactory.DefaultHighlighter

java.lang.Object
  extended by 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
protected  java.awt.geom.Rectangle2D.Double bounds
          cache for highlighter bounds
protected  Element element
          highlighted Element
protected  PointIndexIterator pointIndexIterator
          iterator over visible control-points
protected  PicPoint ptBuffer
          buffer used by paint only ; may be safely used by subclasses as well
protected  java.awt.geom.Rectangle2D rectBuffer
          buffer used by paint only ; may be safely used by subclasses as well
protected  java.awt.Shape shape
          highlighter shape ; should be null if N/A in subclass
 
Constructor Summary
DefaultHighlighterFactory.DefaultHighlighter(Element element)
           
 
Method Summary
 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.
 java.awt.geom.Rectangle2D getBounds()
           
protected  PointIndexIterator getControlPointsIterator()
          Returns an iterator over control-points that should be displayed by the hightligher.
 Element getElement()
          returns the higlighted Element
 HighlighterFactory getHighlighterFactory()
          Fetches the HighlighterFactory implementation that is feeding the view hierarchy.
 HitInfo hitTest(PEMouseEvent e)
          Current implementation returns a HitInfo.Point if a click occured on one of the controlled-point indices returned by getControlPointsIterator() ; return null otherwise.
 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 a DefaultPointIndexIterator, using the highlighter color if the given allocation intersects the bounds of this view, then iterates over the shapes array, and paints any non-null element.
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.
protected  void syncShape(double scale)
          Synchronize the shape needed to paint this highlighter, with the model ; This implementation does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

DefaultHighlighterFactory.DefaultHighlighter

public DefaultHighlighterFactory.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:
getHighlighterFactory in interface Highlighter
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" :

Specified by:
changedUpdate in interface Highlighter

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 a DefaultPointIndexIterator, using the highlighter color if the given allocation intersects the bounds of this view, then iterates over the shapes array, and paints any non-null element.

Specified by:
paint in interface Highlighter
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:
getBounds in interface Highlighter
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 by getControlPointsIterator() ; return null otherwise.

Specified by:
hitTest in interface Highlighter
Returns:
a HitInfo corresponding to the given mouse-event

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org