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

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

Introduction

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

Prototype

public XYItemRenderer getRenderer() 

Source Link

Document

Returns the renderer for the primary dataset.

Usage

From source file:com.intel.stl.ui.configuration.view.LFTHistogramPanel.java

@Override
public void initComponents() {
    dataset = new HistogramDataset();
    JFreeChart chart = ComponentFactory.createHistogramChart(K0427_PORT_NUMBER.getValue(),
            K0390_NUM_LIDS.getValue(), dataset);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);/*from w w  w .  j a v a2s .com*/
    plot.setRangePannable(true);
    final String portLabel = "<html>" + K0427_PORT_NUMBER.getValue() + ": ";
    final String lidCountLabel = "<br>" + K0390_NUM_LIDS.getValue() + ": ";
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int arg1, int arg2) {
            int portNum = (int) dataset.getXValue(arg1, arg2);
            int lidCount = (int) dataset.getYValue(arg1, arg2);
            return portLabel + portNum + lidCountLabel + lidCount + "</html>";
        }
    });
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chartPanel = new ChartPanel(chart);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(PREFERRED_CHART_SIZE);
    propsPanel.add(chartPanel);
}

From source file:ch.unibe.iam.scg.archie.ui.charts.ConsultationMoneyChart.java

/**
 * @see ch.unibe.iam.scg.archie.ui.charts.AbstractChartComposite#
 * initializeChart()//from  w w  w. j ava 2 s .  co m
 */
@Override
protected JFreeChart initializeChart() {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(ConsultationMoneyChart.CHART_TITLE, // title
            "", // x-axis label
            "Amount", // y-axis label
            (XYDataset) this.creator.getDataset(), // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    // Set chart background color to it's parents background
    chart.setBackgroundPaint(new Color(this.parent.getBackground().getRed(),
            this.parent.getBackground().getGreen(), this.parent.getBackground().getBlue()));

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    return chart;
}

From source file:org.simbrain.plot.histogram.HistogramPanel.java

public void reRender() {
    XYPlot plot = (XYPlot) mainChart.getPlot();
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    Iterator<ColoredDataSeries> series = model.getSeriesData().iterator();
    for (int i = 0; i < model.getData().size(); i++) {
        if (i < colorPallet.length) {
            ColoredDataSeries s = series.next();
            Color c = s.color;//  w  ww. j ava2  s.c  o m
            if (c == null) {
                c = assignColor();
                s.color = c;
            }
            renderer.setSeriesPaint(i, c, true);
        }
    }
}

From source file:net.nosleep.superanalyzer.analysis.views.PlayCountView.java

private void createChart() {
    _chart = ChartFactory.createXYBarChart(Misc.getString("PLAY_COUNT"), Misc.getString("PLAY_COUNT"), false,
            Misc.getString("NUMBER_OF_SONGS"), _dataset, PlotOrientation.VERTICAL, false, true, false);

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("PLAY_COUNT_SUBTITLE")));

    // then customise it a little...
    XYPlot plot = (XYPlot) _chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    plot.setForegroundAlpha(0.75f);//from w w w  .java2 s  .  c o  m

    ChartUtilities.applyCurrentTheme(_chart);

    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setShadowVisible(false);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    domainAxis.setLowerMargin(0);
    domainAxis.setUpperMargin(0);
    // domainAxis.setLowerBound(0);
    // domainAxis.setAutoRangeIncludesZero(true);
    // domainAxis.setAutoRangeStickyZero(true);

    Misc.formatChart(plot);
    renderer.setSeriesPaint(0, Theme.getColorSet()[1]);

}

From source file:arduinoserialread.SerialRead.java

private void initGUI() {

    // init the frame
    frame.setTitle("Arduino Serial Read");
    frame.setBounds(100, 100, 600, 500);
    frame.setMinimumSize(new Dimension(600, 500));
    frame.setLocationRelativeTo(null);//from   w  ww  . j  a  va2  s .com
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // init control panel
    JPanel ctrlPanel = new JPanel();
    ctrlPanel.setLayout(new FlowLayout());

    // init the serial connection panel
    serialCOM = new SerialConnectionPanel();
    ctrlPanel.add(serialCOM);
    frame.getContentPane().add(ctrlPanel, BorderLayout.SOUTH);

    // init the connection status
    ConnectionStatus connectionStatus = new ConnectionStatus();
    ctrlPanel.add(connectionStatus);

    // init connect and disconnect button
    connect = new JButton("connect");
    ctrlPanel.add(connect);
    disconnect = new JButton("disconnect");
    ctrlPanel.add(disconnect);

    // init real time chart
    TimeSeries series = new TimeSeries("DATA");
    DateAxis timeAxis = new DateAxis("Time");
    dataset = new TimeSeriesCollection(series);
    NumberAxis rangeAxis = new NumberAxis("Data");
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setAutoRange(true);
    XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis, new StandardXYItemRenderer());
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.getRenderer().setSeriesPaint(0, new Color(0, 142, 192));
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setAutoRange(true);
    domainAxis.setFixedAutoRange(30000.0); // 30 seconds
    // init the JFreeChart
    JFreeChart chart = new JFreeChart("Real-Time Data Chart", plot);
    chart.setBorderPaint(Color.lightGray);
    chart.setBorderVisible(true);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();
    // add real time chart to the frame
    ChartPanel chartPanel = new ChartPanel(chart);
    frame.getContentPane().add(chartPanel, BorderLayout.CENTER);

}

From source file:com.intel.stl.ui.configuration.view.HoQLifeBarChartPanel.java

@Override
public void initComponents() {
    dataset = new XYSeriesCollection();

    JFreeChart chart = ComponentFactory.createXYBarChart(K0342_PORT_VL_TITLE.getValue(),
            K1069_HOQLIFE.getValue(), dataset, (XYItemLabelGenerator) null);

    XYPlot plot = chart.getXYPlot();
    plot.setDomainPannable(true);//from  w ww. java2 s  .co  m
    plot.setRangePannable(true);
    final String vlLabel = "<html>" + K0342_PORT_VL_TITLE.getValue() + ": ";
    final String hoqLabel = "<br>" + K1069_HOQLIFE.getValue() + ": ";

    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarAlignmentFactor(0);
    renderer.setMargin(0.2);

    renderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int arg1, int arg2) {
            int vlNum = (int) dataset.getXValue(arg1, arg2);
            int hoqCount = (int) dataset.getYValue(arg1, arg2);
            return vlLabel + vlNum + hoqLabel + hoqCount + "</html>";
        }
    });
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chartPanel = new ChartPanel(chart);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(PREFERRED_CHART_SIZE);
    propsPanel.add(chartPanel);
}

From source file:org.gwaspi.reports.PlinkReportLoader.java

private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection seriesCol) {//from  w w  w .java 2 s  . co m
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setSeriesPaint(0, Color.blue);

    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", seriesCol,
            PlotOrientation.VERTICAL, true, false, false);

    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    subplot.setDomainGridlineStroke(new BasicStroke(0.0f));
    subplot.setDomainMinorGridlineStroke(new BasicStroke(0.0f));
    subplot.setDomainGridlinePaint(Color.blue);
    subplot.setRangeGridlineStroke(new BasicStroke(0.0f));
    subplot.setRangeMinorGridlineStroke(new BasicStroke(0.0f));
    subplot.setRangeGridlinePaint(Color.blue);

    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setAxisLineVisible(true);
    chrAxis.setTickLabelsVisible(true);
    chrAxis.setTickMarksVisible(true);
    chrAxis.setTickUnit(new NumberTickUnit(10000));
    chrAxis.setAutoRangeIncludesZero(false);

    NumberAxis log10Axis = (NumberAxis) subplot.getRangeAxis();
    log10Axis.setTickMarkInsideLength(2.0f);
    log10Axis.setTickMarkOutsideLength(2.0f);
    log10Axis.setMinorTickCount(2);
    log10Axis.setMinorTickMarksVisible(true);
    log10Axis.setAxisLineVisible(true);
    log10Axis.setAutoRangeIncludesZero(false);

    XYItemRenderer lblRenderer = subplot.getRenderer();
    MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(4.0d, chromosome);

    lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator);
    lblRenderer.setSeriesItemLabelGenerator(1, lblGenerator);
    lblRenderer.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12));
    lblRenderer.setSeriesItemLabelFont(1, new Font("Serif", Font.PLAIN, 12));
    lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0));
    lblRenderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0));
    lblRenderer.setSeriesItemLabelsVisible(0, true);
    lblRenderer.setSeriesItemLabelsVisible(1, true);

    combinedPlot.add(subplot, 1);
}

From source file:com.intel.stl.ui.configuration.view.SC2VLNTMTBarChartPanel.java

@Override
public void initComponents() {
    dataset = new XYSeriesCollection();

    JFreeChart chart = ComponentFactory.createXYBarChart(K1105_SC.getValue(), K1110_VLNT.getValue(), dataset,
            (XYItemLabelGenerator) null);

    XYPlot plot = chart.getXYPlot();
    plot.setDomainPannable(true);//  w w  w. jav a2s .c o m
    plot.setRangePannable(true);
    final String scLabel = "<html>" + K1105_SC.getValue() + ": ";
    final String vlntLabel = "<br>" + K1110_VLNT.getValue() + ": ";

    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarAlignmentFactor(0);
    renderer.setMargin(0.2);

    renderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int arg1, int arg2) {
            int scNum = (int) dataset.getXValue(arg1, arg2);
            int vlntCount = (int) dataset.getYValue(arg1, arg2);
            return scLabel + scNum + vlntLabel + vlntCount + "</html>";
        }
    });
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chartPanel = new ChartPanel(chart);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(PREFERRED_CHART_SIZE);
    propsPanel.add(chartPanel);
}

From source file:in.BBAT.presenter.DualAxisDemo2.java

/**
 * A demonstration application showing how to create a time series chart with dual axes.
 *
 * @param title  the frame title./*  w  w w . ja v a2s.co  m*/
 */
public DualAxisDemo2(final String title) {

    super(title);

    // create a title...
    final String chartTitle = "Memory & CPU usage";
    final XYDataset dataset = createDataset1();

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Time", "Memory usage (kB)",
            dataset, true, true, false);

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

    final XYPlot plot = chart.getXYPlot();
    final NumberAxis axis2 = new NumberAxis("CPU usage (%)");
    axis2.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, createDataset2());
    plot.mapDatasetToRangeAxis(1, 1);
    final XYItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //            rr.setPlotShapes(true);
        rr.setShapesFilled(true);
    }

    final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setSeriesPaint(0, Color.black);
    //        renderer2.setPlotShapes(true);
    renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
    plot.setRenderer(1, renderer2);

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss"));

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:flexflux.analyses.result.TDRFBAResult.java

public void plot() {

    JPanel panel = new JPanel();
    JScrollPane sp = new JScrollPane(panel);
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

    // one chart by entity

    Color[] colors = new Color[] { Color.RED, Color.GREEN, Color.BLUE };
    int index = 0;
    for (String s : entities) {

        XYSeriesCollection dataset = new XYSeriesCollection();

        XYSeries series = new XYSeries(s);

        for (Double time : times) {
            series.add(time, resultMap.get(time).get(s));
        }/*  w  w  w.j a va  2 s.  c  o m*/

        final JFreeChart chart = ChartFactory.createXYLineChart(s, // chart
                // title
                "Time (h)", // domain axis label
                "Value", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                true, // include legend
                true, // tooltips
                false // urls
        );

        chart.setBackgroundPaint(Color.white);

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

        plot.setBackgroundPaint(Color.WHITE);
        plot.setRangeGridlinePaint(Color.GRAY);
        plot.setDomainGridlinePaint(Color.GRAY);

        plot.getRenderer().setSeriesPaint(0, colors[index % colors.length]);

        index++;

        ChartPanel chartPanel = new ChartPanel(chart);

        dataset.addSeries(series);

        panel.add(chartPanel);
        panel.add(new JSeparator());

    }

    Dimension d = panel.getComponent(0).getPreferredSize();
    d.height *= 2;

    sp.getViewport().setPreferredSize(d);

    JFrame frame = new JFrame("Time-dependant FBA results");

    frame.add(sp);
    frame.pack();
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);

}