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:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(TITLE, "mm:ss", "Value", dataset, true, true,
            false);/*  ww w  .  j ava 2s . co  m*/
    final XYPlot plot = result.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    ValueAxis domain = plot.getDomainAxis();
    domain.setAutoRange(true);
    ValueAxis range = plot.getRangeAxis();
    range.setRange(0, MINMAX);
    range.setAutoRangeMinimumSize(20);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    for (int i = 0; i < SERIES; i++) {
        renderer.setSeriesStroke(i, new BasicStroke(2.0f));
    }

    return result;
}

From source file:de.berlios.statcvs.xml.chart.AbstractTimeSeriesChart.java

/**
 * @param filename/*from  w  w w  .j av  a  2 s  . c  om*/
 * @param title
 */
public AbstractTimeSeriesChart(ReportSettings settings, String filename, String title, String rangeLabel) {
    super(settings, filename, title);

    tsc = new TimeSeriesCollection();

    setChart(ChartFactory.createTimeSeriesChart(settings.getProjectName(), I18n.tr("Date"), rangeLabel, tsc,
            true, true, false));

    //Paint[] colors = new Paint[1];
    //colors[0] = Color.blue;
    //getChart().getPlot().setSeriesPaint(colors);

    // setup axis
    XYPlot plot = getChart().getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setVerticalTickLabels(true);
    plot.setRenderer(new XYStepRenderer());

    // the 4th color is yellow which has almost no contrast to the white 
    // background color, therefore we use a different color
    plot.getRenderer().setSeriesPaint(0, Color.red);
    plot.getRenderer().setSeriesPaint(1, Color.blue);
    plot.getRenderer().setSeriesPaint(2, Color.green);
    plot.getRenderer().setSeriesPaint(3, Color.magenta);
    plot.getRenderer().setSeriesPaint(4, Color.orange);
    plot.getRenderer().setSeriesPaint(5, Color.cyan);
    plot.getRenderer().setSeriesPaint(6, Color.pink);
}

From source file:org.vrjuggler.perfmon.PerformanceMonitorGUI.java

private JFreeChart createTimeSeriesChart(TimeSeriesCollection dataset) {
    JFreeChart result = ChartFactory.createTimeSeriesChart("Performance Monitoring Statistics", "Time",
            "Sample", dataset, true, true, false);
    XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);//from   ww w  .j  a  va  2s .  c o m
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setAutoRange(true);
    //axis.setRange( 0.0, 10.0 );
    return result;
}

From source file:net.sf.mzmine.chartbasics.chartthemes.ChartThemeParameters.java

public void applyToChart(JFreeChart chart) {
    // apply chart settings
    boolean showTitle = this.getParameter(ChartThemeParameters.showTitle).getValue();
    boolean changeTitle = this.getParameter(ChartThemeParameters.changeTitle).getValue();
    String title = this.getParameter(ChartThemeParameters.changeTitle).getEmbeddedParameter().getValue();
    boolean showLegends = this.getParameter(ChartThemeParameters.showLegends).getValue();

    boolean usexlabel = this.getParameter(ChartThemeParameters.xlabel).getValue();
    boolean useylabel = this.getParameter(ChartThemeParameters.ylabel).getValue();
    String xlabel = this.getParameter(ChartThemeParameters.xlabel).getEmbeddedParameter().getValue();
    String ylabel = this.getParameter(ChartThemeParameters.ylabel).getEmbeddedParameter().getValue();

    Color gbColor = this.getParameter(ChartThemeParameters.color).getValue();
    chart.setBackgroundPaint(gbColor);/*from  ww w. ja va2s.co  m*/
    chart.getPlot().setBackgroundPaint(gbColor);

    if (changeTitle)
        chart.setTitle(title);
    chart.getTitle().setVisible(showTitle);
    ((List<Title>) chart.getSubtitles()).stream().forEach(t -> t.setVisible(showLegends));

    if (chart.getXYPlot() != null) {
        XYPlot p = chart.getXYPlot();
        if (usexlabel)
            p.getDomainAxis().setLabel(xlabel);
        if (useylabel)
            p.getRangeAxis().setLabel(ylabel);

        boolean xgrid = this.getParameter(ChartThemeParameters.xGridPaint).getValue();
        boolean ygrid = this.getParameter(ChartThemeParameters.yGridPaint).getValue();
        Color cxgrid = this.getParameter(ChartThemeParameters.xGridPaint).getEmbeddedParameter().getValue();
        Color cygrid = this.getParameter(ChartThemeParameters.yGridPaint).getEmbeddedParameter().getValue();
        p.setDomainGridlinesVisible(xgrid);
        p.setDomainGridlinePaint(cxgrid);
        p.setRangeGridlinesVisible(ygrid);
        p.setRangeGridlinePaint(cygrid);

        p.getDomainAxis().setVisible(this.getParameter(ChartThemeParameters.showXAxis).getValue());
        p.getRangeAxis().setVisible(this.getParameter(ChartThemeParameters.showYAxis).getValue());
    }
}

From source file:EHRAppointment.ChartPanelDraw.java

private JComboBox createDate() { // to change the vertical and horizontal data
    final JComboBox date = new JComboBox();
    final String[] dateCmds = { "Horizontal Dates", "Vertical Dates" };
    date.setModel(new DefaultComboBoxModel(dateCmds));
    date.addActionListener(new ActionListener() {

        @Override//w w w  . j a  va2 s . co  m
        public void actionPerformed(ActionEvent e) {
            JFreeChart chart = chartPanel.getChart();
            XYPlot plot = (XYPlot) chart.getPlot();
            DateAxis domain = (DateAxis) plot.getDomainAxis();
            if (dateCmds[0].equals(date.getSelectedItem())) {
                domain.setVerticalTickLabels(false);
            } else {
                domain.setVerticalTickLabels(true);
            }
        }
    });
    return date;
}

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

@Override
public JFreeChart createChart() {
    JFreeChart chart = super.createChart();

    // set minimum/maximum bounds on the two axes
    XYPlot xyPlot = chart.getXYPlot();
    double cutoff = getPercentParam("cut", 100, 200, 5000);
    xyPlot.setDomainAxis(truncAxis(xyPlot.getDomainAxis(), cutoff));
    xyPlot.setRangeAxis(truncAxis(xyPlot.getRangeAxis(), cutoff));
    xyPlot.setRenderer(new TruncatedItemRenderer(xyPlot.getRenderer()));

    // add a box illustrating the target range
    if (data.numRows() > 0) {
        double box = getPercentParam("pct", 0, 50, 100);
        xyPlot.addAnnotation(new XYBoxAnnotation(-box, -box, box, box));
        xyPlot.addAnnotation(new XYLineAnnotation(-box, 0, box, 0));
        xyPlot.addAnnotation(new XYLineAnnotation(0, -box, 0, box));
    }/*w  w w. j a  v  a2  s.c  om*/

    return chart;
}

From source file:net.relet.freimap.NodeInfo.java

private void sexupLayout(JFreeChart chart) {
    chart.setAntiAlias(true);/*from w w w .ja v  a 2s .c o m*/
    chart.setBackgroundPaint(VisorFrame.bgcolor);
    chart.setBorderVisible(false);
    TextTitle title = chart.getTitle();
    title.setFont(VisorFrame.smallerfont);
    title.setPaint(VisorFrame.fgcolor);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(VisorFrame.bgcolor);
    plot.setDomainAxis(new DateAxis());
    sexupAxis(plot.getDomainAxis());
    sexupAxis(plot.getRangeAxis());
}

From source file:com.xilinx.kintex7.DMATrendChart.java

public void makeChart() {
    series1 = new TimeSeries(seriesLabels[0]);
    series2 = new TimeSeries(seriesLabels[1]);
    series3 = new TimeSeries(seriesLabels[2]);
    dataset = new TimeSeriesCollection();
    dataset.addSeries(series1);//  w w w  . jav  a 2  s  .c  o  m
    dataset.addSeries(series2);
    dataset.addSeries(series3);
    chart = ChartFactory.createTimeSeriesChart(title, "Time", "Throughput(Gbps)", dataset, true, true, false);
    chart.setBackgroundPaint(bg);
    final XYPlot plot = chart.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(30000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(0.0, 30.0);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // set the renderer's stroke
    Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL);
    renderer.setBaseOutlineStroke(stroke);

    //StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator("{1}", null, null);
    //renderer.setSeriesToolTipGenerator(0, tt);
    // label the points
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMaximumFractionDigits(2);
    XYItemLabelGenerator generator = new StandardXYItemLabelGenerator(
            StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format);
    renderer.setBaseItemLabelGenerator(generator);
    renderer.setBaseItemLabelsVisible(true);

    plot.setRenderer(renderer);

    final XYPlot plot1 = chart.getXYPlot();
    ValueAxis axis1 = plot1.getDomainAxis();
    axis1.setAutoRange(true);
    axis1.setFixedAutoRange(30000.0); // 60 seconds
    axis1 = plot.getRangeAxis();
    axis1.setRange(0.0, 30.0);
    plot1.setRenderer(renderer);

    final XYPlot plot2 = chart.getXYPlot();
    ValueAxis axis2 = plot1.getDomainAxis();
    axis2.setAutoRange(true);
    axis2.setFixedAutoRange(30000.0); // 60 seconds
    axis2 = plot.getRangeAxis();
    axis2.setRange(0.0, 30.0);
    plot2.setRenderer(renderer);
}

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

public void chartMouseClicked(ChartMouseEvent chartmouseevent) {
    int i = chartmouseevent.getTrigger().getX();
    int j = chartmouseevent.getTrigger().getY();
    System.out.println("x = " + i + ", y = " + j);
    Point2D point2d = chartPanel.translateScreenToJava2D(new Point(i, j));
    XYPlot xyplot = (XYPlot) chart.getPlot();
    ChartRenderingInfo chartrenderinginfo = chartPanel.getChartRenderingInfo();
    java.awt.geom.Rectangle2D rectangle2d = chartrenderinginfo.getPlotInfo().getDataArea();
    ValueAxis valueaxis = xyplot.getDomainAxis();
    org.jfree.ui.RectangleEdge rectangleedge = xyplot.getDomainAxisEdge();
    ValueAxis valueaxis1 = xyplot.getRangeAxis();
    org.jfree.ui.RectangleEdge rectangleedge1 = xyplot.getRangeAxisEdge();
    double d = valueaxis.java2DToValue(point2d.getX(), rectangle2d, rectangleedge);
    double d1 = valueaxis1.java2DToValue(point2d.getY(), rectangle2d, rectangleedge1);
    System.out.println("Chart: x = " + d + ", y = " + d1);
}

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

/**
 * A demonstration application showing a bubble chart using matrix series.
 *
 * @param title the frame title.//from w ww.  j a v a2  s . com
 */
public BubblyBubblesDemo(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.blue));

    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.setInverted(true);  // uncoment to reproduce a bug in jFreeChart
    rangeAxis.setLowerBound(-0.5);

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