Example usage for org.jfree.chart.plot CombinedDomainXYPlot remove

List of usage examples for org.jfree.chart.plot CombinedDomainXYPlot remove

Introduction

In this page you can find the example usage for org.jfree.chart.plot CombinedDomainXYPlot remove.

Prototype

public void remove(XYPlot subplot) 

Source Link

Document

Removes a subplot from the combined chart and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:com.att.aro.ui.view.diagnostictab.GraphPanel.java

public void setChartOptions(List<ChartPlotOptions> optionsSelected) {

    if (optionsSelected == null || optionsSelected.contains(ChartPlotOptions.DEFAULT_VIEW)) {
        optionsSelected = ChartPlotOptions.getDefaultList();
    }//from www.j a v  a2  s.  c  o  m

    // Remove all plots from combined plot
    CombinedDomainXYPlot plot = getPlot();
    for (GraphPanelPlotLabels subplot : getSubplotMap().values()) {
        if (subplot != null && subplot.getPlot() != null) {
            plot.remove(subplot.getPlot());
            subplot.getLabel().setVisible(false);
        }
    }

    // Add selected plots
    for (ChartPlotOptions option : graphHelper.getPlotOrder()) {
        // Keep charts in order of enum
        if (optionsSelected.contains(option)) {
            GraphPanelPlotLabels subplot = getSubplotMap().get(option);
            if (subplot != null && subplot.getPlot() != null) {
                plot.add(subplot.getPlot(), subplot.getWeight());
                subplot.getLabel().setVisible(true);
            }
        }
    }
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            layoutGraphLabels();

        }
    });
}

From source file:com.att.aro.diagnostics.GraphPanel.java

/**
 * Sets the chart plot options to those selected by clicking the Options
 * menu item in the View menu./* w  w w .j av a 2s  .co m*/
 * 
 * @param optionsSelected
 *            A List of ChartPlotOptions to be set on the GraphPanel
 *            chart.
 */
public synchronized void setChartOptions(List<ChartPlotOptions> optionsSelected) {

    if (optionsSelected == null || optionsSelected.contains(ChartPlotOptions.DEFAULT_VIEW)) {
        optionsSelected = ChartPlotOptions.getDefaultList();
    }

    // Remove all plots from combined plot
    CombinedDomainXYPlot plot = getPlot();
    for (GraphPanelPlotLabels subplot : subplotMap.values()) {
        if (subplot != null && subplot.getPlot() != null) {

            plot.remove(subplot.getPlot());
            subplot.getLabel().setVisible(false);
        }
    }

    // Add selected plots
    for (ChartPlotOptions option : GraphPanel.plotOrder) {

        // Keep charts in order of enum
        if (optionsSelected.contains(option)) {
            GraphPanelPlotLabels subplot = subplotMap.get(option);
            if (subplot != null && subplot.getPlot() != null) {
                plot.add(subplot.getPlot(), subplot.getWeight());
                subplot.getLabel().setVisible(true);
            }
        }
    }

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            layoutGraphLabels();
        }
    });
}

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

private void updateMFI(int days, boolean show) {
    if (this.priceVolumeChart == null) {
        this.priceVolumeChart = this.createPriceVolumeChart(this.priceDataset, this.volumeDataset);
    }/*from w ww.  j ava  2 s.c o m*/
    if (this.candlestickChart == null) {
        this.candlestickChart = this.createCandlestickChart(this.priceOHLCDataset);
    }

    final TAEx taEx = TAEx.newInstance(TA.MFI, new Integer(days));

    if (show) {
        if (price_volume_ta_map.containsKey(taEx) == false) {
            final XYDataset dataset = org.yccheok.jstock.charting.TechnicalAnalysis.createMFI(this.chartDatas,
                    getMFIKey(days), days);
            NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_MFI"));
            rangeAxis1.setAutoRangeIncludesZero(false); // override default
            rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars
            DecimalFormat format = new DecimalFormat("0");
            rangeAxis1.setNumberFormatOverride(format);

            final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date"));
            timeAxis.setLowerMargin(0.02); // reduce the default margins
            timeAxis.setUpperMargin(0.02);

            XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null);

            XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
            renderer1.setBaseToolTipGenerator(
                    new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")));
            plot.setRenderer(0, renderer1);
            price_volume_ta_map.put(taEx, plot);
        }

        if (candlestick_ta_map.containsKey(taEx) == false) {
            try {
                /* Not sure why. I cannot make priceVolumeChart and candlestickChart sharing the same
                 * plot. If not, this will inhibit incorrect zooming behavior.
                 */
                candlestick_ta_map.put(taEx, (XYPlot) price_volume_ta_map.get(taEx).clone());
            } catch (CloneNotSupportedException ex) {
                log.error(null, ex);
            }
        }

        if (this.activeTAExs.contains(taEx) == false) {
            // Avoid duplication.
            final XYPlot price_volume_ta = price_volume_ta_map.get(taEx);
            final XYPlot candlestick_ta = candlestick_ta_map.get(taEx);

            final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot();
            final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot();
            if (price_volume_ta != null)
                cplot0.add(price_volume_ta, 1); // weight is 1.
            if (candlestick_ta != null)
                cplot1.add(candlestick_ta, 1); // weight is 1.
            org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.priceVolumeChart);
            org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.candlestickChart);
        }
    } else {
        final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot();
        final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot();
        final XYPlot price_volume_ta = price_volume_ta_map.get(taEx);
        final XYPlot candlestick_ta = candlestick_ta_map.get(taEx);

        if (price_volume_ta != null)
            cplot0.remove(price_volume_ta);
        if (candlestick_ta != null)
            cplot1.remove(candlestick_ta);
    }

    if (show && this.activeTAExs.contains(taEx) == false) {
        this.activeTAExs.add(taEx);
        JStock.instance().getChartJDialogOptions().add(taEx);
    } else if (!show) {
        this.activeTAExs.remove(taEx);
        JStock.instance().getChartJDialogOptions().remove(taEx);
    }
}

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

private void updateCCI(int days, boolean show) {
    if (this.priceVolumeChart == null) {
        this.priceVolumeChart = this.createPriceVolumeChart(this.priceDataset, this.volumeDataset);
    }/*from   w w  w  .j  av a2s.c  om*/
    if (this.candlestickChart == null) {
        this.candlestickChart = this.createCandlestickChart(this.priceOHLCDataset);
    }

    final TAEx taEx = TAEx.newInstance(TA.CCI, new Integer(days));

    if (show) {
        if (price_volume_ta_map.containsKey(taEx) == false) {
            final XYDataset dataset = org.yccheok.jstock.charting.TechnicalAnalysis.createCCI(this.chartDatas,
                    getCCIKey(days), days);
            NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_CCI"));
            rangeAxis1.setAutoRangeIncludesZero(false); // override default
            rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars
            DecimalFormat format = new DecimalFormat("0");
            rangeAxis1.setNumberFormatOverride(format);

            final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date"));
            timeAxis.setLowerMargin(0.02); // reduce the default margins
            timeAxis.setUpperMargin(0.02);

            XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null);

            XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
            renderer1.setBaseToolTipGenerator(
                    new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")));
            plot.setRenderer(0, renderer1);
            org.yccheok.jstock.charting.Utils.setPriceSeriesPaint(renderer1);
            price_volume_ta_map.put(taEx, plot);
        }

        if (candlestick_ta_map.containsKey(taEx) == false) {
            try {
                /* Not sure why. I cannot make priceVolumeChart and candlestickChart sharing the same
                 * plot. If not, this will inhibit incorrect zooming behavior.
                 */
                candlestick_ta_map.put(taEx, (XYPlot) price_volume_ta_map.get(taEx).clone());
            } catch (CloneNotSupportedException ex) {
                log.error(null, ex);
            }
        }

        if (this.activeTAExs.contains(taEx) == false) {
            // Avoid duplication.
            final XYPlot price_volume_ta = price_volume_ta_map.get(taEx);
            final XYPlot candlestick_ta = candlestick_ta_map.get(taEx);

            final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot();
            final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot();
            if (price_volume_ta != null)
                cplot0.add(price_volume_ta, 1); // weight is 1.
            if (candlestick_ta != null)
                cplot1.add(candlestick_ta, 1); // weight is 1.
            org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.priceVolumeChart);
            org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.candlestickChart);
        }
    } else {
        final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot();
        final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot();
        final XYPlot price_volume_ta = price_volume_ta_map.get(taEx);
        final XYPlot candlestick_ta = candlestick_ta_map.get(taEx);

        if (price_volume_ta != null)
            cplot0.remove(price_volume_ta);
        if (candlestick_ta != null)
            cplot1.remove(candlestick_ta);
    }

    if (show && this.activeTAExs.contains(taEx) == false) {
        this.activeTAExs.add(taEx);
        JStock.instance().getChartJDialogOptions().add(taEx);
    } else if (!show) {
        this.activeTAExs.remove(taEx);
        JStock.instance().getChartJDialogOptions().remove(taEx);
    }
}

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

private void updateRSI(int days, boolean show) {
    if (this.priceVolumeChart == null) {
        this.priceVolumeChart = this.createPriceVolumeChart(this.priceDataset, this.volumeDataset);
    }/*  w  w  w .jav a2s  . c  o  m*/
    if (this.candlestickChart == null) {
        this.candlestickChart = this.createCandlestickChart(this.priceOHLCDataset);
    }

    final TAEx taEx = TAEx.newInstance(TA.RSI, new Integer(days));

    if (show) {
        if (price_volume_ta_map.containsKey(taEx) == false) {
            final XYDataset dataset = org.yccheok.jstock.charting.TechnicalAnalysis.createRSI(this.chartDatas,
                    getRSIKey(days), days);
            NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_RSI"));
            rangeAxis1.setAutoRangeIncludesZero(false); // override default
            rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars
            DecimalFormat format = new DecimalFormat("0");
            rangeAxis1.setNumberFormatOverride(format);

            final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date"));
            timeAxis.setLowerMargin(0.02); // reduce the default margins
            timeAxis.setUpperMargin(0.02);

            XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null);

            XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
            renderer1.setBaseToolTipGenerator(
                    new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")));
            plot.setRenderer(0, renderer1);
            price_volume_ta_map.put(taEx, plot);
        }

        if (candlestick_ta_map.containsKey(taEx) == false) {
            try {
                /* Not sure why. I cannot make priceVolumeChart and candlestickChart sharing the same
                 * plot. If not, this will inhibit incorrect zooming behavior.
                 */
                candlestick_ta_map.put(taEx, (XYPlot) price_volume_ta_map.get(taEx).clone());
            } catch (CloneNotSupportedException ex) {
                log.error(null, ex);
            }
        }

        if (this.activeTAExs.contains(taEx) == false) {
            // Avoid duplication.
            final XYPlot price_volume_ta = price_volume_ta_map.get(taEx);
            final XYPlot candlestick_ta = candlestick_ta_map.get(taEx);
            final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot();
            final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot();

            if (price_volume_ta != null)
                cplot0.add(price_volume_ta, 1); // weight is 1.
            if (candlestick_ta != null)
                cplot1.add(candlestick_ta, 1); // weight is 1.
            org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.priceVolumeChart);
            org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.candlestickChart);
        }
    } else {
        final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot();
        final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot();
        final XYPlot price_volume_ta = price_volume_ta_map.get(taEx);
        final XYPlot candlestick_ta = candlestick_ta_map.get(taEx);

        if (price_volume_ta != null)
            cplot0.remove(price_volume_ta);
        if (candlestick_ta != null)
            cplot1.remove(candlestick_ta);
    }

    if (show && this.activeTAExs.contains(taEx) == false) {
        this.activeTAExs.add(taEx);
        JStock.instance().getChartJDialogOptions().add(taEx);
    } else if (!show) {
        this.activeTAExs.remove(taEx);
        JStock.instance().getChartJDialogOptions().remove(taEx);
    }
}

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

private void updateMACD(MACD.Period period, boolean show) {
    if (this.priceVolumeChart == null) {
        this.priceVolumeChart = this.createPriceVolumeChart(this.priceDataset, this.volumeDataset);
    }//from   w w w .  j  a v a2 s  .c om
    if (this.candlestickChart == null) {
        this.candlestickChart = this.createCandlestickChart(this.priceOHLCDataset);
    }

    final TAEx taEx = TAEx.newInstance(TA.MACD, period);
    if (show) {
        if (price_volume_ta_map.containsKey(taEx) == false) {
            final MACD.ChartResult macdChartResult = org.yccheok.jstock.charting.TechnicalAnalysis
                    .createMACD(this.chartDatas, getMACDKey(period), period);

            // MACD!
            NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_MACD"));
            rangeAxis1.setAutoRangeIncludesZero(false); // override default
            rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars
            DecimalFormat format = new DecimalFormat("0.00#");
            rangeAxis1.setNumberFormatOverride(format);

            final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date"));
            timeAxis.setLowerMargin(0.02); // reduce the default margins
            timeAxis.setUpperMargin(0.02);

            XYPlot plot = new XYPlot(macdChartResult.outMACD, timeAxis, rangeAxis1, null);

            XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
            renderer1.setBaseToolTipGenerator(
                    new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")));
            plot.setRenderer(0, renderer1);
            org.yccheok.jstock.charting.Utils.setPriceSeriesPaint(renderer1);

            // MACD SIGNAL!
            plot.setDataset(1, macdChartResult.outMACDSignal);
            XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
            renderer2.setBaseToolTipGenerator(
                    new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")));
            plot.setRenderer(1, renderer2);

            // VOLUME!
            //plot.setRangeAxis(1, rangeAxis1);
            plot.setDataset(2, macdChartResult.outMACDHist);
            //plot.mapDatasetToRangeAxis(1, 1);

            XYBarRenderer renderer3 = new XYBarRenderer(0.20);

            renderer3.setBaseToolTipGenerator(
                    new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00")));
            plot.setRenderer(2, renderer3);

            price_volume_ta_map.put(taEx, plot);
        }

        if (candlestick_ta_map.containsKey(taEx) == false) {
            try {
                /* Not sure why. I cannot make priceVolumeChart and candlestickChart sharing the same
                 * plot. If not, this will inhibit incorrect zooming behavior.
                 */
                candlestick_ta_map.put(taEx, (XYPlot) price_volume_ta_map.get(taEx).clone());
            } catch (CloneNotSupportedException ex) {
                log.error(null, ex);
            }
        }

        if (this.activeTAExs.contains(taEx) == false) {
            // Avoid duplication.
            final XYPlot price_volume_ta = price_volume_ta_map.get(taEx);
            final XYPlot candlestick_ta = candlestick_ta_map.get(taEx);

            final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot();
            final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot();
            if (price_volume_ta != null)
                cplot0.add(price_volume_ta, 1); // weight is 1.
            if (candlestick_ta != null)
                cplot1.add(candlestick_ta, 1); // weight is 1.
            org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.priceVolumeChart);
            org.yccheok.jstock.charting.Utils.applyChartThemeEx(this.candlestickChart);
        }
    } else {
        final CombinedDomainXYPlot cplot0 = (CombinedDomainXYPlot) this.priceVolumeChart.getPlot();
        final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot) this.candlestickChart.getPlot();
        final XYPlot price_volume_ta = price_volume_ta_map.get(taEx);
        final XYPlot candlestick_ta = candlestick_ta_map.get(taEx);

        if (price_volume_ta != null)
            cplot0.remove(price_volume_ta);
        if (candlestick_ta != null)
            cplot1.remove(candlestick_ta);
    }

    if (show && this.activeTAExs.contains(taEx) == false) {
        this.activeTAExs.add(taEx);
        JStock.instance().getChartJDialogOptions().add(taEx);
    } else if (!show) {
        this.activeTAExs.remove(taEx);
        JStock.instance().getChartJDialogOptions().remove(taEx);
    }
}