com.java4less.rchart
Class Legend

java.lang.Object
  |
  +--com.java4less.rchart.ChartComponent
        |
        +--com.java4less.rchart.Legend

public class Legend
extends ChartComponent


The legend contains the description of the data displayed in the chart. A legend can be displayed on the right side of the chart (default), at the top or at the bottom. The property Layout of the Chart modifies the behaviour.

A legend is a list of pairs:

LineStyle + Text: a line will be displayed next to the next.
FillStle + Text: a small boy will be displayed nex to the text.
Image + Text: the image will be displayed next to the text.
Example:

Legend l=new Legend();
l.border=new LineStyle(0.2f,java.awt.Color.black,LineStyle.LINE_NORMAL);
l.addItem("Company A",new FillStyle(java.awt.Color.cyan));
l.addItem("Company B",new FillStyle(java.awt.Color.green));

the legend must be assigned to the chart:

chart.legend=l;


Field Summary
 FillStyle background
          background of the legend.
 LineStyle border
          border of the legend.
 java.awt.Color color
           
 java.awt.Font font
           
 int legendMargin
          margin of the legend.
 java.lang.String title
          title of the legend
 boolean verticalLayout
          if false the items will be displayed from left to right.
 
Fields inherited from class com.java4less.rchart.ChartComponent
height, width, x, y
 
Constructor Summary
Legend()
           
 
Method Summary
 void addItem(java.lang.String Name, java.lang.Object icon)
          Adds an item.
 void draw(java.awt.Graphics g)
           
 void drawHorizontal(java.awt.Graphics g)
           
 void drawVertical(java.awt.Graphics g)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

background

public FillStyle background
background of the legend.

border

public LineStyle border
border of the legend.

legendMargin

public int legendMargin
margin of the legend.

title

public java.lang.String title
title of the legend

color

public java.awt.Color color

font

public java.awt.Font font

verticalLayout

public boolean verticalLayout
if false the items will be displayed from left to right.
Constructor Detail

Legend

public Legend()
Method Detail

addItem

public void addItem(java.lang.String Name,
                    java.lang.Object icon)
Adds an item. The item is a description and an icon. The icon can be an Image, a Linestyle or a FillStyle.

draw

public void draw(java.awt.Graphics g)

drawHorizontal

public void drawHorizontal(java.awt.Graphics g)

drawVertical

public void drawVertical(java.awt.Graphics g)