http://www.jpicedt.org

jpicedt.graphic.view.highlighter
Class CompositeHighlighter

java.lang.Object
  extended by jpicedt.graphic.view.highlighter.DefaultHighlighter
      extended by jpicedt.graphic.view.highlighter.CompositeHighlighter
All Implemented Interfaces:
Highlighter

public class CompositeHighlighter
extends DefaultHighlighter

A Highlighter for a BranchElement.

Since:
jPicEdt 1.4
Version:
$Id: CompositeHighlighter.java,v 1.8 2013/03/27 06:54:41 vincentb1 Exp $
Author:
Sylvain Reynal

Nested Class Summary
static class CompositeHighlighter.HighlightingMode
          Local highlighting mode corresponding to each Element in the parent BranchElement being highlighted Global highlighting mode corresponding to the 8 outer control-points being highlighted
 
Field Summary
protected  CompositeHighlighter.HighlightingMode highlightingMode
          highlight mode (default to GLOBAL)
 
Fields inherited from class jpicedt.graphic.view.highlighter.DefaultHighlighter
bounds, element, factory, pointIndexIterator, ptBuffer, rectBuffer, shape
 
Constructor Summary
CompositeHighlighter(BranchElement e, DefaultHighlighterFactory f)
          construct a new Highlighter for the given BranchElement.
 
Method Summary
 BranchElement getElement()
          returns the higlighted Element
 CompositeHighlighter.HighlightingMode getHighlightingMode()
          Return the current highlighting mode.
 HitInfo hitTest(PEMouseEvent e)
          Returns a HitInfo corresponding to the given mouse-event.
 boolean intersect(Rectangle2D r, ArrayList<Element> list)
          If this highligher intersects the given rectangle, add the associated BranchElement (or a child Element thereof if it's more appropriate) and returns true.
 void paint(Graphics2D g, Rectangle2D allocation, double scale)
          Render the Highlighter to the given graphic context.
 void setHighlightingMode(CompositeHighlighter.HighlightingMode mode)
          set the current highlighting mode ; this influences the way the Highligther is painted, but also the result returned by HitTest.
protected  void syncShape(double scale)
          Synchronize the array of "shapes" needed to paint this highlighter, with the model ;
 void toggleHighlightingMode()
          Toggle the current highlighting mode.
 
Methods inherited from class jpicedt.graphic.view.highlighter.DefaultHighlighter
changedUpdate, getBounds, getControlPointsIterator, getHighlighterFactory, syncBounds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

highlightingMode

protected CompositeHighlighter.HighlightingMode highlightingMode
highlight mode (default to GLOBAL)

Constructor Detail

CompositeHighlighter

public CompositeHighlighter(BranchElement e,
                            DefaultHighlighterFactory f)
construct a new Highlighter for the given BranchElement.

Method Detail

getElement

public BranchElement getElement()
Description copied from interface: Highlighter
returns the higlighted Element

Specified by:
getElement in interface Highlighter
Overrides:
getElement in class DefaultHighlighter
Returns:
the higlighted Element.

setHighlightingMode

public void setHighlightingMode(CompositeHighlighter.HighlightingMode mode)
set the current highlighting mode ; this influences the way the Highligther is painted, but also the result returned by HitTest.

Parameters:
mode - either LOCAL_MODE or GLOBAL_MODE

getHighlightingMode

public CompositeHighlighter.HighlightingMode getHighlightingMode()
Return the current highlighting mode.


toggleHighlightingMode

public void toggleHighlightingMode()
Toggle the current highlighting mode.


syncShape

protected void syncShape(double scale)
Synchronize the array of "shapes" needed to paint this highlighter, with the model ;

Overrides:
syncShape in class DefaultHighlighter
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(Graphics2D g,
                  Rectangle2D allocation,
                  double scale)
Render the Highlighter to the given graphic context.
In GLOBAL mode, only the 8 control-points are rendered, whereas in LOCAL mode, only children's highlighters are rendered.

Specified by:
paint in interface Highlighter
Overrides:
paint in class DefaultHighlighter
allocation - current clipping
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.

hitTest

public HitInfo hitTest(PEMouseEvent e)
Returns a HitInfo corresponding to the given mouse-event. In GLOBAL mode, hit test occurs on the 8 control-points and the highlighter's stroke, while in LOCAL mode, it occurs on the children's view and highlighter. Note that in the latter case, the returned HitInfo is the same as the one given by invoking hitTest() directly on the corresponding child (i.e., no HitInfo.Composite is returned whatsoever).

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

intersect

public boolean intersect(Rectangle2D r,
                         ArrayList<Element> list)
If this highligher intersects the given rectangle, add the associated BranchElement (or a child Element thereof if it's more appropriate) and returns true.

Specified by:
intersect in interface Highlighter
Overrides:
intersect in class DefaultHighlighter

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org