Example usage for org.jfree.chart.renderer.xy StandardXYItemRenderer StandardXYItemRenderer

List of usage examples for org.jfree.chart.renderer.xy StandardXYItemRenderer StandardXYItemRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy StandardXYItemRenderer StandardXYItemRenderer.

Prototype

public StandardXYItemRenderer(int type) 

Source Link

Document

Constructs a new renderer.

Usage

From source file:JchartTest.GetChartAction.java

@Override
public String execute() throws Exception {
    ValueAxis xAxis = new NumberAxis("Input Increase");
    ValueAxis yAxis = new NumberAxis("Production");
    XYSeries xySeries = new XYSeries(new Integer(1));
    xySeries.add(0, 200);//from   w w  w  .  jav  a2s.  c  o  m
    xySeries.add(1, 300);
    xySeries.add(2, 500);
    xySeries.add(3, 700);
    xySeries.add(4, 700);
    xySeries.add(5, 900);
    XYSeriesCollection xyDataset = new XYSeriesCollection(xySeries);
    // create XYPlot
    XYPlot xyPlot = new XYPlot(xyDataset, xAxis, yAxis,
            new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES));
    chart = new JFreeChart(xyPlot);
    return SUCCESS;
}

From source file:org.jfree.chart.demo.TimePeriodValuesDemo1.java

public TimePeriodValuesDemo1(String s) {
    super(s);/*from  ww w.j  av  a2 s .c  om*/
    XYDataset xydataset = createDataset1();
    XYBarRenderer xybarrenderer = new XYBarRenderer();
    DateAxis dateaxis = new DateAxis("Date");
    dateaxis.setVerticalTickLabels(true);
    dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.HOUR, 1));
    dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm"));
    dateaxis.setLowerMargin(0.01D);
    dateaxis.setUpperMargin(0.01D);
    NumberAxis numberaxis = new NumberAxis("Value");
    XYPlot xyplot = new XYPlot(xydataset, dateaxis, numberaxis, xybarrenderer);
    XYDataset xydataset1 = createDataset2();
    StandardXYItemRenderer standardxyitemrenderer = new StandardXYItemRenderer(3);
    standardxyitemrenderer.setBaseShapesFilled(true);
    xyplot.setDataset(1, xydataset1);
    xyplot.setRenderer(1, standardxyitemrenderer);
    JFreeChart jfreechart = new JFreeChart("Supply and Demand", xyplot);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    chartpanel.setMouseZoomable(true, false);
    setContentPane(chartpanel);
}

From source file:peakmlviewer.dialog.PCADialog.java

public PCADialog(MainWnd mainwnd, Shell parent, String title) {
    super(parent, SWT.NONE);

    // save the parent pointer
    this.title = title;
    this.parent = parent;

    this.mainwnd = mainwnd;

    // create the window and set its properties
    shell = new Shell(parent, SWT.EMBEDDED | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    shell.setSize(500, 300);/*w  ww  .  jav a  2  s .  c om*/
    shell.setText(title);

    // create the jfreechart
    plot = new XYPlot(collection, new NumberAxis("principal component 1"),
            new NumberAxis("principal component 2"), new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);
    plot.getRenderer().setBaseItemLabelsVisible(true);
    plot.getRenderer().setBaseItemLabelGenerator(new XYItemLabelGenerator() {
        public String generateLabel(XYDataset dataset, int series, int item) {
            return labels[item];
        }
    });

    chart = new JFreeChart("Principle Component Analysis", plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.WHITE);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // add the components
    // --------------------------------------------------------------------------------
    // This uses the SWT-trick for embedding awt-controls in an SWT-Composit.
    try {
        System.setProperty("sun.awt.noerasebackground", "true");
    } catch (NoSuchMethodError error) {
        ;
    }

    java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(shell);

    // create a new ChartPanel, without the popup-menu (5x false)
    frame.add(new ChartPanel(chart, false, false, false, false, false));
    // --------------------------------------------------------------------------------
}

From source file:bzstats.chart.KillRatioHistoryChart.java

protected JFreeChart getChart() {

    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    fillDataset(dataset);//from   w  ww. j a v  a  2 s .  c o  m

    XYPlot plot = new XYPlot();

    NumberAxis xaxis = new NumberAxis("Time");
    xaxis.setTickLabelsVisible(false);
    NumberAxis yaxis = new NumberAxis("Killratio");

    plot.setDomainAxis(xaxis);
    plot.setRangeAxis(yaxis);
    plot.setDataset(dataset);
    plot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES));

    JFreeChart chart = new JFreeChart("Killratio", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.addSubtitle(new TextTitle("kills/deaths"));

    chart.setBackgroundPaint(Color.white);

    return chart;

}

From source file:org.sonar.server.charts.deprecated.SparkLinesChart.java

private void configureRenderer() {
    renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakAnnotationReportPanel.java

protected void initComponents() {
    setLayout(new BorderLayout());

    // create chart
    theDataset = new DefaultXYDataset();
    theChart = org.jfree.chart.ChartFactory.createScatterPlot("Annotation", "Count", "Intensity", theDataset,
            org.jfree.chart.plot.PlotOrientation.VERTICAL, true, false, false);
    thePlot = (XYPlot) theChart.getPlot();
    thePlot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES));

    theChartPanel = new ChartPanel(theChart);
    theChartPanel.setDomainZoomable(true);
    theChartPanel.setRangeZoomable(false);
    //theChartPanel.setPopupMenu(null);
    add(theChartPanel, BorderLayout.CENTER);

    // create toolbar
    theToolBar = createToolBar();//from   w  w  w . j a  va 2  s  . co  m
    add(theToolBar, BorderLayout.SOUTH);
}

From source file:org.apache.phoenix.pherf.result.impl.ImageResultHandler.java

@Override
public synchronized void write(Result result) throws Exception {
    TimeSeriesCollection timeSeriesCollection = new TimeSeriesCollection();
    int rowCount = 0;
    int maxLegendCount = 20;
    int chartDimension = 1100;

    ResultValue<DataModelResult> resultValue = result.getResultValues().get(0);
    DataModelResult dataModelResult = resultValue.getResultValue();

    for (ScenarioResult scenarioResult : dataModelResult.getScenarioResult()) {
        for (QuerySetResult querySetResult : scenarioResult.getQuerySetResult()) {
            for (QueryResult queryResult : querySetResult.getQueryResults()) {
                for (ThreadTime tt : queryResult.getThreadTimes()) {
                    TimeSeries timeSeries = new TimeSeries(
                            queryResult.getStatement() + " :: " + tt.getThreadName());
                    rowCount++;//  w ww  .  jav a2 s.c  o m
                    synchronized (tt.getRunTimesInMs()) {
                        for (RunTime rt : tt.getRunTimesInMs()) {
                            if (rt.getStartTime() != null) {
                                timeSeries.add(new Millisecond(rt.getStartTime()), rt.getElapsedDurationInMs());
                            }
                        }
                    }
                    timeSeriesCollection.addSeries(timeSeries);
                }
            }
        }
    }
    boolean legend = rowCount > maxLegendCount ? false : true;
    JFreeChart chart = ChartFactory.createTimeSeriesChart(dataModelResult.getName(), "Time", "Query Time (ms)",
            timeSeriesCollection, legend, true, false);
    StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
    chart.getXYPlot().setRenderer(renderer);
    chart.getXYPlot().setBackgroundPaint(Color.WHITE);
    chart.getXYPlot().setRangeGridlinePaint(Color.BLACK);
    for (int i = 0; i < rowCount; i++) {
        chart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(3f));
    }
    try {
        ChartUtilities.saveChartAsJPEG(new File(resultFileName), chart, chartDimension, chartDimension);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

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

public XYPlot drawStandardXYPlot(Shape shape, Color color, int minSignal, int maxSignal) {
    // Set up renderer
    StandardXYItemRenderer batteryRenderer = new StandardXYItemRenderer(
            StandardXYItemRenderer.SHAPES_AND_LINES);
    batteryRenderer.setAutoPopulateSeriesShape(false);
    batteryRenderer.setBaseShape(shape);
    batteryRenderer.setSeriesPaint(0, color);

    // Normalize the throughput axis so that it represents max value
    NumberAxis axis = new NumberAxis();
    axis.setVisible(false);//from   www .  j  a v  a 2  s.  c om
    axis.setAutoRange(false);
    axis.setRange(minSignal, maxSignal);

    // Create plot
    XYPlot barPlot = new XYPlot(null, null, axis, batteryRenderer);
    barPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    barPlot.getRangeAxis().setVisible(false);

    return barPlot;
}

From source file:org.jfree.chart.demo.TimePeriodValuesDemo.java

/**
 * A demonstration application showing how to....
 *
 * @param title  the frame title./*from   ww  w  .ja va 2s  .  co  m*/
 */
public TimePeriodValuesDemo(final String title) {

    super(title);

    final XYDataset data1 = createDataset1();
    final XYItemRenderer renderer1 = new XYBarRenderer();

    final DateAxis domainAxis = new DateAxis("Date");
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setTickUnit(new DateTickUnit(DateTickUnit.HOUR, 1));
    domainAxis.setDateFormatOverride(new SimpleDateFormat("hh:mm"));
    domainAxis.setLowerMargin(0.01);
    domainAxis.setUpperMargin(0.01);
    final ValueAxis rangeAxis = new NumberAxis("Value");

    final XYPlot plot = new XYPlot(data1, domainAxis, rangeAxis, renderer1);

    final XYDataset data2 = createDataset2();
    final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(
            StandardXYItemRenderer.SHAPES_AND_LINES);
    renderer2.setShapesFilled(true);

    plot.setDataset(1, data2);
    plot.setRenderer(1, renderer2);

    final JFreeChart chart = new JFreeChart("Supply and Demand", plot);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);

}

From source file:edu.mit.fss.examples.member.gui.PowerSubsystemPanel.java

/**
 * Instantiates a new power subsystem panel for a subsystem.
 *
 * @param subsystem the subsystem/*www  .j a v a 2s.c  o m*/
 */
public PowerSubsystemPanel(SpacePowerSubsystem subsystem) {
    this.subsystem = subsystem;

    logger.trace("Creating and adding energy storage chart panel.");
    storageDataset = new TimeSeriesCollection();
    storageSeries = new TimeSeries("Storage");
    storageDataset.addSeries(storageSeries);
    storageChart = ChartFactory.createTimeSeriesChart(null, "Time", "Stored Energy (W-hr)", storageDataset,
            false, false, false);
    storageChart.setBackgroundPaint(getBackground());
    if (storageChart.getPlot() instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) storageChart.getPlot();
        XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
        renderer.setSeriesShape(0, new Ellipse2D.Double(-2, -2, 4, 4));
        xyPlot.setRenderer(renderer);
        xyPlot.setBackgroundPaint(Color.WHITE);
        xyPlot.setDomainGridlinePaint(Color.GRAY);
        xyPlot.setRangeGridlinePaint(Color.GRAY);
    }
    addTab("Storing", new ChartPanel(storageChart));

    logger.trace("Creating and adding energy transformation chart panel.");
    powerDataset = new TimeSeriesCollection();
    generationSeries = new TimeSeries("Generation");
    powerDataset.addSeries(generationSeries);
    consumptionSeries = new TimeSeries("Consumption");
    powerDataset.addSeries(consumptionSeries);
    powerChart = ChartFactory.createTimeSeriesChart(null, "Time", "Power (W)", powerDataset, true, false,
            false);
    powerChart.setBackgroundPaint(getBackground());
    if (powerChart.getPlot() instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) powerChart.getPlot();
        XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
        renderer.setSeriesShape(0, new Ellipse2D.Double(-2, -2, 4, 4));
        renderer.setSeriesPaint(0, Color.red);
        renderer.setSeriesShape(1, new Ellipse2D.Double(-2, -2, 4, 4));
        renderer.setSeriesPaint(1, Color.green);
        xyPlot.setRenderer(renderer);
        xyPlot.setBackgroundPaint(Color.WHITE);
        xyPlot.setDomainGridlinePaint(Color.GRAY);
        xyPlot.setRangeGridlinePaint(Color.GRAY);
    }
    JPanel chartPanel = new JPanel(new BorderLayout());
    chartPanel.add(new ChartPanel(powerChart), BorderLayout.CENTER);
    chartPanel.add(new JButton(exportAction), BorderLayout.SOUTH);
    addTab("Transforming", chartPanel);
}