*/
public boolean doAction(double x, double y, Object o, String action, CompoundEdit undoableEdit) {
if (action.equals("mouseover")) {
if (chartRenderingInfo==null) return false;
XYPlot plot = (XYPlot)chart.getXYPlot();
PlotRenderingInfo info = chartRenderingInfo.getPlotInfo();
Rectangle2D dataArea = info.getDataArea();
if (dataArea.contains(x, y)) {
plot.setRangeCrosshairVisible(true);
plot.setDomainCrosshairVisible(true);
String msg = "";
// set the crosshair value for the horizontal axis...
ValueAxis da = plot.getDomainAxis();
if (da != null) {
double hvalue = da.translateJava2DToValue(x, info.getDataArea(),plot.getDomainAxisEdge());
plot.setDomainCrosshairValue(hvalue,false);
String label = da.getLabel();
if ((label!=null) && (!label.equals(""))) msg += label;
else msg+= resources.getString("X");
msg += "=" + AxisLabelFormatter.labelFormat(hvalue);
}
// set the crosshair value for the vertical axis...
ValueAxis ra = plot.getRangeAxis();
if (ra != null) {
double vvalue = ra.translateJava2DToValue(y, info.getDataArea(),plot.getRangeAxisEdge());
plot.setRangeCrosshairValue(vvalue,false);
if (!msg.equals("")) msg+=" ";
String label = ra.getLabel();
if ((label!=null) && (!label.equals(""))) msg += label;
else msg+= resources.getString("Y");
msg += "=" + AxisLabelFormatter.labelFormat(vvalue);
}
notifyChange(dataArea.getBounds());
if (!msg.equals("")) JSynoptic.setStatus(msg);
} else {
plot.setRangeCrosshairVisible(false);
plot.setDomainCrosshairVisible(false);
}
}
if (action.equals("mouseout")) {
XYPlot plot = (XYPlot)chart.getXYPlot();
plot.setRangeCrosshairVisible(false);
plot.setDomainCrosshairVisible(false);
JSynoptic.setStatus("");
}
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;
}
//for DataSource Collection ----> dirty duplication...
if (action.equals(resources.getString("setXY1Yn"))) {
try {
XYPlot plot = chart.getXYPlot();
SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
dst.setDataSourceCollection((DataSourceCollection)o);
chart.setTitle(dst.getName());
plot.getDomainAxis().setLabel(dst.getXLabel(0));
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSourceCollection"));
}
}
if (action.equals(resources.getString("addY1Yn"))) {
try {
XYPlot plot = chart.getXYPlot();
SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
dst.addDataSourceCollection((DataSourceCollection)o);
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSourceCollection"));
}
}
if (action.equals(resources.getString("setSecXY1Yn"))) {
try {
XYPlot plot = chart.getXYPlot();
SourceXYDataset dst2 = (SourceXYDataset)plot.getSecondaryDataset(0);
//If not any previous Secondary Dataset was found
if (dst2==null) {
//we build a new one
dst2 = new SourceXYDataset();
//and link it
plot.setSecondaryDataset(0,dst2);
}
dst2.setDataSourceCollection((DataSourceCollection)o);
//If we got no secondary domain axis
if (plot.getSecondaryDomainAxis(0)==null) {
//we build a new one
NumberAxis axis = new NumberAxis();
axis.setAutoRange(true);
//and link it
plot.setSecondaryDomainAxis(0,axis);
}
//If we got no secondary range axis
if (plot.getSecondaryRangeAxis(0)==null) {
//We build a new one
NumberAxis axis = new NumberAxis();
axis.setAutoRange(true);
//and link it
plot.setSecondaryRangeAxis(0,axis);
}
//We reset the title
chart.setTitle(chart.getTitle().getText() + " and " + dst2.getName());
//We set Xlabel
plot.getSecondaryDomainAxis(0).setLabel(dst2.getXLabel(0));
//If necessary we set the renderer
if (plot.getSecondaryRenderer(0)==null) {
plot.setSecondaryRenderer(0,new JSynopticStandardXYItemRenderer(2));
}
//We map the secondary dataset to secondary domain axis
plot.mapSecondaryDatasetToDomainAxis(0,new Integer(0));
//We map the secondary dataset to secondary range axis
plot.mapSecondaryDatasetToRangeAxis(0,new Integer(0));
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileSettingXDataSource"));
}
}
if (action.equals(resources.getString("addSecY1Yn"))) {
try {
XYPlot plot = chart.getXYPlot();
SourceXYDataset dst2 = (SourceXYDataset)plot.getSecondaryDataset(0);
dst2.addYSource((DataSource)o);
//If we got no secondary range axis
if (plot.getSecondaryRangeAxis(0)==null) {
//We build a new one
NumberAxis axis = new NumberAxis();
axis.setAutoRange(true);
//and link it
plot.setSecondaryRangeAxis(0,axis);
}
//We map the secondary dataset to secondary range axis
plot.mapSecondaryDatasetToRangeAxis(0,new Integer(0));
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileAddingYDataSource"));
}
}
//for DataSource ----> dirty duplication...
if (action.equals(resources.getString("setX"))) {
try {
XYPlot plot = chart.getXYPlot();
SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
dst.setXSource((DataSource)o);
plot.getDomainAxis().setLabel(dst.getXLabel(0));
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileSettingXDataSource"));
}
}
if (action.equals(resources.getString("addY"))) {
try {
XYPlot plot = chart.getXYPlot();
SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
dst.addYSource((DataSource)o);
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileAddingYDataSource"));
}
}
if (action.equals(resources.getString("setSecX"))) {
try {
XYPlot plot = chart.getXYPlot();
SourceXYDataset dst2 = (SourceXYDataset)plot.getSecondaryDataset(0);
//If not any previous Secondary Dataset was found
if (dst2==null) {
//we build a new one
dst2 = new SourceXYDataset();
//and link it
plot.setSecondaryDataset(0,dst2);
}
dst2.setXSource((DataSource)o);
//If we got no axis
if (plot.getSecondaryDomainAxis(0)==null) {
//we build a new one
NumberAxis axis = new NumberAxis();
axis.setAutoRange(true);
//and link it
plot.setSecondaryDomainAxis(0,axis);
}
//We set the label
plot.getSecondaryDomainAxis(0).setLabel(dst2.getXLabel(0));
//If necessary we set the renderer
if (plot.getSecondaryRenderer(0)==null) {
plot.setSecondaryRenderer(0,new JSynopticStandardXYItemRenderer(2));
}
//We map the secondary dataset to secondary domain axis
plot.mapSecondaryDatasetToDomainAxis(0,new Integer(0));
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileSettingXDataSource"));
}
}
if (action.equals(resources.getString("addSecY"))) {
try {
XYPlot plot = chart.getXYPlot();
SourceXYDataset dst2 = (SourceXYDataset)plot.getSecondaryDataset(0);
dst2.addYSource((DataSource)o);
//If we got no axis
if (plot.getSecondaryRangeAxis(0)==null) {
//We build a new one
NumberAxis axis = new NumberAxis();
axis.setAutoRange(true);
//and link it
plot.setSecondaryRangeAxis(0,axis);
}
//We map the secondary dataset to secondary range axis
plot.mapSecondaryDatasetToRangeAxis(0,new Integer(0));
notifyChange();
} catch (ClassCastException cce) {
JSynoptic.setStatus(resources.getString("ErrorWhileAddingYDataSource"));
}
}