jview
Class ArrowIcon

java.lang.Object
  extended by jview.ArrowIcon
All Implemented Interfaces:
Icon

public class ArrowIcon
extends Object
implements Icon

An icon that implements an arrow pointing in any direction up/down/left/right. Even multiple arrow heads are allowed. No arrow heads render a square. The principal dimension of the arrow are best studied using the following image (/z/wooz/stella/clipart/all_arrows.png).


Nested Class Summary
static class ArrowIcon.Show
          Test class for display.
 
Field Summary
static String ACTIONCOMMAND
          The action-event command for continuous-exposure button.
private  double angle
          The arrow opening angle.
private  Color back
          The background color, or from main component.
private  double base
          The arrow base width, follows from angle and head.
static double DEFANGLE
          Default miter angle in degrees.
static double DEFHEAD
          Default relative size of an arrow head.
static double DEFHIGH
          Default relative size of a vertical arrow neck.
static double DEFLEN
          Default relative size of a horizontal arrow neck.
static double DEFQUAD
          Default relative size of the arrows quadratic box.
static double DEFSIZE
          The default icon size multiplication factor.
static int DOWN
          The integer value for arrow head down.
private  Color fill
          The fill color, or foreground from main component.
private  double head
          The arrow head size.
private  double high
          The arrow half-height, 0-.5.
private  Insets inset
          If icon is drawn with special insets.
static int LEFT
          The integer value for arrow head left.
private  double len
          The arrow length, 0-1.
private  int mask
          All head directions.
private  Color outline
          The forground color, or from main component.
private  double quad
          The arrow quadratic portion.
static int RIGHT
          The integer value vor for arrow head.
static int UP
          The integer value for arrow head up.
private  double zoom
          This icon is customizable in size, but fix sized once constructed.
 
Constructor Summary
ArrowIcon(int arrows)
          Minimum constructor, specifying only the arrow directions as an bit-wise or of UP, LEFT, DOWN, and RIGHT.
ArrowIcon(int arrows, double size)
          Constructs a new arrow icon with all arrow properties, but no colors specified.
ArrowIcon(int arrows, double size, double q, double l, double h, double a, double deg)
          Constructs a new arrow icon with all arrow properties, but no colors specified.
ArrowIcon(int arrows, double size, double q, double l, double h, double a, double deg, Color o, Color f, Color b)
          Constructs a new arrow icon with all arrow properties specified.
 
Method Summary
private  Polygon getArrowPolygon(int x0, int y0)
          Calculates the actual arrow polygon, upper left corner of entire Icon is x, y.
private  int getHorizontalArrowCount()
          Counts the number of horizontal arrows, 0, 1, or 2.
 int getIconHeight()
          The height of the icon equals the size specified on construct.
 int getIconWidth()
          The width of the icon equals the size specified on construct.
 Insets getInsets()
          Gets the additional insets.
private  int getVerticalArrowCount()
          Counts the number of vertical arrows, 0, 1, or 2.
 boolean isHorizontalArrow()
          Returns true, if the mask implies at least one arrow in horizontal direction.
 boolean isVerticalArrow()
          Returns true, if the mask implies at least one arrow in vertical direction.
 void paintIcon(Component button, Graphics g, int x, int y)
          Paints the icon.
 void setColor(Color o, Color f, Color b)
          Sets outline, fill and background color, in that order.
 void setGeometry(double q, double l, double h, double a, double deg)
          Changes the geometry of the displayed arrow(s).
 void setInsets(Insets i)
          Sets additional insets.
 void setSize(double s)
          Sets the magnification of the arrow, which is the size in pixel of the quadratic arrow box.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTIONCOMMAND

public static final String ACTIONCOMMAND
The action-event command for continuous-exposure button.

See Also:
Constant Field Values

UP

public static final int UP
The integer value for arrow head up.

See Also:
Constant Field Values

LEFT

public static final int LEFT
The integer value for arrow head left.

See Also:
Constant Field Values

DOWN

public static final int DOWN
The integer value for arrow head down.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
The integer value vor for arrow head.

See Also:
Constant Field Values

DEFSIZE

public static final double DEFSIZE
The default icon size multiplication factor.

See Also:
Constant Field Values

DEFQUAD

public static final double DEFQUAD
Default relative size of the arrows quadratic box.

See Also:
Constant Field Values

DEFLEN

public static final double DEFLEN
Default relative size of a horizontal arrow neck.

See Also:
Constant Field Values

DEFHIGH

public static final double DEFHIGH
Default relative size of a vertical arrow neck.

See Also:
Constant Field Values

DEFHEAD

public static final double DEFHEAD
Default relative size of an arrow head.

See Also:
Constant Field Values

DEFANGLE

public static final double DEFANGLE
Default miter angle in degrees.

See Also:
Constant Field Values

zoom

private double zoom
This icon is customizable in size, but fix sized once constructed.


quad

private double quad
The arrow quadratic portion.


len

private double len
The arrow length, 0-1.


high

private double high
The arrow half-height, 0-.5.


head

private double head
The arrow head size.


base

private double base
The arrow base width, follows from angle and head.


angle

private double angle
The arrow opening angle.


outline

private Color outline
The forground color, or from main component.


fill

private Color fill
The fill color, or foreground from main component.


back

private Color back
The background color, or from main component.


mask

private int mask
All head directions.


inset

private Insets inset
If icon is drawn with special insets.

Constructor Detail

ArrowIcon

public ArrowIcon(int arrows)
Minimum constructor, specifying only the arrow directions as an bit-wise or of UP, LEFT, DOWN, and RIGHT. Default size is DEFSIZE, which is the size in pixel if no arrow heads are specified (shows as a solid square)


ArrowIcon

public ArrowIcon(int arrows,
                 double size)
Constructs a new arrow icon with all arrow properties, but no colors specified.


ArrowIcon

public ArrowIcon(int arrows,
                 double size,
                 double q,
                 double l,
                 double h,
                 double a,
                 double deg)
Constructs a new arrow icon with all arrow properties, but no colors specified.


ArrowIcon

public ArrowIcon(int arrows,
                 double size,
                 double q,
                 double l,
                 double h,
                 double a,
                 double deg,
                 Color o,
                 Color f,
                 Color b)
Constructs a new arrow icon with all arrow properties specified.

Method Detail

setInsets

public void setInsets(Insets i)
Sets additional insets.


setGeometry

public void setGeometry(double q,
                        double l,
                        double h,
                        double a,
                        double deg)
Changes the geometry of the displayed arrow(s).


setColor

public void setColor(Color o,
                     Color f,
                     Color b)
Sets outline, fill and background color, in that order. Null is allowed and means use the component foreground (ouline and fill) and background.


setSize

public void setSize(double s)
Sets the magnification of the arrow, which is the size in pixel of the quadratic arrow box.


getInsets

public Insets getInsets()
Gets the additional insets.


isHorizontalArrow

public boolean isHorizontalArrow()
Returns true, if the mask implies at least one arrow in horizontal direction.


isVerticalArrow

public boolean isVerticalArrow()
Returns true, if the mask implies at least one arrow in vertical direction.


getIconWidth

public int getIconWidth()
The width of the icon equals the size specified on construct.

Specified by:
getIconWidth in interface Icon

getIconHeight

public int getIconHeight()
The height of the icon equals the size specified on construct.

Specified by:
getIconHeight in interface Icon

paintIcon

public void paintIcon(Component button,
                      Graphics g,
                      int x,
                      int y)
Paints the icon.

Specified by:
paintIcon in interface Icon

getArrowPolygon

private Polygon getArrowPolygon(int x0,
                                int y0)
Calculates the actual arrow polygon, upper left corner of entire Icon is x, y.


getHorizontalArrowCount

private int getHorizontalArrowCount()
Counts the number of horizontal arrows, 0, 1, or 2.


getVerticalArrowCount

private int getVerticalArrowCount()
Counts the number of vertical arrows, 0, 1, or 2.