Package org.faceless.graph2
Class Key
- java.lang.Object
-
- org.faceless.graph2.Key
-
public class Key extends Object
A Key can optionally be added to theGraph
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 theaddSeries
oraddCustom
, methods will clear the Key of any default values, allowing you to set the values as you see fit.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
setHorizontalAdvance(int advance)
Set the horizontal padding to place between each item on the same linevoid
setMargin(int margin)
Set the margin around the Key.void
setMargin(int top, int right, int bottom, int left)
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.void
setPadding(int top, int right, int bottom, int left)
Set the padding for the Key.void
setVerticalAdvance(int advance)
Set the vertical padding to place between each line in the key
-
-
-
Constructor Detail
-
Key
public Key(Style backstyle)
Create a new Key- Parameters:
backstyle
- the style to display the background box of the key in, ornull
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 ifnull
is passed in as a style toaddSeries
oraddCustom
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 Keystyle
- The style to render the text in. May benull
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 benull
to display only text.text
- The text to add to the Key. May benull
to display only the marker.style
- The style to render the text in. May benull
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 yourOutput
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 theGraph.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 yourOutput
object.
-
setMargin
public void setMargin(int top, int right, int bottom, int left)
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 theGraph.addKey(Key,int)
method. The default is 10 for each- Parameters:
top
- the margin to use at the top of the key box, in pixels or whatever measurement is used by yourOutput
object.right
- the margin to use at the right of the key box, in pixels or whatever measurement is used by yourOutput
object.bottom
- the margin to use at the bottom of the key box, in pixels or whatever measurement is used by yourOutput
object.left
- the margin to use at the left of the key box, in pixels or whatever measurement is used by yourOutput
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 yourOutput
object.
-
setPadding
public void setPadding(int top, int right, int bottom, int left)
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 for each parameter.- Parameters:
top
- the padding to use inside at the top of the key box, in pixels or whatever measurement is used by yourOutput
object.right
- the padding to use inside at the right of the key box, in pixels or whatever measurement is used by yourOutput
object.bottom
- the padding to use inside at the bottom of the key box, in pixels or whatever measurement is used by yourOutput
object.left
- the padding to use inside at the left of the key box, in pixels or whatever measurement is used by yourOutput
object.
-
setVerticalAdvance
public void setVerticalAdvance(int advance)
Set the vertical padding to place between each line in the key
-
setHorizontalAdvance
public void setHorizontalAdvance(int advance)
Set the horizontal padding to place between each item on the same line
-
-