if (!manifestation.isLocked()) {
String name = legendEntry.getComputedBaseDisplayName();
spinnerValue = legendEntry.getNumberRegressionPoints();
if (name.isEmpty()) name = legendEntry.getFullBaseDisplayName();
final LineSettings settings = legendEntry.getLineSettings();
// Color submenu
String subMenuText = String.format(BUNDLE.getString("SelectColor.label"), name);
JMenu subMenu = new JMenu(subMenuText);
Color currentColor = legendEntry.getForeground();
for (int i = 0; i < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT; i++) {
JMenuItem item = new JRadioButtonMenuItem("",
new SolidColorIcon(PlotLineColorPalette.getColor(i)),
(currentColor == PlotLineColorPalette.getColor(i))
);
final int colorIndex = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
legendEntry.setForeground(PlotLineColorPalette.getColor(colorIndex));
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
add(subMenu);
// Thickness submenu
subMenuText = String.format(BUNDLE.getString("SelectThickness.label"), name);
subMenu = new JMenu(subMenuText);
for (int i = 1; i <= PlotConstants.MAX_LINE_THICKNESS; i++) {
JMenuItem item = new JRadioButtonMenuItem("" + i,
(settings.getThickness() == i));
final int thickness = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setThickness(thickness);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
add(subMenu);
// Marker submenu
if (manifestation.getPlot() != null &&
manifestation.getPlot().getPlotLineDraw().drawMarkers()) {
subMenuText = String.format(BUNDLE.getString("SelectMarker.label"), name);
subMenu = new JMenu(subMenuText);
for (int i = 0; i < PlotConstants.MAX_NUMBER_OF_DATA_ITEMS_ON_A_PLOT; i++) {
JMenuItem item = new JRadioButtonMenuItem("",
new PlotMarkerIcon(PlotLineShapePalette.getShape(i), false),
(settings.getMarker() == i && !settings.getUseCharacter()));
item.setForeground(legendEntry.getForeground());
final int marker = i;
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings.setMarker(marker);
settings.setUseCharacter(false);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
subMenu.add(item);
}
JMenuItem other = new JRadioButtonMenuItem(BUNDLE.getString("SelectCharacter.label"),
settings.getUseCharacter());
if (!settings.getCharacter().isEmpty()) {
FontRenderContext frc = ((Graphics2D) manifestation.getGraphics()).getFontRenderContext();
other.setIcon(new PlotMarkerIcon(
PlotLineShapePalette.getShape(settings.getCharacter(), frc),
PlotLineColorPalette.getColor(settings.getColorIndex()),
false));
}
other.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
final CharacterDialog dialog = new CharacterDialog();
dialog.setInitialString(settings.getCharacter());
dialog.ok.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
settings.setCharacter(dialog.field.getText().trim());
settings.setUseCharacter(true);
legendEntry.setLineSettings(settings);
manifestation.persistPlotLineSettings();
}
});
dialog.setVisible(true);