Skip navigation links
http://www.jpicedt.org
jpicedt.graphic.view

Class DefaultViewFactory.LeafElementView

    • Constructor Summary

      Constructors 
      Constructor and Description
      LeafElementView(Element e)
      construct a new View for the given Element
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void changedUpdate(DrawingEvent.EventType eventType)
      Give notification from the model that a change occured for an element this view is responsible for rendering.
      ViewFactory getViewFactory()
      Fetches the ViewFactory implementation that is feeding the view hierarchy.
      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).
      void paint(java.awt.Graphics2D g, java.awt.geom.Rectangle2D a)
      Render the View to the given graphic context.
      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
      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.
      protected void syncShape()
      Synchronize the "shape" variable with the model ; obviously, this implementation does nothing !
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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:
        getViewFactory in interface View
        Overrides:
        getViewFactory in class AbstractView
        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.
        • changedUpdate on the highlighter delegate, if any.
        then call repaint with the union of the old and the new bounds as the argument.
        Subclass might simply want to update shape before calling super.changedUpdate(), or override syncAttributes() and syncBounds() 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:
        hitTest in class AbstractView
        Returns:
        a HitInfo corresponding to the given mouse-event
http://www.jpicedt.org

Submit a bug : syd@jpicedt.org