package jas.plot; import jas.plot.java2.PlotGraphics12; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Insets; import java.awt.LayoutManager2; import java.util.Enumeration; import java.util.Vector; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPopupMenu; /** * Represents a plot legend */ public class Legend extends MovableObject { private SetablePlotGraphics pg = new PlotGraphics12(); /** * Create an empty legend */ public Legend() { super("Legend"); setLayout(new LegendLayout()); setBorder(BorderFactory.createLineBorder(Color.black)); } /** * Adds a legend entry to a legend */ public void add(final LegendEntry e) { super.add(new LegendComponent(e)); EditableLabel label = new EditableLabel(e.getTitle(),"Legend Entry",JLabel.LEFT) { protected void fireActionPerformed() { super.fireActionPerformed(); if (e instanceof MutableLegendEntry) ((MutableLegendEntry) e).setTitle(getText()); } }; label.setShowFontMenuItem(false); super.add(label); } /** * Removes a legend entry from a legend */ public void remove(LegendEntry e) { int n = getComponentCount(); for (int i=0; i 0) menu.addSeparator(); menu.add(new FontMenuItem(this,getPrefix())); super.modifyPopupMenu(menu,source); } public void setFont(Font font) { super.setFont(font); int n = getComponentCount(); for (int i=1; i