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

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

Introduction

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

Prototype

public void setRangeCrosshairVisible(boolean flag) 

Source Link

Document

Sets the flag indicating whether or not the range crosshair is visible.

Usage

From source file:de.hs.mannheim.modUro.reader.JCellCountDiagram.java

protected JFreeChart createChart(XYDataset dataset, List<String> cellTypes) {
    String title = "Cell count";

    JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title
            "t", // x-axis label
            "n", // y-axis label
            dataset);//  w  w  w. j a v  a  2 s.  c o m

    String fontName = "Palatino";
    xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));

    XYPlot plot = (XYPlot) xyLineChart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLowerMargin(0.0);
    // plot.getRangeAxis().setRange(0.0, 1.01);
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    xyLineChart.getLegend().setFrame(BlockBorder.NONE);
    xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    // set the default stroke for all series
    int i = 0;
    for (String celltype : cellTypes) {
        r.setSeriesPaint(i, CellTypeColor.getColor(celltype));
        i++;
    }
    r.setSeriesPaint(i, Color.BLACK);
    return xyLineChart;
}

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

/**
 * Creates a combined XYPlot chart./*from  w  w w. ja v a2s .c o m*/
 *
 * @return the combined chart.
 */
private JFreeChart createCombinedChart() {

    // create a default chart based on some sample data...
    final TimeSeriesCollection dataset0 = new TimeSeriesCollection();
    final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries();
    dataset0.addSeries(eur);

    final TimeSeriesCollection dataset1 = new TimeSeriesCollection();
    final TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30);
    dataset1.addSeries(eur);
    dataset1.addSeries(mav);

    final TimeSeriesCollection dataset2 = new TimeSeriesCollection();
    dataset2.addSeries(eur);

    JFreeChart chart = null;

    // make a common vertical axis for all the sub-plots
    final NumberAxis valueAxis = new NumberAxis("Value");
    valueAxis.setAutoRangeIncludesZero(false); // override default

    // make a horizontally combined plot
    final CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis);

    // add subplot 1...
    final XYPlot subplot1 = new XYPlot(dataset0, new DateAxis("Date 1"), null, new StandardXYItemRenderer());
    subplot1.setDomainCrosshairVisible(true);
    subplot1.setRangeCrosshairVisible(true);
    parent.add(subplot1, 1);

    // add subplot 2...
    final XYPlot subplot2 = new XYPlot(dataset1, new DateAxis("Date 2"), null, new StandardXYItemRenderer());
    subplot2.setDomainCrosshairVisible(true);
    subplot2.setRangeCrosshairVisible(true);
    parent.add(subplot2, 1);

    // add subplot 3...
    final XYPlot subplot3 = new XYPlot(dataset2, new DateAxis("Date 3"), null, new XYBarRenderer(0.20));
    subplot3.setDomainCrosshairVisible(true);
    subplot3.setRangeCrosshairVisible(true);
    parent.add(subplot3, 1);

    // now make the top level JFreeChart
    chart = new JFreeChart("Demo Chart", JFreeChart.DEFAULT_TITLE_FONT, parent, true);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle("This is a subtitle", new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;

}

From source file:de.iteratec.visualizationmodel.jfreechart.ChartFactory.java

public JFreeChart createXYStepChart(XYDataset dataset) {
    XYToolTipGenerator toolTipGenerator = !showTooltips ? null : new StandardXYToolTipGenerator();
    XYURLGenerator urlGenerator = !showUrls ? null : new StandardXYURLGenerator();
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);

    XYPlot plot = new XYPlot(dataset, (ValueAxis) xAxis, (ValueAxis) yAxis, null);
    plot.setRenderer(renderer);/*w w w .j  a va 2  s.  c om*/
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(5.0f));
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend);
    THEME.apply(chart);
    return chart;
}

From source file:org.schreibubi.JCombinations.logic.visitors.ChartNodesVisitorOverlay.java

private void accumulateVisit(OurTreeNode o) throws Exception {
    this.dutYData = new ArrayList<ArrayList<Double>>();
    this.dutName = new ArrayList<String>();

    for (int i = 0; i < o.getChildCount(); i++)
        ((OurTreeNode) o.getChildAt(i)).accept(this);

    /*/*from   w  ww  .  ja  v a2 s .co  m*/
     * ArrayList< Double > x = s.getXdataDefault().getXPositions(); for ( int j = 0; j < this.dutYData.size(); j++ ) {
     * ArrayList< Double > y = this.dutYData.get( j ); XYSeries xy = new XYSeries( this.dutName.get( j ) ); for ( int i =
     * 0; i < y.size(); i++ ) { xy.add( x.get( i ), y.get( i ) ); } this.xyseries.addSeries( xy ); }
     */
    NumberAxis xAxis = new NumberAxis(" X ");
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(" Y ");
    yAxis.setAutoRangeIncludesZero(false);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRendererExtended(true, true);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xyseries = new XYSeriesCollection();

    XYPlot plot = new XYPlot(xyseries, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    ExtendedJFreeChart chart = new ExtendedJFreeChart("Overlay", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    this.charts.add(chart);

}

From source file:ws.moor.bt.grapher.ChartBuilder.java

public JFreeChart getChart() {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(chartName, timeAxisLabel, valueAxisLabel, timeSeries,
            showLegend && (timeSeries.getSeriesCount() > 1), false, false);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    plot.getRenderer().setSeriesPaint(0, Color.black);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesPaint(1, Color.black);
    plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f));
    plot.getRenderer().setSeriesPaint(2, Color.black);
    plot.getRenderer().setSeriesStroke(2, new BasicStroke(0.1f));

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

    return chart;
}

From source file:ws.moor.bt.gui.charts.RemotePeerCompletion.java

private JFreeChart createChart(HistogramDataset dataset) {

    JFreeChart chart = ChartFactory.createHistogram("Remote Peer Completion", "Completion %", "Peers", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setRangeCrosshairVisible(true);

    plot.getDomainAxis().setAutoRange(false);
    plot.getDomainAxis().setRange(0.0, 100.0);

    return chart;
}

From source file:org.n52.io.img.ChartRenderer.java

private void showCrosshairsOnAxes(XYPlot xyPlot) {
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
}

From source file:org.schreibubi.JCombinations.logic.visitors.ChartNodesVisitor.java

public void visit(Shmoo s) throws Exception {
    if (s.componentSelected(this.treePaths, OurTreeNode.MYSELF | OurTreeNode.PARENTS | OurTreeNode.CHILDS)) {
        NumberAxis xAxis = new NumberAxis(s.getTrim() + " [" + s.getXdataDefault().getUnit() + "]");
        xAxis.setAutoRangeIncludesZero(false);
        NumberAxis yAxis = new NumberAxis(
                s.getMeasure() + " [" + ((Ydata) s.getYdata().get(0)).getUnit() + "]");
        yAxis.setAutoRangeIncludesZero(false);
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRendererExtended(true, true);
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

        this.dutData = new ArrayList<ArrayList<Double>>();
        this.dutName = new ArrayList<String>();
        for (int i = 0; i < s.getChildCount(); i++)
            (s.getChildAt(i)).accept(this);

        XYSeriesCollection xyseries = new XYSeriesCollection();
        ArrayList<Double> x = s.getXdataDefault().getXPositions();
        for (int j = 0; j < this.dutData.size(); j++) {
            ArrayList<Double> y = this.dutData.get(j);
            XYSeries xy = new XYSeries(this.dutName.get(j));
            for (int i = 0; i < y.size(); i++)
                xy.add(x.get(i), y.get(i));
            xyseries.addSeries(xy);/*from  w ww.j  a v a 2 s .  co  m*/
        }

        XYPlot plot = new XYPlot(xyseries, xAxis, yAxis, renderer);
        plot.setOrientation(PlotOrientation.VERTICAL);
        plot.setDomainCrosshairVisible(true);
        plot.setRangeCrosshairVisible(true);
        Marker marker = s.getMarker();
        if (marker != null)
            plot.addRangeMarker(marker, Layer.BACKGROUND);
        ExtendedJFreeChart chart = new ExtendedJFreeChart(s.getDescription(), JFreeChart.DEFAULT_TITLE_FONT,
                plot, false);
        if (marker == null)
            chart.addSubtitle(new TextTitle(s.getSubtitle()));
        else
            chart.addSubtitle(new TextTitle(
                    s.getSubtitle() + " " + s.getValueAt(3) + "/" + s.getValueAt(4) + "/" + s.getValueAt(5)));

        chart.setTreePath(s.getTreePath());
        this.charts.add(chart);
    }

}

From source file:org.bench4Q.console.ui.section.P_WIRTSection.java

/**
 * print out a WIRT picture./*from  w  w  w . j  a v a  2 s. c  o m*/
 * 
 * @return
 */
public JPanel printWIRTPic() {
    wirtCDFPrepare();
    DefaultXYDataset ds = new DefaultXYDataset();
    ds.addSeries("test", result);
    JFreeChart chart = ChartFactory.createXYLineChart("WIRT CDF", "time (ms)", "percent", ds,
            PlotOrientation.VERTICAL, false, false, false);
    final XYPlot plot = chart.getXYPlot();
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairLockedOnData(true);
    plot.setBackgroundPaint(Color.WHITE);

    plot.setRangeCrosshairVisible(true);

    final ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;
}

From source file:chart.JChartSegment.java

/**
 * Creates a sample chart./*  w  w w  . j  av a2s  . com*/
 *
 * @param dataset the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset, List<NSubsequence> subsequence) {
    final JFreeChart chart = ChartFactory.createXYLineChart("Test", "Time", "Value", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.WHITE);
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    MyRender renderer = new MyRender(dataset, subsequence);
    plot.setRenderer(renderer);
    renderer.setSeriesShapesVisible(0, false);
    chart.setBackgroundPaint(Color.white);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeIncludesZero(false);
    return chart;
}