org.faceless.graph2
Class Key

java.lang.Object
  extended by org.faceless.graph2.Key

public class Key
extends Object

A Key can optionally be added to the Graph to display information about the data displayed on the Graph. At it's simplest you could do something like the following:

 AxesGraph graph = new AxesGraph();
 Series series = makeMySeries();
 graph.addSeries(series);
 graph.addKey(new Key(null), Align.BOTTOM);
 
which will add all the series to the Graph. If you want more control over the contents off the key, calling the addSeries or addCustom, methods will clear the Key of any default values, allowing you to set the values as you see fit.

See Also:
Graph.addKey(org.faceless.graph2.Key, int)

Constructor Summary
Key(Style backstyle)
          Create a new Key
 
Method Summary
 void addCustom(AbstractMarker marker, String text, TextStyle style)
          Add a custom marker and/or text to the Key.
 void addSeries(Series series, TextStyle style)
          Add the specified series to the Key.
 void setDefaultTextStyle(TextStyle style)
          Set the default text style to use on the key.
 void setMargin(int margin)
          Set the margin around the Key.
 void setMaxWidth(int width)
          Set the maximum width of the Key box.
 void setPadding(int padding)
          Set the padding for the Key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Key

public Key(Style backstyle)
Create a new Key

Parameters:
backstyle - the style to display the background box of the key in, or null not to display a box
Method Detail

setDefaultTextStyle

public void setDefaultTextStyle(TextStyle style)
Set the default text style to use on the key. This is the style used if null is passed in as a style to addSeries or addCustom methods.

Parameters:
style - the default style to render the text in

addSeries

public void addSeries(Series series,
                      TextStyle style)
Add the specified series to the Key. The text displayed next to the Series is the series name

Parameters:
series - the series to add to the Key
style - The style to render the text in. May be null to use the default.

addCustom

public void addCustom(AbstractMarker marker,
                      String text,
                      TextStyle style)
Add a custom marker and/or text to the Key.

Parameters:
marker - The marker to add to the Key. May be null to display only text.
text - The text to add to the Key. May be null to display only the marker.
style - The style to render the text in. May be null to use the default.
Since:
2.4

setMaxWidth

public void setMaxWidth(int width)
Set the maximum width of the Key box. To display Keys vertically in a single column set this value to 0.

Parameters:
width - the maximum width of the key box, in pixels or whatever measurement is used by your Output object.

setMargin

public void setMargin(int margin)
Set the margin around the Key. The margin is the space between the outside edge of the Key box and the edge of the graph itself if the key is positioned at the edge of the box using the Graph.addKey(Key,int) method. The default is 10.

Parameters:
margin - the margin to use around the key box, in pixels or whatever measurement is used by your Output object.

setPadding

public void setPadding(int padding)
Set the padding for the Key. The padding is the space between the inside edge of the Key box and the actual contents of the Key. The default is 7.

Parameters:
padding - the padding to use inside the key box, in pixels or whatever measurement is used by your Output object.


Copyright © 2001-2011 Big Faceless Organization