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

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

Introduction

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

Prototype

public XYPlot() 

Source Link

Document

Creates a new XYPlot instance with no dataset, no axes and no renderer.

Usage

From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsQuantilesChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    xAxis.setRange(0.0, 102.0);//from  ww  w . j  a va  2s  . c  o  m
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    yAxis.setRange(-0.05, 0.3);
    //      xAxis.setVisible(false);
    //      xAxis.setFixedAutoRange(1.0);
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    renderer2.setSeriesItemLabelsVisible(0, true);
    //      renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, this.dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(2.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    chart.removeLegend();
    return chart;
}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

public ChartCreator(Plotable plotable) {
    super(new JFreeChart(new XYPlot()));
    zoomListeners = new ArrayList<>();
    getPopupMenu().remove(10);//  ww w .j a v a 2  s  . c om
    getPopupMenu().remove(9);
    getPopupMenu().remove(8);
    getPopupMenu().remove(7);
    getPopupMenu().remove(6);
    getPopupMenu().remove(3);
    getPopupMenu().add(new DataAndModelChartSaveAsItem(), 3);
    plotables = new LinkedHashMap<>();
    shortLegend = new LinkedHashMap<>();
    longLegend = new LinkedHashMap<>();
    colors = new LinkedHashMap<>();
    shapes = new LinkedHashMap<>();
    colorLists = new LinkedHashMap<>();
    shapeLists = new LinkedHashMap<>();

    plotables.put("", plotable);
    shortLegend.put("", "");
    longLegend.put("", "");
}

From source file:playground.dgrether.analysis.charts.DgTravelTimeCalculatorChart.java

@Override
public JFreeChart createChart() {
    XYSeriesCollection dataset = this.createDataSet();
    XYPlot plot = new XYPlot();
    DgAxisBuilder axisBuilder = new DgDefaultAxisBuilder();
    ValueAxis xAxis = axisBuilder.createValueAxis("Simulation Time");
    //    xAxis.setRange(this.controllerConfig.getFirstIteration(), this.controllerConfig.getLastIteration() + 2);
    ValueAxis yAxis = axisBuilder.createValueAxis("Travel Time");
    //    yAxis.setRange(-0.05, 0.3);
    //    xAxis.setVisible(false);
    //    xAxis.setFixedAutoRange(1.0);
    plot.setDomainAxis(xAxis);/*from   w w w .  j a  v a 2 s.co  m*/
    plot.setRangeAxis(yAxis);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, false);
    renderer2.setSeriesItemLabelsVisible(0, true);
    //    renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator);
    plot.setDataset(0, dataset);
    renderer2.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer2.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a"));
    renderer2.setSeriesStroke(1, new BasicStroke(1.0f));
    renderer2.setSeriesOutlineStroke(1, new BasicStroke(1.0f));
    renderer2.setSeriesPaint(1, colorScheme.getColor(2, "a"));
    renderer2.setSeriesStroke(2, new BasicStroke(1.0f));
    renderer2.setSeriesOutlineStroke(2, new BasicStroke(1.0f));
    renderer2.setSeriesPaint(2, colorScheme.getColor(3, "a"));
    renderer2.setSeriesStroke(3, new BasicStroke(1.0f));
    renderer2.setSeriesOutlineStroke(3, new BasicStroke(1.0f));
    renderer2.setSeriesPaint(3, colorScheme.getColor(4, "a"));

    plot.setRenderer(0, renderer2);

    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    //    chart.removeLegend();
    return chart;
}

From source file:org.altusmetrum.altosuilib_2.AltosUIGraph.java

public AltosUIGraph(AltosUIEnable enable) {

    this.enable = enable;
    this.graphers = new ArrayList<AltosUIGrapher>();
    this.series_index = 0;
    this.axis_index = 0;

    xAxis = new NumberAxis("Time (s)");

    xAxis.setAutoRangeIncludesZero(true);

    plot = new XYPlot();
    plot.setDomainAxis(xAxis);/*from   ww  w  .j a  v a 2  s .c om*/
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDomainPannable(true);
    plot.setRangePannable(true);

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

    ChartUtilities.applyCurrentTheme(chart);

    plot.setDomainGridlinePaint(gridline_color);
    plot.setRangeGridlinePaint(gridline_color);
    plot.setBackgroundPaint(background_color);
    plot.setBackgroundAlpha((float) 1);

    chart.setBackgroundPaint(background_color);
    chart.setBorderPaint(border_color);
    panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new java.awt.Dimension(800, 500));

    AltosPreferences.register_units_listener(this);
}

From source file:com.spotify.heroic.http.render.RenderUtils.java

private static JFreeChart buildChart(final String title, final XYDataset lineAndShape, final XYDataset interval,
        final XYItemRenderer lineAndShapeRenderer, final XYItemRenderer intervalRenderer) {
    final ValueAxis timeAxis = new DateAxis();
    timeAxis.setLowerMargin(0.02);//from w w  w.j  ava2 s.c  o  m
    timeAxis.setUpperMargin(0.02);

    final NumberAxis valueAxis = new NumberAxis();
    valueAxis.setAutoRangeIncludesZero(false);

    final XYPlot plot = new XYPlot();

    plot.setDomainAxis(0, timeAxis);
    plot.setRangeAxis(0, valueAxis);

    plot.setDataset(0, lineAndShape);
    plot.setRenderer(0, lineAndShapeRenderer);

    plot.setDomainAxis(1, timeAxis);
    plot.setRangeAxis(1, valueAxis);

    plot.setDataset(1, interval);
    plot.setRenderer(1, intervalRenderer);

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
}

From source file:jgnash.ui.report.compiled.SecurityHighLowChart.java

JPanel createPanel() {

    combo = new SecurityComboBox();

    // create an empty chart for panel construction
    chartPanel = new ChartPanel(new JFreeChart(new XYPlot()));

    FormLayout layout = new FormLayout("p, 4dlu:g", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);

    builder.append(combo);//  w  ww  . jav  a2 s  . co m
    builder.nextLine();
    builder.appendRelatedComponentsGapRow();
    builder.nextLine();
    builder.appendRow(RowSpec.decode("fill:p:g"));
    builder.append(chartPanel, 2);

    combo.addActionListener(e -> updateChart());

    return builder.getPanel();
}

From source file:ch.algotrader.client.chart.ChartTab.java

public ChartTab(ChartPlugin chartPlugin) {

    super(new JFreeChart(new XYPlot()), true, true, true, true, true);
    this.chartPlugin = chartPlugin;

    initPopupMenu();/*from w  ww  . j  av a2  s  .  co m*/
}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

public ChartCreator(Map<String, Plotable> plotables, Map<String, String> shortLegend,
        Map<String, String> longLegend) {
    super(new JFreeChart(new XYPlot()));
    zoomListeners = new ArrayList<>();
    getPopupMenu().remove(10);/*from   ww  w. j  ava  2s  .  c  o  m*/
    getPopupMenu().remove(9);
    getPopupMenu().remove(8);
    getPopupMenu().remove(7);
    getPopupMenu().remove(6);
    getPopupMenu().remove(3);
    getPopupMenu().add(new DataAndModelChartSaveAsItem(), 3);
    this.plotables = plotables;
    this.shortLegend = shortLegend;
    this.longLegend = longLegend;
    colors = new LinkedHashMap<>();
    shapes = new LinkedHashMap<>();
    colorLists = new LinkedHashMap<>();
    shapeLists = new LinkedHashMap<>();
}

From source file:com.bdb.weather.display.RainPlot.java

private void createChartElements() {
    String unitString = Depth.getDefaultUnit().toString();
    rateDomain = String.format(RAIN_RATE_DOMAIN_PREFIX, unitString);
    rainPlot = new XYPlot();
    rainPlot.setRangeAxis(RainRangeAxis.create());
    rainRatePlot = new XYPlot();
    rainRatePlot.setRangeAxis(RainRangeAxis.create());

    plot = new CombinedDomainXYPlot();
    plot.setDomainAxis(new DateAxis("Time"));

    plot.add(rainRatePlot);//from  w ww. j  a v a 2 s.  c  o m
    plot.add(rainPlot);

    chart = new JFreeChart(plot);
    chart.getLegend().setPosition(RectangleEdge.RIGHT);

    chartViewer = new ChartViewer(chart);
    chartViewer.setMaxHeight(10000);
    chartViewer.setMaxWidth(10000);
    chartViewer.setMinHeight(200);
    chartViewer.setMinWidth(400);

    rainDataset = new TimeSeriesCollection();
    rainSeries = new TimeSeries(RAIN_DOMAIN);
    rainDataset.addSeries(rainSeries);
    rainPlot.setDataset(rainDataset);

    rainRateDataset = new TimeSeriesCollection();
    rainRateSeries = new TimeSeries(rateDomain);
    rainRateDataset.addSeries(rainRateSeries);
    rainRatePlot.setDataset(rainRateDataset);

    XYToolTipGenerator ttg = new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            DateFormat.getTimeInstance(), Depth.getDefaultFormatter());

    XYBarRenderer renderer = new XYBarRenderer();
    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setBasePaint(Color.BLUE);
    renderer.setSeriesPaint(0, Color.BLUE);
    renderer.setBaseToolTipGenerator(ttg);
    plot.setRenderer(renderer);

    XYItemRenderer rateRenderer = new XYLineAndShapeRenderer(true, false);
    rateRenderer.setBasePaint(Color.RED);
    rateRenderer.setSeriesPaint(0, Color.RED);
    rateRenderer.setBaseToolTipGenerator(ttg);
    rainRatePlot.setRenderer(rateRenderer);
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.panel.Chromatogram1DViewPanel.java

/**
 * Creates new form Chromatogram1DViewPanel
 *///from  w ww .ja v  a2s.co m
public Chromatogram1DViewPanel(InstanceContent topComponentInstanceContent, Lookup tcLookup,
        ADataset1D<IChromatogram1D, IScan> ds) {
    initComponents();
    this.content = topComponentInstanceContent;
    this.lookup = tcLookup;
    chart = new JFreeChart(new XYPlot());
    ContextAwareChartPanel chartPanel = new ContextAwareChartPanel(chart, true, true, true, true, true);
    Cursor crosshairCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
    chartPanel.setCursor(crosshairCursor);
    chartPanel.setInitialDelay(100);
    chartPanel.setDismissDelay(30000);
    chartPanel.setReshowDelay(0);
    chartPanel.setFocusable(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPopupMenuActionProvider(new ActionProvider());
    addKeyListener(this);
    this.chartPanel = chartPanel;
    add(chartPanel, BorderLayout.CENTER);
    content.add(chartPanel);
}