Class Arrow

  • All Implemented Interfaces:
    PicObjectConstants

    public class Arrow
    extends java.lang.Object
    implements PicObjectConstants
    A class implementing the arrow attribute. This class acts as a model and a view at the same time. A syncAttributes() method allows for synchronizing the current attribute set with the arrow parameters used by the paint() method.

    This class is also a container for predefined arrows (implemented as static inner classes).

    Since:
    jPicEdt 1.3.1
    Version:
    $Id: Arrow.java,v 1.9.2.2 2007/09/02 11:56:26 reynal Exp $
    Author:
    Sylvain Reynal
    • Field Detail

      • globalScaleWidth

        protected double globalScaleWidth
      • globalScaleLength

        protected double globalScaleLength
      • NONE

        public static final Arrow NONE
      • ARROW_HEAD

        public static final Arrow ARROW_HEAD
      • REVERSE_ARROW_HEAD

        public static final Arrow REVERSE_ARROW_HEAD
      • DOUBLE_ARROW_HEAD

        public static final Arrow DOUBLE_ARROW_HEAD
      • DOUBLE_REVERSE_ARROW_HEAD

        public static final Arrow DOUBLE_REVERSE_ARROW_HEAD
      • T_BAR_CENTERED

        public static final Arrow T_BAR_CENTERED
      • T_BAR_FLUSHED

        public static final Arrow T_BAR_FLUSHED
      • SQUARE_BRACKET

        public static final Arrow SQUARE_BRACKET
      • ROUNDED_BRACKET

        public static final Arrow ROUNDED_BRACKET
      • CIRCLE_FLUSHED

        public static final Arrow CIRCLE_FLUSHED
      • CIRCLE_CENTERED

        public static final Arrow CIRCLE_CENTERED
      • DISK_FLUSHED

        public static final Arrow DISK_FLUSHED
      • DISK_CENTERED

        public static final Arrow DISK_CENTERED
    • Constructor Detail

      • Arrow

        protected Arrow​(java.lang.String name)
        Parameters:
        name - the name (possibly explicit) of this Arrow
      • Arrow

        protected Arrow​(Arrow src)
    • Method Detail

      • copy

        public Arrow copy()
      • getName

        public java.lang.String getName()
        Return the name of this arrow.
      • syncAttributes

        public void syncAttributes​(PicAttributeSet set)
        Configure the parameters of this arrow (size, scale, inset, ...) from the given attribute set, aka view/model synchronization. Note that (according to PsTricks doc), attributes apply to both arrows at once for a given element; hence there's no need to separate left and right attributes. This implementation simply synchronizes global scale factors (ARROW_SCALE_WIDTH and ARROW_SCALE_LENGTH), and should be overriden in each concrete subclass.

        Usage: this method should invoked by the view responsible for rendering the drawing, whenever synchronization is needed b/w the view and the model, i.e. whenever at least one attribute value changed.

      • getIndex

        public static int getIndex​(Arrow arrow)
        Returns an integer associated with the given arrow (essentially for JComboxBox's...)
        Parameters:
        arrow - one of the predefined Arrow'ss
      • getArrow

        public static Arrow getArrow​(int indx)
        Returns the Arrow corresponding to the given indx Arrow.NONE if indx > number of arrows
      • getPredefinedArrows

        public static Arrow[] getPredefinedArrows()
        Returns an array of predefined arrows
      • createArrowIcons

        public static javax.swing.ImageIcon[] createArrowIcons​(boolean rightArrow)
        build icons for e.g. ComboBoxlists from predefined arrows
        Parameters:
        rightArrow - false for left arrow, true for right arrow
      • main

        public static void main​(java.lang.String[] arg)
      • paint

        public void paint​(java.awt.Graphics2D g,
                          double linewidth,
                          PicPoint loc,
                          PicPoint dir)
        Paints this arrow. Convenient call to #paint(Graphics2D, double, double, double, PicPoint).
        Parameters:
        g - graphic context
        linewidth - current lineWidth of the object this arrow is attached to (in mm)
        loc - arrow reference point on the screen (that is, line end-point)
        dir - a vector of length 1 indicating the direction of the arrow (see PEToolKit.getDirector...)
      • paint

        public void paint​(java.awt.Graphics2D g,
                          double linewidth,
                          double locX,
                          double locY,
                          PicPoint dir)
        Paints this arrow (this implementation does nothing)
        Parameters:
        g - graphic context
        linewidth - current lineWidth of the object this arrow is attached to (in mm)
        locX - X-coord of arrow reference point on the screen (that is, line end-point)
        locY - Y-coord of arrow reference point on the screen (that is, line end-point)
        dir - a vector of length 1 indicating the direction of the arrow (see PEToolKit.getDirector...)
      • toString

        public java.lang.String toString()
        Returns a string representation of this Arrow for debugging purpose
        Overrides:
        toString in class java.lang.Object