Package jpicedt.graphic.view
Interface View
-
- All Known Implementing Classes:
AbstractView,CompositeView,DefaultViewFactory.AbstractCurveView,DefaultViewFactory.EllipseView,DefaultViewFactory.LeafElementView,DefaultViewFactory.ParallelogramView,DefaultViewFactory.PicNodeConnectionView,DefaultViewFactory.TextView,DefaultViewFactory.TextViewHybrid,EepicViewFactory.AbstractCurveView,EepicViewFactory.EllipseView,EepicViewFactory.TextView,LatexViewFactory.AbstractCurveView,LatexViewFactory.EllipseView,LatexViewFactory.ParallelogramView
public interface Viewa View is a graphic representation of a Element. It can be rendered using its paint method.It provides the following capabilities :
- Rendering to a Graphics2D context ;
- Highlighting ;
- Mouse-hit testing (this is here because a View knows better than anyone how a graphic element
looks on the screen, and thus where a user should click to select/whatever/... the element). As
an example, consider a rectangle element that has a "fill-color" attribute set to "green", and
is indeed paint in green in some View implementation, but is transparent in some other implementation :
then when the user clicks inside the rectangle, the first implementation should return a "hit-ok" while
the second should return "hit-fail", even thought the element has the same "fill-color" in both cases.
View implementation that don't implement editing capabilities may have their hitTest method simply return null to signal that every mouse-click just fails, and their paintHighlighter do nothing.
[pending] Another approach would be to define aka EditableView interface inheriting from View and adding the afore-mentioned methods ?
- 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidchangedUpdate(DrawingEvent.EventType eventType)Give notification from the model that a change occured for an element this view is responsible for rendering.java.awt.geom.Rectangle2DgetBounds()PECanvasgetContainer()Fetches the container hosting the view.DrawinggetDrawing()Fetches the document associated with the view.ElementgetElement()java.awt.GraphicsgetGraphics()Fetch a Graphics for rendering.HighlightergetHighlighter()Returns the Highlighter responsible for rendering the highlighted part of this view.ViewgetParentView()Returns the parent of the view, as given by the tree-structure the associated graphic element belongs to.ViewFactorygetViewFactory()Fetches the ViewFactory implementation that is feeding the view hierarchy.HitInfohitTest(PEMouseEvent e, boolean isHighlightVisible)voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation)Render the View of the underlying Element to the given graphic context.voidpaintHighlighter(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)Render the Highlighter to the given graphic context.voidrepaint(java.awt.geom.Rectangle2D clip)ask the hosting container to repaint itselfvoidsetElement(Element e)set the element the View is responsible for renderingvoidsetHighlighter(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
java.awt.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(java.awt.geom.Rectangle2D clip)
ask the hosting container to repaint itself- Parameters:
clip- the clip rectangle in model-coordinate
-
paint
void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation)Render the View of the underlying Element to the given graphic context.- Parameters:
allocation- the graphic clip
-
getBounds
java.awt.geom.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(java.awt.Graphics2D g, java.awt.geom.Rectangle2D allocation, double scale)Render the Highlighter to the given graphic context.- Parameters:
allocation- current clippingscale- 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)
- 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
-
-