KavaChart 5.2.2 API

com.ve.kavachart.chart
Class Gc

java.lang.Object
  extended bycom.ve.kavachart.chart.Gc
All Implemented Interfaces:
java.io.Serializable

public class Gc
extends java.lang.Object
implements java.io.Serializable

This is a general purpose graphics class for drawing functionality and for storing graphical attributes. Most other KavaChart classes contain at least one Gc instance, which is used for storing things like line color and fill color, as well as drawing methods. Internally, KavaChart uses a "lower left" origin, which is more natural to most chart styles than Java's "top left" origin. The Gc class converts all incoming coordinates into KavaChart's "lower left" origin.

See Also:
RotateString, Globals, Serialized Form

Field Summary
protected static java.awt.Color[] colors
           
static int COMMA_FORMAT
          American style numbers with commas and a decimal period (e.g.
static int DEFAULT_FORMAT
          default number format
static java.awt.Font defaultFont
           
static int EURO_FORMAT
          European style numbers with periods and a comma at the decimal point (e.g.
static int FILL_GRADIENT
           
static int FILL_SOLID
           
static int FILL_TEXTURE
           
protected  java.awt.Color fillColor
           
protected  int fillStyle
           
protected  Globals globals
           
protected  java.awt.Image image
           
static int keepABOVE
          string above given point
static int keepBELOW
          string below given point
static int keepLEFT
          string to the left of given point
static int keepRIGHT
          string to the right of given point
static java.lang.String LINE_BREAK
           
static int LINE_DASH
           
static int LINE_DOT
           
static int LINE_DOT_DASH
           
static int LINE_SOLID
           
protected  java.awt.Color lineColor
           
protected  int lineStyle
           
protected  int lineWidth
           
protected  int markerSize
           
protected  int markerStyle
           
static int MK_CIRCLE
           
static int MK_DIAMOND
           
static int MK_NONE
           
static int MK_SQUARE
           
static int MK_TRIANGLE
           
protected  boolean outlineFills
           
static java.awt.Color TRANSPARENT
          A utility color - Gc.TRANSPARENT items will not be drawn
 
Constructor Summary
Gc(boolean unique, Globals g, boolean isPie)
          Sets the fill, marker, and line to a unique color.
Gc(java.awt.Color clr, Globals g)
          Sets the fill, marker, and line color to a user specified color.
Gc(Globals g)
          Sets the fill, marker, and line color to black.
Gc(int datasetNumber, Globals g)
          Sets the fill, marker, and line color based on the dataset index number.
 
Method Summary
static java.awt.Color darker(Globals g, java.awt.Color c)
          A platform-neutral static method for getting a darker color.
 void drawArc(java.awt.Graphics g, java.awt.Point center, java.awt.Point heightWidth, int startAngle, int endAngle)
          Draws an arc using the current fill color and KavaChart's coordinates.
 void drawImage(java.awt.Graphics g, java.awt.Point pt)
          Draw an image centered at a given point using Javachart's coordinate system.
 void drawLine(java.awt.Graphics g, int startx, int starty, int endx, int endy)
          A drawLine that uses KavaChart's coordinate system.
 void drawLine(java.awt.Graphics g, java.awt.Point start, java.awt.Point end)
          Draws a line in the current line color using KavaChart's coordinates
protected static void drawMarker(java.awt.Graphics g, int x, int y, int type, int size)
          Draws a marker in the specified size and type at the specified location
 void drawPolygon(java.awt.Graphics g, java.awt.Point[] pts)
          Fills a polygon using the current fillColor, using an array of points in KavaChart's coordinate system.
 void drawPolyline(java.awt.Graphics g, java.awt.Point[] pts)
          Draws a polyline using the current lineColor.
 void drawPolymarker(java.awt.Graphics g, java.awt.Point[] pts)
          Draws markers in the current markerSize and markerType and fillColor
 void drawSmartString(java.awt.Graphics g, int startx, int starty, int alignment, int angle, java.awt.FontMetrics fm, java.lang.String str)
          Draws a string in the current color and Font at the specified location, position, and angle.
 void drawString(java.awt.Graphics g, int startx, int starty, java.lang.String str)
          A drawString that uses KavaChart's coordinate system.
 void fillArc(java.awt.Graphics g, java.awt.Point center, java.awt.Point heightWidth, int startAngle, int endAngle, boolean lastSlice)
          Fills an Arc in the current fill color from a center point
 void fillRect(java.awt.Graphics g, java.awt.Point ll, java.awt.Point ur)
          Fills a rectangle with the current fill color
 java.awt.Color getFillColor()
          Returns the current fillColor.
 int getFillStyle()
           
 Globals getGlobals()
           
 int getGradient()
           
 GcHelper getHelper()
          Returns this Gc's helper class.
 java.awt.Image getImage()
          Returns the Image used with this Gc.
 java.awt.Color getLineColor()
          Returns the current lineColor.
 int getLineStyle()
          Returns the current lineStyle.
 int getLineWidth()
          Returns the current lineWidth This integer value is the number of pixels wide this Gc will draw lines.
 int getMarkerSize()
          Returns the marker size.
 int getMarkerStyle()
          Returns the marker style.
 boolean getOutlineFills()
          Returns true if this Gc is set up to outline polygons
 java.awt.Color getSecondaryFillColor()
           
protected static int getStringHeight(java.awt.FontMetrics fm, java.lang.String str)
          Returns the height of a label taking line breaks into account
protected static int getStringWidth(java.awt.FontMetrics fm, java.lang.String str)
          Returns the width of a label taking line breaks into account
 int getTexture()
           
 void setFillColor(java.awt.Color c)
          Sets the current fillColor.
 void setFillStyle(int style)
           
 void setGlobals(Globals g)
           
 void setGradient(int grad)
           
 void setImage(java.awt.Image i)
          Assigns an Image for use with this Gc.
 void setLineColor(java.awt.Color c)
          Sets the current lineColor.
 void setLineStyle(int i)
          Sets the current lineStyle.
 void setLineWidth(int i)
          Sets the current lineWidth Sets the number of pixels wide for this Gc's lines and polylines.
 void setMarkerSize(int i)
          Sets the marker size in pixels
 void setMarkerStyle(int i)
          Sets the marker style For example setMarkerStyle(Gc.MK_CIRCLE)
 void setOutlineFills(boolean outline)
          Determines whether polygons and rectangles will be outlined with lineColor
 void setSecondaryFillColor(java.awt.Color c)
          Sets a secondary fill color on this Gc's Helper class.
 void setTexture(int texture)
          Installs a GcHelper if none exists, sets the fillStyle to FILL_TEXTURE, and sets the predefined pattern on the GcHelper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fillColor

protected java.awt.Color fillColor

image

protected transient java.awt.Image image

globals

protected Globals globals

lineColor

protected java.awt.Color lineColor

lineStyle

protected int lineStyle

lineWidth

protected int lineWidth

outlineFills

protected boolean outlineFills

colors

protected static java.awt.Color[] colors

TRANSPARENT

public static java.awt.Color TRANSPARENT
A utility color - Gc.TRANSPARENT items will not be drawn


DEFAULT_FORMAT

public static final int DEFAULT_FORMAT
default number format

See Also:
Constant Field Values

COMMA_FORMAT

public static final int COMMA_FORMAT
American style numbers with commas and a decimal period (e.g. 1,000.00)

See Also:
Constant Field Values

EURO_FORMAT

public static final int EURO_FORMAT
European style numbers with periods and a comma at the decimal point (e.g. 1.000,00)

See Also:
Constant Field Values

keepBELOW

public static final int keepBELOW
string below given point

See Also:
Constant Field Values

keepLEFT

public static final int keepLEFT
string to the left of given point

See Also:
Constant Field Values

keepABOVE

public static final int keepABOVE
string above given point

See Also:
Constant Field Values

keepRIGHT

public static final int keepRIGHT
string to the right of given point

See Also:
Constant Field Values

defaultFont

public static java.awt.Font defaultFont

MK_NONE

public static final int MK_NONE
See Also:
Constant Field Values

MK_SQUARE

public static final int MK_SQUARE
See Also:
Constant Field Values

MK_DIAMOND

public static final int MK_DIAMOND
See Also:
Constant Field Values

MK_CIRCLE

public static final int MK_CIRCLE
See Also:
Constant Field Values

MK_TRIANGLE

public static final int MK_TRIANGLE
See Also:
Constant Field Values

markerSize

protected int markerSize

markerStyle

protected int markerStyle

FILL_SOLID

public static final int FILL_SOLID
See Also:
Constant Field Values

FILL_GRADIENT

public static final int FILL_GRADIENT
See Also:
Constant Field Values

FILL_TEXTURE

public static final int FILL_TEXTURE
See Also:
Constant Field Values

fillStyle

protected int fillStyle

LINE_SOLID

public static final int LINE_SOLID
See Also:
Constant Field Values

LINE_DASH

public static final int LINE_DASH
See Also:
Constant Field Values

LINE_DOT

public static final int LINE_DOT
See Also:
Constant Field Values

LINE_DOT_DASH

public static final int LINE_DOT_DASH
See Also:
Constant Field Values

LINE_BREAK

public static final java.lang.String LINE_BREAK
See Also:
Constant Field Values
Constructor Detail

Gc

public Gc(int datasetNumber,
          Globals g)
Sets the fill, marker, and line color based on the dataset index number.

Parameters:
g - This chart's Globals class

Gc

public Gc(java.awt.Color clr,
          Globals g)
Sets the fill, marker, and line color to a user specified color.

Parameters:
clr - User's color
g - This chart's Globals class

Gc

public Gc(Globals g)
Sets the fill, marker, and line color to black.

Parameters:
g - This chart's Globals class

Gc

public Gc(boolean unique,
          Globals g,
          boolean isPie)
Sets the fill, marker, and line to a unique color.

Parameters:
unique - True if color should be unique
g - This chart's Globals class
Method Detail

drawArc

public void drawArc(java.awt.Graphics g,
                    java.awt.Point center,
                    java.awt.Point heightWidth,
                    int startAngle,
                    int endAngle)
Draws an arc using the current fill color and KavaChart's coordinates.

Parameters:
g - The affected Graphics class
center - Center point
heightWidth - Size of arc
startAngle - Starting angle
endAngle - Ending angle

drawImage

public void drawImage(java.awt.Graphics g,
                      java.awt.Point pt)
Draw an image centered at a given point using Javachart's coordinate system.

Parameters:
g - The affected Graphics
pt - Center of image

drawLine

public void drawLine(java.awt.Graphics g,
                     int startx,
                     int starty,
                     int endx,
                     int endy)
A drawLine that uses KavaChart's coordinate system. Uses the current lineColor.

Parameters:
g - The affected Graphics class
startx - X coordinate of starting point
starty - Y coordinate of starting point
endx - X coordinate of end point
endy - Y coordinate of end point

drawLine

public void drawLine(java.awt.Graphics g,
                     java.awt.Point start,
                     java.awt.Point end)
Draws a line in the current line color using KavaChart's coordinates

Parameters:
g - Graphics class to draw
start - Start point
end - End point

drawMarker

protected static void drawMarker(java.awt.Graphics g,
                                 int x,
                                 int y,
                                 int type,
                                 int size)
Draws a marker in the specified size and type at the specified location

Parameters:
x - int
y - int
type - int
size - int

darker

public static java.awt.Color darker(Globals g,
                                    java.awt.Color c)
A platform-neutral static method for getting a darker color. This is used for bar faces, area edges, etc. to support transparency.


drawPolygon

public void drawPolygon(java.awt.Graphics g,
                        java.awt.Point[] pts)
Fills a polygon using the current fillColor, using an array of points in KavaChart's coordinate system.

Parameters:
g - The affected graphics
pts - Array of polygon's points

drawPolyline

public void drawPolyline(java.awt.Graphics g,
                         java.awt.Point[] pts)
Draws a polyline using the current lineColor.

Parameters:
g - The affected graphics
pts - Array of polyline's points

drawPolymarker

public void drawPolymarker(java.awt.Graphics g,
                           java.awt.Point[] pts)
Draws markers in the current markerSize and markerType and fillColor

Parameters:
g - The affected graphics
pts - Array of marker points

drawSmartString

public void drawSmartString(java.awt.Graphics g,
                            int startx,
                            int starty,
                            int alignment,
                            int angle,
                            java.awt.FontMetrics fm,
                            java.lang.String str)
Draws a string in the current color and Font at the specified location, position, and angle. This method attempts to handle strings in a "smart" fashion, adjusting alignment points based on whether the string should remain above, below, to the left, or to the right of the specified location. Strings with a rotation angle are aligned with one of the corners of the string's extent box. Strings with an angle of 0 are centered at the location.

Parameters:
g - Graphics affected
startx - X position of string
starty - Y position of string
alignment - keepABOVE, keepBELOW, etc.
angle - Rotation angle in degrees
fm - A FontMetrics class for the unrotated string
str - The String to draw

drawString

public void drawString(java.awt.Graphics g,
                       int startx,
                       int starty,
                       java.lang.String str)
A drawString that uses KavaChart's coordinate system. Also handles null-pointer exceptions.

Parameters:
g - The affected Graphics
startx - X coordinate of starting point
starty - Y coordinate of starting point
str - The string to be drawn

fillArc

public void fillArc(java.awt.Graphics g,
                    java.awt.Point center,
                    java.awt.Point heightWidth,
                    int startAngle,
                    int endAngle,
                    boolean lastSlice)
Fills an Arc in the current fill color from a center point

Parameters:
g - The affected Graphics
center - Center point
heightWidth - Size of arc
startAngle - Starting angle
endAngle - Ending angle
lastSlice - outline both sides of the last slice only, or if a pie slice is exploded

fillRect

public void fillRect(java.awt.Graphics g,
                     java.awt.Point ll,
                     java.awt.Point ur)
Fills a rectangle with the current fill color

Parameters:
g - Graphics class to draw
ll - lower left corner of rectangle
ur - upper right corner of rectangle

getFillColor

public java.awt.Color getFillColor()
Returns the current fillColor.

Returns:
Fill color

getImage

public java.awt.Image getImage()
Returns the Image used with this Gc. For Line and Regress charts this Image is used for data markers. For Bar and Column charts, this Image is the tile for the data bars. Currently not implemented for Bar and Colum charts.

Returns:
Marker image

getLineColor

public java.awt.Color getLineColor()
Returns the current lineColor.

Returns:
Line color

getLineStyle

public int getLineStyle()
Returns the current lineStyle. Currently not implemented

Returns:
Line style

getLineWidth

public int getLineWidth()
Returns the current lineWidth This integer value is the number of pixels wide this Gc will draw lines.

Returns:
Line width

getMarkerSize

public int getMarkerSize()
Returns the marker size. The return value is in pixels

Returns:
Marker size

getMarkerStyle

public int getMarkerStyle()
Returns the marker style.

Returns:
Marker style

getOutlineFills

public boolean getOutlineFills()
Returns true if this Gc is set up to outline polygons

Returns:
boolean

getStringWidth

protected static int getStringWidth(java.awt.FontMetrics fm,
                                    java.lang.String str)
Returns the width of a label taking line breaks into account

Parameters:
fm - a font metrics class initialized for this label
str - the label string
Returns:
label width

getStringHeight

protected static int getStringHeight(java.awt.FontMetrics fm,
                                     java.lang.String str)
Returns the height of a label taking line breaks into account

Parameters:
fm - a font metrics class initialized for this label
str - the label string
Returns:
label height

setFillColor

public void setFillColor(java.awt.Color c)
Sets the current fillColor.

Parameters:
c - Fill color

setImage

public void setImage(java.awt.Image i)
Assigns an Image for use with this Gc. For Line and Regress charts this Image is used to create data markers. For Bar and Column charts, this Image is used as a tile for the data bars. Currently not implemented for Bar and Colum charts.

Parameters:
i - Marker image

setLineColor

public void setLineColor(java.awt.Color c)
Sets the current lineColor.

Parameters:
c - Line color

setLineStyle

public void setLineStyle(int i)
Sets the current lineStyle. For example setLineStyle(Gc.LINE_DASH)

Parameters:
i - Line style

setLineWidth

public void setLineWidth(int i)
Sets the current lineWidth Sets the number of pixels wide for this Gc's lines and polylines.

Parameters:
i - Line width

setMarkerSize

public void setMarkerSize(int i)
Sets the marker size in pixels

Parameters:
i - Marker size

setMarkerStyle

public void setMarkerStyle(int i)
Sets the marker style For example setMarkerStyle(Gc.MK_CIRCLE)

Parameters:
i - Marker style

setOutlineFills

public void setOutlineFills(boolean outline)
Determines whether polygons and rectangles will be outlined with lineColor

Parameters:
outline - boolean

setGradient

public void setGradient(int grad)

getGradient

public int getGradient()

getHelper

public GcHelper getHelper()
Returns this Gc's helper class. If none exists, one is created and returned. Creation date: (1/22/2002 2:41:10 PM)

Returns:
com.ve.kavachart.chart.GcHelper

setSecondaryFillColor

public void setSecondaryFillColor(java.awt.Color c)
Sets a secondary fill color on this Gc's Helper class. This is used as a second color for Gradients or Textures (pattern fills). Creation date: (1/22/2002 3:02:48 PM)

Parameters:
c - java.awt.Color

getSecondaryFillColor

public java.awt.Color getSecondaryFillColor()

setTexture

public void setTexture(int texture)
Installs a GcHelper if none exists, sets the fillStyle to FILL_TEXTURE, and sets the predefined pattern on the GcHelper. Creation date: (1/22/2002 2:35:06 PM)


getTexture

public int getTexture()

setFillStyle

public void setFillStyle(int style)

getFillStyle

public int getFillStyle()

setGlobals

public void setGlobals(Globals g)

getGlobals

public Globals getGlobals()

KavaChart 5.2.2 API