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

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

Introduction

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

Prototype

public ValueAxis getDomainAxis() 

Source Link

Document

Returns the domain axis with index 0.

Usage

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

/**
 * A demonstration application showing a bubble chart using matrix series.
 *
 * @param title the frame title.//from w  w w .  ja va 2s .  c  o m
 */
public BubblyBubblesDemo2(final String title) {
    super(title);

    this.series = createInitialSeries();

    final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.series);

    final JFreeChart chart = ChartFactory.createBubbleChart(TITLE, "X", "Y", dataset, PlotOrientation.VERTICAL,
            true, true, false);

    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.yellow));

    final XYPlot plot = chart.getXYPlot();
    plot.setForegroundAlpha(0.5f);

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setLowerBound(-0.5);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    rangeAxis.setLowerBound(-0.5);

    final ChartPanel chartPanel = new ChartPanel(chart);
    //        chartPanel.setVerticalZoom(true);
    //      chartPanel.setHorizontalZoom(true);
    setContentPane(chartPanel);
}

From source file:net.sourceforge.processdash.ui.web.reports.XYChart.java

@Override
protected Axis getAxis(JFreeChart chart, PlotOrientation dir) {
    try {// w  ww .  ja  v  a  2 s .com
        XYPlot p = chart.getXYPlot();
        if (dir.equals(p.getOrientation()))
            return p.getRangeAxis();
        else
            return p.getDomainAxis();
    } catch (Exception e) {
        return null;
    }
}

From source file:edu.gmu.cs.sim.util.media.chart.XYChartGenerator.java

public void setXAxisRange(double lower, double upper) {
    XYPlot xyplot = (XYPlot) (chart.getPlot());
    xyplot.getDomainAxis().setRange(lower, upper);
}

From source file:eu.stratosphere.addons.visualization.swt.SWTVertexToolTip.java

private ChartComposite createThreadChart(VertexVisualizationData visualizationData, Color backgroundColor) {

    final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]",
            "Thread Utilization [%]", visualizationData.getThreadDataSet(), PlotOrientation.VERTICAL, true,
            true, false);//from w  w w  .  ja va2 s  .c  om

    chart.setBackgroundPaint(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(),
            backgroundColor.getBlue()));

    // Set axis properly
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.getDomainAxis().setAutoRange(true);
    xyPlot.getDomainAxis().setAutoRangeMinimumSize(60);

    // xyPlot.getRangeAxis().setAutoRange(true);
    xyPlot.getRangeAxis().setRange(0, 100);

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

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

/**
 * Callback method for receiving notification of a mouse click on a chart.
 *
 * @param event  information about the event.
 *///w ww  . j a v a2  s. c om
public void chartMouseClicked(ChartMouseEvent event) {
    int x = event.getTrigger().getX();
    int y = event.getTrigger().getY();

    // the following translation takes account of the fact that the chart image may 
    // have been scaled up or down to fit the panel...
    Point2D p = chartPanel.translateScreenToJava2D(new Point(x, y));

    // now convert the Java2D coordinate to axis coordinates...
    XYPlot plot = chartPanel.getChart().getXYPlot();
    Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
    double xx = plot.getDomainAxis().java2DToValue(p.getX(), dataArea, plot.getDomainAxisEdge());
    double yy = plot.getRangeAxis().java2DToValue(p.getY(), dataArea, plot.getRangeAxisEdge());

    // just for fun, lets convert the axis coordinates back to component coordinates...
    double xxx = plot.getDomainAxis().valueToJava2D(xx, dataArea, plot.getDomainAxisEdge());
    double yyy = plot.getRangeAxis().valueToJava2D(yy, dataArea, plot.getRangeAxisEdge());

    Point2D p2 = chartPanel.translateJava2DToScreen(new Point2D.Double(xxx, yyy));
    System.out
            .println("Mouse coordinates are (" + x + ", " + y + "), in data space = (" + xx + ", " + yy + ").");
    System.out.println("--> (" + p2.getX() + ", " + p2.getY() + ")");
}

From source file:org.jgrasstools.gears.utils.chart.Scatter.java

public void setXRange(double min, double max) {
    XYPlot plot = (XYPlot) getChart().getPlot();
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setRange(min, max);/*from  w ww .j a v  a2 s.c  o m*/
}

From source file:edu.gmu.cs.sim.util.media.chart.XYChartGenerator.java

/** Sets the name of the X Axis label. */
public void setXAxisLabel(String val) {
    XYPlot xyplot = (XYPlot) (chart.getPlot());
    xyplot.getDomainAxis().setLabel(val);
    xyplot.axisChanged(new AxisChangeEvent(xyplot.getDomainAxis()));
    xLabel.setValue(val);
}

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

/**
 * A demonstration application showing a scatter plot.
 *
 * @param title  the frame title./*  w w w.  j a  v  a2  s  .c o  m*/
 */
public ScatterPlotDemo4(final String title) {

    super(title);
    final XYDataset data = new SampleXYDataset2();
    final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo", "X", "Y", data,
            PlotOrientation.VERTICAL, true, true, false);
    final XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new XYDotRenderer());
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);

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

}

From source file:grisu.frontend.view.swing.files.preview.fileViewers.JobStatusGridFileViewer.java

private static ChartPanel createChart(String title, String y_axis, XYDataset dataset, boolean createLegend) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            "Date", // x-axis label
            y_axis, // y-axis label
            dataset, // data
            createLegend, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );//  w ww  . ja  v  a 2s . c o  m

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = (XYPlot) chart.getPlot();
    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.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

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

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

    return new ChartPanel(chart);

}

From source file:api3.window.sound.panel.SoundPanel.java

public void plot(PanelData data, JFreeChart chart, JPanel plotPanel) {
    chart = ChartFactory.createXYLineChart(data.name, "prbka", "warto", data.dataset,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    LOG.info("PLOTTING      1");
    domainAxis = (NumberAxis) plot.getDomainAxis();
    plot.addRangeMarker(new ValueMarker(0, Color.BLACK, new BasicStroke(1)));

    ChartPanel chartPanel = new ChartPanel(chart);
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createEtchedBorder());
    chartPanel.setBorder(border);/*from   w w  w  . ja v a  2  s  . c  o m*/
    LOG.info("PLOTTING      2");
    plotPanel.removeAll();
    plotPanel.add(chartPanel);
    plotPanel.revalidate();
    LOG.info("PLOTTING      3");
}