|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.faceless.graph2.Graph
org.faceless.graph2.PieGraph
public class PieGraph
A subclass of graph for displaying data in a circular Pie graph.
This is the only type of graph that isn't plotted against an Axis.
Plotting a PieGraph is much simpler than plotting an AxesGraph
.
Here's a simple example:
PieGraph graph = new PieGraph(); graph.set("Apples", 200); graph.set("Oranges", 100);Labels can be added to each slice by calling the
setLabel
method.
Field Summary |
---|
Fields inherited from class org.faceless.graph2.Graph |
---|
VERSION |
Constructor Summary | |
---|---|
PieGraph()
Create a new PieGraph |
Method Summary | |
---|---|
void |
addLabel(String key,
AbstractMarker marker,
double distance,
Style callout)
Add a label to one of the slices in the pie. |
double |
getProportion(String name)
Return the proportion of the pie that the named slice occupies. |
void |
set(String name,
double value)
Add a slice to the Pie. |
void |
setColor(String name,
Paint color)
Set the color for the specified slice |
void |
setDepth(double depth)
Set the depth of the Pie when it's displayed in 3-D. |
void |
setDoughnut(double size)
Set the size of the "hole in the doughnut". |
void |
setExtend(String name,
double radius)
Extend the specified slice away from the center of the pie |
void |
setLabel(String key,
AbstractMarker marker,
double distance)
Set the label of one of the slices in the pie. |
void |
setOtherSlice(String name,
double percentage)
Create an "Other" slice, which can be used to group slices that are too small to show useful information. |
void |
setSliceSize(double size)
Set the number of degrees each straight line makes up in a PieGraph. |
void |
setStyle(Style style)
Set the overall style for the graph. |
Methods inherited from class org.faceless.graph2.Graph |
---|
addKey, addKey, addText, draw, interrupt, isInterrupted, setAutoColors, setColorOrdering, setDefaultColors, setFixedAspectRatio, setFixedSize, setLicenseKey, setLightLevel, setLightVector, setMetaData, setXRotation, setYRotation, setZRotation |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PieGraph()
Method Detail |
---|
public void setDoughnut(double size)
size
- the size of the doughnut hole - from 0 to 99public void setSliceSize(double size)
createPattern()
will result in much slower rendering. The minimal value is 0.5 and the maximum is 5.
public void set(String name, double value)
name
- the name of the slicevalue
- the size of the slicepublic double getProportion(String name)
setOtherSlice(java.lang.String, double)
),
then passing in the name of that slice will give you the proportion
it occupies.
name
- the name of the slice to get the proportion of
public void setColor(String name, Paint color)
name
- the name of the slicecolor
- the color to paint the slice inpublic void setStyle(Style style)
public void setExtend(String name, double radius)
name
- the name of the sliceradius
- the distance from the center of the pie to move the slice,
as a percentage of the radius of the pie. Typical values would be about 0.2public void setLabel(String key, AbstractMarker marker, double distance)
addLabel()
with null
for the value of callout
.
key
- the slice to add the label tomarker
- the marker to display. May be a Text
, Marker
or Image
distance
- How far from the center of the pie to put the slice, as a ratio of the radius.For example, a value of 1.2 puts the marker just outside the edge of the pie and a value of 0.7 puts it inside the pie.addLabel(java.lang.String, org.faceless.graph2.AbstractMarker, double, org.faceless.graph2.Style)
public void addLabel(String key, AbstractMarker marker, double distance, Style callout)
distance
is less than or
greater than 0. Labels may be rotated by specifying a value to TextStyle.setRotate(double)
when creating the label, and the special value TextStyle.ROTATE_AUTO
may be used to cause labels to rotate to match the slice. Slices may have multiple
labels.
The optional callout
parameter is the style to draw the line to that
label in when distance
is greater than 1. It may be null
,
in which case no line will be drawn.
As a special case for Pie Graphs, if the marker is a Text
object
containing the text "0%%", "0.0%%" or "0.00%%", that text will be replaced
by the the size of the slice as a percentage. If this isn't flexible enough
the value from getProportion(java.lang.String)
can be formatted as required.
key
- the slice to add the label tomarker
- the marker to display. May be a Text
, Marker
or Image
distance
- How far from the center of the pie to put the slice, as a ratio of the radius.For example, a value of 1.2 puts the marker just outside the edge of the pie and a value of 0.7 puts it inside the pie.callout
- The style to draw the line to the marker from the edge of the pie. For
labels with a distance
of < 0, this value is ignored.public void setDepth(double depth)
depth
- the depth of the Pie, as a percentage of the radius of the piepublic void setOtherSlice(String name, double percentage)
name
- the name to use for the slicepercentage
- the threshold to determine which slices to add. Any slices
that would be smaller than this percentage are added to the other slice
instead of being displayed directly. Zero means no other slice is used.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |