org.faceless.graph
Class Style

java.lang.Object
  extended by org.faceless.graph.Style

public class Style
extends Object

Styles control the colors, borders and fonts of an element. Although a style can have several attributes, not all of them are necessarily used for each element (for example, a face doesn't need a font, and a line of text has no border)

The various "aspects" a style can have are:

Once a style has been applied to an element, it cannot be changed.

In version 1.0.3 and later, changes have been made to the way fonts are handled. Previously, the java.awt.Font class was used to define the font, which is practical for output to a subclass of ImageOutput but doesn't work well for output to non-AWT based output devices, like PDF. Consequently calls to the setFont method should be changed from setFont(new Font("Helvetica", Font.PLAIN, 12)) to setFont("Helvetica", Font.PLAIN, 12). The same applies to any constructors taking a java.awt.Font - pass in the font name, style and size instead of the font itself.


Field Summary
static int BOTTOM
          For use with setAlign(int) to align text to it's baseline (the default).
static int CENTER
          For use with setAlign(int) to center the text horizontally.
static int GRID_BOTH
          For use with setGrid(int) to draw horizontal and vertical grid lines
static int GRID_HORIZONTAL
          For use with setGrid(int) to draw horizontal grid lines
static int GRID_VERTICAL
          For use with setGrid(int) to draw vertical grid lines
static int LEFT
          For use with setAlign(int) to left align text (the default).
static int MIDDLE
          For use with setAlign(int) to center the text vertically.
static int RIGHT
          For use with setAlign(int) to right align text.
static int TOP
          For use with setAlign(int) to align text at it's top.
 
Constructor Summary
Style(Paint color)
          Create a new Style in the specified color.
Style(Paint color, Color bordercolor)
          Create a new Style and set it's color and bordercolor.
Style(Paint color, String fontname, int fontstyle, float fontsize)
          Convenience constructor - create a new Style to be used with Text
Style(Paint color, String fontname, int fontstyle, float fontsize, int align)
          Convenience constructor - create a new Style to be used with Text, and set it's alignment.
 
Method Summary
 Object clone()
          Clone the style.
 int getAlign()
          Get the alignment for this style.
 Color getBorderColor()
          Get the border color for this style
 Paint getColor()
          Get the main color for this style
static Color getDefaultBorderColor()
          Returns the value set by setDefaultBorderColor(java.awt.Color) since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis
 String getFontName()
          Get the font name for this style.
static double getFontScale()
          Return the current font scale.
 float getFontSize()
          Get the font size, after being adjust to account for the scale set by setFontScale(double)
 int getFontStyle()
          Get the font style (Font.ITALIC, Font.PLAIN, Font.BOLD or a combination) for this style.
 double getLineDashOff()
           
 double getLineDashOn()
           
 double getLineDashPhase()
           
 double getLineThickness()
          Get the line thickness for this style
 double getRotate()
          Get the text rotation for this style, in degrees clockwise
 void setAlign(int align)
          Set the text alignment for this style.
 void setBorderColor(Color color)
          Set the border color for this style
 void setColor(Paint color)
          Set the main color for this style
static void setDefaultBorderColor(Color c)
          This method changes the default border color of new styles.
static void setDefaultLineThickness(double thickness)
          Set the default line thickness for all styles. 1 is the default, 0.5 is half as thick, and so on.
 void setFont(String name, int style, float size)
          Set the font for this style
static void setFontScale(double val)
          Every text element that's created may have it's font automatically scaled up or down by a percentage by setting a different fontscale.
 void setGrid(int border)
          Set which grid lines to display for this style - only used by the styles passed to AxesGraph.optionZWallStyle(org.faceless.graph.Style), AxesGraph.optionYWallStyle(org.faceless.graph.Style) and AxesGraph.optionFloorStyle(org.faceless.graph.Style), values should be either GRID_HORIZONTAL to draw horizontal grid lines, GRID_VERTICAL to draw vertical grid lines, or the GRID_BOTH to draw the full grid (the default)
static void setLightLevel(int level)
          Set the level of light (technically, the level of shade) that should be applied to a graph.
static void setLightVector(int x, int y, int z)
          Set the vector of where the light is coming from.
 void setLineDash(double dashon, double dashoff, double dashphase)
           
 void setLineThickness(double thick)
          Set the line thickness for this style. 1 is the default, 0.5 is half as thick, and so on.
static void setPieEdgeDegrees(double val)
          Adjust the number of degrees taken by each of the small faces used to draw the edge of a PieGraph.
 void setRotate(double val)
          Set the text rotation for this style, in degrees clockwise
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOP

public static final int TOP
For use with setAlign(int) to align text at it's top.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
For use with setAlign(int) to right align text.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
For use with setAlign(int) to align text to it's baseline (the default).

See Also:
Constant Field Values

LEFT

public static final int LEFT
For use with setAlign(int) to left align text (the default).

See Also:
Constant Field Values

MIDDLE

public static final int MIDDLE
For use with setAlign(int) to center the text vertically.

See Also:
Constant Field Values

CENTER

public static final int CENTER
For use with setAlign(int) to center the text horizontally.

See Also:
Constant Field Values

GRID_HORIZONTAL

public static final int GRID_HORIZONTAL
For use with setGrid(int) to draw horizontal grid lines

See Also:
Constant Field Values

GRID_VERTICAL

public static final int GRID_VERTICAL
For use with setGrid(int) to draw vertical grid lines

See Also:
Constant Field Values

GRID_BOTH

public static final int GRID_BOTH
For use with setGrid(int) to draw horizontal and vertical grid lines

See Also:
Constant Field Values
Constructor Detail

Style

public Style(Paint color)
Create a new Style in the specified color. Although colors may have an alpha component, not all Output classes can understand it.

Parameters:
color - the main color of the element

Style

public Style(Paint color,
             Color bordercolor)
Create a new Style and set it's color and bordercolor. Because either of these can be null, this constructor is generally used to create transparent floors or walls for an AxesGraph by setting the color parameter to null.

Parameters:
color - the main color of the element
color - the border color of the element

Style

public Style(Paint color,
             String fontname,
             int fontstyle,
             float fontsize)
Convenience constructor - create a new Style to be used with Text

Parameters:
color - The main color of the element
fontname - The font for the element
fontstyle - The font style for the element. Either java.awt.Font.PLAIN, Font.ITALIC, Font.BOLD or Font.BOLD+Font.ITALIC
fontsize - The font size for the element, in points
Since:
1.0.3
See Also:
ImageOutput.setFontMap(java.lang.String, int, java.awt.Font), PDFOutput.setFontMap(java.lang.String, int, PDFFont)

Style

public Style(Paint color,
             String fontname,
             int fontstyle,
             float fontsize,
             int align)
Convenience constructor - create a new Style to be used with Text, and set it's alignment.

Parameters:
color - The main color of the element
fontname - The font for the element
fontstyle - The font style for the element. Either java.awt.Font.PLAIN, Font.ITALIC, Font.BOLD or Font.BOLD+Font.ITALIC
fontsize - The font size for the element, in points
align - The alignment for the element. A logical OR of TOP, MIDDLE or BOTTOM and LEFT, CENTER or RIGHT
Since:
1.0.3
See Also:
ImageOutput.setFontMap(java.lang.String, int, java.awt.Font), PDFOutput.setFontMap(java.lang.String, int, PDFFont)
Method Detail

setColor

public void setColor(Paint color)
Set the main color for this style


setBorderColor

public void setBorderColor(Color color)
Set the border color for this style


setLineThickness

public void setLineThickness(double thick)
Set the line thickness for this style. 1 is the default, 0.5 is half as thick, and so on. Not all Output classes can use this option. A value of zero means "make the lines as thin as possible".


setLineDash

public void setLineDash(double dashon,
                        double dashoff,
                        double dashphase)

setFont

public void setFont(String name,
                    int style,
                    float size)
Set the font for this style

Since:
1.0.3

setGrid

public void setGrid(int border)
Set which grid lines to display for this style - only used by the styles passed to AxesGraph.optionZWallStyle(org.faceless.graph.Style), AxesGraph.optionYWallStyle(org.faceless.graph.Style) and AxesGraph.optionFloorStyle(org.faceless.graph.Style), values should be either GRID_HORIZONTAL to draw horizontal grid lines, GRID_VERTICAL to draw vertical grid lines, or the GRID_BOTH to draw the full grid (the default)

Parameters:
borders - the borders to draw
Since:
1.0.7

setRotate

public void setRotate(double val)
Set the text rotation for this style, in degrees clockwise


setAlign

public void setAlign(int align)

Set the text alignment for this style. Alignment controls where a text element is drawn in relation to it's anchor point. For instance, TOP|LEFT would cause the top left corner of the text to be placed on the anchor point, whereas CENTER|MIDDLE would place center the text horizontally and vertically on it's anchor.

Parameters:
align - The text alignment. Valid values are TOP, RIGHT, BOTTOM, LEFT, CENTER (for horizontal centering), MIDDLE (for vertical centering), or any logical OR'ing of these values, eg. TOP|CENTER.

getColor

public Paint getColor()
Get the main color for this style


getBorderColor

public Color getBorderColor()
Get the border color for this style


getLineThickness

public double getLineThickness()
Get the line thickness for this style


getLineDashPhase

public double getLineDashPhase()

getLineDashOn

public double getLineDashOn()

getLineDashOff

public double getLineDashOff()

getRotate

public double getRotate()
Get the text rotation for this style, in degrees clockwise


getAlign

public int getAlign()
Get the alignment for this style. See setAlign(int)


getFontName

public String getFontName()
Get the font name for this style.

Since:
1.0.3

getFontSize

public float getFontSize()
Get the font size, after being adjust to account for the scale set by setFontScale(double)

Since:
1.0.3

getFontStyle

public int getFontStyle()
Get the font style (Font.ITALIC, Font.PLAIN, Font.BOLD or a combination) for this style.

Since:
1.0.3

clone

public Object clone()
Clone the style.

Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

setFontScale

public static void setFontScale(double val)
Every text element that's created may have it's font automatically scaled up or down by a percentage by setting a different fontscale. This was intended for subclasses of Output, so those that use a totally different scaling can set it in one go. But it's useful for the end user too. The default is 1, and a value of 0.5 would make all the text half the original size.

since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis


getFontScale

public static double getFontScale()
Return the current font scale. See setFontScale(double)

since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis


setLightLevel

public static void setLightLevel(int level)
Set the level of light (technically, the level of shade) that should be applied to a graph. A value of 0 is no shading at all, a value of 100 gives deep shadows. The default is 70.

since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis


setLightVector

public static void setLightVector(int x,
                                  int y,
                                  int z)
Set the vector of where the light is coming from. The light is assumed to be coming from an infinite distance away in the specified direction, so don't worry about the length of the vector. The default is (1,0,0), which makes the light appear to come from the right side of the graph. Calling Style.setLightVector(-1,0,1) would put the light to the left and in front of the graph, while a vector (0,-1,0) would put the light directly underneath the graph, for a strange result indeed.

since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis


setDefaultBorderColor

public static void setDefaultBorderColor(Color c)
This method changes the default border color of new styles. By default, this is set to black, but it can be set to null for a different look, or a different color altogether. This is useful if the graph is to be rendered over a black background, for example.

since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis


getDefaultBorderColor

public static Color getDefaultBorderColor()
Returns the value set by setDefaultBorderColor(java.awt.Color)

since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis


setDefaultLineThickness

public static void setDefaultLineThickness(double thickness)
Set the default line thickness for all styles. 1 is the default, 0.5 is half as thick, and so on. Not all Output classes can use this option. A value of zero means "make the lines as thin as possible".

since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis


setPieEdgeDegrees

public static void setPieEdgeDegrees(double val)
Adjust the number of degrees taken by each of the small faces used to draw the edge of a PieGraph. The higher the number of faces, the less noticeable the "banding" effect will be on the edge of a 3D shaded PieGraph, but at the expense of slower rendering. The default value is 5 degrees.

Parameters:
val - the number of degrees per face at the edge of a PieGraph

since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis



Copyright © 2001-2012 Big Faceless Organization