http://www.jpicedt.org

jpicedt.graphic.view
Interface View

All Known Implementing Classes:
AbstractCurveView, AbstractCurveView, AbstractCurveView, AbstractView, CompositeView, EllipseView, EllipseView, EllipseView, LeafElementView, ParallelogramView, ParallelogramView, PicNodeConnectionView, TextView, TextView, TextViewHybrid

public interface View

A View is a graphic representation of an Element. It can be rendered using its paint() method.

It provides the following capabilities :

View's belong to a tree that has the same structure as the associated Drawing, since each View is attached to an element in the tree.

Since:
jpicedt 1.3.2
Version:
$Id: View.java,v 1.12 2013/03/27 06:53:31 vincentb1 Exp $
Author:
Sylvain Reynal

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.
 Rectangle2D getBounds()
           
 PECanvas getContainer()
          Fetches the container hosting the view.
 Drawing getDrawing()
          Fetches the document associated with the view.
 Element getElement()
          Returns the element the View is responsible for rendering
 Graphics getGraphics()
          Fetch a Graphics for rendering.
 Highlighter getHighlighter()
          Returns the Highlighter responsible for rendering the highlighted part of this view.
 View getParentView()
          Returns the parent of the view, as given by the tree-structure the associated graphic element belongs to.
 ViewFactory getViewFactory()
          Fetches the ViewFactory implementation that is feeding the view hierarchy.
 HitInfo hitTest(PEMouseEvent e, boolean isHighlightVisible)
          Returns a HitInfo corresponding to the given mouse-event
 boolean intersect(Rectangle2D r, boolean isHighlightVisible, ArrayList<Element> list)
          If this view or its highlighter intersects the given rectangle, add the associated Element (or a child Element if it's more appropriate, for instance for composite views) to the given list.
 void paint(Graphics2D g, Rectangle2D allocation)
          Render the View of the underlying Element to the given graphic context.
 void paintHighlighter(Graphics2D g, Rectangle2D allocation, double scale)
          Render the Highlighter to the given graphic context.
 void repaint(Rectangle2D clip)
          Ask the hosting container to repaint itself.
 void setElement(Element e)
          set the element the View is responsible for rendering
 void setHighlighter(Highlighter h)
          Sets the Highlighter responsible for rendering the highlighted part of this view.
 

Method Detail

getElement

Element getElement()
Returns the element the View is responsible for rendering


setElement

void setElement(Element e)
set the element the View is responsible for rendering


getParentView

View getParentView()
Returns the parent of the view, as given by the tree-structure the associated graphic element belongs to.

Returns:
the parent, null if none

getContainer

PECanvas getContainer()
Fetches the container hosting the view. This is useful for things like scheduling a repaint, finding out the host components font, etc.

Returns:
the container, null if none

getViewFactory

ViewFactory getViewFactory()
Fetches the ViewFactory implementation that is feeding the view hierarchy.

Returns:
the factory, null if none

getGraphics

Graphics getGraphics()
Fetch a Graphics for rendering. This can be used to determine font characteristics, and will be different for a print view than a component view.

Since:
1.3

getDrawing

Drawing getDrawing()
Fetches the document associated with the view.

Returns:
the drawing, null if none

changedUpdate

void changedUpdate(DrawingEvent.EventType eventType)
Give notification from the model that a change occured for an element this view is responsible for rendering.


repaint

void repaint(Rectangle2D clip)
Ask the hosting container to repaint itself.

Parameters:
clip - the clip rectangle in model-coordinate

paint

void paint(Graphics2D g,
           Rectangle2D allocation)
Render the View of the underlying Element to the given graphic context.

Parameters:
allocation - the graphic clip

getBounds

Rectangle2D getBounds()
Returns:
the bounds of this View.
This will determine the clipping rectangle passed as a parameter to repaint.

getHighlighter

Highlighter getHighlighter()
Returns the Highlighter responsible for rendering the highlighted part of this view.

Returns:
null if this view cannot be highlighted

setHighlighter

void setHighlighter(Highlighter h)
Sets the Highlighter responsible for rendering the highlighted part of this view.

Parameters:
h - the delegate ; null if this View mustn't support highlighting.

paintHighlighter

void paintHighlighter(Graphics2D g,
                      Rectangle2D allocation,
                      double scale)
Render the Highlighter to the given graphic context.

Parameters:
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 lines/rectangle/… appear with the same lenght on the screen whatever the scale factor that's set to the graphic context.

hitTest

HitInfo hitTest(PEMouseEvent e,
                boolean isHighlightVisible)
Returns a HitInfo corresponding to the given mouse-event

Parameters:
e - the mouse event for which a HitInfo is returned
isHighlightVisible - whether the receiver should include the highlighter shapes (e.g. end-points) in the click-sensitive area.

intersect

boolean intersect(Rectangle2D r,
                  boolean isHighlightVisible,
                  ArrayList<Element> list)
If this view or its highlighter intersects the given rectangle, add the associated Element (or a child Element if it's more appropriate, for instance for composite views) to the given list.

Parameters:
isHighlightVisible - whether the receiver should include the highlighter shapes (e.g. control-points) in the intersection area.
Returns:
whether the given rectangle intersects this view or its highlighter (that is, whether the given list has been modified or not.

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org