Example usage for org.jfree.chart JFreeChart setRenderingHints

List of usage examples for org.jfree.chart JFreeChart setRenderingHints

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart setRenderingHints.

Prototype

public void setRenderingHints(RenderingHints renderingHints) 

Source Link

Document

Sets the rendering hints for the chart.

Usage

From source file:gui.DendrogramChart.java

ChartPanel getChartPanel(Dendrogram d, boolean log) {
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Similarity", "No. of Groups", null,
            PlotOrientation.VERTICAL, true, true, false);

    setChartData(chart, log);/*from  w  ww.  ja v a 2 s  .c  o  m*/

    RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    chart.setRenderingHints(rh);
    chart.removeLegend();

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(new Color(255, 255, 220));
    plot.setDomainGridlinePaint(new Color(128, 128, 128));
    plot.setRangeGridlinePaint(new Color(128, 128, 128));
    if (log == false) {
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setLowerBound(0);
        rangeAxis.setNumberFormatOverride(new DecimalFormat("0"));
        rangeAxis.setLabelFont(Prefs.labelFont);
    } else {
        // LogarithmicAxis logXAxis = new LogarithmicAxis("Similarity");
        // logXAxis.setAllowNegativesFlag(true);
        LogarithmicAxis logYAxis = new LogarithmicAxis("No. Of Groups");
        logYAxis.setAllowNegativesFlag(false);

        // plot.setDomainAxis(logXAxis);
        plot.setRangeAxis(logYAxis);
    }

    ChartPanel chartPanel = new ChartPanel(chart);
    // chartPanel.setPopupMenu(null);
    return chartPanel;
}

From source file:gui.QTLResultsPanel.java

private JPanel getChart(Trait trait) {
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Position (cM)", "LOD Score", null,
            PlotOrientation.VERTICAL, true, true, false);

    setChartData(chart, trait);//from  w  w w . j ava2s.c o  m

    RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    chart.setRenderingHints(rh);
    chart.removeLegend();

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(new Color(255, 255, 220));
    plot.setDomainGridlinePaint(new Color(128, 128, 128));
    plot.setRangeGridlinePaint(new Color(128, 128, 128));

    ValueAxis axis = plot.getRangeAxis();
    if (trait.maxLOD <= 3) {
        axis.setUpperBound(3);
    }

    PermResult result = trait.getPermResult();
    if (result != null) {
        float[] dashPattern = { 5, 5 };
        BasicStroke s1 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10, dashPattern, 0);

        ValueMarker m1 = new ValueMarker(result.getSig90(), new Color(0, 0, 60), s1, null, null, 1.0f);
        ValueMarker m2 = new ValueMarker(result.getSig95(), new Color(0, 0, 60), s1, null, null, 1.0f);

        plot.addRangeMarker(m1);
        plot.addRangeMarker(m2);

        if (result.getSig95() > trait.maxLOD && result.getSig95() >= 3) {
            axis.setUpperBound(result.getSig95() * (1.05));
        }
    }

    chartPanel = new ChartPanel(chart);
    chartPanel.setPopupMenu(null);
    return chartPanel;
}

From source file:jboost.visualization.HistogramFrame.java

private JFreeChart createRocChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("ROC", // chart title
            "False positive rate", // x axis label
            "True positive rate", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include
            // legend
            true, // tooltips
            false // urls
    );// w  w  w  .jav  a  2s  . c o  m

    chart.setAntiAlias(false);
    RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
    chart.setRenderingHints(hints);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    lower_tprMarker = new ValueMarker(0.5);
    lower_tprMarker.setPaint(Color.blue);
    lower_fprMarker = new ValueMarker(0.5);
    lower_fprMarker.setPaint(Color.blue);
    plot.addRangeMarker(lower_tprMarker);
    plot.addDomainMarker(lower_fprMarker);

    upper_tprMarker = new ValueMarker(0.5);
    upper_tprMarker.setPaint(Color.red);
    upper_fprMarker = new ValueMarker(0.5);
    upper_fprMarker.setPaint(Color.red);
    plot.addRangeMarker(upper_tprMarker);
    plot.addDomainMarker(upper_fprMarker);

    return chart;

}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.JFreeChartPlotEngine.java

/**
 * Updates the chart panel to show the provided {@link JFreeChart}. If the chart is
 * <code>null</code> an empty Plot will be shown. If an overlay has been defined and the chart
 * is a {@link XYPlot} the overlay is also drawn.
 *///  w  w  w.  jav  a2s. c o  m
private synchronized void updateChartPanel(final JFreeChart chart) {
    Runnable updateChartPanelRunnable = new Runnable() {

        @Override
        public void run() {
            if (chart != chartPanel.getChart()) {
                if (chart == null) {
                    chartPanel.setChart(new JFreeChart(new CategoryPlot()));

                    fireChartChanged(new JFreeChart(new CategoryPlot()));
                } else {
                    RenderingHints renderingHints = chart.getRenderingHints();

                    // enable antialiasing
                    renderingHints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON));

                    // disable normalization (normalization tries to draw the center of strokes
                    // at whole pixels, which causes e.g.
                    // scaled shapes to appear more like potatoes than like circles)
                    renderingHints.add(new RenderingHints(RenderingHints.KEY_STROKE_CONTROL,
                            RenderingHints.VALUE_STROKE_PURE));
                    chart.setRenderingHints(renderingHints);

                    chartPanel.setChart(chart);
                    fireChartChanged(chart);
                }
            }
            if (chart != null) {
                chartPanel.removeOverlay(crosshairOverlay);
                crosshairOverlay = new MultiAxesCrosshairOverlay();

                if (chart.getPlot() instanceof XYPlot) {
                    // add overlays for range axes
                    int axisIdx = 0;
                    for (RangeAxisConfig rangeAxisConfig : plotInstance.getCurrentPlotConfigurationClone()
                            .getRangeAxisConfigs()) {
                        for (AxisParallelLineConfiguration line : rangeAxisConfig.getCrossHairLines()
                                .getLines()) {
                            Crosshair crosshair = new Crosshair(line.getValue(), line.getFormat().getColor(),
                                    line.getFormat().getStroke());
                            crosshairOverlay.addRangeCrosshair(axisIdx, crosshair);
                        }
                        ++axisIdx;
                    }

                    // add overlays for domain axis
                    for (AxisParallelLineConfiguration line : plotInstance.getCurrentPlotConfigurationClone()
                            .getDomainConfigManager().getCrosshairLines().getLines()) {
                        Crosshair crosshair = new Crosshair(line.getValue(), line.getFormat().getColor(),
                                line.getFormat().getStroke());
                        crosshairOverlay.addDomainCrosshair(crosshair);
                    }
                    chartPanel.addOverlay(crosshairOverlay);
                }
            }
        }
    };

    if (SwingUtilities.isEventDispatchThread()) {
        updateChartPanelRunnable.run();
    } else {
        SwingUtilities.invokeLater(updateChartPanelRunnable);
    }

}