JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart3d
Class JCLineStyle

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

public class JCLineStyle
extends JCStyle

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

See Also:
Serialized Form

Field Summary
protected  int cap
          Sets the cap style.
protected  Color color
          Sets the line color.
protected  int colorIndex
          Sets the index into the default color array.
static int CUSTOM
           
static int DASH_DOT
           
static float[] DASH_DOT_ARRAY
           
protected  int join
          Sets the join style.
static float[] LEGEND_DASH_DOT_ARRAY
           
static float[] LEGEND_LONG_DASH_ARRAY
           
static float[] LEGEND_LSL_DASH_ARRAY
           
static float[] LEGEND_SHORT_DASH_ARRAY
           
static int LONG_DASH
           
static float[] LONG_DASH_ARRAY
           
static int LSL_DASH
           
static float[] LSL_DASH_ARRAY
           
static int NONE
           
protected  int pattern
          Sets the line pattern.
static int SHORT_DASH
           
static float[] SHORT_DASH_ARRAY
           
static int SOLID
           
protected  int width
          Sets the line width.
protected  int[] xp
           
protected  int[] yp
           
 
Fields inherited from class com.klg.jclass.chart3d.JCStyle
defaultColors, FILL_STYLE, LINE_STYLE, parent, SYMBOL_STYLE
 
Constructor Summary
JCLineStyle(int width, Color color, int pattern)
          Constructor for line style objects.
JCLineStyle(int width, Color color, int pattern, int cap, int join)
          Full Constructor for line style objects.
JCLineStyle(int width, Color color, int pattern, int cap, int join, float[] dashArray, float[] legendDashArray)
          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 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 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).
 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[] getDashArray()
          Returns the dash array.
 int getJoin()
          Gets the Join property, which dictates the join style to use when joining two lines.
 float[] getLegendDashArray()
          Returns the legend dash array.
 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.
static com.klg.jclass.chart3d.JCLineStyle makeDefault(com.klg.jclass.chart3d.JCChart3d c)
          Creates a default line style.
 void resetGraphics(Graphics gc)
          Resets the graphics object to a default drawing style.
 void setCap(int cap)
          Sets the Cap property, which dictates the cap style to use at the ends of a line.
 void setColor(Color color)
          Sets the Color property of JCLineStyle, which determines the color used to draw the line.
 void setJoin(int join)
          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.chart3d.JCStyle
getDefaultColors, setDefaultColors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

join

protected int join
Sets the join style.


cap

protected int cap
Sets the cap style.


pattern

protected int pattern
Sets the line pattern.


width

protected int width
Sets the line width.


colorIndex

protected int colorIndex
Sets the index into the default color array.


color

protected Color color
Sets the line 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

xp

protected int[] xp

yp

protected int[] yp
Constructor Detail

JCLineStyle

public JCLineStyle(int width,
                   Color color,
                   int pattern)
Constructor for line style objects.

Parameters:
width - line width
color - line color
pattern - line pattern; one of NONE, SOLID, LONG_DASH, SHORT_DASH, LSL_DASH, DASH_DOT, or CUSTOM

JCLineStyle

public JCLineStyle(int width,
                   Color color,
                   int pattern,
                   int cap,
                   int join)
Full Constructor for line style objects.

Parameters:
width - line width
color - line color
pattern - line pattern; one of NONE, SOLID, LONG_DASH, SHORT_DASH, LSL_DASH, DASH_DOT, or CUSTOM
cap -
join -

JCLineStyle

public JCLineStyle(int width,
                   Color color,
                   int pattern,
                   int cap,
                   int join,
                   float[] dashArray,
                   float[] legendDashArray)
Full Constructor for line style objects.

Parameters:
width - line width
color - line color
pattern - line pattern
cap - line cap style
join - line join style
dashArray - line dash array
legendDashArray - legend dash array
Method Detail

makeDefault

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

Parameters:
c - the chart for which to generate the default line style
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. This is 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 - the graphics object to reset

draw

public void draw(Graphics gc,
                 int x1,
                 int y1,
                 int x2,
                 int y2)
Draws a line between two points according to 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)

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)

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

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 seems to work well, although if the values are too small nothing will be drawn.

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 color)
Sets the Color property of JCLineStyle, which determines the color used to draw the line.

Parameters:
color - 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:
the index into the default color array

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 join)
Sets the Join property, which dictates the join style to use when joining two lines.

Parameters:
join - the new join style

getCap

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

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

setCap

public void setCap(int cap)
Sets the Cap property, which dictates the cap style to use at the ends of a line.

Parameters:
cap -

getDashArray

public float[] getDashArray()
Returns the dash array.

Returns:
the current dash array

getLegendDashArray

public float[] getLegendDashArray()
Returns the legend dash array.

Returns:
the current legend dash array

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