Package jpicedt.graphic.view
Class DefaultViewFactory.LeafElementView
- java.lang.Object
-
- jpicedt.graphic.view.AbstractView
-
- jpicedt.graphic.view.DefaultViewFactory.LeafElementView
-
- All Implemented Interfaces:
View,ViewConstants
- Direct Known Subclasses:
DefaultViewFactory.AbstractCurveView,DefaultViewFactory.EllipseView,DefaultViewFactory.ParallelogramView,DefaultViewFactory.PicNodeConnectionView,DefaultViewFactory.TextView,DefaultViewFactory.TextViewHybrid
- Enclosing class:
- DefaultViewFactory
protected abstract class DefaultViewFactory.LeafElementView extends AbstractView
a View for rendering leaf-elements ; implements attributes caching, and shape rendering. Subclasses might just override thechangedUpdate method, and update theshapevariable accordingly.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.PaintinteriorPaintpaint for interior (cached)protected doublelineWidthline width to be used to compute the view bounds (cached)protected java.awt.PaintoutlinePaintpaint for outline (cached)protected java.awt.StrokeoutlineStrokestroke for outline (cached)protected doubleoverStrikeWidthoverstrike widthprotected java.awt.geom.Rectangle2D.DoubleshadowBoundsbufferprotected java.awt.Shapeshapeshape to be drawn ; subclass must update it properly-
Fields inherited from class jpicedt.graphic.view.AbstractView
bounds, element, highlighter
-
Fields inherited from interface jpicedt.graphic.view.ViewConstants
BARBELL_SIZE, CLICK_DISTANCE
-
-
Constructor Summary
Constructors Constructor Description LeafElementView(Element e)construct a new View for the given Element
-
Method Summary
All Methods Instance Methods Concrete 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.ViewFactorygetViewFactory()Fetches the ViewFactory implementation that is feeding the view hierarchy.HitInfohitTest(PEMouseEvent e)This implementation returns a HitInfo.Interior if the view is filled and a click occured on the interior, or a HitInfo.Stroke if a click occured on the stroke path (this use a FlatteningPathIterator built from the currentshape).voidpaint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D a)Render the View to the given graphic context.protected voidsyncAttributes()Synchronizes cached attributes values with the model ; lineWidth, from the LINE_WIDTH attribute outlineStroke, from the ViewFactory, usingcreateStrokeoutinePaint, from the ViewFactory, usingcreatePaintForOutlineinteriorPaint, from the ViewFactory, usingcreatePaintForInterioroverStrikeWidth, from the OVER_STRIKE and OVER_STRIKE_WIDTH attributesprotected voidsyncBounds()Synchronizes the bounding box with the model ; "bounds" is first computed from the current shape's bound, if any, then its size gets increased by BARBELL_SIZE, line-thickness, overstrike width, and possibly the shadow area.protected voidsyncShape()Synchronize the "shape" variable with the model ; obviously, this implementation does nothing !-
Methods inherited from class jpicedt.graphic.view.AbstractView
getBounds, getContainer, getDrawing, getElement, getGraphics, getHighlighter, getParentView, hitTest, paintHighlighter, repaint, setElement, setHighlighter
-
-
-
-
Field Detail
-
shape
protected java.awt.Shape shape
shape to be drawn ; subclass must update it properly
-
lineWidth
protected double lineWidth
line width to be used to compute the view bounds (cached)
-
overStrikeWidth
protected double overStrikeWidth
overstrike width
-
outlineStroke
protected java.awt.Stroke outlineStroke
stroke for outline (cached)
-
interiorPaint
protected java.awt.Paint interiorPaint
paint for interior (cached)
-
outlinePaint
protected java.awt.Paint outlinePaint
paint for outline (cached)
-
shadowBounds
protected java.awt.geom.Rectangle2D.Double shadowBounds
buffer
-
-
Constructor Detail
-
LeafElementView
public LeafElementView(Element e)
construct a new View for the given Element
-
-
Method Detail
-
getViewFactory
public ViewFactory getViewFactory()
Fetches the ViewFactory implementation that is feeding the view hierarchy. This implementation first try to fetch a ViewFactory from the parent view, in case the root-view was produced from another ViewFactory (which for instance partially delegates to this factory), then, if there's no parent view, return the enclosing class.- Specified by:
getViewFactoryin interfaceView- Overrides:
getViewFactoryin classAbstractView- Returns:
- the factory, 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.To reduce the burden for subclasses, this implemention dispatches to the following methods, in that order, depending on the value of "eventType" :
-
syncAttributes()if it's an ATTRIBUTE_CHANGE event type or during initialization -
syncShape()in any case -
syncBounds()in any case. -
changedUpdateon the highlighter delegate, if any.
Subclass might simply want to updateshapebefore callingsuper.changedUpdate(), or overridesyncAttributes()andsyncBounds()if they must implement more specific behaviour. -
-
syncAttributes
protected void syncAttributes()
Synchronizes cached attributes values with the model ;- lineWidth, from the LINE_WIDTH attribute
- outlineStroke, from the ViewFactory, using
createStroke - outinePaint, from the ViewFactory, using
createPaintForOutline - interiorPaint, from the ViewFactory, using
createPaintForInterior - overStrikeWidth, from the OVER_STRIKE and OVER_STRIKE_WIDTH attributes
-
syncBounds
protected void syncBounds()
Synchronizes the bounding box with the model ; "bounds" is first computed from the current shape's bound, if any, then its size gets increased by BARBELL_SIZE, line-thickness, overstrike width, and possibly the shadow area.
-
syncShape
protected void syncShape()
Synchronize the "shape" variable with the model ; obviously, this implementation does nothing !
-
paint
public void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D a)Render the View to the given graphic context. This implementation relies on a bottom-to-top z-ordering policy, ie first renders the shadow, then the interior and hatches, finally the outline (=stroke).- Parameters:
a- the current graphic clip
-
hitTest
public HitInfo hitTest(PEMouseEvent e)
This implementation returns a HitInfo.Interior if the view is filled and a click occured on the interior, or a HitInfo.Stroke if a click occured on the stroke path (this use a FlatteningPathIterator built from the currentshape).- Specified by:
hitTestin classAbstractView- Returns:
- a HitInfo corresponding to the given mouse-event
-
-