ucar.visad
Class ShapeUtility

java.lang.Object
  extended by ucar.visad.ShapeUtility

public class ShapeUtility
extends Object

A utility class for manipulating VisAD Shapes (VisADGeometryArrays). Adapted from RAP's ShapeFactory class.

Version:
$Revision: 1.40 $
Author:
MetApps Development Team

Field Summary
static String AIRPLANE
          Id for a 2-D airplane shape
static String AIRPLANE3D
          Id for a 3-D airplane shape
static float B_Y
          coordinates
static float C_X
          coordinates
static float C_Y
          coordinates
static float C_Z
          coordinates
static String CIRCLE
          shape name from WeatherSymbols
static String CROSS
          Id for a cross shape
static String CUBE
          Id for a cube shape
static float D_Z
          coordinates
static String DIAMOND
          shape name from WeatherSymbols
static String DOWNARROW
          Id for a plus shape
static String DOWNLINE
          Id for a plus shape
static String FILLED_CIRCLE
          shape name from WeatherSymbols
static String FILLED_DIAMOND
          shape name from WeatherSymbols
static String FILLED_SPHERE
          Id for a filled triangle shape
static String FILLED_SQUARE
          Id for a filled square shape
static String FILLED_STAR
          shape name from WeatherSymbols
static String FILLED_TRIANGLE
          Id for a filled triangle shape
static String HORLINE
          Id for a horizontal line shape
static float L_X
          coordinates
static String LEFTARROW
          Id for a plus shape
static float MB_Y
          coordinates
static String MINUS
          Id for a plus shape
static int MISC_ID_CIRCLE
          The identifier for a circle station location marker
static int MISC_ID_DIAMOND
          The identifier for a diamond station location marker
static int MISC_ID_FILLED_CIRCLE
          The identifier for a filled circle station location marker
static int MISC_ID_FILLED_DIAMOND
          The identifier for a filled diamond station location marker
static int MISC_ID_FILLED_SQUARE
          The identifier for a filled square station location marker
static int MISC_ID_FILLED_STAR
          The identifier for a filled start station location marker
static int MISC_ID_FILLED_TRIANGLE
          The identifier for a filled triangle station location marker
static int MISC_ID_MINUS
          The identifier for a minus station location marker
static int MISC_ID_PIN
          The identifier for a pin station location marker
static int MISC_ID_PLUS
          The identifier for a plus station location marker
static int MISC_ID_SQUARE
          The identifier for a square station location marker
static int MISC_ID_STAR
          The identifier for a star station location marker
static int MISC_ID_TRIANGLE
          The identifier for a triangle station location marker
static int[] MISC_IDS
          shape ids from WeatherSymbols
static String[] MISC_NAMES
          shape names from WeatherSymbols
static float ML_X
          coordinates
static float MR_X
          coordinates
static float MT_Y
          coordinates
static String NONE
          Id for a null shape
static String PIN
          shape id
static String PLUS
          Id for a plus shape
static String PYRAMID_4FACE
          Id for a pyramid of 4 faces (triangular base)
static String PYRAMID_5FACE
          Id for a pyramid of 5 faces (square base)
static float R_X
          coordinates
static String RIGHTARROW
          Id for a plus shape
static TwoFacedObject[] SHAPES
          Array of all of the shapes
static String SQUARE
          Id for a square (unfilled) shape
static String STAR
          shape name from WeatherSymbols
static float T_Y
          coordinates
static double[] TEXT_BASE
          use in text calls
static double[] TEXT_START
          use in text calls
static double[] TEXT_UP
          use in text calls
static String TRIANGLE
          Id for a triangle (unfilled) shape
static float U_Z
          coordinates
static String UPARROW
          Id for a plus shape
static String VERTLINE
          Id for a vertical line shape
 
Constructor Summary
ShapeUtility()
          Default constructor
 
Method Summary
static void blendColor(VisADGeometryArray shape, Color color)
          Blend the color for the shape specified with color.
static void blendColor(VisADGeometryArray shape, float R, float G, float B)
          Blend the color for the shape specified with RGB components specified
static Rectangle2D bounds2d(VisADGeometryArray shape)
          Return the bounds of this shape
static Rectangle2D bounds2d(VisADGeometryArray[] shapes)
          Return the bounds of array of shapes
static Rectangle2D bounds2d(VisADGeometryArray shape, Rectangle2D rect)
          Return the bounds of this shape
static VisADGeometryArray[] clone(VisADGeometryArray[] shapes)
          Do a deep clone of the given shapes array
static VisADGeometryArray[] createShape(String s)
          Create a shape from a string name
static VisADGeometryArray makeShape(String s)
          Deprecated. Use create shape
static VisADGeometryArray offset(VisADGeometryArray shape, float[] off)
          Offset the shape by the amounts in off.
static VisADGeometryArray offset(VisADGeometryArray shape, float dx, float dy, float dz)
          Offset the shape by the amounts in off.
static void reScale(VisADGeometryArray[] shapes, double scale)
          Rescale the shapes
static void reScale(VisADGeometryArray[] shapes, double[] scale)
          Rescale the shapes
static void reScale(VisADGeometryArray[] shapes, double[] scaleArray, double scale)
          Rescale the shapes
static void reScale(VisADGeometryArray shape, double scale)
          Rescale the shape
static void reScale(VisADGeometryArray shape, double[] scale)
          Rescale the shape
static void reScale(VisADGeometryArray shape, double[] scaleArray, double scale)
          Rescale the shape
static void rotate(VisADGeometryArray shape, float angle)
          Rotate the given shape about the z axis the given angle (in radians).
static void rotateX(VisADGeometryArray shape, float angle)
          Rotate the given shape about the x axis the given angle (in radians).
static void rotateY(VisADGeometryArray shape, float angle)
          Rotate the given shape about the y axis the given angle (in radians).
static void rotateZ(VisADGeometryArray shape, float angle)
          Rotate the given shape about the z axis the given angle (in radians).
static void setColor(VisADGeometryArray[] shapes, Color color)
          Set the color for the shapes in the array.
static void setColor(VisADGeometryArray[] shapes, float[] RGB)
          Set the color for the shapes in the array.
static void setColor(VisADGeometryArray shape, Color color)
          Set the color for the shape specified.
static void setColor(VisADGeometryArray shape, float[] RGB)
          Set the color for the shape specified.
static void setColor(VisADGeometryArray shape, float R, float G, float B)
          Set the color for the shape specified.
static VisADGeometryArray[] setSize(VisADGeometryArray[] shapes, float size)
          Set the size of the shapes.
static VisADGeometryArray setSize(VisADGeometryArray shape, float size)
          Set the size of the shapes.
static VisADGeometryArray setSize(VisADGeometryArray shape, float x, float y, float z)
          Set the size of the shapes.
static VisADGeometryArray shapeFont(String s, Font f)
          Wrapper for PlotText using font.
static VisADGeometryArray shapeFont(String s, Font f, boolean center)
          Wrapper for PlotText.
static VisADGeometryArray shapeText(String s)
          Wrapper for PlotText.
static VisADGeometryArray shapeText(String s, boolean center)
          Wrapper for PlotText.
static VisADGeometryArray shapeText(String s, int fontSize, boolean center)
          Wrapper for PlotText.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEXT_START

public static final double[] TEXT_START
use in text calls


TEXT_BASE

public static final double[] TEXT_BASE
use in text calls


TEXT_UP

public static final double[] TEXT_UP
use in text calls


PLUS

public static final String PLUS
Id for a plus shape

See Also:
Constant Field Values

MINUS

public static final String MINUS
Id for a plus shape

See Also:
Constant Field Values

DOWNLINE

public static final String DOWNLINE
Id for a plus shape

See Also:
Constant Field Values

RIGHTARROW

public static final String RIGHTARROW
Id for a plus shape

See Also:
Constant Field Values

LEFTARROW

public static final String LEFTARROW
Id for a plus shape

See Also:
Constant Field Values

UPARROW

public static final String UPARROW
Id for a plus shape

See Also:
Constant Field Values

DOWNARROW

public static final String DOWNARROW
Id for a plus shape

See Also:
Constant Field Values

HORLINE

public static final String HORLINE
Id for a horizontal line shape

See Also:
Constant Field Values

VERTLINE

public static final String VERTLINE
Id for a vertical line shape

See Also:
Constant Field Values

CROSS

public static final String CROSS
Id for a cross shape

See Also:
Constant Field Values

SQUARE

public static final String SQUARE
Id for a square (unfilled) shape

See Also:
Constant Field Values

NONE

public static final String NONE
Id for a null shape

See Also:
Constant Field Values

FILLED_SQUARE

public static final String FILLED_SQUARE
Id for a filled square shape

See Also:
Constant Field Values

CUBE

public static final String CUBE
Id for a cube shape

See Also:
Constant Field Values

PYRAMID_4FACE

public static final String PYRAMID_4FACE
Id for a pyramid of 4 faces (triangular base)

See Also:
Constant Field Values

PYRAMID_5FACE

public static final String PYRAMID_5FACE
Id for a pyramid of 5 faces (square base)

See Also:
Constant Field Values

TRIANGLE

public static final String TRIANGLE
Id for a triangle (unfilled) shape

See Also:
Constant Field Values

FILLED_TRIANGLE

public static final String FILLED_TRIANGLE
Id for a filled triangle shape

See Also:
Constant Field Values

FILLED_SPHERE

public static final String FILLED_SPHERE
Id for a filled triangle shape

See Also:
Constant Field Values

AIRPLANE

public static final String AIRPLANE
Id for a 2-D airplane shape

See Also:
Constant Field Values

AIRPLANE3D

public static final String AIRPLANE3D
Id for a 3-D airplane shape

See Also:
Constant Field Values

PIN

public static final String PIN
shape id

See Also:
Constant Field Values

MISC_ID_SQUARE

public static final int MISC_ID_SQUARE
The identifier for a square station location marker

See Also:
Constant Field Values

MISC_ID_FILLED_SQUARE

public static final int MISC_ID_FILLED_SQUARE
The identifier for a filled square station location marker

See Also:
Constant Field Values

MISC_ID_CIRCLE

public static final int MISC_ID_CIRCLE
The identifier for a circle station location marker

See Also:
Constant Field Values

MISC_ID_FILLED_CIRCLE

public static final int MISC_ID_FILLED_CIRCLE
The identifier for a filled circle station location marker

See Also:
Constant Field Values

MISC_ID_TRIANGLE

public static final int MISC_ID_TRIANGLE
The identifier for a triangle station location marker

See Also:
Constant Field Values

MISC_ID_FILLED_TRIANGLE

public static final int MISC_ID_FILLED_TRIANGLE
The identifier for a filled triangle station location marker

See Also:
Constant Field Values

MISC_ID_DIAMOND

public static final int MISC_ID_DIAMOND
The identifier for a diamond station location marker

See Also:
Constant Field Values

MISC_ID_FILLED_DIAMOND

public static final int MISC_ID_FILLED_DIAMOND
The identifier for a filled diamond station location marker

See Also:
Constant Field Values

MISC_ID_STAR

public static final int MISC_ID_STAR
The identifier for a star station location marker

See Also:
Constant Field Values

MISC_ID_FILLED_STAR

public static final int MISC_ID_FILLED_STAR
The identifier for a filled start station location marker

See Also:
Constant Field Values

MISC_ID_PLUS

public static final int MISC_ID_PLUS
The identifier for a plus station location marker

See Also:
Constant Field Values

MISC_ID_PIN

public static final int MISC_ID_PIN
The identifier for a pin station location marker

See Also:
Constant Field Values

MISC_ID_MINUS

public static final int MISC_ID_MINUS
The identifier for a minus station location marker

See Also:
Constant Field Values

CIRCLE

public static final String CIRCLE
shape name from WeatherSymbols

See Also:
Constant Field Values

FILLED_CIRCLE

public static final String FILLED_CIRCLE
shape name from WeatherSymbols

See Also:
Constant Field Values

DIAMOND

public static final String DIAMOND
shape name from WeatherSymbols

See Also:
Constant Field Values

FILLED_DIAMOND

public static final String FILLED_DIAMOND
shape name from WeatherSymbols

See Also:
Constant Field Values

STAR

public static final String STAR
shape name from WeatherSymbols

See Also:
Constant Field Values

FILLED_STAR

public static final String FILLED_STAR
shape name from WeatherSymbols

See Also:
Constant Field Values

MISC_NAMES

public static final String[] MISC_NAMES
shape names from WeatherSymbols


MISC_IDS

public static final int[] MISC_IDS
shape ids from WeatherSymbols


SHAPES

public static final TwoFacedObject[] SHAPES
Array of all of the shapes


L_X

public static final float L_X
coordinates

See Also:
Constant Field Values

ML_X

public static final float ML_X
coordinates

See Also:
Constant Field Values

C_X

public static final float C_X
coordinates

See Also:
Constant Field Values

MR_X

public static final float MR_X
coordinates

See Also:
Constant Field Values

R_X

public static final float R_X
coordinates

See Also:
Constant Field Values

T_Y

public static final float T_Y
coordinates

See Also:
Constant Field Values

MT_Y

public static final float MT_Y
coordinates

See Also:
Constant Field Values

C_Y

public static final float C_Y
coordinates

See Also:
Constant Field Values

MB_Y

public static final float MB_Y
coordinates

See Also:
Constant Field Values

B_Y

public static final float B_Y
coordinates

See Also:
Constant Field Values

D_Z

public static final float D_Z
coordinates

See Also:
Constant Field Values

C_Z

public static final float C_Z
coordinates

See Also:
Constant Field Values

U_Z

public static final float U_Z
coordinates

See Also:
Constant Field Values
Constructor Detail

ShapeUtility

public ShapeUtility()
Default constructor

Method Detail

makeShape

public static VisADGeometryArray makeShape(String s)
Deprecated. Use create shape

Create a predefined shape. Shapes are drawn on a 1x1(x1) box. Use setSize() methods to rescale.

Parameters:
s - shape to create
Returns:
corresponding shape

createShape

public static VisADGeometryArray[] createShape(String s)
Create a shape from a string name

Parameters:
s - name of the staring
Returns:
corresponding array

shapeText

public static VisADGeometryArray shapeText(String s)
Wrapper for PlotText. Uses default values for start, base, and up to draw the text along the X axis.

Parameters:
s - string to turn into a shape.
Returns:
corresponding VisADGeometryArray

shapeText

public static VisADGeometryArray shapeText(String s,
                                           boolean center)
Wrapper for PlotText. Uses default values for start, base, and up to draw the text along the X axis.

Parameters:
s - string to turn into a shape.
center - center the text
Returns:
corresponding VisADGeometryArray

shapeText

public static VisADGeometryArray shapeText(String s,
                                           int fontSize,
                                           boolean center)
Wrapper for PlotText. Uses default values for start, base, and up to draw the text along the X axis.

Parameters:
s - string to turn into a shape.
fontSize - the font size
center - center the text
Returns:
corresponding VisADGeometryArray

shapeFont

public static VisADGeometryArray shapeFont(String s,
                                           Font f)
Wrapper for PlotText using font. Uses default values for start, base, and up to draw the text along the X axis.

Parameters:
s - string to turn into a shape.
f - font to use
Returns:
corresponding VisADGeometryArray

shapeFont

public static VisADGeometryArray shapeFont(String s,
                                           Font f,
                                           boolean center)
Wrapper for PlotText. Uses default values for start, base, and up to draw the text along the X axis.

Parameters:
s - string to turn into a shape.
f - font to use
center - center the text
Returns:
corresponding VisADGeometryArray

setSize

public static VisADGeometryArray[] setSize(VisADGeometryArray[] shapes,
                                           float size)
Set the size of the shapes. Scales the size by size.

Parameters:
shapes - shapes to resize
size - scaling factor
Returns:
resized shapes

setSize

public static VisADGeometryArray setSize(VisADGeometryArray shape,
                                         float size)
Set the size of the shapes. Scales the size by size.

Parameters:
shape - shapes to resize
size - scaling factor
Returns:
rescaled shape

setSize

public static VisADGeometryArray setSize(VisADGeometryArray shape,
                                         float x,
                                         float y,
                                         float z)
Set the size of the shapes. Scales the size by size.

Parameters:
shape - shapes to resize
x - scaling factor
y - scaling factor
z - scaling factor
Returns:
rescaled shape

offset

public static VisADGeometryArray offset(VisADGeometryArray shape,
                                        float[] off)
Offset the shape by the amounts in off.

Parameters:
shape - shape to offset
off - offset (x, y, z)
Returns:
offset shape

offset

public static VisADGeometryArray offset(VisADGeometryArray shape,
                                        float dx,
                                        float dy,
                                        float dz)
Offset the shape by the amounts in off.

Parameters:
shape - shape to offset
dx - delta x
dy - delta y
dz - delta z
Returns:
offset shape

bounds2d

public static Rectangle2D bounds2d(VisADGeometryArray shape)
Return the bounds of this shape

Parameters:
shape - shape to bound
Returns:
Rectangle of shape coordinates

bounds2d

public static Rectangle2D bounds2d(VisADGeometryArray shape,
                                   Rectangle2D rect)
Return the bounds of this shape

Parameters:
shape - shape to bound
rect - The rectangle to set. If null then create a new one.
Returns:
Rectangle of shape coordinates

bounds2d

public static Rectangle2D bounds2d(VisADGeometryArray[] shapes)
Return the bounds of array of shapes

Parameters:
shapes - shape to bound
Returns:
Rectangle of region bounded by shape coordinates

setColor

public static void setColor(VisADGeometryArray[] shapes,
                            Color color)
Set the color for the shapes in the array.

Parameters:
shapes - array of shapes to color
color - color to use.

setColor

public static void setColor(VisADGeometryArray[] shapes,
                            float[] RGB)
Set the color for the shapes in the array.

Parameters:
shapes - array of shapes to color
RGB - array of color components (R, G, B) to use.

setColor

public static void setColor(VisADGeometryArray shape,
                            Color color)
Set the color for the shape specified.

Parameters:
shape - shape to color
color - color to use.

blendColor

public static void blendColor(VisADGeometryArray shape,
                              Color color)
Blend the color for the shape specified with color.

Parameters:
shape - shape to color
color - color to use for blending.

setColor

public static void setColor(VisADGeometryArray shape,
                            float R,
                            float G,
                            float B)
Set the color for the shape specified.

Parameters:
shape - shape to color
R - red color component
G - green color component
B - blue color component

setColor

public static void setColor(VisADGeometryArray shape,
                            float[] RGB)
Set the color for the shape specified.

Parameters:
shape - shape to color
RGB - array of color components (R, G, B) to use.

blendColor

public static void blendColor(VisADGeometryArray shape,
                              float R,
                              float G,
                              float B)
Blend the color for the shape specified with RGB components specified

Parameters:
shape - shape to color
R - red color component
G - green color component
B - blue color component

reScale

public static void reScale(VisADGeometryArray[] shapes,
                           double scale)
Rescale the shapes

Parameters:
shapes - shapes to scale
scale - scale factor

reScale

public static void reScale(VisADGeometryArray shape,
                           double scale)
Rescale the shape

Parameters:
shape - shape to scale
scale - scale factor

reScale

public static void reScale(VisADGeometryArray[] shapes,
                           double[] scale)
Rescale the shapes

Parameters:
shapes - shapes to scale
scale - xyz scale factor

reScale

public static void reScale(VisADGeometryArray[] shapes,
                           double[] scaleArray,
                           double scale)
Rescale the shapes

Parameters:
shapes - shapes to scale
scaleArray - xyz scale factor
scale - extra scale factor

clone

public static VisADGeometryArray[] clone(VisADGeometryArray[] shapes)
Do a deep clone of the given shapes array

Parameters:
shapes - shape to clone
Returns:
The cloned array

reScale

public static void reScale(VisADGeometryArray shape,
                           double[] scale)
Rescale the shape

Parameters:
shape - shape to scale
scale - xyz scale factor

reScale

public static void reScale(VisADGeometryArray shape,
                           double[] scaleArray,
                           double scale)
Rescale the shape

Parameters:
shape - shape to scale
scaleArray - xyz scale factor
scale - scale factor

rotate

public static void rotate(VisADGeometryArray shape,
                          float angle)
Rotate the given shape about the z axis the given angle (in radians).

Parameters:
shape - The shape to rotate
angle - Radians

rotateZ

public static void rotateZ(VisADGeometryArray shape,
                           float angle)
Rotate the given shape about the z axis the given angle (in radians).

Parameters:
shape - The shape to rotate
angle - Radians

rotateX

public static void rotateX(VisADGeometryArray shape,
                           float angle)
Rotate the given shape about the x axis the given angle (in radians).

Parameters:
shape - The shape to rotate
angle - Radians

rotateY

public static void rotateY(VisADGeometryArray shape,
                           float angle)
Rotate the given shape about the y axis the given angle (in radians).

Parameters:
shape - The shape to rotate
angle - Radians