|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph2.Graph
public abstract class Graph
The abstract base class for all Graphs in the Big Faceless Graph Library version 2.x. All the types of Graph in the package have certain things in common.
setXRotation(double)
and friends.
draw
method is called to write
the Graph to an Output
, which could be a PNG image, a PDF or similar. Once
it's drawn to an output, it cannot be redrawn.
Currently the two types of Graph available are PieGraph
and AxesGraph
,
and you should see those classes for more information
Field Summary | |
---|---|
static String |
VERSION
The current version of the Graph library. |
Method Summary | |
---|---|
void |
addKey(Key key,
double x,
double y)
Set a Key on the graph, and position it at the specified location on the Graph. |
void |
addKey(Key key,
int position)
Set a Key on the graph and position it at the edges of the Output. |
void |
addText(String text,
TextStyle style)
Add some text to the Graph. |
void |
draw(Output out)
Draw the Graph to the specified Output object. |
void |
interrupt()
Interrupt the draw() method. |
boolean |
isInterrupted()
Return whether the graph has been interrupted before it could be finalized. |
void |
setAutoColors(Color c1,
Color c2)
Set the Graph to auto-generate colors for its data by adjusting the hue, saturation and brightness between the two specified colors. |
void |
setColorOrdering(String order)
Set the order the auto-generated colors are used. |
void |
setDefaultColors(Paint[] colors)
Set the default colors for the graph. |
void |
setFixedAspectRatio(boolean val)
Whether this graph should have a fixed aspect ratio. |
void |
setFixedSize(double zoom,
double x,
double y)
When plotting a number of graphs that are supposed to be exactly the same size, this method can be used to set the zoom, x and y position to fixed values, rather than allowing the graph to be autosized to fit. |
static void |
setLicenseKey(String key)
Set the license key for the library. |
void |
setLightLevel(int level)
Set the level of light (technically, the level of shade) that should be applied to a graph. |
void |
setLightVector(int x,
int y,
int z)
Set the vector of where the light is coming from. |
void |
setMetaData(String key,
String value)
Set some descriptive text on the graph. |
void |
setXRotation(double val)
How far to rotate the graph around the X-axis (the line running from the left of the graph to the right), in degrees clockwise. |
void |
setYRotation(double val)
How far to rotate the graph around the Y-axis (the line running from the top of the graph to the bottom), in degrees clockwise. |
void |
setZRotation(double val)
How far to rotate the graph around the Z-axis (the line running from the front of the graph to the back), in degrees clockwise. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String VERSION
Method Detail |
---|
public final void setAutoColors(Color c1, Color c2)
c1
- the first Color in the rangec2
- the first Color in the rangepublic void setDefaultColors(Paint[] colors)
colors
- the colors to usepublic void setColorOrdering(String order)
order
- the ordering to use - "value" or anything else to use the defaultpublic void addKey(Key key, int position)
key
- the Key to use on the graphposition
- where to position the Key - a combination of values from the Align
classpublic void addKey(Key key, double x, double y)
key
- the Key to use on the graphx
- the X co-ordinate to position the key, from 0 to 1y
- the Y co-ordinate to position the key, from 0 to 1public void addText(String text, TextStyle style)
Text
class. The alignment of the style
parameter determines where on the graph the
text is displayed.
text
- the text to displaystyle
- the style to display the text inpublic void setXRotation(double val)
val
- the rotation to usepublic void setYRotation(double val)
val
- the rotation to usepublic void setZRotation(double val)
val
- the rotation to usepublic void setFixedAspectRatio(boolean val)
val
- whether to have a fixed aspect ratio or not. Default is true for PieGraphs, false otherwise.public void setFixedSize(double zoom, double x, double y)
When plotting a number of graphs that are supposed to be exactly
the same size, this method can be used to set the zoom, x and y
position to fixed values, rather than allowing the graph to be
autosized to fit. Be warned that for some types of graph (eg.
those plotted against a DateAxis
), the values that should
be set here could seem quite 'odd', so a fair amount of experimentation
will be required to find appropriate values for each graph.
As a hint, for date axes you probably want to set zoom to about 0.0002
and x to something near to -DateAxis.toDouble(date)
, where
"date" is the first date being plotted. For PieGraphs, X and Y should be
about equal to center the graph, which has a default radius of 100.
zoom
- the zoom valuex
- the amount to add to the X co-ordinates of the graphy
- the amount to add to the Y co-ordinates of the graph - remember in
graphs, y=0 is at the bottom of the graph, so positive values
move items on the graph up the page.public final void draw(Output out)
Output
object. Once this method has been
called once, it cannot be called again on the same graph.
out
- the Output
to draw the graph to
IllegalStateException
- if the graph has already been drawn.public void setLightLevel(int level)
level
- the level of lighting used to shade the graphpublic void setLightVector(int x, int y, int z)
graph.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.
x
- the X component of the vectory
- the Y component of the vectorz
- the Z component of the vectorpublic void setMetaData(String key, String value)
Output
being used, but
typically will result in metadata of some sort being embedded in
the final graph. For instance, to set the author of the graph you
could call setMetaData("Author", "Joe Bloggs")
.
key
- The type of MetaData to use. Values recognised include
Author, Title, Description and Copyright, although other keys may be
used and will be inserted if possible.value
- the value to insertpublic final void interrupt()
draw()
method. This may be called from another thread to
interrupt the drawing routine if the resulting graph is no longer of interest.
The Output
the draw()
method is writing to should be discarded,
as it will be left in an undefined state, as will this object. If this method is called
before the draw()
method has been called, then when it is called it will
exit immediately. If called afterwards, it will have no effect.
public final boolean isInterrupted()
draw()
method
will be in an undefined state and should be discarded.
public static void setLicenseKey(String key)
Set the license key for the library. When the library is purchased, the Big Faceless Organization supplies a key which removes the "DEMO" stamp on each of the graphs.
Please note this method is static - it should be called BEFORE the first Graph is created, like so:
Graph.setLicenseKey(.....); Graph graph = new AxesGraph();
key
- the license key
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |