visad.bom
Class SceneGraphRenderer

java.lang.Object
  extended by visad.bom.SceneGraphRenderer

public class SceneGraphRenderer
extends Object

Render the non-texture components of a scene graph to a Graphics2D. This does not handle any 3D aspect, rotation, etc.


Nested Class Summary
 class SceneGraphRenderer.ChartException
          Chart exception
 class SceneGraphRenderer.Hatching
          Provide a set of simple hatching patterns
 
Field Summary
protected  ArrayList colours
          list of colours
protected  boolean gradientFill
          flag for gradient fill
protected  int height
          actual height
static int MODE_2D
          2D mode
static int MODE_3D
          3D mode
protected  boolean monochrome
          flag for monochrome
protected  float pixelWidth
          pixel width
protected  boolean plotMap
          plot map flag
protected  boolean useTransparency
          flag for transparency
protected  AffineTransform viewPort
          the viewport
protected  int width
          actual width
 
Constructor Summary
SceneGraphRenderer()
          Default constructor
 
Method Summary
 void drawShape(float[][] vertices, Color colour, float width, Graphics2D graphics)
          Draw the outline of a shape onto the chart
 void drawShape(float[][] vertices, Color colour, float width, int dashStyle, Graphics2D graphics)
          Draw the outline of a shape onto the chart
 void drawShapeReprojected(float[][] vertices, Color colour, float width, Graphics2D graphics)
          Draw a reprojected shape
 void drawShapeReprojected(float[][] vertices, Color colour, float width, int dashStyle, Graphics2D graphics)
          Draw a reprojected shape
 void drawShapeReprojected(float[][] vertices, Color colour, float width, int dashStyle, Graphics2D graphics, boolean isScreen)
          Draw a reprojected shape
 void drawString(String text, Font font, Color colour, float x, float y, Graphics2D graphics)
          Draw text onto the chart
 void fillShape(float[][] vertices, Color colour, Graphics2D graphics)
          Fill a shape onto the chart
 void fillShape(float[][] data, int texture, Graphics2D graphics)
          Fill a shape onto the chart
 void fillShapeReprojected(float[][] vertices, Color colour, Graphics2D graphics)
          Fill a reprojected shape
 void fillShapeReprojected(float[][] vertices, Color colour, Graphics2D graphics, boolean isScreen)
          Fill a reprojected shape
 void fillShapeReprojected(float[][] vertices, int texture, Graphics2D graphics)
          Fill a reprojected shape from a texture
 void fillShapeReprojected(float[][] vertices, int texture, Graphics2D graphics, boolean isScreen)
          Fill a reprojected shape from a texture
 Color[] getColours()
          Get a list of the colours used in the chart This may be necessary if the chart is being plotted to a medium with limited colours, eg. 8 bit PNG.
 float getLineWidth()
          Get the line width
 float[][] getLonLatSamples(int xSize, int ySize)
          Return an array of Longitudes/Latitudes corresponding to the pixels of the chart.
 void plot(Graphics2D graphics, DisplayImpl display, CoordinateSystem cs, int width, int height)
          Implements the Plottable interface.
 int print(Graphics graphics, PageFormat pageFormat, int pageIndex, DisplayImpl display, CoordinateSystem cs)
          Print the display
 void setTransformToScreenCoords(boolean value)
          Set whether the vertices should be transformed from display coords to screen coords before drawing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

protected int width
actual width


height

protected int height
actual height


MODE_2D

public static final int MODE_2D
2D mode

See Also:
Constant Field Values

MODE_3D

public static final int MODE_3D
3D mode

See Also:
Constant Field Values

pixelWidth

protected float pixelWidth
pixel width


monochrome

protected boolean monochrome
flag for monochrome


gradientFill

protected boolean gradientFill
flag for gradient fill


useTransparency

protected boolean useTransparency
flag for transparency


colours

protected ArrayList colours
list of colours


plotMap

protected boolean plotMap
plot map flag


viewPort

protected AffineTransform viewPort
the viewport

Constructor Detail

SceneGraphRenderer

public SceneGraphRenderer()
Default constructor

Method Detail

getLonLatSamples

public float[][] getLonLatSamples(int xSize,
                                  int ySize)
Return an array of Longitudes/Latitudes corresponding to the pixels of the chart. Based on the Charts CoordinateSystem and ViewPort. In the case of an A0 chart, the number of pixels may be huge, so supply an X and Y size allowing a smaller subset to be used if necessary The purpose of this method is to allow an image to be interpolated onto the chart as an overlay (eg. sat image)

Parameters:
xSize - The size of the target X dimension
ySize - The size of the target Y dimension
Returns:
An array of Longitudes/Latitudes corresponding to the pixels of the chart, sampled to match the target x/y size. Based on the Charts CoordinateSystem and ViewPort

getColours

public Color[] getColours()
Get a list of the colours used in the chart This may be necessary if the chart is being plotted to a medium with limited colours, eg. 8 bit PNG. The antialiasing and gradient fill used in some charts can easily grab all the available colours By taking the ones used specifically by the chart, the important colours can be reserved in the colour table ensuring that any colour loss has only minimal cosmetic effect

Returns:
The colours used by this chart

getLineWidth

public float getLineWidth()
Get the line width

Returns:
the line width

plot

public void plot(Graphics2D graphics,
                 DisplayImpl display,
                 CoordinateSystem cs,
                 int width,
                 int height)
Implements the Plottable interface. This will plot the chart to a vector graphics file Don't use this method directly. It is called by the Plotter class

Parameters:
graphics - The java2d object used by the third party graphics library to render the graphics file
display - the display to render
cs - the display side coordinate system
width - the width of the output
height - the height of the output

print

public int print(Graphics graphics,
                 PageFormat pageFormat,
                 int pageIndex,
                 DisplayImpl display,
                 CoordinateSystem cs)
Print the display

Parameters:
graphics - Graphics to print to
pageFormat - the page format
pageIndex - the page index
display - the display to render
cs - the display side coordinate system
Returns:
flag for success

drawShapeReprojected

public void drawShapeReprojected(float[][] vertices,
                                 Color colour,
                                 float width,
                                 Graphics2D graphics)
Draw a reprojected shape

Parameters:
vertices - vertices
colour - default color
width - line width
graphics - the graphics

drawShapeReprojected

public void drawShapeReprojected(float[][] vertices,
                                 Color colour,
                                 float width,
                                 int dashStyle,
                                 Graphics2D graphics)
Draw a reprojected shape

Parameters:
vertices - vertices
colour - default color
width - line width
dashStyle - line dash style
graphics - the graphics

drawShapeReprojected

public void drawShapeReprojected(float[][] vertices,
                                 Color colour,
                                 float width,
                                 int dashStyle,
                                 Graphics2D graphics,
                                 boolean isScreen)
Draw a reprojected shape

Parameters:
vertices - vertices
colour - default color
width - line width
dashStyle - line dash style
graphics - the graphics
isScreen - vertices are in screen coordinates

drawShape

public void drawShape(float[][] vertices,
                      Color colour,
                      float width,
                      int dashStyle,
                      Graphics2D graphics)
               throws VisADException
Draw the outline of a shape onto the chart

Parameters:
vertices - The vertices of the shape. A 2-Dimensional array. The first dimension contains the longitude values of the shape The second dimension contains the latitude values of the shape
colour - The colour of the shape
width - The thickness of the outline
dashStyle - Set to 0 if the outline is to be drawn as dashes
graphics - The java2d graphics object supplied by the plotting/printing medium
Throws:
VisADException

drawShape

public void drawShape(float[][] vertices,
                      Color colour,
                      float width,
                      Graphics2D graphics)
               throws VisADException
Draw the outline of a shape onto the chart

Parameters:
vertices - The vertices of the shape. A 2-Dimensional array. The first dimension contains the longitude values of the shape The second dimension contains the latitude values of the shape
colour - The colour of the shape
width - The thickness of the outline
graphics - The java2d graphics object supplied by the plotting/printing medium
Throws:
VisADException

fillShapeReprojected

public void fillShapeReprojected(float[][] vertices,
                                 Color colour,
                                 Graphics2D graphics)
Fill a reprojected shape

Parameters:
vertices - the vertices of the shape
colour - the color
graphics - the graphics

fillShapeReprojected

public void fillShapeReprojected(float[][] vertices,
                                 Color colour,
                                 Graphics2D graphics,
                                 boolean isScreen)
Fill a reprojected shape

Parameters:
vertices - the vertices of the shape
colour - the color
graphics - the graphics
isScreen - true if vertices are in screen (AWT) coordinates

fillShape

public void fillShape(float[][] vertices,
                      Color colour,
                      Graphics2D graphics)
               throws VisADException
Fill a shape onto the chart

Parameters:
vertices - The vertices of the shape. A 2-Dimensional array. The first dimension contains the longitude values of the shape The second dimension contains the latitude values of the shape
colour - The colour of the shape
graphics - The java2d graphics object supplied by the plotting/printing medium
Throws:
VisADException

fillShapeReprojected

public void fillShapeReprojected(float[][] vertices,
                                 int texture,
                                 Graphics2D graphics)
Fill a reprojected shape from a texture

Parameters:
vertices - the shape vertices
texture - The hatching texture to fill the shape with can be Hatching.DIAGONAL1, Hatching.DIAGONAL2, Hatching.DIAGONAL_BOTH, Hatching.HORIZONTAL = 3, Hatching.VERTICAL or Hatching.SQUARE
graphics - The java2d graphics object supplied by the plotting/printing medium

fillShapeReprojected

public void fillShapeReprojected(float[][] vertices,
                                 int texture,
                                 Graphics2D graphics,
                                 boolean isScreen)
Fill a reprojected shape from a texture

Parameters:
vertices - the shape vertices
texture - The hatching texture to fill the shape with can be Hatching.DIAGONAL1, Hatching.DIAGONAL2, Hatching.DIAGONAL_BOTH, Hatching.HORIZONTAL = 3, Hatching.VERTICAL or Hatching.SQUARE
graphics - The java2d graphics object supplied by the plotting/printing medium
isScreen - true if vertices are in screen (AWT) coordinates

fillShape

public void fillShape(float[][] data,
                      int texture,
                      Graphics2D graphics)
               throws VisADException
Fill a shape onto the chart

Parameters:
data - The vertices of the shape. A 2-Dimensional array. The first dimension contains the longitude values of the shape The second dimension contains the latitude values of the shape
texture - The hatching texture to fill the shape with can be Hatching.DIAGONAL1, Hatching.DIAGONAL2, Hatching.DIAGONAL_BOTH, Hatching.HORIZONTAL = 3, Hatching.VERTICAL or Hatching.SQUARE
graphics - The java2d graphics object supplied by the plotting/printing medium
Throws:
VisADException - problem transforming from lat/lon to display space

drawString

public void drawString(String text,
                       Font font,
                       Color colour,
                       float x,
                       float y,
                       Graphics2D graphics)
                throws VisADException
Draw text onto the chart

Parameters:
text - The text to draw onto the chart
font - The font of the text
colour - The colour of the text
x - The x position of the text (longitude)
y - The y position of the text (latitude)
graphics - The java2d graphics object supplied by the plotting/printing medium
Throws:
VisADException

setTransformToScreenCoords

public void setTransformToScreenCoords(boolean value)
Set whether the vertices should be transformed from display coords to screen coords before drawing. This ends up bypassing the use of the AffineTransform when drawing. Use this if you are in a rotated 3D display.

Parameters:
value - true to transform