public class IlvLegend
extends java.lang.Object
An IlvLegend
object is associated with a unique chart (you
cannot share a legend among several charts). Each time a change occurs
on the chart, the legend is automatically notified and updates itself
accordingly. Usually, items are automatically added to the legend that invokes
the IlvChartRenderer#createLegendItems
method of each renderer of
the chart. In this case, items are by default instances of
.
IlvRendererLegendItem
You may also wish to add items that are not associated with any renderer
(for example for information purpose or when an annotation has been added to
the chart). In this case, you should create
objects and add them explicitly to the legend.
IlvIconLegendItem
Since legend items inherit from JComponent
, they are added to the legend
using the Container.add()
method and can be retrieved
using the standard AWT Container methods (get()
, getAll()
).
The IlvLegend
class inherits from JComponent
,
it can thus be added to any Container
, in particular to an
IlvChart
instance (Note that this is the only component that can
be added directly to the chart. See IlvChart
for more information.)
When added to a chart, a legend can either be placed around the chart
area or within it, depending on its constraints (see
IlvChartLayout
.) It can also have a dockable
behavior (click on its border and drag it around) if its movable property
is set to true
.
By default, an IlvLegend
uses a custom layout manager (instance
of IlvLegendLayout
) to dynamically lay out the items
depending on the current legend position. You can change this default layout
by using the layout manager of your choice invoking the setLayout()
method.
A legend may also generate an event to all the registered listeners
each time an item is clicked. This behavior is associated with the
interactive
property.
Note: So that the auto-transparency capability of the IlvLegend
class works properly with the Swing RepaintManager, the IlvLegend
class does
not use the opaque
property to know whether it should fill its
background or not. Instead, a new property paintingBackground
(see #setPaintingBackground
) with the same purpose has been added in
JViews 5.0. The default value is true
, which means that the legend paints its
background by default. Note that this behavior is different from the
IlvChart
behavior that is not filled by default.
Here is a picture showing the different parameters and components of a legend :
chartLegend {
class : "ilog.views.chart.IlvLegend";
antiAliasing : "false";
antiAliasingText : "false";
background : "green";
baseTextDirection : "Inherited";
border : "@#emptyBorder";
floatingLayoutDirection : "2";
followChartResize : "false";
font : "sansserif-BOLD-8";
foreground : "green";
horizontalOrientation : "2";
interactive : "false";
location : "0,0";
movable : "false";
opaque : "false";
paintingBackground : "false";
symbolSize : "0,0";
symbolTextSpacing : "2";
title : "<value>";
toolTipText : "<value>";
verticalOrientation : "2";
}
Modifier and Type | Property and Description |
---|---|
boolean |
antiAliasing
Sets the antiAliasing property. |
boolean |
antiAliasingText
Sets the antiAliasingText property. |
java.awt.Color |
background
Sets the background color of this component. |
int |
baseTextDirection
Sets the base text direction for this legend. |
Border |
border
Sets the border of this component. |
java.lang.String |
class
Creates a new IlvLegend object. |
int |
floatingLayoutDirection
Sets the flow direction of the floating layout. |
boolean |
followChartResize
Sets whether the legend location is updated on a chart resize event. |
java.awt.Font |
font
Sets the font for this component. |
java.awt.Color |
foreground
Sets the foreground color of this component. |
int |
horizontalOrientation
Sets the orientation used by a horizontal layout. |
boolean |
interactive
Sets the interactive mode property. |
java.awt.Point |
location
Moves the legend to a new location. |
boolean |
movable
Sets the legend movable property. |
boolean |
opaque
If true the component paints every pixel within its bounds. |
boolean |
paintingBackground
Sets the paintingBackground property. |
Dimension |
symbolSize
Sets the size of the items symbols. |
int |
symbolTextSpacing
Sets the space (in pixels) between the symbol and the text of a legend item. |
java.lang.String |
title
Sets the legend title. |
java.lang.String |
toolTipText
Registers the text to display in a tool tip. |
int |
verticalOrientation
Sets the orientation used by a vertical layout. |
public java.lang.String class
IlvLegend
object.
By default, a legend is movable and uses a TitledBorder
.
class : "ilog.views.chart.IlvLegend";
public boolean antiAliasing
antiAliasing
property.
When this property is set
to true
, all drawings in the legend component and subcomponents are
antialiased. This property does not affect text. To toggle the
anti-aliasing of text, use the #setAntiAliasingText
method.
The default value of this property is false
.
antiAliasing : "false";
public boolean antiAliasingText
antiAliasingText
property.
When this property is set to true
, all text drawings in the legend
component and subcomponents are antialiased.
This property only affects text. To toggle the anti-aliasing of other
drawings, use the #setAntiAliasing
method.
The default value of this property is false
.
antiAliasingText : "false";
public java.awt.Color background
background : "green";
public int baseTextDirection
The base text direction influences the display of text strings that are composed of segments that are read from left to right as well as of segments that are read from right to left. It determines the order of these segments.
Possible values are:
IlvBidiUtil#COMPONENT_DIRECTION
,
IlvBidiUtil#CONTEXTUAL_DIRECTION
,
IlvBidiUtil#LEFT_TO_RIGHT
, IlvBidiUtil#RIGHT_TO_LEFT
,
and IlvBidiUtil#INHERITED_DIRECTION
, which in this case is
equivalent to the chart's base text direction.
CSS example:
baseTextDirection : "Inherited";
Allowed values: |
Inherited |
Component Orientation |
Left-To-Right |
Right-To-Left |
Contextual |
public Border border
border : "@#emptyBorder";
EmptyBorder
for an example of implementing a border.public int floatingLayoutDirection
IlvLegendLayout
instance.
floatingLayoutDirection : "2";
public boolean followChartResize
true
, the legend position is updated when its
chart is resized so that its position relative to the chart does not change.
When set to false
, the legend position does not change.
The default value is false
.
followChartResize : "false";
public java.awt.Font font
font : "sansserif-BOLD-8";
public java.awt.Color foreground
foreground : "green";
public int horizontalOrientation
horizontalOrientation : "2";
public boolean interactive
mode
is true
, an event is fired each time the user clicks
on an item.
interactive : "false";
public java.awt.Point location
IlvChartLayout.ABSOLUTE
.
location : "0,0";
public boolean movable
movable
is true
, the legend can be moved by dragging it
anywhere within the chart bounds. If false
, the
legend is set unmovable.
movable : "false";
public boolean opaque
opaque : "false";
public boolean paintingBackground
paintingBackground
property. If paint
is true
, the legend fills its background before
drawing its items.
paintingBackground : "false";
public Dimension symbolSize
symbolSize : "0,0";
public int symbolTextSpacing
symbolTextSpacing : "2";
public java.lang.String title
title : "<value>";
public java.lang.String toolTipText
toolTipText : "<value>";
public int verticalOrientation
verticalOrientation : "2";
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.