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:net.bioclipse.model.ScatterPlotMouseHandler.java

private Number getDomainX(ChartPanel chartPanel, XYPlot plot, Point2D mousePoint) {
    ChartRenderingInfo info = chartPanel.getChartRenderingInfo();
    Rectangle2D dataArea = info.getPlotInfo().getDataArea();
    Number x = plot.getDomainAxis().java2DToValue(mousePoint.getX(), dataArea, plot.getDomainAxisEdge());

    return x;/*from w  ww .j a  v a  2s .  co m*/
}

From source file:sim.app.sugarscape.Charts.java

JFreeChart createGiniChart() {
    JFreeChart chart3 = ChartFactory.createXYLineChart("Lorenz Curve", "Population Percentage",
            "Percentage of Total Wealth", new XYSeriesCollection(model.lorenz_curve), PlotOrientation.VERTICAL,
            true, true, false);// w  w  w .j a v a2 s .  c  o  m
    XYPlot plot = chart3.getXYPlot();
    ValueAxis yAxis = plot.getRangeAxis();
    //xAxis.setFixedDimension(100);
    yAxis.setFixedDimension(1.0);
    //yAxis.setRange(0,1);
    ValueAxis xAxis = plot.getDomainAxis();
    xAxis.setFixedDimension(50);

    //StandardXYItemRenderer 
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.black);
    NumberAxis axis2 = new NumberAxis("Average Agent Vision");

    //axis2.setAutoRangeIncludesZero(false);
    axis2.setRange(0, 12);
    plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    //XYSeriesCollection vision = new XYSeriesCollection(lorenz_agent_vision);
    //plot.setDataset(1, vision);
    return chart3;
}

From source file:slash.navigation.converter.gui.elevationview.ElevationView.java

private XYPlot createPlot(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();
    plot.setForegroundAlpha(0.65F);//from  ww w  .  ja v  a 2  s  .  c o  m

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    Font font = new JLabel().getFont();
    rangeAxis.setLabelFont(font);

    NumberAxis valueAxis = (NumberAxis) plot.getDomainAxis();
    valueAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    valueAxis.setLowerMargin(0.0);
    valueAxis.setUpperMargin(0.0);
    valueAxis.setLabelFont(font);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{2}m @ {1} Km",
            NumberFormat.getIntegerInstance(), NumberFormat.getIntegerInstance()));
    return plot;
}

From source file:subterranean.crimson.server.graphics.graphs.LineChart.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("", "", "", dataset, false, false, false);

    XYPlot plot = result.getXYPlot();
    plot.setDataset(1, new TimeSeriesCollection(s2));

    plot.setBackgroundPaint(new Color(0x000000));
    plot.setDomainGridlinesVisible(false);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);/* ww w . j a  v a 2 s.c  o  m*/

    xaxis.setFixedAutoRange(160000.0); // 160 seconds
    xaxis.setVerticalTickLabels(false);

    ValueAxis yaxis = plot.getRangeAxis();

    yaxis.setAutoRange(true);
    yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return result;
}

From source file:clientv2.GUI.java

/**
 * Creates a chart//from w w w.j  av  a2  s.  co m
 *
 * @param TS
 * @param GraphName
 * @return
 */
public JFreeChart createChart(TimeSeriesCollection TS, String GraphName, double minRange, double maxRange) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(GraphName, "Time", "Value", TS, true, true, false);
    final XYPlot plot = chart.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    plot.getRangeAxis().setRange(minRange, maxRange);
    plot.setBackgroundPaint(WHITE);
    plot.setDomainMinorGridlinePaint(BLACK);
    plot.setDomainGridlinePaint(BLACK);
    plot.setRangeMinorGridlinePaint(BLACK);
    plot.setRangeGridlinesVisible(true);

    axis.setFixedAutoRange(20000.0);

    return chart;
}

From source file:io.github.mzmine.util.jfreechart.ManualZoomDialog.java

/**
 * Constructor/*  ww  w .j  a  v  a  2 s  .  c o m*/
 */
public ManualZoomDialog(Window parent, XYPlot plot) {

    initOwner(parent);

    setTitle("Manual zoom");

    setGraphic(new ImageView("file:icons/axesicon.png"));

    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);

    xAxis = (NumberAxis) plot.getDomainAxis();
    yAxis = (NumberAxis) plot.getRangeAxis();

    try {
        URL layersDialogFXML = getClass().getResource(DIALOG_FXML);
        FXMLLoader loader = new FXMLLoader(layersDialogFXML);
        loader.setController(this);
        GridPane grid = loader.load();
        getDialogPane().setContent(grid);
    } catch (Exception e) {
        e.printStackTrace();
    }

    final Button btOk = (Button) getDialogPane().lookupButton(ButtonType.OK);
    btOk.addEventFilter(ActionEvent.ACTION, event -> {
        commitChanges(event);
    });

}

From source file:no.met.jtimeseries.marinogram.MarinogramWrapper.java

@Override
public XYPlot getPlot() throws ParseException {
    //extra check to avoid add plots on multiple getPlot calls
    if (combiPlot != null) {
        return combiPlot;
    }//  w  w  w.ja  v  a  2  s .co m
    for (int i = plots.size() - 1; i >= 0; i--) {
        MarinogramPlot marinogramPlot = plots.get(i);
        XYPlot plot = marinogramPlot.getPlot();

        if (combiPlot == null) {
            // create a stacked plot with the domain axis of the first plot
            combiPlot = new StackedXYPlot(plot.getDomainAxis());
            combiPlot.setGap(0.0d);
        }
        if (plot != null) {
            ExtendedDateAxis xAxis = (ExtendedDateAxis) plot.getDomainAxis();
            xAxis.setAxislineExtended(true);

            if (i == 0) {
                xAxis.setTickLabelsVisible(true);
            }
            combiPlot.add(plot, marinogramPlot.getHeight());
        }
    }

    return combiPlot;
}

From source file:org.sunzoft.sunstock.StockMain.java

protected JFreeChart createChart() {
    // 2Chart[??]
    XYDataset dataset = initChartData();
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dataset);

    XYPlot xyplot = (XYPlot) chart.getPlot();

    //addIndexChart(xyplot);        

    ChartUtils.setAntiAlias(chart);// 
    ChartUtils.setTimeSeriesStyle(xyplot, false, true);
    ChartUtils.setLegendEmptyBorder(chart);

    // X??//from  www.j a v a2  s.  c o m
    DateAxis domainAxis = (DateAxis) xyplot.getDomainAxis();
    domainAxis.setAutoTickUnitSelection(false);
    domainAxis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());

    DateTickUnit dateTickUnit;
    if (dataset.getItemCount(0) < 30)
        dateTickUnit = new DateTickUnit(DateTickUnitType.DAY, 5, new SimpleDateFormat("yyyy-MM-dd")); // ??
    else if (dataset.getItemCount(0) < 100)
        dateTickUnit = new DateTickUnit(DateTickUnitType.DAY, 10, new SimpleDateFormat("yyyy-MM-dd")); // ??
    else if (dataset.getItemCount(0) < 200)
        dateTickUnit = new DateTickUnit(DateTickUnitType.MONTH, 1, new SimpleDateFormat("yyyy/MM")); // ??
    else if (dataset.getItemCount(0) < 500)
        dateTickUnit = new DateTickUnit(DateTickUnitType.MONTH, 3, new SimpleDateFormat("yyyy/MM")); // ??
    else if (dataset.getItemCount(0) < 1000)
        dateTickUnit = new DateTickUnit(DateTickUnitType.MONTH, 6, new SimpleDateFormat("yyyy/MM")); // ??
    else
        dateTickUnit = new DateTickUnit(DateTickUnitType.YEAR, 1, new SimpleDateFormat("yyyy")); // ??
    // ??
    domainAxis.setTickUnit(dateTickUnit);
    return chart;
}

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

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("Connection Types", "Time", "Connections", dataset,
            true, false, false);//from   w w  w  . ja va2 s  . com
    chart.setBackgroundPaint(Color.white);

    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);

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

    return chart;
}

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

/**
 * A moving average demo.//from  w  w w .  j av a  2 s . c  o  m
 *
 * @param title  the frame title.
 */
public MovingAverageDemo(final String title) {

    super(title);

    // create a title...
    final String chartTitle = "Legal & General Unit Trust Prices";
    final XYDataset dataset = createDataset();

    final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Price Per Unit", dataset,
            true, true, false);

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);
    final XYPlot plot = chart.getXYPlot();
    final XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        rr.setPlotShapes(true);
        rr.setShapesFilled(true);
    }
    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}