Package ucar.visad

Class ShapeUtility

java.lang.Object
ucar.visad.ShapeUtility

public class ShapeUtility extends Object
A utility class for manipulating VisAD Shapes (VisADGeometryArrays). Adapted from RAP's ShapeFactory class.
Author:
IDV Development Team
  • Field Details

  • Constructor Details

    • ShapeUtility

      public ShapeUtility()
      Default constructor
  • Method Details

    • makeShape

      public static VisADGeometryArray makeShape(String s)
      Create a predefined shape. Shapes are drawn on a 1x1(x1) box. Use setSize() methods to rescale.
      Parameters:
      s - shape to create deprecated Use create shape
      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.
    • 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.
    • 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 R, float G, float B, float A)
      Set the color for the shape specified.
      Parameters:
      shape - shape to color
      R - red color component
      G - green color component
      B - blue color component
      A - alpha component
    • 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.
    • 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
    • rotate

      public static void rotate(VisADGeometryArray shape, javax.media.j3d.Transform3D transform)
      Rotate a shape
      Parameters:
      shape - the shape
      transform - the 3D transform
    • rotate

      public static void rotate(VisADGeometryArray shape, javax.media.j3d.Transform3D transform, float deltax, float deltay, float deltaz)
      Rotate a shape
      Parameters:
      shape - the shape
      transform - the transform
      deltax - delta x
      deltay - delta y
      deltaz - delta z
    • 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