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.common.view.ComponentFactory.java

public static JFreeChart createPlainHistoryChart(IntervalXYDataset dataset,
        XYItemLabelGenerator labelGenerator) {
    if (dataset == null) {
        throw new IllegalArgumentException("No dataset.");
    }//from  w  ww. j a v  a2 s  .c  o  m

    JFreeChart jfreechart = ChartFactory.createXYBarChart(null, null, true, null, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(null);
    xyplot.setOutlinePaint(null);
    XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    if (labelGenerator != null) {
        renderer.setBaseItemLabelGenerator(labelGenerator);
    }
    renderer.setBaseItemLabelFont(UIConstants.H4_FONT);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    // xyplot.getDomainAxis().setVisible(false);
    xyplot.getDomainAxis().setAxisLineVisible(true);
    xyplot.getDomainAxis().setTickLabelsVisible(false);
    NumberAxis axis = (NumberAxis) xyplot.getRangeAxis();
    axis.setRangeType(RangeType.POSITIVE);
    axis.setVisible(false);
    return jfreechart;
}

From source file:com.ivli.roim.controls.VOILUTPanel.java

public VOILUTPanel(LUTControl aP) {

    iCurveName = java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("VOILUTPANEL.VOI_LUT");

    iLUT = LUTControl.create(aP);//from   w w  w. j a  v  a2 s.  c om

    aP.addWindowChangeListener(this);

    initComponents();

    XYPlot plot = new XYPlot();

    plot.setDataset(0, makeLUTCurve());
    plot.setRenderer(0, new XYSplineRenderer());

    ((XYSplineRenderer) plot.getRenderer()).setShapesVisible(false);
    plot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_VOI_CURVE")));

    XYSeriesCollection col2 = new XYSeriesCollection();
    col2.addSeries(makeHistogram());

    plot.setDataset(1, col2);
    plot.setRenderer(1, new XYBarRenderer());
    plot.setRangeAxis(1, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_SPACE")));
    plot.mapDatasetToRangeAxis(1, 1);

    plot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
            .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_HISTOGRAM")));
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);
    // change the rendering order so the primary dataset appears "behind" the 
    // other datasets...
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);

    JFreeChart jfc = new JFreeChart(plot);

    jfc.setBorderVisible(true);
    jfc.removeLegend();
    iPanel = new ChartPanel(jfc);
    iPanel.setSize(jPanel1.getPreferredSize());
    jPanel1.add(iPanel);//, java.awt.BorderLayout.CENTER);              
    iLUT.setSize(jPanel2.getPreferredSize());
    jPanel2.add(iLUT);
    iLabelMin.setText(String.format("%.0f", iLUT.getView().getMin()));
    iLabelMax.setText(String.format("%.0f", iLUT.getView().getMax()));

    validate();
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.XYBarChartExpression.java

protected void configureChart(final JFreeChart chart) {
    super.configureChart(chart);

    final XYPlot xypl = chart.getXYPlot();
    final XYItemRenderer renderer = xypl.getRenderer();
    final XYBarRenderer br = (XYBarRenderer) renderer;
    br.setDrawBarOutline(isChartSectionOutline());
    if (margin != null) {
        br.setMargin(margin.doubleValue());
    }/* w  w  w  .ja  va 2 s . co  m*/

    br.setShadowVisible(shadowVisible);
    br.setShadowXOffset(shadowXOffset);
    br.setShadowYOffset(shadowYOffset);

    if ((isStacked()) && renderPercentages && (br instanceof StackedXYBarRenderer)) {
        final StackedXYBarRenderer sbr = (StackedXYBarRenderer) br;
        sbr.setRenderAsPercentages(true);

        final ValueAxis rangeAxis = xypl.getRangeAxis();
        final int level = getRuntime().getProcessingContext().getCompatibilityLevel();
        if (ClassicEngineBoot.isEnforceCompatibilityFor(level, 3, 8)) {
            if (getRangeMinimum() != 0) {
                rangeAxis.setLowerBound(getRangeMinimum());
            }
            if (getRangeMaximum() != 1) {
                rangeAxis.setUpperBound(getRangeMaximum());
            }
            if (getRangeMinimum() == 0 && getRangeMaximum() == 0) {
                rangeAxis.setLowerBound(0);
                rangeAxis.setUpperBound(1);
                rangeAxis.setAutoRange(true);
            }
        } else {
            rangeAxis.setLowerBound(getRangeMinimum());
            rangeAxis.setUpperBound(getRangeMaximum());
            rangeAxis.setAutoRange(isRangeAxisAutoRange());
        }
    }

}

From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo5.java

protected JFreeChart createChart(IntervalXYDataset dataset) {
    domainLabel = "Row_Number";
    rangeLabel = "Frequency";

    JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset,
            PlotOrientation.VERTICAL, false, //!legendPanelOn,
            true, false);//  w w w.  j a  va  2  s .  c  o m

    // then customise it a little...
    // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do"));
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new ClusteredXYBarRenderer());
    XYItemRenderer renderer = plot.getRenderer();

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    return chart;
}

From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.TimeSeriesPlot.java

@Override
protected void applyRendering(XYPlot plot) {
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(StringUtility.getDateFormat());

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(false);
    renderer.setSeriesPaint(0, DATA_COLOR);

    if (m_markerTimestamp > 0) {
        final Marker target = new ValueMarker(m_markerTimestamp);
        target.setPaint(Color.RED);
        target.setLabel("Short Term");
        if ((m_markerPosition * 2) > getDatasetSize()) {
            //Move the label to the left of the marker
            target.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
            target.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        } else {/*from ww w . j a v a  2s.c  om*/
            target.setLabelAnchor(RectangleAnchor.TOP_LEFT);
            target.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        }
        plot.addDomainMarker(target);
    }
}

From source file:org.webcat.grader.graphs.BoxAndWhiskerChart.java

@Override
protected JFreeChart generateChart(WCChartTheme chartTheme) {
    setChartHeight(36);// w w  w .  j a  va 2 s .c o m

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, yAxisLabel(), boxAndWhiskerXYDataset(),
            false);
    chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
    chart.setPadding(new RectangleInsets(0, 6, 0, 6));

    XYPlot plot = chart.getXYPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setOutlineVisible(false);
    plot.setBackgroundPaint(new Color(0, 0, 0, 0));
    XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer();
    renderer.setAutoPopulateSeriesOutlinePaint(true);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(-0.5, assignmentOffering.assignment().submissionProfile().availablePoints() + 0.5);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    Font oldFont = rangeAxis.getTickLabelFont();
    rangeAxis.setTickLabelFont(oldFont.deriveFont(oldFont.getSize2D() * 0.8f));

    return chart;
}

From source file:carfuzzy.Operations.java

public JFreeChart setYAxisForImplication(double imp, XYSeries series, XYSeriesCollection collection,
        Output out) {//from  w  ww  .  j ava 2s .c o  m
    JFreeChart chart;
    if (out == Output.stop) {
        series.updateByIndex(0, imp);
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
    } else if (out == Output.speedUp) {
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
        series.updateByIndex(3, imp);
    } else {
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
    }
    collection.addSeries(series);
    String x_axis = "Implication";

    chart = XYGraph.drawChart(collection, x_axis, "Membership");
    XYPlot plot = chart.getXYPlot();
    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setRange(0, 10);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesStroke(0, new BasicStroke(3.5f));
    return chart;
}

From source file:net.sf.smbt.ui.btc.views.AbstractBlockchainView.java

public void addCharts(Composite folder) {
    chart = ChartFactory.createXYStepChart(getChartTitle(), getXAxisLabel(), getYAxisLabel(), null,
            PlotOrientation.VERTICAL, true, // legend
            true, // tooltips
            false // urls
    );// w  ww  . ja va2s  .com

    // then customise it a little...

    final XYPlot plot = chart.getXYPlot();

    chart.getTitle().setPaint(Color.LIGHT_GRAY);

    chart.setBackgroundPaint(new java.awt.Color(66, 66, 66));
    plot.setBackgroundPaint(new java.awt.Color(66, 66, 66));
    plot.getRenderer().setSeriesVisibleInLegend(false);

    plot.getRangeAxis().setTickLabelPaint(Color.LIGHT_GRAY);
    plot.getRangeAxis().setLabelPaint(Color.LIGHT_GRAY);

    plot.getDomainAxis().setTickLabelPaint(Color.LIGHT_GRAY);
    plot.getDomainAxis().setLabelPaint(Color.LIGHT_GRAY);

    plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f));

    // and present it in a frame...

    new ChartComposite(folder, SWT.NONE, chart, true);
}

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 {// w ww.  j a  v  a  2s  . c o 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);
}

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

private Chromatogram1DHeatmapViewerPanel createPanel(ADataset2D<IChromatogram1D, IScan> ds) {
    XYPlot p = createPlot(ds);
    final PaintScale ps = ((XYBlockRenderer) p.getRenderer()).getPaintScale();
    p.setDomainGridlinesVisible(false);/*w w w .  j  a v a2  s  .c om*/
    p.setRangeGridlinesVisible(false);
    JFreeChart jfc = new JFreeChart(p);
    final ChartPanel cp = new ChartPanel(jfc, true);
    cp.setZoomFillPaint(new Color(192, 192, 192, 96));
    cp.setZoomOutlinePaint(new Color(220, 220, 220, 192));
    cp.setFillZoomRectangle(false);
    cp.getChart().getLegend().setVisible(true);
    Chromatogram1DHeatmapViewerPanel panel = new Chromatogram1DHeatmapViewerPanel(content, getLookup(), ds);
    if (panel.getBackgroundColor() == null) {
        panel.setBackgroundColor((Color) ps.getPaint(ps.getLowerBound()));
    }
    cp.addKeyListener(panel);
    cp.setFocusable(true);
    cp.setDisplayToolTips(true);
    cp.setDismissDelay(3000);
    cp.setInitialDelay(0);
    cp.setReshowDelay(0);
    cp.setVisible(true);
    cp.setRefreshBuffer(true);
    cp.setMouseWheelEnabled(true);
    //FIXME fix peak overlay
    //      if (project != null) {
    //         for (Peak1DContainer peaks : project.getPeaks(chromatogram)) {
    //            Peak1DHeatmapOverlay overlay = new Peak1DHeatmapOverlay(chromatogram, peaks.getName(), peaks.getDisplayName(), peaks.getShortDescription(), true, peaks);
    //            cp.addOverlay(overlay);
    //            content.add(overlay);
    //         }
    //      }
    panel.setChartPanel(cp);
    if (ps != null) {
        panel.setPaintScale(ps);
    }
    panel.setPlot(p);
    return panel;
}