NASA World Wind

gov.nasa.worldwind.render
Class FrameFactory

java.lang.Object
  extended by gov.nasa.worldwind.render.FrameFactory

public class FrameFactory
extends Object

Static class for drawing 2D frames.

All shapes are drawn inside a bounding rectangle whose lower left corner is at the origin. Shapes with a leader use an offset point that indicate where the leader triangle should point at - it usually has a negative y since the leader connects at the bottom of the frame (at y = 0).

See Also:
AbstractAnnotation

Field Summary
static String LEADER_NONE
           
static String LEADER_TRIANGLE
           
static String SHAPE_ELLIPSE
           
static String SHAPE_NONE
           
static String SHAPE_RECTANGLE
           
 
Constructor Summary
FrameFactory()
           
 
Method Summary
static DoubleBuffer createShapeBuffer(String shape, double width, double height, int cornerRadius)
          Create a vertex buffer for a shape with the specified width, height and corner radius.
static DoubleBuffer createShapeWithLeaderBuffer(String shape, double width, double height, Point leaderOffset, int cornerRadius)
          Create a vertex buffer for a shape with the specified width, height and corner radius.
static void drawBuffer(DrawContext dc, int glMode, DoubleBuffer verts)
          Draw a vertex buffer in a given gl mode.
static void drawBuffer(DrawContext dc, int glMode, DoubleBuffer verts, DoubleBuffer coords)
          Draw a vertex buffer with texture coordinates in a given gl mode.
static void drawShape(DrawContext dc, String shape, double width, double height, int glMode, int cornerRadius)
          Draw a shape with the specified width and height, gl mode and corner radius.
static void drawShapeWithLeader(DrawContext dc, String shape, double width, double height, Point leaderOffset, int glMode, int cornerRadius)
          Draw a shape with the specified width and height, gl mode and corner radius.
static DoubleBuffer getTextureCoordinates(DoubleBuffer verts, double width, double height, double textureWidth, double textureHeight)
          Computes texture coordinates for a vertex buffer, a dimension and a texture size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEADER_NONE

public static final String LEADER_NONE
See Also:
Constant Field Values

LEADER_TRIANGLE

public static final String LEADER_TRIANGLE
See Also:
Constant Field Values

SHAPE_ELLIPSE

public static final String SHAPE_ELLIPSE
See Also:
Constant Field Values

SHAPE_NONE

public static final String SHAPE_NONE
See Also:
Constant Field Values

SHAPE_RECTANGLE

public static final String SHAPE_RECTANGLE
See Also:
Constant Field Values
Constructor Detail

FrameFactory

public FrameFactory()
Method Detail

createShapeBuffer

public static DoubleBuffer createShapeBuffer(String shape,
                                             double width,
                                             double height,
                                             int cornerRadius)
Create a vertex buffer for a shape with the specified width, height and corner radius. Corner radius only apply to SHAPE_RECTANGLE - set to zero for square corners.

Parameters:
shape - the shape - can be one of SHAPE_RECTANGLE or SHAPE_ELLIPSE.
width - the width of the overall shape.
height - the height of the shape.
cornerRadius - the rounded corners radius. Set to zero for square corners.
Returns:
the vertex buffer.

createShapeWithLeaderBuffer

public static DoubleBuffer createShapeWithLeaderBuffer(String shape,
                                                       double width,
                                                       double height,
                                                       Point leaderOffset,
                                                       int cornerRadius)
Create a vertex buffer for a shape with the specified width, height and corner radius. The shape includes a leader triangle pointing to a specified point. Corner radius only apply to SHAPE_RECTANGLE - set to zero for square corners.

Parameters:
shape - the shape - can be one of SHAPE_RECTANGLE or SHAPE_ELLIPSE.
width - the width of the overall shape.
height - the height of the shape excluding the leader.
leaderOffset - the coordinates of the point to which the leader leads.
cornerRadius - the rounded corners radius. Set to zero for square corners.
Returns:
the vertex buffer.

drawBuffer

public static void drawBuffer(DrawContext dc,
                              int glMode,
                              DoubleBuffer verts)
Draw a vertex buffer in a given gl mode. Vertex buffers coming from the createShapeBuffer() methods support both GL.GL_TRIANGLE_FAN and GL.LINE_STRIP.

Parameters:
dc - the current DrawContext.
glMode - the desired drawing GL mode.
verts - the vertex buffer to draw.

drawBuffer

public static void drawBuffer(DrawContext dc,
                              int glMode,
                              DoubleBuffer verts,
                              DoubleBuffer coords)
Draw a vertex buffer with texture coordinates in a given gl mode. Vertex buffers coming from the createShapeBuffer() methods support both GL.GL_TRIANGLE_FAN and GL.LINE_STRIP.

Parameters:
dc - the current DrawContext.
glMode - the desired drawing GL mode.
verts - the vertex buffer to draw.

drawShape

public static void drawShape(DrawContext dc,
                             String shape,
                             double width,
                             double height,
                             int glMode,
                             int cornerRadius)
Draw a shape with the specified width and height, gl mode and corner radius. GL mode came be one of GL.GL_TRIANGLE_FAN and GL.LINE_STRIP. Corner radius only apply to SHAPE_RECTANGLE - set to zero for square corners.

Parameters:
dc - the current DrawContext.
shape - the shape - can be one of SHAPE_RECTANGLE or SHAPE_ELLIPSE.
width - the width of the overall shape.
height - the height of the shape.
glMode - the GL mode - can be one of GL.GL_TRIANGLE_FAN and GL.LINE_STRIP.
cornerRadius - the rounded corners radius. Set to zero for square corners.

drawShapeWithLeader

public static void drawShapeWithLeader(DrawContext dc,
                                       String shape,
                                       double width,
                                       double height,
                                       Point leaderOffset,
                                       int glMode,
                                       int cornerRadius)
Draw a shape with the specified width and height, gl mode and corner radius. The shape includes a leader triangle pointing to a specified point. GL mode came be one of GL.GL_TRIANGLE_FAN and GL.LINE_STRIP. Corner radius only apply to SHAPE_RECTANGLE - set to zero for square corners.

Parameters:
dc - the current DrawContext.
shape - the shape - can be one of SHAPE_RECTANGLE or SHAPE_ELLIPSE.
width - the width of the overall shape.
height - the height of the shape excluding the leader.
leaderOffset - the coordinates of the point to which the leader leads.
glMode - the GL mode - can be one of GL.GL_TRIANGLE_FAN and GL.LINE_STRIP.
cornerRadius - the rounded corners radius. Set to zero for square corners.

getTextureCoordinates

public static DoubleBuffer getTextureCoordinates(DoubleBuffer verts,
                                                 double width,
                                                 double height,
                                                 double textureWidth,
                                                 double textureHeight)
Computes texture coordinates for a vertex buffer, a dimension and a texture size. Coordinates are computed so that the texture image proportions and size are preserved. The texture is aligned at top left corner of the vertices bounding rectangle.

Parameters:
verts - the vertex buffer containing the vertices for which texture coordinates have to be computed.
width - the vertices bounding rectangle width - excluding the leader if any.
height - the vertices bounding rectangle height - excluding the leader if any.
textureWidth - the texture width
textureHeight - the texture height
Returns:
the texture coordinates DoubleBuffer

NASA World Wind