http://www.jpicedt.org

jpicedt.graphic.view
Interface View

All Known Implementing Classes:
AbstractView

public interface View

a View is a graphic representation of a 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.5.2.1 2007/09/02 11:56:29 reynal 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()
           
 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)
           
 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

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

setElement

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


getParentView

public 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

public 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

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

Returns:
the factory, null if none

getGraphics

public 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

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

Returns:
the drawing, null if none

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.


repaint

public void repaint(Rectangle2D clip)
ask the hosting container to repaint itself

Parameters:
clip - the clip rectangle in model-coordinate

paint

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

Parameters:
allocation - the graphic clip

getBounds

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

getHighlighter

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

Returns:
null if this view cannot be highlighted

setHighlighter

public 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

public 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

public HitInfo hitTest(PEMouseEvent e,
                       boolean isHighlightVisible)
Parameters:
isHighlightVisible - whether the receiver should include the highlighter shapes (e.g. end-points) in the click-sensitive area.
Returns:
a HitInfo corresponding to the given mouse-event

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org