Chart FX 7 for Java Server

com.softwarefx.chartfx.server
Class LegendItemAttributes

java.lang.Object
  extended by com.softwarefx.chartfx.server.LegendItemAttributes

public class LegendItemAttributes
extends Object

Provides access to the customization of a specific item in the LegendBox.

The LegendItemAttributes Class allows you to configure how SeriesAttributes, ConditionalAttributes, CustomGridLine, or Axis.getKeyLabels() of the Axis Class are rendered in the LegendBox.SeriesAttributes

First, a new LegendItemAttributes object needs to be created. Next, this object needs to be mapped to the specific object it will customize. The final stage consists of modifing properties of the LegendItemAttributes object such as setFontStyle(java.util.EnumSet) and setTextColor(java.awt.Color). Notice that the setVisible(boolean) property is usefull if you do not want a specific object being displayed in the LegendBox. For example, the following piece of code makes the first Chart.getSeries()of the Chartinvisble in the LegendBox:

LegendItemAttributes item = new LegendItemAttributes();
item.setVisible(false);
chart1.getLegendBox().getItemAttributes().set(chart1.getSeries(), 0, item);


Constructor Summary
LegendItemAttributes()
           
 
Method Summary
 EnumSet<FontStyle> getFontStyle()
          Gets the FontStyle.
 int getOrderIndex()
          Gets the OrderIndex.
 Color getTextColor()
          Gets the TextColor.
 boolean isInverted()
          Gets the Inverted.
 boolean isVisible()
          Gets the Visible.
 void setFontStyle(EnumSet<FontStyle> value)
          Sets the font style for the legend box item.
 void setInverted(boolean value)
          Sets a value allowing you to invert the order of the LegendBox Items.
 void setOrderIndex(int value)
          Sets the index for ordering the legend box items.
 void setTextColor(Color value)
          Sets a value allowing you to set the text color for the legend item.
 void setVisible(boolean value)
          Sets a value allowing you hide or show the legend item.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LegendItemAttributes

public LegendItemAttributes()
Method Detail

getFontStyle

public EnumSet<FontStyle> getFontStyle()

Gets the FontStyle. For more detail see setFontStyle(java.util.EnumSet).


getOrderIndex

public int getOrderIndex()

Gets the OrderIndex. For more detail see setOrderIndex(int).


getTextColor

public Color getTextColor()

Gets the TextColor. For more detail see setTextColor(java.awt.Color).


isInverted

public boolean isInverted()

Gets the Inverted. For more detail see setInverted(boolean).


isVisible

public boolean isVisible()

Gets the Visible. For more detail see setVisible(boolean).


setFontStyle

public void setFontStyle(EnumSet<FontStyle> value)

Sets the font style for the legend box item.

Remarks:
  • For more information regarding the FontStyle type, please refer to the Java API Documentation.

  • See Also:
    setInverted(boolean), setOrderIndex(int), setTextColor(java.awt.Color), setVisible(boolean), LegendBox

    setInverted

    public void setInverted(boolean value)

    Sets a value allowing you to invert the order of the LegendBox Items.

    Remarks:
  • When set to true, all the selected items in the LegendBox will ve inverted.

  • See Also:
    setFontStyle(java.util.EnumSet), setOrderIndex(int), setTextColor(java.awt.Color), setVisible(boolean), LegendBox

    setOrderIndex

    public void setOrderIndex(int value)

    Sets the index for ordering the legend box items.

    Remarks:
  • The LegendBox can contain diferente legend items (e.g. Series Legends and Custom Gridlines Legends), which will be automatically grouped and sorted as shown in the folowing picture:

  • The order in which the legend groups are sorted can be changed by setting the OrderIndex:

    LegendItemAttributes lia1 = new LegendItemAttributes();
    LegendItemAttributes lia2 = new LegendItemAttributes();
    LegendItemAttributes lia3 = new LegendItemAttributes();
    LegendItemAttributes lia4 = new LegendItemAttributes();

    lia1.setOrderIndex(2);
    lia2.setOrderIndex(4);
    lia3.setOrderIndex(1);
    lia4.setOrderIndex(3);

    chart1.getLegendBox().getItemAttributes().set(chart1.getSeries(), lia1);
    chart1.getLegendBox().getItemAttributes().set(chart1.getAxisY().getCustomGridLines(), lia2);
    chart1.getLegendBox().getItemAttributes().set(chart1.getAxisX().getCustomGridLines(), lia3);
    chart1.getLegendBox().getItemAttributes().set(chart1.getLegendBox().getCustomItems(), lia4);

    Which will produce the following:

  • When you use this feature, you must set an OrderIndex value to all the items in the LegendBox, or you will get unexpected results.

  • Chart FX will reorder the items in the LegenBox by sorting them by the assigned OrderIndex values. This values do not have to be correlative values. The above example would have produced the same results if the values 1, 10, 50, 200 were used.

  • See Also:
    setFontStyle(java.util.EnumSet), setInverted(boolean), setTextColor(java.awt.Color), setVisible(boolean), LegendBox

    setTextColor

    public void setTextColor(Color value)

    Sets a value allowing you to set the text color for the legend item.

    Remarks:
  • For more information regarding the Color type, please refer to the Java API Documentation

  • See Also:
    setFontStyle(java.util.EnumSet), setInverted(boolean), setOrderIndex(int), setVisible(boolean), LegendBox

    setVisible

    public void setVisible(boolean value)

    Sets a value allowing you hide or show the legend item.

    Remarks:
  • When a legend item is hidden in the legend, the chart element will still be displayed in the chart.

  • See Also:
    LegendBox

    http://www.softwarefx.com

    2008 Software FX, Inc. All Rights Reserved. Chart FX is a registered trademark of Software FX, Inc
    All other names are trademarks or registered trademarks of their respective owners.