/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info: http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2003, by :
* Corporate:
* Astrium SAS
* EADS CRC
* Individual:
* Nicolas Brodu
*
* $Id: BarChartShape.java,v 1.10 2008/09/29 10:27:46 ogor Exp $
*
* Changes
* -------
* 05-Nov-2003 : Initial version (NB);
*
*/
package jsynoptic.plugins.jfreechart;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Paint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ResourceBundle;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.undo.CompoundEdit;
import jsynoptic.base.ContextualActionProvider;
import jsynoptic.ui.JSynoptic;
import jsynoptic.ui.LongAction;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryLabelPosition;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.CategoryItemRenderer;
import org.jfree.chart.ui.ChartPropertyEditPanel;
import org.jfree.text.TextBlockAnchor;
import org.jfree.ui.RectangleEdge;
import org.jfree.ui.TextAnchor;
import simtools.data.DataInfo;
import simtools.data.DataSource;
import simtools.data.DataSourceCollection;
import simtools.data.DataSourceListener;
import simtools.data.DataSourcePool;
import simtools.data.UnsupportedOperation;
import simtools.shapes.AbstractShape;
import simtools.ui.ColorMapper;
import simtools.ui.DynamicColorChooser;
import simtools.ui.FontChooserPanel;
import simtools.ui.GenericMapper;
import simtools.ui.MapperListener;
import simtools.ui.ResourceFinder;
import simtools.ui.TextMapper;
/**
* A shape to manage JFreeChart Bar Charts
*/
public class BarChartShape extends ChartShape implements ContextualActionProvider, DataSourceListener, MapperListener {
static final long serialVersionUID = -3848715079146141774L;
public static ResourceBundle resources = ResourceFinder.get(BarChartShape.class);
protected Vector mappers;
protected transient Vector mapperSources;
public BarChartShape(JFreeChart chart) {
this(chart,0,0,400,300);
}
public BarChartShape(JFreeChart chart, int ox, int oy, int width, int height) {
super(chart, ox, oy, width, height);
CategoryPlot plot = chart.getCategoryPlot();
//CategoryAxis
ValueAxis raxis = plot.getRangeAxis();
raxis.setAutoRange(true);
mapperSources = new Vector();
mappers = new Vector();
// plot.setRenderer(new JSynopticStandardXYItemRenderer());
}
/* (non-Javadoc)
* @see jsynoptic.base.ContextualActionProvider#getActions(double, double, java.lang.Object, int)
*/
public String[] getActions(double x, double y, Object o, int context) {
if (context==MOUSE_OVER_CONTEXT) {
return null;
}
if (context==MOUSE_OUT_CONTEXT) {
return null;
}
if (context==MOUSE_PRESSED_CONTEXT) {
return null;
}
Vector v = new Vector();
v.add(resources.getString("Properties..."));
CategoryPlot plot = chart.getCategoryPlot();
SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
if (o instanceof DataSource) {
v.add(resources.getString("AddSource"));
}
else if (o instanceof DataSourceCollection) {
v.add(resources.getString("SetSources"));
v.add(resources.getString("AddSources"));
}
return (String[])v.toArray(new String[v.size()]);
}
/* (non-Javadoc)
* @see jsynoptic.base.ContextualActionProvider#doAction(double, double, java.lang.Object, java.lang.String)
*/
public boolean doAction(double x, double y, Object o, String action, CompoundEdit undoableEdit) {
if (action.equals(resources.getString("Properties..."))) {
new LongAction(LongAction.LONG_ACTION_SHAPE, null, this) {
protected void doAction() {
ChartPropertyEditPanel panel = new ChartPropertyEditPanel(chart);
JTabbedPane tab = findTab(panel);
PlotPanel plotPanel = null;
if (tab!=null) tab.add(plotPanel = new PlotPanel(),0);
int result = JOptionPane.showConfirmDialog(null, panel,
resources.getString("ChartProperties"), JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
panel.updateChartProperties(chart);
if (plotPanel!=null) plotPanel.updateChartProperties();
}
notifyChange();
}
}.start();
return true;
}
if (action.equals(resources.getString("AddSource"))) {
try {
CategoryPlot plot = chart.getCategoryPlot();
SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
dst.addSource((DataSource)o);
mappers.add(null); mapperSources.add(null); // no mapper by default
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSource"));
}
}
if (action.equals(resources.getString("AddSources"))) {
try {
CategoryPlot plot = chart.getCategoryPlot();
SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
dst.addDataSourceCollection((DataSourceCollection)o);
for (int i=0; i<((DataSourceCollection)o).size(); ++i) {
mappers.add(null); mapperSources.add(null); // no mapper by default
}
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSourceCollection"));
}
}
if (action.equals(resources.getString("SetSources"))) {
try {
CategoryPlot plot = chart.getCategoryPlot();
SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
dst.setDataSourceCollection((DataSourceCollection)o);
chart.setTitle(dst.getName());
for (int i=0; i<mappers.size(); ++i) {
DataSource ds = (DataSource)mapperSources.get(i);
if (ds!=null) ds.removeListener(this);
ColorMapper cm = (ColorMapper)mappers.get(i);
if (cm!=null) cm.removeListener(this);
}
for (int i=0; i<((DataSourceCollection)o).size(); ++i) {
mappers.add(null); mapperSources.add(null); // no mapper by default
}
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSourceCollection"));
}
}
return true;
}
/* (non-Javadoc)
* @see jsynoptic.base.ContextualActionProvider#canDoAction(double, double, java.lang.Object, java.lang.String, int)
*/
public boolean canDoAction(double x, double y, Object o, String action, int context) {
return true;
}
static protected class CbxEntry {
public int datasetIndex;
public String name;
public Color color;
public DataSource source;
public ColorMapper mapper;
public CbxEntry(int datasetIndex, String name, Color c, DataSource ds, ColorMapper cm) {
this.name = name;
this.datasetIndex=datasetIndex;
color = c;
source = ds;
mapper = cm;
}
public String toString() {
return name;
}
}
public class PlotPanel extends JPanel {
protected JTextField tfTitle;
protected JComboBox pcbxcurves, cbxmapper;
protected JButton pcurvecolor, pcurvedelete, editCategories, beditmapper, bnewmapper, bdelmapper;
protected JTextField pcbxeditortf;
protected boolean peditLocked;
protected CbxEntry pactiveEntry;
protected JRadioButton hSeriesOrientation, vSeriesOrientation;
protected JRadioButton hLabelOrientation, vLabelOrientation;
protected TextMapper mapper;
public PlotPanel() {
setLayout(new BorderLayout());
JPanel panel;
Box section;
Box content = Box.createVerticalBox();
setName(resources.getString("PlotProperties"));
CategoryPlot plot = chart.getCategoryPlot();
SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
// Create the title section
section=Box.createHorizontalBox();
section.add(new JLabel(resources.getString("PlotTitle:")));
section.add(tfTitle = new JTextField());
tfTitle.setText(chart.getTitle().getText());
content.add(section);
section=Box.createVerticalBox();
section.setBorder(BorderFactory.createTitledBorder(resources.getString("Series")));
Box box = Box.createHorizontalBox();
box.add(pcbxcurves = new JComboBox());
box.add(pcurvecolor = new JButton(" "));
box.add(pcurvedelete = new JButton(resources.getString("Delete")));
section.add(box);
box = Box.createHorizontalBox();
box.add(new JLabel(resources.getString("Orientation")));
box.add(Box.createHorizontalGlue());
box.add(hSeriesOrientation = new JRadioButton(resources.getString("Horizontal")));
box.add(vSeriesOrientation = new JRadioButton(resources.getString("Vertical")));
hSeriesOrientation.setSelected(plot.getOrientation() == PlotOrientation.HORIZONTAL);
vSeriesOrientation.setSelected(plot.getOrientation() == PlotOrientation.VERTICAL);
ButtonGroup bg = new ButtonGroup();
bg.add(hSeriesOrientation);
bg.add(vSeriesOrientation);
section.add(box);
content.add(section);
pcbxcurves.setEditable(true);
Color noCurveColor = pcurvecolor.getBackground();
pcurvecolor.setFocusPainted(false);
CategoryItemRenderer renderer = plot.getRenderer();
int n = dst.getRowCount();
for (int i=0; i<n; ++i) {
DataSource ds = (DataSource)mapperSources.get(i);
if (ds==null) ds = dst.getSource(i); // take the datasource associated with this series by default
pcbxcurves.addItem(new CbxEntry(i,dst.getName(i),(Color)renderer.getSeriesPaint(i),ds,(ColorMapper)mappers.get(i)));
}
pcbxeditortf = (JTextField)pcbxcurves.getEditor().getEditorComponent();
pupdateForEntry(pcbxcurves.getSelectedItem());
pcbxcurves.addPopupMenuListener(new PopupMenuListener() {
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
peditLocked = true;
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
peditLocked = false;
}
public void popupMenuCanceled(PopupMenuEvent e) {
peditLocked = false;
}
});
pcbxcurves.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange()==ItemEvent.DESELECTED) pactiveEntry = null;
else pupdateForEntry(e.getItem());
}
});
pcbxeditortf.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
updateName();
}
public void removeUpdate(DocumentEvent e) {
updateName();
}
public void changedUpdate(DocumentEvent e) {
updateName();
}
public void updateName() {
if ((peditLocked) || (pactiveEntry == null)) return;
pactiveEntry.name = pcbxeditortf.getText();
}
});
pcurvecolor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (pactiveEntry==null) return;
DynamicColorChooser dialog = new DynamicColorChooser(
null, resources.getString("ChooseAColor"),null ,pactiveEntry.color,pactiveEntry.source,pactiveEntry.mapper);
dialog.pack();
dialog.setVisible(true);
if (dialog.isOk()){
pactiveEntry.color = dialog.getColor();
pactiveEntry.source = dialog.getSource();
pactiveEntry.mapper = dialog.getMapper();
pupdateForEntry(pactiveEntry);
}
}
});
pcurvedelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (pactiveEntry==null) return;
pcbxcurves.removeItem(pactiveEntry);
}
});
section=Box.createVerticalBox();
section.setBorder(BorderFactory.createTitledBorder(resources.getString("Categories")));
box = Box.createHorizontalBox();
box.add(new JLabel(resources.getString("LabelsOrientation")));
box.add(Box.createHorizontalGlue());
box.add(hLabelOrientation = new JRadioButton(resources.getString("Horizontal")));
box.add(vLabelOrientation = new JRadioButton(resources.getString("Vertical")));
CategoryLabelPosition clp = vSeriesOrientation.isSelected() ? plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.BOTTOM) : plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.LEFT);
boolean vertical = clp.getAngle() != 0;
hLabelOrientation.setSelected(!vertical);
vLabelOrientation.setSelected(vertical);
bg = new ButtonGroup();
bg.add(hLabelOrientation);
bg.add(vLabelOrientation);
section.add(box);
mapper = (dst.getClassifier()==null) ? null : dst.getClassifier().getMapper();
box = Box.createHorizontalBox();
box.add(new JLabel(resources.getString("Mapper")));
box.add(Box.createHorizontalGlue());
box.add(cbxmapper = new JComboBox());
cbxmapper.addItem(resources.getString("=======NONE======="));
int idx = 0;
if (TextMapper.textMappers!=null) for (int i =0; i<TextMapper.textMappers.size(); ++i) {
TextMapper tm = (TextMapper)TextMapper.textMappers.get(i);
if (tm.equals(mapper)) idx = i +1;
cbxmapper.addItem(tm);
}
cbxmapper.setEditable(false);
cbxmapper.setSelectedIndex(idx);
box.add(cbxmapper);
box.add(beditmapper = new JButton(resources.getString("Edit")));
box.add(bnewmapper = new JButton(resources.getString("New")));
box.add(bdelmapper = new JButton(resources.getString("Delete")));
if (idx==0) {
beditmapper.setEnabled(false);
bdelmapper.setEnabled(false);
}
cbxmapper.setRenderer(new ListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
String s = value.toString();
if (s.length()>18) s = s.substring(0,15) + "...";
return new JLabel(s);
}
});
beditmapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mapper==null) return;
mapper.editDialog(null);
cbxmapper.repaint(); // in case of name change
}
});
bnewmapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mapper = TextMapper.createTextMapperDialog(null);
if (TextMapper.textMappers==null) TextMapper.textMappers = new Vector();
TextMapper.textMappers.add(mapper);
cbxmapper.addItem(mapper);
cbxmapper.setSelectedItem(mapper);
}
});
bdelmapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mapper==null) return;
if (TextMapper.textMappers!=null) TextMapper.textMappers.remove(mapper);
cbxmapper.removeItem(mapper);
cbxmapper.setSelectedIndex(0);
mapper = null;
bdelmapper.setEnabled(false);
beditmapper.setEnabled(false);
}
});
cbxmapper.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int idx = cbxmapper.getSelectedIndex();
if (idx==0) {
beditmapper.setEnabled(false);
bdelmapper.setEnabled(false);
mapper = null;
} else {
mapper = (TextMapper)cbxmapper.getItemAt(idx);
beditmapper.setEnabled(true);
bdelmapper.setEnabled(true);
}
}
});
section.add(box);
content.add(section);
add(content, BorderLayout.NORTH);
}
protected void pupdateForEntry(Object o) {
if (o instanceof CbxEntry) pactiveEntry = (CbxEntry)o;
else pactiveEntry = null;
if (pactiveEntry == null) return;
pcurvecolor.setBackground(pactiveEntry.color);
}
protected void updateChartProperties() {
chart.setTitle(tfTitle.getText());
CategoryPlot plot = chart.getCategoryPlot();
SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
int n = dst.getRowCount();
// If some curves were deleted, remove them
if (n != pcbxcurves.getItemCount()) {
boolean[] toKeep = new boolean[n]; // boolean are initialized to false by JVM
for (int i=0; i<pcbxcurves.getItemCount(); ++i)
toKeep[((CbxEntry)pcbxcurves.getItemAt(i)).datasetIndex] = true;
// Now we can remove the deleted curves, and update the existing ones
// Start from the end, to remove the entries and keep the index OK
for (int i=n-1; i>=0; i--) {
if (!toKeep[i]) {
GenericMapper mapper = (GenericMapper)mappers.remove(i);
if (mapper!=null) mapper.removeListener(BarChartShape.this);
DataSource source = (DataSource)mapperSources.remove(i);
if (source!=null) source.removeListener(BarChartShape.this);
dst.removeSource(i);
}
}
}
// Now we match the data set and the list
int len = pcbxcurves.getItemCount();
for (int i=0; i<len; ++i) {
CbxEntry e = (CbxEntry)pcbxcurves.getItemAt(i);
dst.setName(i,e.name);
CategoryItemRenderer renderer = plot.getRenderer();
DataSource ds = (DataSource)mapperSources.get(i);
if ((e.source==null) && (ds!=null)) ds.removeListener(BarChartShape.this);
mapperSources.set(i,e.source);
if (e.source!=null) e.source.addListener(BarChartShape.this);
ColorMapper cm = (ColorMapper)mappers.get(i);
if ((e.mapper==null) && (cm!=null)) cm.removeListener(BarChartShape.this);
mappers.set(i,e.mapper);
if (e.mapper!=null) e.mapper.addListener(BarChartShape.this);
if ((e.mapper!=null) && (e.source!=null)) {
e.mapper.setDefaultPaint(e.color);
renderer.setSeriesPaint(i,e.mapper.getPaint(e.source));
}
else renderer.setSeriesPaint(i,e.color);
}
plot.setOrientation(hSeriesOrientation.isSelected() ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL);
CategoryLabelPosition clp = vSeriesOrientation.isSelected() ? plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.BOTTOM) : plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.LEFT);
clp = new CategoryLabelPosition(clp.getCategoryAnchor(),
hSeriesOrientation.isSelected() ? (vLabelOrientation.isSelected() ? TextBlockAnchor.BOTTOM_CENTER : TextBlockAnchor.CENTER_RIGHT) : (vLabelOrientation.isSelected() ? TextBlockAnchor.CENTER_RIGHT : TextBlockAnchor.TOP_CENTER),
hSeriesOrientation.isSelected() ? (vLabelOrientation.isSelected() ? TextAnchor.BOTTOM_CENTER : TextAnchor.CENTER_RIGHT) : (vLabelOrientation.isSelected() ? TextAnchor.CENTER_RIGHT : TextAnchor.TOP_CENTER),
vLabelOrientation.isSelected() ? - Math.PI / 2.0 : 0.0);
if (vSeriesOrientation.isSelected()) plot.getDomainAxis().setCategoryLabelPositions(new CategoryLabelPositions(
plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.TOP),
clp,
plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.LEFT),
plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.RIGHT)
));
//);setBottomCategoryLabelPosition(clp);
else plot.getDomainAxis().setCategoryLabelPositions(new CategoryLabelPositions(
plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.TOP),
plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.BOTTOM),
clp,
plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.RIGHT)
));
//setLeftCategoryLabelPosition(clp);
if (mapper==null) return;
if (dst.getClassifier()==null) {
dst.setClassifier(new CategoryClassifier(mapper));
}
else dst.getClassifier().setMapper(mapper);
}
}
// Monitor changes in source and mapper used for dynamic colors.
/* (non-Javadoc)
* @see simtools.ui.MapperListener#mappingChanged(simtools.ui.GenericMapper)
*/
public void mappingChanged(GenericMapper mapper) {
notifyChange();
}
public void checkMapperChange(DataSource ds, long index) {
CategoryPlot plot = chart.getCategoryPlot();
CategoryItemRenderer renderer = plot.getRenderer();
boolean hasChanged = false;
for (int i=0; i<mapperSources.size(); ++i) {
if (ds.equals(mapperSources.get(i))) {
ColorMapper cm = (ColorMapper)mappers.get(i);
if (cm!=null) {
Paint p1 = hasChanged ? null : renderer.getSeriesPaint(i);
renderer.setSeriesPaint(i,cm.getPaint(ds,index));
// check colors only if useful => when one color changed, don't check the others
if (!hasChanged) {
Paint p2 = renderer.getSeriesPaint(i);
if (!p1.equals(p2)) hasChanged = true;
}
}
}
}
if (hasChanged) notifyChange();
}
/* (non-Javadoc)
* @see simtools.data.DataSourceListener#DataSourceValueChanged(simtools.data.DataSource, long, long)
*/
public void DataSourceValueChanged(DataSource ds, long minIndex, long maxIndex) {
checkMapperChange(ds,maxIndex);
}
/* (non-Javadoc)
* @see simtools.data.DataSourceListener#DataSourceIndexRangeChanged(simtools.data.DataSource, long, long)
*/
public void DataSourceIndexRangeChanged(DataSource ds, long startIndex, long lastIndex) {
checkMapperChange(ds,lastIndex);
}
/* (non-Javadoc)
* @see simtools.data.DataSourceListener#DataSourceInfoChanged(simtools.data.DataSource, simtools.data.DataInfo)
*/
public void DataSourceInfoChanged(DataSource ds, DataInfo newInfo) {
// Don't care if mapper source info changed
}
/* (non-Javadoc)
* @see simtools.data.DataSourceListener#DataSourceValueRangeChanged(simtools.data.DataSource)
*/
public void DataSourceValueRangeChanged(DataSource ds) {
// Don't care if mapper source range changed, it's the mapper business
}
/* (non-Javadoc)
* @see simtools.data.DataSourceListener#DataSourceOrderChanged(simtools.data.DataSource, int)
*/
public void DataSourceOrderChanged(DataSource ds, int newOrder) {
// Don't care if mapper source order changed
}
/* (non-Javadoc)
* @see simtools.data.DataSourceListener#DataSourceReplaced(simtools.data.DataSource, simtools.data.DataSource)
*/
public void DataSourceReplaced(DataSource oldData, DataSource newData) {
int n = mapperSources.size();
for (int i=0; i<n; ++i) {
if(mapperSources.get(i)==oldData){
mapperSources.set(i,newData);
}
}
}
// Take care of serialisation. Special handling for datasources
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
out.defaultWriteObject();
int n = mapperSources.size();
out.writeInt(n);
for (int i=0; i<n; ++i) {
DataSourcePool.global.writeDataSource(out, (DataSource)mapperSources.get(i));
}
}
private void readObject(java.io.ObjectInputStream in) throws java.lang.ClassNotFoundException, java.io.IOException {
in.defaultReadObject();
mapperSources = new Vector();
int n =in.readInt();
for (int i=0; i<n; ++i) {
mapperSources.add(DataSourcePool.global.readDataSource(in));
}
}
/* (non-Javadoc)
* @see simtools.shapes.AbstractShape#cloneShape()
*/
protected AbstractShape cloneShape() {
ChartShape cs = (ChartShape)super.cloneShape();
CategoryPlot plot = chart.getCategoryPlot();
SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
((CategoryPlot)cs.chart.getPlot()).setDataset(dst.cloneSet());
return cs;
}
}