http://www.jpicedt.org

jpicedt.graphic.view
Class CompositeView

java.lang.Object
  extended by jpicedt.graphic.view.AbstractView
      extended by jpicedt.graphic.view.CompositeView
All Implemented Interfaces:
View

public class CompositeView
extends AbstractView

A CompositeView is a graphic representation of a BranchElement. Since jpicedt 1.5, this can also represent a path à-la-pscustom, that is, built from the children's path (except PicText's).

Since:
jpicedt 1.4
Version:
$Id: CompositeView.java,v 1.16 2013/03/27 07:20:36 vincentb1 Exp $
Author:
Sylvain Reynal

Field Summary
protected  AttributesViewFactory factory
           
 
Fields inherited from class jpicedt.graphic.view.AbstractView
bounds, element, highlighter
 
Constructor Summary
CompositeView(BranchElement e, AttributesViewFactory f)
          Construct a new View for the given BranchElement.
 
Method Summary
 void changedUpdate(DrawingEvent.EventType eventType)
          Give notification from the model that a change occured for an element this view is responsible for rendering.
 BranchElement getElement()
          Returns the element the View is responsible for rendering
 HitInfo hitTest(PEMouseEvent e)
          Returns a HitInfo corresponding to the given mouse-event.
protected  boolean intersect(Rectangle2D r, ArrayList<Element> list)
          If this view intersects the given rectangle, return the associated BranchElement in GLOBAL mode, or a child Element if in LOCAL mode.
protected  boolean isDisplayAsPath()
           
 void paint(Graphics2D g, Rectangle2D a)
          Render the View for the graphic element to the given graphic context.
 
Methods inherited from class jpicedt.graphic.view.AbstractView
getBounds, getContainer, getDrawing, getGraphics, getHighlighter, getParentView, getViewFactory, hitTest, intersect, paintHighlighter, repaint, setElement, setHighlighter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected AttributesViewFactory factory
Constructor Detail

CompositeView

public CompositeView(BranchElement e,
                     AttributesViewFactory f)
Construct a new View for the given BranchElement.

Parameters:
f - not used yet; used only for reflection purpose
Method Detail

getElement

public BranchElement getElement()
Description copied from interface: View
Returns the element the View is responsible for rendering

Specified by:
getElement in interface View
Overrides:
getElement in class AbstractView
Returns:
the element the View is responsible for rendering.

isDisplayAsPath

protected boolean isDisplayAsPath()
Returns:
whether this view should display the associated BranchElement as a path (aka pscustom) or not. Fetches the appropriate information from the BranchElement itself (actually PicGroup as it is). Note that any subclass of this view that does not support such feature should simply override to return false.

changedUpdate

public void changedUpdate(DrawingEvent.EventType eventType)
Give notification from the model that a change occured for an element this view is responsible for rendering. This implementation update the view's bounds from the element's bounding box, delegating highlighter's bounds to the current Highlighter delegate.


paint

public void paint(Graphics2D g,
                  Rectangle2D a)
Render the View for the graphic element to the given graphic context. This called "paint" on each child's view if its bounds rectangle intersects the clip.

Parameters:
a - the current graphic clip

hitTest

public HitInfo hitTest(PEMouseEvent e)
Description copied from class: AbstractView
Returns a HitInfo corresponding to the given mouse-event. Only the view's shape should be included in this test.

Specified by:
hitTest in class AbstractView
Returns:
a HitInfo corresponding to the given click-point in model-coordinate. The returned object depends on the highlighting mode of the associated CompositeHighlighter, if any. In GLOBAL mode, a HitInfo.Composite is returned on the first successfull hit-test on children, with the corresponding child-index. In LOCAL mode, a HitInfo corresponding to all successfull hit-test on children is returned, i.e., possibly wrapped into a HitInfo.List if more than one Element matches the hit. In the latter case, a HitInfo.Composite is NEVER returned, except in the case where the PicGroup contains another PicGroup itself.
If the associated highlighter is not a CompositeHighlighter, the behavior defaults to the GLOBAL mode.

intersect

protected boolean intersect(Rectangle2D r,
                            ArrayList<Element> list)
If this view intersects the given rectangle, return the associated BranchElement in GLOBAL mode, or a child Element if in LOCAL mode. Otherwise return null.

Specified by:
intersect in class AbstractView

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org