JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart
Class JCLineStyle

java.lang.Object
  |
  +--com.klg.jclass.chart.JCStyle
        |
        +--com.klg.jclass.chart.JCLineStyle
All Implemented Interfaces:
Serializable

public class JCLineStyle
extends JCStyle

JCLineStyle controls how a line is drawn. It stores the line pattern and line width, and then draws lines accordingly.

See Also:
Serialized Form

Field Summary
protected  int cap
           
protected  Color color
           
protected  int colorIndex
           
static int CUSTOM
           
static int DASH_DOT
           
static float[] DASH_DOT_ARRAY
           
protected  float[] dashArray
           
protected  int join
           
static float[] LEGEND_DASH_DOT_ARRAY
           
static float[] LEGEND_LONG_DASH_ARRAY
           
static float[] LEGEND_LSL_DASH_ARRAY
           
static float[] LEGEND_SHORT_DASH_ARRAY
           
protected  float[] legendDashArray
           
static int LONG_DASH
           
static float[] LONG_DASH_ARRAY
           
static int LSL_DASH
           
static float[] LSL_DASH_ARRAY
           
static int NONE
           
protected  int pattern
           
static int SHORT_DASH
           
static float[] SHORT_DASH_ARRAY
           
static int SOLID
           
protected  int width
           
protected  int[] xp
           
protected  int[] yp
           
 
Fields inherited from class com.klg.jclass.chart.JCStyle
defaultColors, parent
 
Constructor Summary
JCLineStyle(int w, Color c, int p)
          Constructor for line style objects.
JCLineStyle(int w, Color c, int p, int cp, int j)
          Full Constructor for line style objects.
JCLineStyle(int w, Color c, int p, int cp, int j, float[] da, float[] dla)
          Full Constructor for line style objects.
 
Method Summary
 void draw(Graphics gc, int x1, int y1, int x2, int y2)
          Draws a line between two points according to the the properties of this line style.
 void draw(Graphics gc, int x1, int y1, int x2, int y2, Color col)
          Draws a line between two points according to the the properties of this line style, except that the color is overridden with the specified color.
 void drawArc(Graphics gc, double x, double y, double width, double height, double startAngle, double arcAngle)
           
 void drawCircle(Graphics gc, int xCenter, int yCenter, int radius)
          Performs the requested draw circle operation given the properties of the JCLineStyle instance.
 void drawLine(Graphics gc, double x1, double y1, double x2, double y2)
           
 void drawLine(Graphics gc, int x1, int y1, int x2, int y2)
          Draws a line between two points according to the given Graphics object (it must already be set with the appropriate drawing attributes).
 void drawRect(Graphics gc, int x, int y, int width, int height)
          Performs the requested draw rect given the values of the properties of the JCLineStyle instance.
 void drawSquaredLine(Graphics gc, int x1, int y1, int x2, int y2, boolean horizOrVert, int delta, int min, int max)
          Draws a squared line between two points according to the given Graphics object (it must already be set with the appropriate drawing attributes).
 boolean equals(Object obj)
          Override the equals method of class Object.
 void fillRect(Graphics gc, int x, int y, int width, int height)
          Performs the requested fill given the values of the properties of the JCLineStyle instance.
 int getCap()
          Gets the Cap property, which dictates the cap style to use at the ends of a line.
 Color getColor()
          Gets the Color property of JCLineStyle, which determines the color used to draw the line.
 int getColorIndex()
          Returns the index used to generate the color.
 float[] getCustomLegendPatternArray()
          Returns the custom legend pattern array used for dashed lines if one has been set by the setPattern(float[], float[]) method.
 float[] getCustomPatternArray()
          Returns the custom pattern array used for dashed lines if one has been set by the setPattern(float[], float[]) method.
 int getJoin()
          Gets the Join property, which dictates the join style to use when joining two lines.
 int getPattern()
          Gets the Pattern property, which dictates the pattern used to draw a line.
 int getWidth()
          Gets the Width property, which controls line width.
 int hashCode()
          Override the hashCode method of class Object.
static com.klg.jclass.chart.JCLineStyle makeDefault(com.klg.jclass.chart.JCChart c)
          Creates a default line style.
 void resetGraphics(Graphics gc)
          Resets the graphics object to a default drawing style.
 void setCap(int c)
          Sets the Cap property, which dictates the cap style to use at the ends of a line.
 void setColor(Color clr)
          Sets the Color property of JCLineStyle, which determines the color used to draw the line.
 void setJoin(int j)
          Sets the Join property, which dictates the join style to use when joining two lines.
 void setPattern(float[] patternArray, float[] legendPatternArray)
          Sets the Pattern property, which dictates the pattern used to draw a line, with a custom user-defined pattern.
 void setPattern(int p)
          Sets the Pattern property, which dictates the pattern used to draw a line.
 void setWidth(int w)
          Sets the Width property, which controls line width.
 boolean updateGraphics(Graphics gc)
          Updates the Graphics object with the elements of this line style (strokes and colors).
 boolean updateGraphics(Graphics gc, int drawLineLength)
          Updates the Graphics object with the elements of this line style (strokes and colors).
 
Methods inherited from class com.klg.jclass.chart.JCStyle
getDefaultColors, setDefaultColors
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

join

protected int join

cap

protected int cap

pattern

protected int pattern

width

protected int width

colorIndex

protected int colorIndex

color

protected Color color

NONE

public static final int NONE
See Also:
Constant Field Values

SOLID

public static final int SOLID
See Also:
Constant Field Values

LONG_DASH

public static final int LONG_DASH
See Also:
Constant Field Values

SHORT_DASH

public static final int SHORT_DASH
See Also:
Constant Field Values

LSL_DASH

public static final int LSL_DASH
See Also:
Constant Field Values

DASH_DOT

public static final int DASH_DOT
See Also:
Constant Field Values

CUSTOM

public static final int CUSTOM
See Also:
Constant Field Values

LONG_DASH_ARRAY

public static final float[] LONG_DASH_ARRAY

SHORT_DASH_ARRAY

public static final float[] SHORT_DASH_ARRAY

LSL_DASH_ARRAY

public static final float[] LSL_DASH_ARRAY

DASH_DOT_ARRAY

public static final float[] DASH_DOT_ARRAY

LEGEND_LONG_DASH_ARRAY

public static final float[] LEGEND_LONG_DASH_ARRAY

LEGEND_SHORT_DASH_ARRAY

public static final float[] LEGEND_SHORT_DASH_ARRAY

LEGEND_LSL_DASH_ARRAY

public static final float[] LEGEND_LSL_DASH_ARRAY

LEGEND_DASH_DOT_ARRAY

public static final float[] LEGEND_DASH_DOT_ARRAY

dashArray

protected float[] dashArray

legendDashArray

protected float[] legendDashArray

xp

protected int[] xp

yp

protected int[] yp
Constructor Detail

JCLineStyle

public JCLineStyle(int w,
                   Color c,
                   int p)
Constructor for line style objects.

Parameters:
w - line width
c - line color
p - line pattern. One of NONE, SOLID, LONG_DASH, LSL_DASH, or DASH_DOT.

JCLineStyle

public JCLineStyle(int w,
                   Color c,
                   int p,
                   int cp,
                   int j)
Full Constructor for line style objects.

Parameters:
w - line width
c - line color
p - line pattern. One of NONE, SOLID, LONG_DASH, LSL_DASH, or DASH_DOT.
cp - cap value
j - join value

JCLineStyle

public JCLineStyle(int w,
                   Color c,
                   int p,
                   int cp,
                   int j,
                   float[] da,
                   float[] dla)
Full Constructor for line style objects.

Parameters:
w - line width
c - line color
p - line pattern. One of NONE, SOLID, LONG_DASH, LSL_DASH, or DASH_DOT.
cp - cap value
j - join value
da - array of floats specifying custom dashed line pattern
dla - array of floats specifying custom dashed line pattern for legend
Method Detail

makeDefault

public static com.klg.jclass.chart.JCLineStyle makeDefault(com.klg.jclass.chart.JCChart c)
Creates a default line style.

Parameters:
c -
Returns:
JCLineStyle object with default width, color, and pattern. The defaults are cycled, so consecutive calls will return different line styles.

updateGraphics

public boolean updateGraphics(Graphics gc)
Updates the Graphics object with the elements of this line style (strokes and colors).

Parameters:
gc - Graphics object to change
Returns:
true if you should now use this object to draw; false if the style is such that no drawing should occur

updateGraphics

public boolean updateGraphics(Graphics gc,
                              int drawLineLength)
Updates the Graphics object with the elements of this line style (strokes and colors). This method scales the dashed lines of the stroke down for small line lengths, such as need to be drawn in the legend.

Parameters:
gc - Graphics object to change
drawLineLength - maximum length of line to be drawn in pixels. Used to scale dashed lines down such that the line will be drawn with the appropriate pattern.
Returns:
true if you should now use this object to draw; false if the style is such that no drawing should occur

resetGraphics

public void resetGraphics(Graphics gc)
Resets the graphics object to a default drawing style.

Parameters:
gc - Graphics object to change

draw

public void draw(Graphics gc,
                 int x1,
                 int y1,
                 int x2,
                 int y2)
Draws a line between two points according to the the properties of this line style.

Parameters:
gc - graphics context to use for drawing
x1 - x value of first point (in pixels)
y1 - y value of first point (in pixels)
x2 - x value of second point (in pixels)
y2 - y value of second point (in pixels)

draw

public void draw(Graphics gc,
                 int x1,
                 int y1,
                 int x2,
                 int y2,
                 Color col)
Draws a line between two points according to the the properties of this line style, except that the color is overridden with the specified color.

Parameters:
gc - graphics context to use for drawing
x1 - x value of first point (in pixels)
y1 - y value of first point (in pixels)
x2 - x value of second point (in pixels)
y2 - y value of second point (in pixels)
col - overriding color

drawLine

public void drawLine(Graphics gc,
                     int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a line between two points according to the given Graphics object (it must already be set with the appropriate drawing attributes).

Parameters:
gc - graphics context to use for drawing
x1 - x value of first point (in pixels)
y1 - y value of first point (in pixels)
x2 - x value of second point (in pixels)
y2 - y value of second point (in pixels)

drawLine

public void drawLine(Graphics gc,
                     double x1,
                     double y1,
                     double x2,
                     double y2)

drawSquaredLine

public void drawSquaredLine(Graphics gc,
                            int x1,
                            int y1,
                            int x2,
                            int y2,
                            boolean horizOrVert,
                            int delta,
                            int min,
                            int max)
Draws a squared line between two points according to the given Graphics object (it must already be set with the appropriate drawing attributes). A squared line is one that, when angled and having a width greater than 1, will square off the edges to the appropriate vertical or horizontal.

Parameters:
gc - graphics context to use for drawing.
x1 - x value of first point (in pixels)
y1 - y value of first point (in pixels)
x2 - x value of second point (in pixels)
y2 - y value of second point (in pixels)
horizOrVert - is this a vertically oriented (false) or horizontally oriented (true) line?
delta - the delta value for 3D calculations in the orientation direction
min - the minimum value to clip against in the orientation direction
max - the maximum value to clip against in the orientation direction

drawRect

public void drawRect(Graphics gc,
                     int x,
                     int y,
                     int width,
                     int height)
Performs the requested draw rect given the values of the properties of the JCLineStyle instance.

Parameters:
gc - graphics context to use for drawing
x - x origin of rect region (in pixels)
y - y origin of rect region (in pixels)
width - width of rect region (in pixels)
height - height of rect region (in pixels)

fillRect

public void fillRect(Graphics gc,
                     int x,
                     int y,
                     int width,
                     int height)
Performs the requested fill given the values of the properties of the JCLineStyle instance.

Parameters:
gc - graphics context to use for drawing
x - x origin of fill region (in pixels)
y - y origin of fill region (in pixels)
width - width of fill region (in pixels)
height - height of fill region (in pixels)

drawCircle

public void drawCircle(Graphics gc,
                       int xCenter,
                       int yCenter,
                       int radius)
Performs the requested draw circle operation given the properties of the JCLineStyle instance.

Parameters:
gc - graphics context to use for drawing
xCenter - x coordinate of center (in pixels)
yCenter - y coordinate of center (in pixels)
radius - radius of circle (in pixels)

drawArc

public void drawArc(Graphics gc,
                    double x,
                    double y,
                    double width,
                    double height,
                    double startAngle,
                    double arcAngle)

getPattern

public int getPattern()
Gets the Pattern property, which dictates the pattern used to draw a line.

Returns:
one of NONE, SOLID, LONG_DASH, SHORT_DASH, LSL_DASH, or DASH_DOT

setPattern

public void setPattern(int p)
Sets the Pattern property, which dictates the pattern used to draw a line.

Parameters:
p - one of NONE, SOLID, LONG_DASH, SHORT_DASH, LSL_DASH, or DASH_DOT
Throws:
IllegalArgumentException - If the patter is not one of NONE, SOLID, LONG_DASH, SHORT_DASH, LSL_DASH, or DASH_DOT.

setPattern

public void setPattern(float[] patternArray,
                       float[] legendPatternArray)
Sets the Pattern property, which dictates the pattern used to draw a line, with a custom user-defined pattern. The pattern type is automatically set to CUSTOM.

Parameters:
patternArray - an array of floats representing the pattern to use when drawing this line
legendPatternArray - An array of floats representing the pattern to use when drawing this line in the legend. (Usually, this means taking the pattern array and cutting the values down. Half workss well, unless the values get too small, in which case nothing will be drawn.)

getCustomPatternArray

public float[] getCustomPatternArray()
Returns the custom pattern array used for dashed lines if one has been set by the setPattern(float[], float[]) method.

Returns:
the user set custom dash array

getCustomLegendPatternArray

public float[] getCustomLegendPatternArray()
Returns the custom legend pattern array used for dashed lines if one has been set by the setPattern(float[], float[]) method.

Returns:
the user set custom legend dash array

getWidth

public int getWidth()
Gets the Width property, which controls line width.

Returns:
positive integer representing line width

setWidth

public void setWidth(int w)
Sets the Width property, which controls line width.

Parameters:
w - positive integer representing line width

getColor

public Color getColor()
Gets the Color property of JCLineStyle, which determines the color used to draw the line.

Returns:
AWT Color class representing the color to be used to draw the lines. If null, the current color of the Graphics object is used.

setColor

public void setColor(Color clr)
Sets the Color property of JCLineStyle, which determines the color used to draw the line.

Parameters:
clr - AWT Color class representing the color to be used to draw the lines. If null, the current color of the Graphics object is used.

getColorIndex

public int getColorIndex()
Returns the index used to generate the color. Only set if default colors are used.

Returns:
index used to generate the color

getJoin

public int getJoin()
Gets the Join property, which dictates the join style to use when joining two lines.

Returns:
one of BasicStroke.JOIN_MITER, BasicStroke.JOIN_BEVEL, or BasicStroke.JOIN_ROUND

setJoin

public void setJoin(int j)
Sets the Join property, which dictates the join style to use when joining two lines.

Parameters:
j - one of BasicStroke.JOIN_MITER, BasicStroke.JOIN_BEVEL, or BasicStroke.JOIN_ROUND

getCap

public int getCap()
Gets the Cap property, which dictates the cap style to use at the ends of a line. Used in jdk 1.2 only.

Returns:
one of BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND, or BasicStroke.CAP_SQUARE

setCap

public void setCap(int c)
Sets the Cap property, which dictates the cap style to use at the ends of a line. Used in jdk 1.2 only.

Parameters:
c - of BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND, or BasicStroke.CAP_SQUARE.

equals

public boolean equals(Object obj)
Override the equals method of class Object. Checks whether the specified object is "equal to" this one.

Overrides:
equals in class Object

hashCode

public int hashCode()
Override the hashCode method of class Object. Returns a hash code value for the object.

Overrides:
hashCode in class Object

Copyright © 2004 Quest Software Inc..
All rights reserved.