http://www.jpicedt.org

jpicedt.graphic.view
Class ArrowView

java.lang.Object
  extended by jpicedt.graphic.view.ArrowView
Direct Known Subclasses:
ArrowView.CircleCentered, ArrowView.CircleFlushed, ArrowView.DiskCentered, ArrowView.DiskFlushed, ArrowView.DoubleHead, ArrowView.DoubleReverseHead, ArrowView.Head, ArrowView.ReverseHead, ArrowView.RoundedBracket, ArrowView.SquareBracket, ArrowView.TBarCentered, ArrowView.TBarFlushed

public abstract class ArrowView
extends Object

A class implementing a view for the arrow attribute. 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.5
Version:
$Id: ArrowView.java,v 1.8 2013/03/27 06:55:16 vincentb1 Exp $
Author:
Sylvain Reynal

Nested Class Summary
static class ArrowView.CircleCentered
           
static class ArrowView.CircleFlushed
           
static class ArrowView.Direction
           
static class ArrowView.DiskCentered
           
static class ArrowView.DiskFlushed
           
static class ArrowView.DoubleHead
           
static class ArrowView.DoubleReverseHead
           
static class ArrowView.Head
           
static class ArrowView.Pencil
           
static class ArrowView.ReverseHead
           
static class ArrowView.RoundedBracket
           
static class ArrowView.SquareBracket
           
static class ArrowView.TBarCentered
           
static class ArrowView.TBarFlushed
           
 
Field Summary
protected  double globalScaleLength
           
protected  double globalScaleWidth
           
protected  float lineWidth
           
 
Constructor Summary
ArrowView(PicAttributeSet set)
          Configure the parameters of this arrow (size, scale, inset, ...) from the given attribute set, aka view/model synchronization.
 
Method Summary
static Map<StyleConstants.ArrowStyle,ImageIcon> createArrowIcons(ArrowView.Direction direction)
          build icons for e.g.
static ArrowView createArrowView(StyleConstants.ArrowStyle arrow, PicAttributeSet set)
          Return a View for the given arrow style.
abstract  ArrowView.Pencil getPencil()
          whether we call g.draw() or g.fill()
abstract  Shape getShape()
           
static void main(String[] arg)
           
 void paint(Graphics2D g)
          Paints this arrow.
 void paint(Graphics2D g, double locX, double locY, PicVector dir)
          Updates then paints this arrow.
 void paint(Graphics2D g, PicPoint loc, PicVector dir)
          Updates then paints this arrow.
abstract  void updateShape(double locX, double locY, PicVector dir)
          To be called when the geometry of the hosting Element changed.
 void updateShape(PicPoint loc, PicVector dir)
          To be called when the geometry of the hosting Element changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

globalScaleWidth

protected double globalScaleWidth

globalScaleLength

protected double globalScaleLength

lineWidth

protected float lineWidth
Constructor Detail

ArrowView

public ArrowView(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.

Method Detail

paint

public void paint(Graphics2D g,
                  PicPoint loc,
                  PicVector dir)
Updates then paints this arrow. Convenient call to #paint(Graphics2D, double, double, PicVector).

Parameters:
g - graphic context
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(Graphics2D g,
                  double locX,
                  double locY,
                  PicVector dir)
Updates then paints this arrow.

Parameters:
g - graphic context
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...)

paint

public void paint(Graphics2D g)
Paints this arrow.

Parameters:
g - graphic context

updateShape

public abstract void updateShape(double locX,
                                 double locY,
                                 PicVector dir)
To be called when the geometry of the hosting Element changed. Note that whenever attributes changed, a whole new Arrow should be instanciated.

Parameters:
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...)

updateShape

public void updateShape(PicPoint loc,
                        PicVector dir)
To be called when the geometry of the hosting Element changed. Note that whenever attributes changed, a whole new Arrow should be instanciated.


getPencil

public abstract ArrowView.Pencil getPencil()
whether we call g.draw() or g.fill()


getShape

public abstract Shape getShape()

createArrowView

public static ArrowView createArrowView(StyleConstants.ArrowStyle arrow,
                                        PicAttributeSet set)
Return a View for the given arrow style.


createArrowIcons

public static Map<StyleConstants.ArrowStyle,ImageIcon> createArrowIcons(ArrowView.Direction direction)
build icons for e.g. ComboBoxlists from predefined arrows

Parameters:
direction - specifies arrow direction, LEFT for left arrow, RIGHT for right arrow

main

public static void main(String[] arg)

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org