Example usage for org.jfree.chart.axis NumberAxis getRange

List of usage examples for org.jfree.chart.axis NumberAxis getRange

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis getRange.

Prototype

public Range getRange() 

Source Link

Document

Returns the range for the axis.

Usage

From source file:com.hazelcast.monitor.server.InstanceChartGenerator.java

static void increaseRange(NumberAxis axis) {
    Range range = axis.getRange();
    double lower = range.getLowerBound();
    double upper = range.getUpperBound();
    double diff = upper - lower;
    axis.setRange(lower - diff * 0.3, upper + diff * 0.3);
}

From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java

protected static XYPlot createXYPlot(XYDataset dataset, Color[] colors) {
    // break up into two datasets, one for bars one for lines
    //LinkedList lines =new LinkedList();
    //LinkedList bars = new LinkedList();
    XYDataset seriesLines = new XYSeriesCollection();
    XYDataset seriesBars = new XYSeriesCollection();
    ((XYSeriesCollection) seriesBars).setIntervalWidth(0.0);

    if (dataset instanceof XYSeriesCollection) {
        while (0 < dataset.getSeriesCount()) {
            XYSeries s = ((XYSeriesCollection) dataset).getSeries(0);
            ((XYSeriesCollection) dataset).removeSeries(0);
            Comparable key = s.getKey();
            boolean lines = false;
            if (key instanceof String)
                lines = ((String) key).startsWith("-");
            if (lines)
                ((XYSeriesCollection) seriesLines).addSeries(s);
            else//w  ww .j  a  va2 s . co  m
                ((XYSeriesCollection) seriesBars).addSeries(s);
        }
    } else {
        seriesBars = dataset;
    }

    NumberAxis axisDomain = new NumberAxis();
    axisDomain.setAutoRange(true);
    axisDomain.setAutoRangeIncludesZero(false);
    //      axisDomain.setRange(400.0, 1600.0);
    // NOTE: zooming in too far kills the chart, prevent this
    axisDomain.addChangeListener(new AxisChangeListener() {
        public void axisChanged(AxisChangeEvent event) {
            NumberAxis axis = (NumberAxis) event.getSource();
            Range range = axis.getRange();
            if (range.getLength() < 2.0) {
                //_log.info("AxisChangeListener " + range.getLength() + " " + range.toString());
                double middle = range.getLowerBound() + range.getLength() / 2.0;
                axis.setRange(new Range(middle - 1.1, middle + 1.1));
            }
        }
    });

    NumberAxis axisRange = new NumberAxis();
    axisRange.setAutoRange(true);
    axisRange.setAutoRangeIncludesZero(true);

    XYToolTipGenerator toolTipGenerator = new XYToolTipGenerator() {
        public String generateToolTip(XYDataset xyDataset, int s, int i) {
            double X = Math.round(xyDataset.getXValue(s, i) * 1000.0) / 1000.0;
            double Y = Math.round(xyDataset.getYValue(s, i) * 1000.0) / 1000.0;
            return "(" + X + ", " + Y + ")";
        }
    };

    XYBarRenderer barRenderer = new XYBarRenderer();
    //dhmay adding 2009/09/14.  As of jfree 1.0.13, shadows on by default        
    barRenderer.setShadowVisible(false);

    //dhmay adding for jfreechart 1.0.6 upgrade.  If this isn't here, we get a
    //nullPointerException in XYBarRenderer.drawItemLabel
    barRenderer.setBaseItemLabelGenerator(new NullLabelGenerator());

    barRenderer.setSeriesItemLabelsVisible(0, true);
    barRenderer.setBaseToolTipGenerator(toolTipGenerator);

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer();
    lineRenderer.setBaseToolTipGenerator(toolTipGenerator);

    XYPlot xy = new XYPlot(null, axisDomain, axisRange, null);

    int ds = 0;
    if (seriesLines.getSeriesCount() > 0) {
        xy.setDataset(ds, seriesLines);
        xy.setRenderer(ds, lineRenderer);
        xy.mapDatasetToRangeAxis(ds, 0);
        ds++;
        for (int i = 0; i < seriesLines.getSeriesCount(); i++) {
            Comparable key = ((XYSeriesCollection) seriesLines).getSeriesKey(i);
            boolean lines = false;
            if (key instanceof String)
                lines = ((String) key).startsWith("-");
            lineRenderer.setSeriesLinesVisible(i, lines);
            lineRenderer.setSeriesShapesVisible(i, !lines);
        }
    }
    if (seriesBars.getSeriesCount() > 0) {
        xy.setDataset(ds, seriesBars);
        xy.setRenderer(ds, barRenderer);
        xy.mapDatasetToRangeAxis(ds, 0);
        ds++;
    }

    setColors(xy, colors);

    return xy;
}

From source file:net.sf.mzmine.chartbasics.ChartLogics.java

/**
 * Auto range the range axis//w  ww. j ava 2  s  .c  om
 * 
 * @param myChart
 * @param zoom
 * @param autoRangeY if true the range (Y) axis auto bounds will be restored
 */
public static void autoDomainAxis(ChartPanel myChart) {
    XYPlot plot = (XYPlot) myChart.getChart().getPlot();
    NumberAxis axis = (NumberAxis) plot.getDomainAxis();
    // trick. Otherwise auto range will fail sometimes
    axis.setRange(axis.getRange());
    axis.setAutoRangeIncludesZero(false);
    myChart.restoreAutoDomainBounds();
}

From source file:net.sf.mzmine.chartbasics.ChartLogics.java

/**
 * Auto range the range axis/*from  w  w  w  .j  a v a 2 s .  c  o m*/
 * 
 * @param myChart
 * @param zoom
 * @param autoRangeY if true the range (Y) axis auto bounds will be restored
 */
public static void autoRangeAxis(ChartPanel myChart) {
    XYPlot plot = (XYPlot) myChart.getChart().getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    // trick. Otherwise auto range will fail sometimes
    rangeAxis.setRange(rangeAxis.getRange());
    rangeAxis.setAutoRangeIncludesZero(true);
    myChart.restoreAutoRangeBounds();
}

From source file:net.sf.jasperreports.charts.util.ChartUtil.java

public void setAutoTickUnit(NumberAxis numberAxis) {
    if (numberAxis.isAutoTickUnitSelection()) {
        Range range = numberAxis.getRange();
        if (range.getLength() >= AUTO_TICK_UNIT_THRESHOLD) {
            // this is a workaround for a floating point error makes JFreeChart
            // select tick units that are too small when the values are very large
            double autoSize = range.getLength() / AUTO_TICK_UNIT_THRESHOLD;
            TickUnit unit = numberAxis.getStandardTickUnits().getCeilingTickUnit(autoSize);
            numberAxis.setTickUnit((NumberTickUnit) unit, false, false);
        }/*  w w  w.  j ava 2  s . com*/
    }
}

From source file:gov.nih.nci.cma.web.graphing.CMAPrincipalComponentAnalysisPlot.java

/**
 * This chart uses the XYAnnotation as a glyph to represent
 * a single pca data point. Glyph shape is determined by survival time.
 * Survival of more than 10 months is represented by a circle. 10 months or less
 * is represented by a square. Component1 values are represented by X
 * Component2 values are represented by Y
 *///from   ww w .j ava 2 s.  c o m

private void createGlyphsAndAddToPlot(XYPlot plot) { //, double glyphScaleFactor) {
    XYShapeAnnotation glyph;
    Shape glyphShape = null;
    Color glyphColor;
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    Range r = domainAxis.getRange();
    double upperBound = r.getUpperBound();

    double dotSize = 0.7;
    if (upperBound >= 50 && upperBound <= 100)
        dotSize = 1d;
    else if (upperBound > 100 && upperBound <= 150)
        dotSize = 2d;
    else if (upperBound > 150 && upperBound <= 200)
        dotSize = 3d;
    else if (upperBound > 200)
        dotSize = 5d;

    //PrincipalComponentAnalysisDataPoint pcaPoint;
    double x, y;
    //for (Iterator i=dataPoints.iterator(); i.hasNext(); ) {
    for (CMAPCADataPoint pcaPoint : dataPoints) {
        x = pcaPoint.getComponentValue(component1);
        y = pcaPoint.getComponentValue(component2);

        String sampleGroupName = pcaPoint.getSampleGroupName();
        String order = sampleGroupNames.get(sampleGroupName);
        glyphShape = getShapeForDataPoint(order, x, y, dotSize);

        glyphColor = colorMap.get(order);
        if (glyphColor == null)
            glyphColor = Color.black;
        glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor);
        String tooltip = "";

        tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getSampleGroupName();

        glyph.setToolTipText(tooltip);
        plot.addAnnotation(glyph);
    }
}

From source file:api3.transform.PlotWave.java

public void plot(double[][] signal, String name, long samplerate) {

    frame.setTitle(name);/*from w  w  w  .j  a  va  2s .com*/

    XYSeries[] soundWave = new XYSeries[signal.length];
    for (int j = 0; j < signal.length; ++j) {
        soundWave[j] = new XYSeries("sygnal" + j);
        for (int i = 0; i < signal[0].length; ++i) {
            double index = (samplerate == 0) ? i : 1000.0 * (double) i / (double) samplerate;
            soundWave[j].add(index, signal[j][i]);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int j = 0; j < signal.length; ++j) {
        dataset.addSeries(soundWave[j]);
    }

    JFreeChart chart = //            (samplerate ==0 )?
            //            ChartFactory.createXYBarChart(
            //            name,
            //            "prbka",
            //            false,
            //            "warto",
            //            new XYBarDataset(dataset,0.0625),
            //            PlotOrientation.VERTICAL,
            //            true,false,false)
            //            :
            ChartFactory.createXYLineChart(name, "prbka", "warto", dataset,
                    PlotOrientation.VERTICAL, true, false, false);

    XYPlot plot = (XYPlot) chart.getPlot();

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();

    slider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent event) {
            int value = slider.getValue();
            double minimum = domainAxis.getRange().getLowerBound();
            double maximum = domainAxis.getRange().getUpperBound();
            double delta = (0.1f * (domainAxis.getRange().getLength()));
            if (value < lastValue) { // left
                minimum = minimum - delta;
                maximum = maximum - delta;
            } else { // right
                minimum = minimum + delta;
                maximum = maximum + delta;
            }
            DateRange range = new DateRange(minimum, maximum);
            domainAxis.setRange(range);
            lastValue = value;
            if (lastValue == slider.getMinimum() || lastValue == slider.getMaximum()) {
                slider.setValue(SLIDER_DEFAULT_VALUE);
            }
        }

    });

    plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1)));

    ChartPanel chartPanel = new ChartPanel(chart);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createEtchedBorder());
    chartPanel.setBorder(border);

    chartPanel.addMouseWheelListener(addZoomWheel());

    panel.add(chartPanel);
    JPanel dashboard = new JPanel(new BorderLayout());
    dashboard.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
    dashboard.add(slider);
    panel.add(dashboard, BorderLayout.SOUTH);

    frame.getContentPane().add((JPanel) panel, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);
}

From source file:org.ala.spatial.web.services.GDMWSController.java

public static void generateCharts123(String outputdir) {
    try {//from   ww  w . ja  va2 s . com
        IniReader ir = new IniReader(outputdir + "/gdm_params.txt");
        double intercept = ir.getDoubleValue("GDMODEL", "Intercept");

        // 1. read the ObservedVsPredicted.csv file
        System.out.println("Loading csv data");
        CSVReader csv = new CSVReader(new FileReader(outputdir + "ObservedVsPredicted.csv"));
        List<String[]> rawdata = csv.readAll();
        double[][] dataCht1 = new double[2][rawdata.size() - 1];
        double[][] dataCht2 = new double[2][rawdata.size() - 1];

        // for Chart 1: obs count
        int[] obscount = new int[11];
        for (int i = 0; i < obscount.length; i++) {
            obscount[i] = 0;
        }

        System.out.println("populating data");
        for (int i = 1; i < rawdata.size(); i++) {
            String[] row = rawdata.get(i);
            double obs = Double.parseDouble(row[4]);
            dataCht1[0][i - 1] = Double.parseDouble(row[6]);
            dataCht1[1][i - 1] = obs;

            dataCht2[0][i - 1] = Double.parseDouble(row[5]) - intercept;
            dataCht2[1][i - 1] = obs;

            int obc = (int) Math.round(obs * 10);
            obscount[obc]++;
        }

        DefaultXYDataset dataset1 = new DefaultXYDataset();
        dataset1.addSeries("", dataCht1);

        DefaultXYDataset dataset2 = new DefaultXYDataset();
        dataset2.addSeries("", dataCht2);

        DefaultCategoryDataset dataset3 = new DefaultCategoryDataset();
        for (int i = 0; i < obscount.length; i++) {
            String col = "0." + i + "-0." + (i + 1);
            if (i == 10) {
                col = "0.9-1.0";
            }
            dataset3.addValue(obscount[i] + 100, "col", col);
        }
        generateChartByType("Response Histogram", "Observed Dissimilarity Class", "Number of Site Pairs",
                dataset3, outputdir, "bar", "resphist");

        XYDotRenderer renderer = new XYDotRenderer();
        //Shape cross = ShapeUtilities.createDiagonalCross(3, 1);
        //renderer.setSeriesShape(0, cross);
        renderer.setDotWidth(3);
        renderer.setDotHeight(3);
        renderer.setSeriesPaint(0, Color.BLACK);

        JFreeChart jChart1 = ChartFactory.createScatterPlot(
                "Observed versus predicted compositional dissimilarity",
                "Predicted Compositional Dissimilarity", "Observed Compositional Dissimilarity", dataset1,
                PlotOrientation.VERTICAL, false, false, false);
        jChart1.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));

        XYPlot plot = (XYPlot) jChart1.getPlot();
        plot.setBackgroundPaint(Color.WHITE);
        plot.setDomainZeroBaselineVisible(true);
        plot.setRangeZeroBaselineVisible(true);
        plot.setDomainGridlinesVisible(true);
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setDomainGridlineStroke(new BasicStroke(0.5F, 0, 1));
        plot.setRangeGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1));
        plot.setRenderer(0, renderer);

        NumberAxis domain = (NumberAxis) plot.getDomainAxis();
        domain.setAutoRangeIncludesZero(false);
        domain.setAxisLineVisible(false);
        domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));

        NumberAxis range = (NumberAxis) plot.getRangeAxis();
        range.setAutoRangeIncludesZero(false);
        range.setAxisLineVisible(false);
        range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));

        double dMinPred = domain.getRange().getLowerBound();
        double dMaxPred = domain.getRange().getUpperBound();

        double dMinObs = range.getRange().getLowerBound();
        double dMaxObs = range.getRange().getUpperBound();

        System.out.println("1..pred.min.max: " + dMinPred + ", " + dMaxPred);

        int regressionLineSegs = 10;
        double dInc = (dMaxPred - dMinPred) / regressionLineSegs;
        double[][] dataReg1 = new double[2][regressionLineSegs + 1];
        DefaultXYDataset dsReg1 = new DefaultXYDataset();
        int i = 0;
        for (double d = dMinPred; d <= dMaxPred; d += dInc, i++) {
            dataReg1[0][i] = d;
            dataReg1[1][i] = d;
        }
        dsReg1.addSeries("", dataReg1);
        XYSplineRenderer regressionRenderer = new XYSplineRenderer();
        regressionRenderer.setBaseSeriesVisibleInLegend(true);
        regressionRenderer.setSeriesPaint(0, Color.RED);
        regressionRenderer.setSeriesStroke(0, new BasicStroke(1.5f));
        regressionRenderer.setBaseShapesVisible(false);
        plot.setDataset(1, dsReg1);
        plot.setRenderer(1, regressionRenderer);

        System.out.println("Writing image....");
        ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/obspredissim.png"), jChart1, 600, 400);

        // For chart 3
        JFreeChart jChart2 = ChartFactory.createScatterPlot(
                "Observed compositional dissimilarity vs predicted ecological distance",
                "Predicted ecological distance", "Observed Compositional Dissimilarity", dataset2,
                PlotOrientation.VERTICAL, false, false, false);
        jChart2.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));

        plot = (XYPlot) jChart2.getPlot();
        plot.setBackgroundPaint(Color.WHITE);
        plot.setDomainZeroBaselineVisible(true);
        plot.setRangeZeroBaselineVisible(true);
        plot.setDomainGridlinesVisible(true);
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setDomainGridlineStroke(new BasicStroke(0.5F, 0, 1));
        plot.setRangeGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1));
        plot.setRenderer(0, renderer);

        domain = (NumberAxis) plot.getDomainAxis();
        domain.setAutoRangeIncludesZero(false);
        domain.setAxisLineVisible(false);
        domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));

        range = (NumberAxis) plot.getRangeAxis();
        range.setAutoRangeIncludesZero(false);
        range.setAxisLineVisible(false);
        range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));

        dMinPred = domain.getRange().getLowerBound();
        dMaxPred = domain.getRange().getUpperBound();

        dMinObs = range.getRange().getLowerBound();
        dMaxObs = range.getRange().getUpperBound();

        System.out.println("2.pred.min.max: " + dMinPred + ", " + dMaxPred);

        regressionLineSegs = 10;
        dInc = (dMaxPred - dMinPred) / regressionLineSegs;
        dataReg1 = new double[2][regressionLineSegs + 1];
        dsReg1 = new DefaultXYDataset();
        i = 0;
        for (double d = dMinPred; d <= dMaxPred; d += dInc, i++) {
            dataReg1[0][i] = d;
            dataReg1[1][i] = (1.0 - Math.exp(-d));
        }
        dsReg1.addSeries("", dataReg1);
        regressionRenderer.setBaseSeriesVisibleInLegend(true);
        regressionRenderer.setSeriesPaint(0, Color.RED);
        regressionRenderer.setSeriesStroke(0, new BasicStroke(1.5f));
        regressionRenderer.setBaseShapesVisible(false);
        plot.setDataset(1, dsReg1);
        plot.setRenderer(1, regressionRenderer);

        System.out.println("Writing image....");
        ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/dissimdist.png"), jChart2, 600, 400);

    } catch (Exception e) {
        System.out.println("Unable to generate charts 2 and 3:");
        e.printStackTrace(System.out);
    }
}

From source file:MWC.GUI.JFreeChart.StepperXYPlot.java

/**
 * Draws the XY plot on a Java 2D graphics device (such as the screen or a
 * printer), together with a current time marker
 * <P>/*from   w w w .ja  va 2  s.  c om*/
 * XYPlot relies on an XYItemRenderer to draw each item in the plot. This
 * allows the visual representation of the data to be changed easily.
 * <P>
 * The optional info argument collects information about the rendering of the
 * plot (dimensions, tooltip information etc). Just pass in null if you do not
 * need this information.
 * 
 * @param g2
 *          The graphics device.
 * @param plotArea
 *          The area within which the plot (including axis labels) should be
 *          drawn.
 * @param info
 *          Collects chart drawing information (null permitted).
 */
public final void draw(final Graphics2D g2, final Rectangle2D plotArea, final Point2D anchor,
        final PlotState state, final PlotRenderingInfo info) {
    super.draw(g2, plotArea, anchor, state, info);

    // do we want to view the line?
    if (!_showLine)
        return;

    // do we have a time?
    if (_currentTime != null) {
        // find the screen area for the dataset
        final Rectangle2D dataArea = info.getDataArea();

        // determine the time we are plotting the line at
        long theTime = _currentTime.getMicros();

        // hmmm, how do we format the date
        final CanBeRelativeToTimeStepper axis = (CanBeRelativeToTimeStepper) this.getDomainAxis();

        // are we working in relative time mode?
        if (axis.isRelativeTimes()) {
            if (_myStepper != null) {
                // yes, we now need to offset the time
                theTime = theTime - _myStepper.getTimeZero().getMicros();
            }
        }

        // hmm, see if we are wroking with a date or number axis
        double linePosition = 0;
        if (axis instanceof DateAxis) {
            // ok, now scale the time to graph units
            final DateAxis dateAxis = (DateAxis) axis;

            // find the new x value
            linePosition = dateAxis.dateToJava2D(new Date(theTime / 1000), dataArea, this.getDomainAxisEdge());

            if (_resetAxes) {
                dateAxis.setAutoRange(true);
                _resetAxes = false;
            }

            if (isGrowWithTime()) {
                final long endMillis = theTime / 1000;
                long startMillis;

                if (_fixedDuration != null) {
                    startMillis = endMillis - _fixedDuration.getMillis();
                } else {
                    startMillis = (long) dateAxis.getLowerBound();
                }

                final Date startDate = new Date(startMillis);
                final Date endDate = new Date(endMillis);

                dateAxis.setRange(startDate, endDate);
            } else {
            }

        } else {
            if (axis instanceof NumberAxis) {
                final NumberAxis numberAxis = (NumberAxis) axis;
                linePosition = numberAxis.valueToJava2D(theTime, dataArea, this.getDomainAxisEdge());

                if (isGrowWithTime())
                    numberAxis.setRange(numberAxis.getRange().getLowerBound(), theTime);
                else {
                    if (_resetAxes) {
                        numberAxis.setAutoRange(true);
                        _resetAxes = false;
                    }
                }

            }
        }

        // ok, finally draw the line - if we're not showing the growing plot
        if (!isGrowWithTime())
            plotStepperLine(g2, linePosition, dataArea);

    }
}

From source file:net.sf.mzmine.modules.visualization.tic.TICPlot.java

@Override
public void actionPerformed(final ActionEvent event) {

    super.actionPerformed(event);

    final String command = event.getActionCommand();

    if ("SHOW_DATA_POINTS".equals(command)) {

        switchDataPointsVisible();/*from   w w  w . j  a v  a 2 s  .com*/
    }

    if ("SHOW_ANNOTATIONS".equals(command)) {

        switchItemLabelsVisible();
    }

    if ("SETUP_AXES".equals(command)) {

        new AxesSetupDialog(getXYPlot()).setVisible(true);
    }

    if ("ZOOM_IN".equals(command)) {

        getXYPlot().getDomainAxis().resizeRange(1.0 / ZOOM_FACTOR);
    }

    if ("ZOOM_OUT".equals(command)) {

        getXYPlot().getDomainAxis().resizeRange(ZOOM_FACTOR);
    }

    if ("SET_SAME_RANGE".equals(command)) {

        // Get current axes range.
        final NumberAxis xAxis = (NumberAxis) getXYPlot().getDomainAxis();
        final NumberAxis yAxis = (NumberAxis) getXYPlot().getRangeAxis();
        final double xMin = xAxis.getRange().getLowerBound();
        final double xMax = xAxis.getRange().getUpperBound();
        final double xTick = xAxis.getTickUnit().getSize();
        final double yMin = yAxis.getRange().getLowerBound();
        final double yMax = yAxis.getRange().getUpperBound();
        final double yTick = yAxis.getTickUnit().getSize();

        // Set the range of these frames
        for (final Window frame : JFrame.getWindows()) {
            if (frame instanceof TICVisualizerWindow) {

                final TICVisualizerWindow ticFrame = (TICVisualizerWindow) frame;
                ticFrame.setAxesRange(xMin, xMax, xTick, yMin, yMax, yTick);
            }
        }
    }

    if ("SHOW_SPECTRUM".equals(command)) {

        visualizer.actionPerformed(event);
    }

    if ("SHOW_LEGEND".equals(command)) {

        // Toggle legend visibility.
        final LegendTitle legend = getChart().getLegend();
        legend.setVisible(!legend.isVisible());
    }
}