|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph.Style
public class Style
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:
Output
types.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 |
---|
public static final int TOP
setAlign(int)
to align text at it's top.
public static final int RIGHT
setAlign(int)
to right align text.
public static final int BOTTOM
setAlign(int)
to align text to it's baseline (the default).
public static final int LEFT
setAlign(int)
to left align text (the default).
public static final int MIDDLE
setAlign(int)
to center the text vertically.
public static final int CENTER
setAlign(int)
to center the text horizontally.
public static final int GRID_HORIZONTAL
setGrid(int)
to draw horizontal grid lines
public static final int GRID_VERTICAL
setGrid(int)
to draw vertical grid lines
public static final int GRID_BOTH
setGrid(int)
to draw horizontal and vertical grid lines
Constructor Detail |
---|
public Style(Paint color)
color
- the main color of the elementpublic Style(Paint color, Color bordercolor)
AxesGraph
by setting the
color
parameter to null.
color
- the main color of the elementcolor
- the border color of the elementpublic Style(Paint color, String fontname, int fontstyle, float fontsize)
color
- The main color of the elementfontname
- The font for the elementfontstyle
- The font style for the element. Either java.awt.Font.PLAIN, Font.ITALIC, Font.BOLD or Font.BOLD+Font.ITALICfontsize
- The font size for the element, in pointsImageOutput.setFontMap(java.lang.String, int, java.awt.Font)
,
PDFOutput.setFontMap(java.lang.String, int, PDFFont)
public Style(Paint color, String fontname, int fontstyle, float fontsize, int align)
color
- The main color of the elementfontname
- The font for the elementfontstyle
- The font style for the element. Either java.awt.Font.PLAIN, Font.ITALIC, Font.BOLD or Font.BOLD+Font.ITALICfontsize
- The font size for the element, in pointsalign
- The alignment for the element. A logical OR of
TOP
, MIDDLE
or BOTTOM
and
LEFT
, CENTER
or RIGHT
ImageOutput.setFontMap(java.lang.String, int, java.awt.Font)
,
PDFOutput.setFontMap(java.lang.String, int, PDFFont)
Method Detail |
---|
public void setColor(Paint color)
public void setBorderColor(Color color)
public void setLineThickness(double thick)
public void setLineDash(double dashon, double dashoff, double dashphase)
public void setFont(String name, int style, float size)
public void setGrid(int border)
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)
borders
- the borders to drawpublic void setRotate(double val)
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.
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.public Paint getColor()
public Color getBorderColor()
public double getLineThickness()
public double getLineDashPhase()
public double getLineDashOn()
public double getLineDashOff()
public double getRotate()
public int getAlign()
setAlign(int)
public String getFontName()
public float getFontSize()
setFontScale(double)
public int getFontStyle()
public Object clone()
clone
in class Object
public String toString()
toString
in class Object
public static void setFontScale(double val)
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
public static double getFontScale()
setFontScale(double)
since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis
public static void setLightLevel(int level)
since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis
public static void setLightVector(int x, int y, int z)
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
public static void setDefaultBorderColor(Color c)
since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis
public static Color getDefaultBorderColor()
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
public static void setDefaultLineThickness(double thickness)
since 1.0.3, use the equivalent non-static methods in the Graph class to set defaults on a per-graph basis
public static void setPieEdgeDegrees(double val)
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |