Example usage for org.jfree.chart.plot XYPlot setRangeAxis

List of usage examples for org.jfree.chart.plot XYPlot setRangeAxis

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setRangeAxis.

Prototype

public void setRangeAxis(int index, ValueAxis axis) 

Source Link

Document

Sets a range axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:com.mugarov.neview.view.GraphPanel.java

public void setValues(ArrayList<DotBag> dotBags, ArrayList<Median> lines, String name) {

    CoordinateSeries ser;/*w w w.j a v  a2s .  co m*/
    for (DotBag db : dotBags) {

        ser = new CoordinateSeries(db.getName());
        for (Dot d : db) {

            ser.add(d.getCoordinates(), d.getName(), d.getScaffoldName());
            //                System.out.println("New dot:"+d.getLogX()+", "+d.getLogY());
        }

        this.dotSeries.add(ser);
    }

    for (Median med : lines) {
        ser = new CoordinateSeries(med.getName());

        ser.add(med.getStart(), med.getName(), null);
        ser.add(med.getEnd(), med.getName(), null);
        //            System.out.println("New line from " + med.getStart().getX()+","+ med.getStart().getY()+" to "+med.getEnd().getX()+","+ med.getEnd().getY());
        this.lineSeries.add(ser);
    }

    this.seriesCollection = new CoordinateSeriesCollection();

    for (CoordinateSeries dotSeries : this.dotSeries) {
        this.seriesCollection.addSeries(dotSeries);
    }
    for (CoordinateSeries line : this.lineSeries) {
        this.seriesCollection.addSeries(line);
    }

    this.chart = ChartFactory.createXYLineChart(name, GraphPanel.XAxis, GraphPanel.YAxis, this.seriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    this.chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();

    ExpAxis x1Axis = new ExpAxis(GraphPanel.XAxis);
    ExpAxis y1Axis = new ExpAxis(GraphPanel.YAxis);

    NumberAxis x2Axis = new NumberAxis("Proportion to max of " + GraphPanel.XAxis);
    NumberAxis y2Axis = new NumberAxis("Proportion to max of " + GraphPanel.YAxis);

    plot.setDomainAxis(0, x1Axis);
    plot.setDomainAxis(1, x2Axis);
    plot.setRangeAxis(0, y1Axis);
    plot.setRangeAxis(1, y2Axis);
    //        plot.setDomainAxis(1, yAxis);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    for (int i = 0; i < this.dotSeries.size(); i++) {
        renderer.setSeriesLinesVisible(i, false);
        renderer.setSeriesPaint(i, this.colorGen.get(i));
    }

    for (int i = this.dotSeries.size(); i < this.lineSeries.size() + this.dotSeries.size(); i++) {
        renderer.setSeriesShapesVisible(i, false);
        //             renderer.setSeriesPaint(i, Color.black);
        renderer.setSeriesPaint(i, this.colorGen.get(i - this.dotSeries.size()));
    }

    renderer.setBaseToolTipGenerator(new ItemGenerator());

    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);

    plot.setDomainGridlinePaint(Color.MAGENTA);
    plot.setRangeGridlinePaint(Color.MAGENTA);

    boolean add = (this.chartPanel == null);
    this.chartPanel = new ChartPanel(chart);

    if (add) {
        this.content.add(this.chartPanel, BorderLayout.CENTER);
        this.scroll.setViewportView(this.chartPanel);
    }

    this.setBackground(Color.green);
    this.chartPanel.setBackground(Color.MAGENTA);
    this.updateUI();
}

From source file:OverlaidXYPlotDemo2.java

/**
 * Creates an overlaid chart.//from  w  w  w  . j a  v  a  2s.  co m
 *
 * @return The chart.
 */
private JFreeChart createOverlaidChart() {

    final DateAxis domainAxis = new DateAxis("Date");
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    final ValueAxis rangeAxis = new NumberAxis("Value");

    // create plot...
    final IntervalXYDataset data1 = createDataset1();
    final XYItemRenderer renderer1 = new XYBarRenderer(0.20);
    renderer1.setToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    final XYPlot plot = new XYPlot(data1, domainAxis, rangeAxis, renderer1);
    final double x = new Day(9, SerialDate.MARCH, 2002).getMiddleMillisecond();
    final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", x, 10000.0);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    plot.addAnnotation(annotation);

    final ValueAxis rangeAxis2 = new NumberAxis("Value 2");
    plot.setRangeAxis(1, rangeAxis2);

    // create subplot 2...
    final XYDataset data2A = createDataset2A();
    final XYItemRenderer renderer2A = new StandardXYItemRenderer();
    renderer2A.setToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    plot.setDataset(1, data2A);
    plot.setRenderer(1, renderer2A);

    final XYDataset data2B = createDataset2B();
    plot.setDataset(2, data2B);
    plot.setRenderer(2, new StandardXYItemRenderer());
    plot.mapDatasetToRangeAxis(2, 1);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setOrientation(PlotOrientation.VERTICAL);

    // return a new chart containing the overlaid plot...
    return new JFreeChart("Overlaid Plot Example", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

}

From source file:com.seagate.kinetic.monitor.view.KineticSpecifiedNodeView.java

private void createStatChart() {
    TimeSeriesCollection putOpsTsc = new TimeSeriesCollection(putOpsTs);
    TimeSeriesCollection putTrgTsc = new TimeSeriesCollection(putTrgTs);
    TimeSeriesCollection getOpsTsc = new TimeSeriesCollection(getOpsTs);
    TimeSeriesCollection getTrgTsc = new TimeSeriesCollection(getTrgTs);
    TimeSeriesCollection deleteOpsTsc = new TimeSeriesCollection(deleteOpsTs);
    TimeSeriesCollection deleteTrgTsc = new TimeSeriesCollection(deleteTrgTs);

    statChart = ChartFactory.createTimeSeriesChart("", "Time", "put kvop/s", putOpsTsc, true, true, false);
    XYPlot xyplot = (XYPlot) statChart.getPlot();
    xyplot.setOrientation(PlotOrientation.VERTICAL);
    xyplot.setDomainPannable(true);/*from ww  w  .  jav a  2s .c o  m*/
    xyplot.setRangePannable(true);

    ValueAxis yAxis = xyplot.getDomainAxis();
    yAxis.setAutoRange(true);
    yAxis.setFixedAutoRange(60000.0);

    NumberAxis numberaxis1 = new NumberAxis("get kvop/s");
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.setDataset(1, getOpsTsc);
    xyplot.mapDatasetToRangeAxis(1, 1);
    StandardXYItemRenderer standardxyitemrenderer1 = new StandardXYItemRenderer();
    xyplot.setRenderer(1, standardxyitemrenderer1);

    NumberAxis numberaxis2 = new NumberAxis("delete kvop/s");
    numberaxis2.setAutoRangeIncludesZero(false);
    xyplot.setRangeAxis(2, numberaxis2);
    xyplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);
    xyplot.setDataset(2, deleteOpsTsc);
    xyplot.mapDatasetToRangeAxis(2, 2);
    StandardXYItemRenderer standardxyitemrenderer2 = new StandardXYItemRenderer();
    xyplot.setRenderer(2, standardxyitemrenderer2);

    NumberAxis numberaxis3 = new NumberAxis("put MB/s");
    xyplot.setRangeAxis(3, numberaxis3);
    xyplot.setDataset(3, putTrgTsc);
    xyplot.mapDatasetToRangeAxis(3, 3);
    StandardXYItemRenderer standardxyitemrenderer3 = new StandardXYItemRenderer();
    xyplot.setRenderer(3, standardxyitemrenderer3);

    NumberAxis numberaxis4 = new NumberAxis("get MB/s");
    numberaxis4.setAutoRangeIncludesZero(false);
    xyplot.setRangeAxis(4, numberaxis4);
    xyplot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_LEFT);
    xyplot.setDataset(4, getTrgTsc);
    xyplot.mapDatasetToRangeAxis(4, 4);
    StandardXYItemRenderer standardxyitemrenderer4 = new StandardXYItemRenderer();
    xyplot.setRenderer(4, standardxyitemrenderer4);

    NumberAxis numberaxis5 = new NumberAxis("delete MB/s");
    xyplot.setRangeAxis(5, numberaxis5);
    xyplot.setDataset(5, deleteTrgTsc);
    xyplot.mapDatasetToRangeAxis(5, 5);
    StandardXYItemRenderer standardxyitemrenderer5 = new StandardXYItemRenderer();
    xyplot.setRenderer(5, standardxyitemrenderer5);

    ChartUtilities.applyCurrentTheme(statChart);
    xyplot.getRenderer().setSeriesPaint(0, Color.black);
    standardxyitemrenderer1.setSeriesPaint(0, Color.red);
    numberaxis1.setLabelPaint(Color.red);
    numberaxis1.setTickLabelPaint(Color.red);
    standardxyitemrenderer2.setSeriesPaint(0, Color.green);
    numberaxis2.setLabelPaint(Color.green);
    numberaxis2.setTickLabelPaint(Color.green);
    standardxyitemrenderer3.setSeriesPaint(0, Color.orange);
    numberaxis3.setLabelPaint(Color.orange);
    numberaxis3.setTickLabelPaint(Color.orange);
    standardxyitemrenderer4.setSeriesPaint(0, Color.blue);
    numberaxis4.setLabelPaint(Color.blue);
    numberaxis4.setTickLabelPaint(Color.blue);
    standardxyitemrenderer5.setSeriesPaint(0, Color.cyan);
    numberaxis5.setLabelPaint(Color.cyan);
    numberaxis5.setTickLabelPaint(Color.cyan);

    final JPanel main = new JPanel(new BorderLayout());
    final JPanel optionsPanel = new JPanel();

    String[] options = { SYSTEM_TOTAL_IOPS_AND_THROUGHPUT_STATISTICS };
    this.orientationComboBox = new JComboBox<String>(options);
    this.orientationComboBox.setSize(600, 50);
    this.orientationComboBox.addActionListener(this);
    optionsPanel.add(this.orientationComboBox);

    chartPanel = new ChartPanel(statChart);
    chartPanel.setMouseWheelEnabled(false);
    chartPanel.setPreferredSize(new Dimension(900, 450));
    chartPanel.setDomainZoomable(true);
    chartPanel.setRangeZoomable(true);

    main.add(optionsPanel, BorderLayout.NORTH);
    main.add(this.chartPanel);
    setContentPane(main);
}

From source file:com.fr3ts0n.ecu.gui.application.ObdDataPlotter.java

/**
 * add a new series to the graph/*from  w  w  w  . j a  va 2s .  c o  m*/
 *
 * @param series The new series to be added
 */
public synchronized void addSeries(TimeSeries series) {

    if (oneRangePerSeries) {
        // get paint for current axis/range/...
        Paint currPaint = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[raIndex
                % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length];

        XYPlot plot = (XYPlot) chart.getPlot();
        // set dataset
        plot.setDataset(raIndex, new TimeSeriesCollection(series));
        // ** set axis
        NumberAxis axis = new NumberAxis();
        axis.setTickLabelFont(legendFont);
        axis.setAxisLinePaint(currPaint);
        axis.setTickLabelPaint(currPaint);
        axis.setTickMarkPaint(currPaint);
        // ** set axis in plot
        plot.setRangeAxis(raIndex, axis);
        plot.setRangeAxisLocation(raIndex,
                raIndex % 2 == 0 ? AxisLocation.TOP_OR_LEFT : AxisLocation.BOTTOM_OR_RIGHT);
        plot.mapDatasetToRangeAxis(raIndex, raIndex);
        // ** create renderer
        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
        renderer.setBaseToolTipGenerator(toolTipGen);
        renderer.setSeriesPaint(0, currPaint);
        // ** set renderer in plot
        plot.setRenderer(raIndex, renderer);

        raIndex++;
    }
    dataset.addSeries(series);
}

From source file:de.suse.swamp.modules.scheduledjobs.Statistics.java

/**
 * Generating the graphs that show the amount of running finished wfs over the time.
 *//*from  ww w  .j a v  a 2 s  .  c  o  m*/
protected void generateWorkflowGraph(String templateName, Date startDate, Date endDate) throws Exception {
    List stats = StatisticStorage.loadStats(templateName, startDate, endDate);
    // only generate if we have stats: 
    if (stats != null && stats.size() > 0) {
        TimeSeriesCollection dataset = new TimeSeriesCollection();
        TimeSeriesCollection avgdataset = new TimeSeriesCollection();
        TimeSeries serie = new TimeSeries("running workflows", Day.class);
        TimeSeries avgserie = new TimeSeries("average age", Day.class);
        for (Iterator datait = stats.iterator(); datait.hasNext();) {
            Dbstatistics statisticItem = (Dbstatistics) datait.next();
            serie.addOrUpdate(new Day(statisticItem.getDate()), statisticItem.getRunningcount());
            avgserie.addOrUpdate(new Day(statisticItem.getDate()), statisticItem.getAvgage() / (3600 * 24));
        }
        dataset.addSeries(serie);
        avgdataset.addSeries(avgserie);

        JFreeChart chart = ChartFactory.createTimeSeriesChart("Running " + templateName + " workflows", "Date",
                "running workflows", dataset, false, false, false);

        // modify chart appearance
        chart.setBackgroundImageAlpha(0.5f);
        XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
        plot.getRangeAxis().setLabelPaint(Color.blue);

        // add the second line: 
        final NumberAxis axis2 = new NumberAxis("Avg. age in days");
        axis2.setLabelPaint(Color.red);
        plot.setRangeAxis(1, axis2);
        plot.setDataset(1, avgdataset);
        plot.mapDatasetToRangeAxis(1, 1);

        final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
        renderer2.setDrawOutlines(false);
        renderer2.setDrawSeriesLineAsPath(true);
        renderer2.setBaseShapesVisible(false);
        plot.setRenderer(1, renderer2);

        File image = new File(statPath + fs + templateName + ".png");
        if (image.exists())
            image.delete();
        try {
            ChartUtilities.saveChartAsPNG(image, chart, 750, 200);
        } catch (Exception e) {
            Logger.ERROR("Error generating graph for " + templateName + ", e: " + e.getMessage());
            e.printStackTrace();
            throw e;
        }
    }
}

From source file:ca.nengo.plot.impl.DefaultPlotter.java

private void doPlot(float[] x, float[][] ideal, float[][] actual, int dim) {
    XYSeriesCollection dataset = new XYSeriesCollection();

    XYSeries idealSeries = new XYSeries("Ideal");
    for (int i = 0; i < x.length; i++) {
        idealSeries.add(x[i], ideal[i][dim]);
    }//from w  w w  .  j av a2 s .  c  om
    dataset.addSeries(idealSeries);

    XYSeries actualSeries = new XYSeries("Actual");
    for (int i = 0; i < x.length; i++) {
        actualSeries.add(x[i], actual[i][dim]);
    }
    dataset.addSeries(actualSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Distortion", "X", "Estimate", dataset,
            PlotOrientation.VERTICAL, true, false, false);

    XYSeries errorSeries = new XYSeries("Error");
    float[][] error = MU.difference(actual, ideal);
    for (int i = 0; i < x.length; i++) {
        //         errorSeries.add(x[i], actual[i][dim] - ideal[i][dim]);
        errorSeries.add(x[i], error[i][dim]);
    }
    XYSeriesCollection errorDataset = new XYSeriesCollection();
    errorDataset.addSeries(errorSeries);
    NumberAxis errorAxis = new NumberAxis("Error");
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeAxis(1, errorAxis);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);
    plot.setDataset(1, errorDataset);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    plot.setRenderer(1, renderer);

    float[] err = MU.transpose(error)[dim];
    float mse = MU.prod(err, err) / (float) err.length;
    showChart(chart, "Distortion Error Plot (MSE=" + mse + ")");
}

From source file:com.jaspersoft.studio.jasper.ChartConverter.java

/**
 * //  w ww  .  jav a2 s.c o  m
 */
private Renderable getRenderer(ReportConverter reportConverter, JRChart chart) {
    JasperReportsConfiguration jContext = (JasperReportsConfiguration) reportConverter
            .getJasperReportsContext();
    String renderType = null;
    Rectangle2D rectangle = null;
    ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(jContext.getClassLoader());
        if (dataset != null && jfreeChart != null)
            dataset.removeChangeListener(jfreeChart.getPlot());

        renderType = chart.getRenderType();// FIXMETHEME try reuse this sequence
        if (renderType == null) {
            renderType = JRPropertiesUtil.getInstance(jContext).getProperty(reportConverter.getReport(),
                    JRChart.PROPERTY_CHART_RENDER_TYPE);
        }

        String themeName = chart.getTheme();
        if (themeName == null) {
            themeName = JRPropertiesUtil.getInstance(jContext).getProperty(reportConverter.getReport(),
                    JRChart.PROPERTY_CHART_THEME);
        }
        ChartTheme theme = ChartUtil.getInstance(jContext).getTheme(themeName);
        if (theme instanceof SimpleChartTheme) {
            SimpleChartTheme sct = (SimpleChartTheme) theme;
            sct.getChartSettings()
                    .setBackgroundImage(getCachedImageProvider(sct.getChartSettings().getBackgroundImage()));
            sct.getPlotSettings()
                    .setBackgroundImage(getCachedImageProvider(sct.getPlotSettings().getBackgroundImage()));
        }
        ChartContext chartContext = null;
        // Object cc = jContext.getMap().get(chart);
        // if (cc != null && cc instanceof ChartContext)
        // chartContext = (ChartContext) cc;
        // else {
        chartContext = new ConvertChartContext(chart, jContext);
        try {
            jfreeChart = theme.createChart(chartContext);
            dataset = chartContext.getDataset();
            if (jfreeChart == null && chart.getChartType() == JRChart.CHART_TYPE_MULTI_AXIS) {
                List<JRChartAxis> axis = ((JRDesignMultiAxisPlot) chart.getPlot()).getAxes();
                Plot mainPlot = null;
                int axisNumber = 0;
                for (JRChartAxis ax : axis) {
                    JRChart chartAxis = ((JRDesignChartAxis) ax).getChart();
                    if (jfreeChart == null) {
                        jfreeChart = getJFreeChart(reportConverter, chartAxis);
                        mainPlot = jfreeChart.getPlot();
                        if (mainPlot instanceof CategoryPlot)
                            ((CategoryPlot) mainPlot).setRangeAxisLocation(0, getChartAxisLocation(ax));
                        else if (mainPlot instanceof XYPlot)
                            ((XYPlot) mainPlot).setRangeAxisLocation(0, getChartAxisLocation(ax));
                    } else {
                        axisNumber++;
                        JFreeChart axisChart = getJFreeChart(reportConverter, chartAxis);
                        if (mainPlot instanceof CategoryPlot) {
                            CategoryPlot mainCatPlot = (CategoryPlot) mainPlot;
                            if (!(axisChart.getPlot() instanceof CategoryPlot))
                                continue;

                            // Get the axis and add it to the multi axis chart plot
                            CategoryPlot axisPlot = (CategoryPlot) axisChart.getPlot();
                            mainCatPlot.setRangeAxis(axisNumber, axisPlot.getRangeAxis());
                            mainCatPlot.setRangeAxisLocation(axisNumber, getChartAxisLocation(ax));

                            // Add the data set and map it to the recently added axis
                            mainCatPlot.setDataset(axisNumber, axisPlot.getDataset());
                            mainCatPlot.mapDatasetToRangeAxis(axisNumber, axisNumber);

                            // Set the renderer to use to draw the dataset.
                            mainCatPlot.setRenderer(axisNumber, axisPlot.getRenderer());

                            // Handle any color series for this chart
                            configureAxisSeriesColors(axisPlot.getRenderer(), chartAxis.getPlot());
                        } else if (mainPlot instanceof XYPlot) {
                            XYPlot mainXyPlot = (XYPlot) mainPlot;
                            if (!(axisChart.getPlot() instanceof XYPlot))
                                continue;

                            // Get the axis and add it to the multi axis chart plot
                            XYPlot axisPlot = (XYPlot) axisChart.getPlot();
                            mainXyPlot.setRangeAxis(axisNumber, axisPlot.getRangeAxis());
                            mainXyPlot.setRangeAxisLocation(axisNumber, getChartAxisLocation(ax));

                            // Add the data set and map it to the recently added axis
                            mainXyPlot.setDataset(axisNumber, axisPlot.getDataset());
                            mainXyPlot.mapDatasetToRangeAxis(axisNumber, axisNumber);

                            // Set the renderer to use to draw the dataset.
                            mainXyPlot.setRenderer(axisNumber, axisPlot.getRenderer());

                            // Handle any color series for this chart
                            configureAxisSeriesColors(axisPlot.getRenderer(), chartAxis.getPlot());
                        }
                    }
                }
            }
        } catch (JRException e) {
            throw new JRRuntimeException(e);
        }

        rectangle = new Rectangle2D.Double(0, 0, chart.getWidth(), chart.getHeight());
    } finally {
        Thread.currentThread().setContextClassLoader(oldLoader);
    }
    return ChartUtil.getInstance(jContext).getChartRenderableFactory(renderType).getRenderable(jContext,
            jfreeChart, null, rectangle);
}

From source file:controletanquesproj1.Grafico.java

/**
 * Creates a chart.//from w  w w  . j  a v a  2  s .c om
 * 
 * @param _datasets
 * @param datasets
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
public JFreeChart createChart() {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title
            "Amostra", // x axis label
            "Amplitude (V)", // y axis label
            getDatasets()[0], // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);
    plot.getRangeAxis(0).setRange(-30, 30);

    final NumberAxis axis2 = new NumberAxis("Altura (cm)");
    axis2.setAutoRange(true);
    axis2.setAutoRangeIncludesZero(false);

    //axis2.setRange(-4.9, 34.9);
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, getDatasets()[1]);
    plot.mapDatasetToRangeAxis(1, 1);

    /*
    getRenderer().setSeriesLinesVisible(0, true);
    getRenderer().setSeriesShapesVisible(0, false);
    getRenderer().setSeriesShapesVisible(1, false);
    getRenderer().setSeriesShapesVisible(2, false);
    getRenderer().setSeriesLinesVisible(3, true);
    getRenderer().setSeriesShapesVisible(3, false);
    */

    renderer[0].setBaseShapesVisible(false);
    renderer[0].setAutoPopulateSeriesPaint(true);

    plot.setRenderer(renderer[0]);

    renderer[1] = new XYLineAndShapeRenderer();
    renderer[1].setBaseLinesVisible(true);
    renderer[1].setBaseShapesVisible(true);

    plot.setRenderer(1, renderer[1]);

    // change the auto tick unit selection to integer units only...
    //final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortCounterPlotWorker.java

@Override
protected Void doInBackground() throws Exception {
    // 1.  counter value (already done, just add following to this)
    // 2.  delta/period
    ////  ww w.  j ava 2 s.c o  m
    //    -- if error counter --
    // 3.  include xmit and rcv traffic deltas? (own scale)
    //
    //
    //    -- if traffic counter --
    // 3.  include rate and utilization values?
    //

    // this is a SwingWorker thread from its pool, give it a recognizable name
    Thread.currentThread().setName("PortCounterPlotWorker");

    logger.info("Worker Building Plot");
    SMT_UpdateService updateService = SMT_UpdateService.getInstance();
    OMS_Collection history = updateService.getCollection();
    OSM_FabricDeltaCollection deltaHistory = history.getOSM_FabricDeltaCollection();

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

    // AXIS 2 - the change, or delta value of the desired counter
    NumberAxis axis2 = new NumberAxis(PortCounterAxisLabel.DELTA.getName());
    axis2.setFixedDimension(10.0);
    axis2.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(1, axis2);

    XYDataset dataset2 = createDeltaDataset(deltaHistory, PortCounter, PortCounterAxisLabel.DELTA.getName());
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    XYItemRenderer renderer2 = new StandardXYItemRenderer();
    plot.setRenderer(1, renderer2);

    // the other two axis are optional, and vary depending on the
    // type of counter
    NumberAxis axis3 = null;
    XYDataset dataset3 = null;
    XYItemRenderer renderer3 = null;
    NumberAxis axis4 = null;
    XYDataset dataset4 = null;
    XYItemRenderer renderer4 = null;

    if (AddExtra) {
        if (isError) {

            // add rcv deltas
            PortCounterName pcr = PortCounterName.rcv_data;
            axis3 = new NumberAxis(PortCounterAxisLabel.RCV_DELTA.getName());
            axis3.setFixedDimension(10.0);
            axis3.setAutoRangeIncludesZero(false);
            plot.setRangeAxis(2, axis3);

            dataset3 = createDeltaDataset(deltaHistory, pcr, pcr.getName());
            plot.setDataset(2, dataset3);
            plot.mapDatasetToRangeAxis(2, 2);
            renderer3 = new StandardXYItemRenderer();
            plot.setRenderer(2, renderer3);

            // add xmit deltas
            pcr = PortCounterName.xmit_data;
            axis4 = new NumberAxis(PortCounterAxisLabel.XMT_DELTA.getName());
            axis4.setFixedDimension(10.0);
            axis4.setAutoRangeIncludesZero(false);
            plot.setRangeAxis(3, axis4);

            dataset4 = createDeltaDataset(deltaHistory, pcr, pcr.getName());
            plot.setDataset(3, dataset4);
            plot.mapDatasetToRangeAxis(3, 3);
            renderer4 = new StandardXYItemRenderer();
            plot.setRenderer(3, renderer4);

            // use a common scale for both xmit and rcv counters
            double minRange = axis3.getLowerBound() < axis4.getLowerBound() ? axis3.getLowerBound()
                    : axis4.getLowerBound();
            double maxRange = axis3.getUpperBound() < axis4.getUpperBound() ? axis4.getUpperBound()
                    : axis3.getUpperBound();
            axis3.setAutoRange(false);
            axis4.setAutoRange(false);
            axis3.setRange(minRange, maxRange);
            axis4.setRange(minRange, maxRange);
        } else {
            // add rate
            PortCounterName pcr = PortCounter;
            axis3 = new NumberAxis(pcr.getName() + " " + PortCounterAxisLabel.RATE.getUnits());
            axis3.setFixedDimension(10.0);
            axis3.setAutoRangeIncludesZero(true);
            plot.setRangeAxis(2, axis3);

            dataset3 = createRateDataset(deltaHistory, pcr, PortCounterAxisLabel.RATE.getName());
            plot.setDataset(2, dataset3);
            plot.mapDatasetToRangeAxis(2, 2);
            renderer3 = new StandardXYItemRenderer();
            plot.setRenderer(2, renderer3);

            // add utilization
            axis4 = new NumberAxis(pcr.getName() + " " + PortCounterAxisLabel.UTILIZATION.getUnits());
            axis4.setFixedDimension(10.0);
            //         axis4.setAutoRangeIncludesZero(true);
            axis4.setRange(0.0, 100.0);
            plot.setRangeAxis(3, axis4);

            dataset4 = createUtilizationDataset(deltaHistory, pcr, PortCounterAxisLabel.UTILIZATION.getName());
            plot.setDataset(3, dataset4);
            plot.mapDatasetToRangeAxis(3, 3);
            renderer4 = new StandardXYItemRenderer();
            plot.setRenderer(3, renderer4);
        }
    }
    ChartUtilities.applyCurrentTheme(Chart);

    Color c1 = Color.black;
    Color c2 = Color.blue;

    Color c3 = Color.green;
    Color c4 = Color.magenta;

    Color ce = Color.red;

    if (isError)
        c2 = ce;

    // change the series and axis colours after the theme has
    // been applied...
    plot.getRenderer().setSeriesPaint(0, c1);

    renderer2.setSeriesPaint(0, c2);
    axis2.setLabelPaint(c2);
    axis2.setTickLabelPaint(c2);

    if (AddExtra) {
        renderer3.setSeriesPaint(0, c3);
        axis3.setLabelPaint(c3);
        axis3.setTickLabelPaint(c3);

        renderer4.setSeriesPaint(0, c4);
        axis4.setLabelPaint(c4);
        axis4.setTickLabelPaint(c4);
    }

    return null;
}

From source file:org.operamasks.faces.render.graph.CompositeChartRenderer.java

private JFreeChart createXYCompositeChart(List<JFreeChart> subcharts, UIChart comp) {
    XYPlot compositePlot = new XYPlot();
    compositePlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    compositePlot.setOrientation(getChartOrientation(comp));

    for (int i = 0; i < subcharts.size(); i++) {
        XYPlot subplot = (XYPlot) subcharts.get(i).getPlot();
        compositePlot.setDataset(i, subplot.getDataset());
        compositePlot.setRenderer(i, subplot.getRenderer());

        if (i == 0) {
            compositePlot.setDomainAxis(0, subplot.getDomainAxis());
            compositePlot.setRangeAxis(0, subplot.getRangeAxis());
        } else {/*from   ww w. jav a 2  s  .  co  m*/
            int yAxisMap = getRangeAxisMap(comp, i);
            ValueAxis yAxis = null;
            if (yAxisMap == -1) {
                yAxisMap = 0; // map to axis zero by default
            } else if (yAxisMap == i) {
                yAxis = subplot.getRangeAxis(); // add subplot axis to composite plot
            }
            compositePlot.setRangeAxis(i, yAxis);
            compositePlot.mapDatasetToRangeAxis(i, yAxisMap);
        }
    }

    return new JFreeChart(null, null, compositePlot, false);
}