JMSLTM Numerical Library 6.1

com.imsl.chart
Class Draw

java.lang.Object
  extended by com.imsl.chart.Draw
Direct Known Subclasses:
DrawMap, DrawPick

public class Draw
extends Object

Chart tree renderer.

Renders the chart tree to the screen.


Field Summary
protected  int currentType
           
protected static int ERROR_BAR
           
protected static int FILL
           
protected  Color fillColor
           
protected  Color fillOutlineColor
           
protected  int fillOutlineType
           
protected  Paint fillPaint
           
protected  int fillType
           
protected  Graphics2D graphics
           
protected  boolean haveErrorBarProperties
           
protected  boolean haveFillProperties
           
protected  boolean haveImageProperties
           
protected  boolean haveLineProperties
           
protected  boolean haveMarkerProperties
           
protected  boolean haveTextProperties
           
protected static int IMAGE
           
protected  Component imageObserver
           
protected static int LAST
          Flag for the last data marker.
protected static int LINE
           
protected  Color lineColor
           
protected  float[] lineDashPattern
           
protected  float lineWidth
           
protected static int MARKER
           
protected static float MARKER_SCALE
          Normal marker size in pixels is screen width times MARKER_SCALE.
protected  Color markerColor
           
protected  float[] markerDashPattern
           
protected  float markerSize
           
protected  float markerThickness
           
protected  int markerType
           
protected  ChartNode node
           
protected static int NONE
           
protected static float[][][] outline
          Markers defined on a [-1,1] x [-1,1] grid.
protected  GeneralPath path
           
protected static double RADIAN
           
protected  float scaleFont
           
protected static int TEXT
           
protected  int textAngle
           
protected  Color textColor
           
protected  Font textFont
           
 
Constructor Summary
Draw(Graphics graphics, Dimension bounds)
          Contructs a Draw object.
 
Method Summary
protected  void check(int type)
           
 void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          Draws the outline of a circular or elliptical arc covering the specified rectangle.
 void drawClippedImage(Image image, int x, int y)
          Draws an image such that any portion of the image beyond the axis range is clipped.
 void drawErrorBar(int x0, int y0, int x1, int y1, int flag)
          Draw an error bar.
 void drawImage(Image image, int x, int y)
          Draw an image.
 void drawLine(int x0, int y0, int x1, int y1)
          Draw a line from (x0,y0) to (x1,y1).
 void drawMarker(int x, int y)
          Draw a marker.
protected  void drawRotatedText(Text text, int x, int y, float angle)
          Draws a text object, at the specified angle, with its lower left point being at (x,y).
protected  void drawText(Graphics g, Text text)
          Draws the text.
 Dimension drawText(Text text, int x, int y)
          Draws a text object.
protected  Dimension drawText(Text text, int x, int y, boolean dimensionOnly)
          Draws a text object.
 void endErrorBar()
          Stop drawing an error bar.
 void endFill()
          Stop drawing a filled region.
 void endImage()
          Stop drawing an image.
 void endLine()
          Finish drawing lines.
 void endMarker()
          Finish drawing markers.
 void endText()
          Stop drawing text.
 void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          Fills a circular or elliptical arc covering the specified rectangle.
 void fillPolygon(int[] xpoints, int[] ypoints, int npoints)
          Fill a polygon.
 void fillPolygon(Polygon polygon)
          Fill a polygon defined by a Polygon object.
 void fillRectangle(int x, int y, int width, int height)
          Fill a rectangle.
 Rectangle getClipBounds()
          Get the clipping rectangle.
 float getDeviceMarkerSize()
          Returns the marker size in device corrdinates.
 double getScaleFont()
          Returns the factor by which fonts are to be scaled.
protected  Dimension getSize(Text text)
          Returns the size of the bounding box for a text object.
 void setClip(Rectangle clip)
          Set the clipping rectangle.
 void setNode(ChartNode node)
          Set the current ChartNode.
 void setScaleFont(double scaleFont)
          Set a factor by which fonts are to be scaled.
 void start(Chart chart)
          Called just before a chart is drawn.
 void startErrorBar()
          Start drawing an error bar.
 void startFill()
          Start drawing a filled region.
 void startImage()
          Start drawing an image.
 void startLine()
          Start drawing lines.
 void startMarker()
          Start drawing markers.
 void startText()
          Start drawing text.
 void stop()
          Called when a chart is finished being drawn.
 void translate(int x, int y)
          Translates the origin to the point (x,y)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentType

protected int currentType

ERROR_BAR

protected static final int ERROR_BAR
See Also:
Constant Field Values

FILL

protected static final int FILL
See Also:
Constant Field Values

fillColor

protected Color fillColor

fillOutlineColor

protected Color fillOutlineColor

fillOutlineType

protected int fillOutlineType

fillPaint

protected Paint fillPaint

fillType

protected int fillType

graphics

protected Graphics2D graphics

haveErrorBarProperties

protected boolean haveErrorBarProperties

haveFillProperties

protected boolean haveFillProperties

haveImageProperties

protected boolean haveImageProperties

haveLineProperties

protected boolean haveLineProperties

haveMarkerProperties

protected boolean haveMarkerProperties

haveTextProperties

protected boolean haveTextProperties

IMAGE

protected static final int IMAGE
See Also:
Constant Field Values

imageObserver

protected Component imageObserver

LAST

protected static final int LAST
Flag for the last data marker.

See Also:
Constant Field Values

LINE

protected static final int LINE
See Also:
Constant Field Values

lineColor

protected Color lineColor

lineDashPattern

protected float[] lineDashPattern

lineWidth

protected float lineWidth

MARKER

protected static final int MARKER
See Also:
Constant Field Values

MARKER_SCALE

protected static final float MARKER_SCALE
Normal marker size in pixels is screen width times MARKER_SCALE.

See Also:
Constant Field Values

markerColor

protected Color markerColor

markerDashPattern

protected float[] markerDashPattern

markerSize

protected float markerSize

markerThickness

protected float markerThickness

markerType

protected int markerType

node

protected ChartNode node

NONE

protected static final int NONE
See Also:
Constant Field Values

outline

protected static final float[][][] outline
Markers defined on a [-1,1] x [-1,1] grid. Each row is a continuous polyline, {x1,y1, x2,y2, x3,y3, etc.} If a row contains only a single number then that number is taken as the radius of a circle with center at (0,0).


path

protected GeneralPath path

RADIAN

protected static final double RADIAN
See Also:
Constant Field Values

scaleFont

protected float scaleFont

TEXT

protected static final int TEXT
See Also:
Constant Field Values

textAngle

protected int textAngle

textColor

protected Color textColor

textFont

protected Font textFont
Constructor Detail

Draw

public Draw(Graphics graphics,
            Dimension bounds)
Contructs a Draw object.

Parameters:
graphics - is the graphics context in which to draw.
bounds - is the size of the chart to be drawn.
Method Detail

check

protected void check(int type)

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Draws the outline of a circular or elliptical arc covering the specified rectangle. The center of the arc is center of this rectangle.

Parameters:
x - An int which specifies the x of the rectangle.
y - An int which specifies the y of the rectangle origin.
width - An int which specifies the width of the rectangle.
height - An int which specifies the height of the rectangle.
startAngle - An int which specifies the start angle in degrees. startAngle = 0 is equivalent to the 3-o'clock position.
arcAngle - An int which specifies the arcAngle. drawArc draws the arc from startAngle to startAngle+arcAngle. A positive arcAngle indicates a counter-clockwise rotation. A negative arcAngle implies a clockwise rotation.

drawClippedImage

public void drawClippedImage(Image image,
                             int x,
                             int y)
Draws an image such that any portion of the image beyond the axis range is clipped.

Parameters:
image - the Image object to be drawn
x - an int which specifies the x-coordinate of the reference point
y - an int which specifies the y-coordinate of the reference point

drawErrorBar

public void drawErrorBar(int x0,
                         int y0,
                         int x1,
                         int y1,
                         int flag)
Draw an error bar.

Parameters:
x0 - an int which specifies the x-coordinate of the beginning reference point
y0 - an int which specifies the y-coordinate of the beginning reference point
x1 - an int which specifies the x-coordinate of the ending reference point
y1 - an int which specifies the y-coordinate of the ending reference point
flag - indicates which caps to draw (0=none, 1=bottom, 2=top, 3=both).

drawImage

public void drawImage(Image image,
                      int x,
                      int y)
Draw an image.

Parameters:
image - the Image object to be drawn
x - an int which specifies the x-coordinate of the reference point
y - an int which specifies the y-coordinate of the reference point

drawLine

public void drawLine(int x0,
                     int y0,
                     int x1,
                     int y1)
Draw a line from (x0,y0) to (x1,y1).

Parameters:
x0 - an int which specifies the x0 of the line origin, (x0,y0)
y0 - an int which specifies the y0 of the line origin, (x0,y0)
x1 - an int which specifies the x1 of the line destination, (x1,y1)
y1 - an int which specifies the y1 of the line destination, (x1,y1)

drawMarker

public void drawMarker(int x,
                       int y)
Draw a marker.

Parameters:
x - an int which specifies the x of the marker destination, (x,y)
y - an int which specifies the y of the marker destination, (x,y)

drawRotatedText

protected void drawRotatedText(Text text,
                               int x,
                               int y,
                               float angle)
Draws a text object, at the specified angle, with its lower left point being at (x,y).


drawText

protected void drawText(Graphics g,
                        Text text)
Draws the text.


drawText

public Dimension drawText(Text text,
                          int x,
                          int y)
Draws a text object.

Parameters:
text - the Text object to be drawn
x - an int which specifies the abscissa of the (x,y) point at which to start drawing the text
y - an int which specifies the ordinate of the (x,y) point at which to start drawing the text

drawText

protected Dimension drawText(Text text,
                             int x,
                             int y,
                             boolean dimensionOnly)
Draws a text object. The angle of the string is given by textAngle. Consider the horizontally and vertically aligned bounding box around the string. The box below corresponds to textAngle == 45.

        *--*--*
        |    o|
        |   l |
        *  l  *
        | e   |
        |H    |
        *--*--*
  

The reference point corresponds to one of the 8 starred points on the bounding box, as indicated by the "alignment" attribute" in the text object.

Parameters:
text - a Text object to be drawn.
x - an int which specifies the x-coordinate of the reference point.
y - an int which specifies the y-coordinate of the reference point.
dimensionOnly - a boolean which is true if only the bounding box is to be computed and no text actually drawn.
Returns:
the dimension of the bounding box.

endErrorBar

public void endErrorBar()
Stop drawing an error bar.


endFill

public void endFill()
Stop drawing a filled region.


endImage

public void endImage()
Stop drawing an image.


endLine

public void endLine()
Finish drawing lines.


endMarker

public void endMarker()
Finish drawing markers.


endText

public void endText()
Stop drawing text.


fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Fills a circular or elliptical arc covering the specified rectangle. The center of the arc is center of this rectangle.

Parameters:
x - An int which specifies the x of the rectangle.
y - An int which specifies the y of the rectangle origin.
width - An int which specifies the width of the rectangle.
height - An int which specifies the height of the rectangle.
startAngle - An int which specifies the start angle in degrees. startAngle = 0 is equivalent to the 3-o'clock position.
arcAngle - An int which specifies the arcAngle.

fillPolygon

public void fillPolygon(int[] xpoints,
                        int[] ypoints,
                        int npoints)
Fill a polygon.

Parameters:
xpoints - an int array which contains the abscissae of the points which define the polygon
ypoints - an int array which contains the ordinates of the points which define the polygon
npoints - an int which specifies the number of points

fillPolygon

public void fillPolygon(Polygon polygon)
Fill a polygon defined by a Polygon object.

Parameters:
polygon - a Polygon object which specifies the polygon to be filled

fillRectangle

public void fillRectangle(int x,
                          int y,
                          int width,
                          int height)
Fill a rectangle.

Parameters:
x - an int which specifies the abscissa of the origin of the rectangle
y - an int which specifies the ordinate of the origin of the rectangle
width - an int which specifies the width of the rectangle
height - an int which specifies the height of the rectangle

getClipBounds

public Rectangle getClipBounds()
Get the clipping rectangle.

Returns:
a Rectangle object which contains the clipping bounds

getDeviceMarkerSize

public float getDeviceMarkerSize()
Returns the marker size in device corrdinates.


getScaleFont

public double getScaleFont()
Returns the factor by which fonts are to be scaled.


getSize

protected Dimension getSize(Text text)
Returns the size of the bounding box for a text object. This does not take into account any rotation.


setClip

public void setClip(Rectangle clip)
Set the clipping rectangle.

Parameters:
clip - a Rectangle object which contains the clipping bounds

setNode

public void setNode(ChartNode node)
Set the current ChartNode. This is used to get drawing attributes from the tree.

Parameters:
node - a ChartNode object

setScaleFont

public void setScaleFont(double scaleFont)
Set a factor by which fonts are to be scaled.


start

public void start(Chart chart)
Called just before a chart is drawn.


startErrorBar

public void startErrorBar()
Start drawing an error bar.


startFill

public void startFill()
Start drawing a filled region.


startImage

public void startImage()
Start drawing an image.


startLine

public void startLine()
Start drawing lines.


startMarker

public void startMarker()
Start drawing markers.


startText

public void startText()
Start drawing text.


stop

public void stop()
Called when a chart is finished being drawn.


translate

public void translate(int x,
                      int y)
Translates the origin to the point (x,y)

Parameters:
x - an int which specifies the x of the new origin
y - an int which specifies the y of the new origin

JMSLTM Numerical Library 6.1

Copyright © 1970-2010 Visual Numerics, Inc.
Built July 30 2010.