jsky.image.graphics
Class ShapeUtil

java.lang.Object
  extended by jsky.image.graphics.ShapeUtil

public class ShapeUtil
extends java.lang.Object

Utility methods for generating various common Shapes for drawing figures.

Version:
$Revision: 1.1 $
Author:
Allan Brighton

Field Summary
static int ARROW_SIZE
          Default length of an arrow
 
Constructor Summary
ShapeUtil()
           
 
Method Summary
static void addArrowLine(java.awt.geom.GeneralPath path, java.awt.geom.Point2D.Double startPos, java.awt.geom.Point2D.Double endPos)
          Add a line with an arrow at the end to the given GeneralPath.
static void main(java.lang.String[] args)
          test main: usage: java GraphicsImageDisplay .
static java.awt.Shape makeArrow(java.awt.geom.Point2D.Double center, java.awt.geom.Point2D.Double north)
          Return a Shape object for the "arrow" symbol (a line from center to north with an arrow at north).
static diva.util.java2d.Polygon2D makeArrowHead(java.awt.geom.Point2D.Double pos, double length, double angle, boolean flip)
          Make and return an arrow head shape at the given position.
static java.awt.Shape makeCompass(java.awt.geom.Point2D.Double center, java.awt.geom.Point2D.Double north, java.awt.geom.Point2D.Double east)
          Return a Shape object for a "compass" symbol (has two lines, from the center point, pointing north and east).
static java.awt.Shape makeCross(double x, double y, double size)
          Return a Shape object for a "cross" (x) symbol.
static java.awt.Shape makeDiamond(double x, double y, double size)
          Return a Shape object for a "diamond" symbol.
static java.awt.Shape makeEllipse(double x, double y, double size)
          Return a Shape object for an "ellipse" symbol.
static java.awt.Shape makeEllipse(java.awt.geom.Point2D.Double center, java.awt.geom.Point2D.Double north, java.awt.geom.Point2D.Double east)
          Return a Shape object for an "ellipse" symbol.
static java.awt.Shape makeLine(java.awt.geom.Point2D.Double center, java.awt.geom.Point2D.Double north, java.awt.geom.Point2D.Double east)
          Return a Shape object for the "line" symbol.
static java.awt.Shape makePlus(java.awt.geom.Point2D.Double center, java.awt.geom.Point2D.Double north, java.awt.geom.Point2D.Double east)
          Return a Shape object for a "plus" (+) symbol.
static java.awt.Shape makeSquare(double x, double y, double size)
          Return a Shape object for a "square" symbol.
static java.awt.Shape makeTriangle(double x, double y, double size)
          Return a Shape object for a "triangle" symbol.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARROW_SIZE

public static final int ARROW_SIZE
Default length of an arrow

See Also:
Constant Field Values
Constructor Detail

ShapeUtil

public ShapeUtil()
Method Detail

makePlus

public static java.awt.Shape makePlus(java.awt.geom.Point2D.Double center,
                                      java.awt.geom.Point2D.Double north,
                                      java.awt.geom.Point2D.Double east)
Return a Shape object for a "plus" (+) symbol.

Parameters:
center - the center point in screen coords
north - the north point in screen coords
east - the east point in screen coords

makeCross

public static java.awt.Shape makeCross(double x,
                                       double y,
                                       double size)
Return a Shape object for a "cross" (x) symbol.

Parameters:
x - the center X coord in screen coords
y - the center Y coord in screen coords
size - the radius of the symbol

makeTriangle

public static java.awt.Shape makeTriangle(double x,
                                          double y,
                                          double size)
Return a Shape object for a "triangle" symbol.

Parameters:
x - the center X coord in screen coords
y - the center Y coord in screen coords
size - the radius of the symbol

makeDiamond

public static java.awt.Shape makeDiamond(double x,
                                         double y,
                                         double size)
Return a Shape object for a "diamond" symbol.

Parameters:
x - the center X coord in screen coords
y - the center Y coord in screen coords
size - the radius of the symbol

makeSquare

public static java.awt.Shape makeSquare(double x,
                                        double y,
                                        double size)
Return a Shape object for a "square" symbol.

Parameters:
x - the center X coord in screen coords
y - the center Y coord in screen coords
size - the radius of the symbol

makeEllipse

public static java.awt.Shape makeEllipse(double x,
                                         double y,
                                         double size)
Return a Shape object for an "ellipse" symbol.

Parameters:
x - the center X coord in screen coords
y - the center Y coord in screen coords
size - the radius of the symbol

makeEllipse

public static java.awt.Shape makeEllipse(java.awt.geom.Point2D.Double center,
                                         java.awt.geom.Point2D.Double north,
                                         java.awt.geom.Point2D.Double east)
Return a Shape object for an "ellipse" symbol.

Parameters:
center - the center point in screen coords
north - the north point in screen coords
east - the east point in screen coords

makeCompass

public static java.awt.Shape makeCompass(java.awt.geom.Point2D.Double center,
                                         java.awt.geom.Point2D.Double north,
                                         java.awt.geom.Point2D.Double east)
Return a Shape object for a "compass" symbol (has two lines, from the center point, pointing north and east).

Parameters:
center - the center point in screen coords
north - the north point in screen coords
east - the east point in screen coords

makeLine

public static java.awt.Shape makeLine(java.awt.geom.Point2D.Double center,
                                      java.awt.geom.Point2D.Double north,
                                      java.awt.geom.Point2D.Double east)
Return a Shape object for the "line" symbol.

Parameters:
center - the center point in screen coords
north - the north point in screen coords
east - the east point in screen coords

makeArrow

public static java.awt.Shape makeArrow(java.awt.geom.Point2D.Double center,
                                       java.awt.geom.Point2D.Double north)
Return a Shape object for the "arrow" symbol (a line from center to north with an arrow at north).

Parameters:
center - the center point in screen coords
north - the north point in screen coords

addArrowLine

public static void addArrowLine(java.awt.geom.GeneralPath path,
                                java.awt.geom.Point2D.Double startPos,
                                java.awt.geom.Point2D.Double endPos)
Add a line with an arrow at the end to the given GeneralPath.

Parameters:
path - the line and arrow are added to the GeneralPath
startPos - the start of the line
endPos - the end of the line (where the arrow should be)

makeArrowHead

public static diva.util.java2d.Polygon2D makeArrowHead(java.awt.geom.Point2D.Double pos,
                                                       double length,
                                                       double angle,
                                                       boolean flip)
Make and return an arrow head shape at the given position.

Parameters:
pos - the position of the point of the arrow in screen coords
length - the length of the arrow
angle - the rotation angle in radians
flip - if true flip the arrow direction

main

public static void main(java.lang.String[] args)
test main: usage: java GraphicsImageDisplay .