JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page
Class JCDrawStyle

java.lang.Object
  |
  +--com.klg.jclass.page.JCDrawStyle
All Implemented Interfaces:
Cloneable

public class JCDrawStyle
extends Object
implements Cloneable

JCDrawStyle creates styles for drawn objects, specifying line and fill attributes (for example, color and width).


Field Summary
static int ALIGN_TO_BOTTOM
          The bottom of the object is aligned to the bottom of the text descender.
static int ALIGN_TO_TOP
          The top of the object is aligned to the top of the text ascender.
static com.klg.jclass.page.JCDrawStyle BLANK
          A drawing style that does not paint drawn lines.
static int CENTER_ABOVE_BASELINE
          The center of the object aligns to the center of the text ascender (space used above the baseline).
static int CENTER_IN_LINE
          The center of the object aligns to the center of the text (between the top of the ascender and bottom of the descender).
static int CENTER_ON_BASELINE
          The center of the object aligns to the text baseline.
protected  JCUnit.Measure dashLength
          The length of dashes and spaces in a broken line style.
static String DEFAULT_1PT_LINE
          The name of the style that draws a solid 1 point line.
static String DEFAULT_2PT_LINE
          The name of the style which draws a solid line 2 points in width.
static String DEFAULT_LINE
          The name of the style which draws a solid line of minimum width.
static int FILL_RULE_EVEN_ODD
          Uses the even/odd rule to determine the inside of a closed figure.
static int FILL_RULE_NON_ZERO_WINDING
          Uses the non-zero winding rule to determine the inside of a closed figure.
protected  Color fillForeground
          Foreground colour for filling graphics.
protected  int fillRule
          Method for determining which parts of a complex polygon are "inside".
protected  Color foreground
          Foreground colour for drawing graphics.
protected  boolean immutable
          Flag identifying if the style may be modified.
protected  Map immutableDrawStyles
           
protected static TreeMap instanceCollection
          A list containing references to all named style instances.
static com.klg.jclass.page.JCDrawStyle LINE
          A default style for thin black lines.
static com.klg.jclass.page.JCDrawStyle LINE_1POINT
          A default style for thick (1 point) black lines.
static com.klg.jclass.page.JCDrawStyle LINE_2POINT
          A default style for very thick (2 point) black lines.
static com.klg.jclass.page.JCDrawStyle LINE_DASHED
          A default style for thin dashed lines.
static com.klg.jclass.page.JCDrawStyle LINE_DOUBLE
          A default style for thin black double lines.
static int LINE_TYPE_BROKEN
          Draws a dashed/dotted line.
static int LINE_TYPE_DOUBLE
          Draws a pair of parallel lines.
static int LINE_TYPE_NONE
          Don't draw the line.
static int LINE_TYPE_PLAIN
          Draws a single unornamented line.
static int LINE_TYPE_SINGLE
          Draws a single unornamented line.
protected  JCUnit.Measure lineSpacing
          The spacing between lines in a multi-line style.
protected  int lineType
          The type of line to draw.
protected  JCUnit.Measure lineWidth
          Width of a drawn line.
protected  String name
          The unique name of the style.
static int POSITION_BELOW_BASELINE
          The top of the object aligns to the text baseline.
static int POSITION_ON_BASELINE
          The bottom of the object aligns to the text baseline.
protected static int styleCount
          Counts of the number of instances of the class.
protected static String UNAMED_STYLE_PREFIX
           
 
Constructor Summary
JCDrawStyle()
          Creates a draw style with default name and values.
JCDrawStyle(String name)
          Creates a draw style with the given name and default values.
JCDrawStyle(String name, Color foreground, int fill_rule, int line_type, JCUnit.Measure line_width, JCUnit.Measure line_spacing, JCUnit.Measure dash_length, boolean immutable)
          Creates a named draw style with the given attributes.
 
Method Summary
 Object clone()
          Returns a style which is a copy of this one.
 boolean equals(Object o)
          Compares this text style to the passed-in style.
 JCUnit.Measure getDashLength()
          Gets the length of dashes and space between dashes in a broken line style.
 JCUnit.Measure getDrawnWidth()
          Gets the total width of a line.
 Color getFillForegroundColor()
          Gets the color in which figures are to be filled.
 int getFillRule()
          Gets the method used to determine the "inside" and "outside" of a polygon.
 Color getForegroundColor()
          Gets the color in which lines are to be drawn.
 com.klg.jclass.page.JCDrawStyle getImmutable()
          Returns this object if it is already immutable; otherwise, sees if a style with the same properties already exists in the immutable cache and returns it.
 JCUnit.Measure getLineSpacing()
          Gets the spacing between drawn lines in a multi-line style.
 int getLineType()
          Gets the type used for drawing lines.
 JCUnit.Measure getLineWidth()
          Gets the width of drawn lines.
 String getName()
          Gets the name of the style.
static Map getStyleList()
          Returns the entire style Map.
static Iterator getStyles()
          Provides an iterator over all immutable styles.
 int hashCode()
          Creates a hash that generates the same value depending on the property values.
 boolean isEqualBorder(com.klg.jclass.page.JCDrawStyle style)
          Compares another draw style to this one and returns true if the two draw styles are equivalent.
 boolean isMutable()
          Determines if the style can be modified.
 void makeImmutable()
          Sets the style so that it can no longer be modified.
 void makeImmutableAndOverride()
          Sets the style so that it can no longer be modified and stores its name in the lookup map, overriding any existing style with the same name.
 void makeImmutableAndStore()
          Sets the style so that it can no longer be modified, storing the style in the name lookup table.
 void setDashLength(JCUnit.Measure length)
          Sets the length of dashes and space between dashes in a broken line style.
 void setFillForegroundColor(Color color)
          Sets the color in which fills are to be drawn.
 void setFillRule(int fill_rule)
          Sets the method used to determine the "inside" and "outside" of a polygon.
 void setForegroundColor(Color color)
          Sets the color in which lines are to be drawn.
 void setLineSpacing(JCUnit.Measure spacing)
          Gets the spacing between drawn lines in a multi-line style.
 void setLineType(int line_type)
          Sets the type of line this style will draw.
 void setLineWidth(JCUnit.Measure width)
          Sets the width of drawn lines.
 void setName(String name)
          Sets a name for the style.
static com.klg.jclass.page.JCDrawStyle stringToStyle(String name)
          Returns the style which matches the given name.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
The unique name of the style.


foreground

protected Color foreground
Foreground colour for drawing graphics.


fillForeground

protected Color fillForeground
Foreground colour for filling graphics.


fillRule

protected int fillRule
Method for determining which parts of a complex polygon are "inside".


lineWidth

protected JCUnit.Measure lineWidth
Width of a drawn line.


lineType

protected int lineType
The type of line to draw.


lineSpacing

protected JCUnit.Measure lineSpacing
The spacing between lines in a multi-line style.


dashLength

protected JCUnit.Measure dashLength
The length of dashes and spaces in a broken line style.


immutable

protected boolean immutable
Flag identifying if the style may be modified.


styleCount

protected static int styleCount
Counts of the number of instances of the class.


instanceCollection

protected static TreeMap instanceCollection
A list containing references to all named style instances.


FILL_RULE_EVEN_ODD

public static final int FILL_RULE_EVEN_ODD
Uses the even/odd rule to determine the inside of a closed figure.

See Also:
Constant Field Values

FILL_RULE_NON_ZERO_WINDING

public static final int FILL_RULE_NON_ZERO_WINDING
Uses the non-zero winding rule to determine the inside of a closed figure.

See Also:
Constant Field Values

LINE_TYPE_NONE

public static final int LINE_TYPE_NONE
Don't draw the line.

See Also:
Constant Field Values

LINE_TYPE_PLAIN

public static final int LINE_TYPE_PLAIN
Draws a single unornamented line.

See Also:
Constant Field Values

LINE_TYPE_SINGLE

public static final int LINE_TYPE_SINGLE
Draws a single unornamented line.

See Also:
Constant Field Values

LINE_TYPE_BROKEN

public static final int LINE_TYPE_BROKEN
Draws a dashed/dotted line.

See Also:
Constant Field Values

LINE_TYPE_DOUBLE

public static final int LINE_TYPE_DOUBLE
Draws a pair of parallel lines.

See Also:
Constant Field Values

POSITION_ON_BASELINE

public static final int POSITION_ON_BASELINE
The bottom of the object aligns to the text baseline.

See Also:
Constant Field Values

POSITION_BELOW_BASELINE

public static final int POSITION_BELOW_BASELINE
The top of the object aligns to the text baseline.

See Also:
Constant Field Values

CENTER_ON_BASELINE

public static final int CENTER_ON_BASELINE
The center of the object aligns to the text baseline.

See Also:
Constant Field Values

CENTER_ABOVE_BASELINE

public static final int CENTER_ABOVE_BASELINE
The center of the object aligns to the center of the text ascender (space used above the baseline).

See Also:
Constant Field Values

CENTER_IN_LINE

public static final int CENTER_IN_LINE
The center of the object aligns to the center of the text (between the top of the ascender and bottom of the descender).

See Also:
Constant Field Values

ALIGN_TO_TOP

public static final int ALIGN_TO_TOP
The top of the object is aligned to the top of the text ascender.

See Also:
Constant Field Values

ALIGN_TO_BOTTOM

public static final int ALIGN_TO_BOTTOM
The bottom of the object is aligned to the bottom of the text descender.

See Also:
Constant Field Values

DEFAULT_LINE

public static final String DEFAULT_LINE
The name of the style which draws a solid line of minimum width.

See Also:
Constant Field Values

DEFAULT_1PT_LINE

public static final String DEFAULT_1PT_LINE
The name of the style that draws a solid 1 point line.

See Also:
Constant Field Values

DEFAULT_2PT_LINE

public static final String DEFAULT_2PT_LINE
The name of the style which draws a solid line 2 points in width.

See Also:
Constant Field Values

UNAMED_STYLE_PREFIX

protected static final String UNAMED_STYLE_PREFIX
See Also:
Constant Field Values

immutableDrawStyles

protected Map immutableDrawStyles

BLANK

public static final com.klg.jclass.page.JCDrawStyle BLANK
A drawing style that does not paint drawn lines. The value of the name property for this style is default blank.


LINE

public static final com.klg.jclass.page.JCDrawStyle LINE
A default style for thin black lines. The value of the name property for this style is default line.


LINE_DOUBLE

public static final com.klg.jclass.page.JCDrawStyle LINE_DOUBLE
A default style for thin black double lines. The value of the name property for this style is default double line.


LINE_1POINT

public static final com.klg.jclass.page.JCDrawStyle LINE_1POINT
A default style for thick (1 point) black lines. The value of the name property for this style is default 1pt line.


LINE_2POINT

public static final com.klg.jclass.page.JCDrawStyle LINE_2POINT
A default style for very thick (2 point) black lines. The value of the name property for this style is default 2pt line


LINE_DASHED

public static final com.klg.jclass.page.JCDrawStyle LINE_DASHED
A default style for thin dashed lines. The value of the name property for this style is dashed line.

Constructor Detail

JCDrawStyle

public JCDrawStyle(String name,
                   Color foreground,
                   int fill_rule,
                   int line_type,
                   JCUnit.Measure line_width,
                   JCUnit.Measure line_spacing,
                   JCUnit.Measure dash_length,
                   boolean immutable)
Creates a named draw style with the given attributes.

Parameters:
name - the name to assign to the style
foreground - the colour to paint drawn objects
fill_rule - the rule used to determine the inside of figures
line_type - the type of line to be drawn
line_width - the width of a drawn line
line_spacing - the distance between double lines
dash_length - the length of dashes and spaces in a broken line
immutable - indicates if this style is to be made immutable

JCDrawStyle

public JCDrawStyle()
Creates a draw style with default name and values.


JCDrawStyle

public JCDrawStyle(String name)
Creates a draw style with the given name and default values.

Parameters:
name - the name to give the new draw style
Method Detail

getName

public String getName()
Gets the name of the style.

Returns:
the name used to describe the style

setName

public void setName(String name)
Sets a name for the style.

Parameters:
name - the new name for the style

getForegroundColor

public Color getForegroundColor()
Gets the color in which lines are to be drawn.

Returns:
the line foreground currently assigned to this style

setForegroundColor

public void setForegroundColor(Color color)
Sets the color in which lines are to be drawn.

Parameters:
color - the foreground color to assign to the graphics

getFillForegroundColor

public Color getFillForegroundColor()
Gets the color in which figures are to be filled.

Returns:
the fill foreground currently assigned to this style

setFillForegroundColor

public void setFillForegroundColor(Color color)
Sets the color in which fills are to be drawn.

Parameters:
color - the foreground color to assign to fill areas

getFillRule

public int getFillRule()
Gets the method used to determine the "inside" and "outside" of a polygon.

Returns:
the rule used to determine the "inside" of a polygon for fills

setFillRule

public void setFillRule(int fill_rule)
Sets the method used to determine the "inside" and "outside" of a polygon.

Parameters:
fill_rule - the rule used to determine "inside" for filling a polygon

getLineWidth

public JCUnit.Measure getLineWidth()
Gets the width of drawn lines.

Returns:
the width used to draw individual lines

setLineWidth

public void setLineWidth(JCUnit.Measure width)
Sets the width of drawn lines.

Parameters:
width - the width to draw individual lines

getLineType

public int getLineType()
Gets the type used for drawing lines.

Returns:
the type of line pattern to use for drawing lines

setLineType

public void setLineType(int line_type)
Sets the type of line this style will draw.

Parameters:
line_type - the type of line that this style will use

getLineSpacing

public JCUnit.Measure getLineSpacing()
Gets the spacing between drawn lines in a multi-line style.

Returns:
the width used to separate multiple parallel lines

setLineSpacing

public void setLineSpacing(JCUnit.Measure spacing)
Gets the spacing between drawn lines in a multi-line style.

Parameters:
spacing - the width used to separate multiple parallel lines

getDrawnWidth

public JCUnit.Measure getDrawnWidth()
Gets the total width of a line.

Returns:
the width required to draw the (possibly multiple) line

getDashLength

public JCUnit.Measure getDashLength()
Gets the length of dashes and space between dashes in a broken line style.

Returns:
the length of a dash in a drawn line

setDashLength

public void setDashLength(JCUnit.Measure length)
Sets the length of dashes and space between dashes in a broken line style.

Parameters:
length - the length of a dash in a drawn line

isMutable

public boolean isMutable()
Determines if the style can be modified.

Returns:
true/false, depending whether or not the style can be modified

makeImmutable

public void makeImmutable()
Sets the style so that it can no longer be modified.


makeImmutableAndStore

public void makeImmutableAndStore()
Sets the style so that it can no longer be modified, storing the style in the name lookup table.


makeImmutableAndOverride

public void makeImmutableAndOverride()
Sets the style so that it can no longer be modified and stores its name in the lookup map, overriding any existing style with the same name.


clone

public Object clone()
Returns a style which is a copy of this one.

Overrides:
clone in class Object
Returns:
a new style with all significant fields copied

isEqualBorder

public boolean isEqualBorder(com.klg.jclass.page.JCDrawStyle style)
Compares another draw style to this one and returns true if the two draw styles are equivalent.

Parameters:
style - the draw style to compare to this one
Returns:
true if the draw styles result in approximately "equivalent" borders

getStyles

public static Iterator getStyles()
Provides an iterator over all immutable styles.

Returns:
an iterator the style class's underlying SortedMap

getStyleList

public static Map getStyleList()
Returns the entire style Map.

Returns:
a Map interface to the styles

stringToStyle

public static com.klg.jclass.page.JCDrawStyle stringToStyle(String name)
Returns the style which matches the given name.

Parameters:
name - the name of an existing style
Returns:
the style object which has that name, or null if not found

hashCode

public int hashCode()
Creates a hash that generates the same value depending on the property values.

Overrides:
hashCode in class Object
Returns:

equals

public boolean equals(Object o)
Compares this text style to the passed-in style. Text styles with the same properties are considered equal regardless of their name.

Overrides:
equals in class Object
Parameters:
o -
Returns:

getImmutable

public com.klg.jclass.page.JCDrawStyle getImmutable()
Returns this object if it is already immutable; otherwise, sees if a style with the same properties already exists in the immutable cache and returns it. If there is no cached style then we clone this style, make it immutable, store it in the cache, and return it.

Returns:

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