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:grafix.telas.MolduraAreaDados.java

private Point2D converterPontoNaMolduraParaPlot_EixoLinear(final Point2D pontoMoldura) {
    XYPlot plot = getPlot();
    ValueAxis vAxis = plot.getRangeAxis();
    ValueAxis dAxis = plot.getDomainAxis();
    double fracaoX = pontoMoldura.getX() / this.getWidth();
    double fracaoY = 1 - (pontoMoldura.getY() / this.getHeight());
    double dX = dAxis.getUpperBound() - dAxis.getLowerBound();
    double dY = vAxis.getUpperBound() - vAxis.getLowerBound();
    return new Point2D.Double(dAxis.getLowerBound() + dX * fracaoX, vAxis.getLowerBound() + dY * fracaoY);
}

From source file:grafix.telas.MolduraAreaDados.java

private Point2D converterPontoNaMolduraParaPlot_EixoLog(final Point2D pontoMoldura) {
    XYPlot plot = getPlot();
    ValueAxis vAxis = plot.getRangeAxis();
    ValueAxis dAxis = plot.getDomainAxis();
    double fracaoX = pontoMoldura.getX() / this.getWidth();
    double fracaoYlog = 1 - (pontoMoldura.getY() / this.getHeight());
    double dX = dAxis.getUpperBound() - dAxis.getLowerBound();
    double dYlog = Math.log10(vAxis.getUpperBound()) - Math.log10(vAxis.getLowerBound());
    double ylog = Math.log10(vAxis.getLowerBound()) + fracaoYlog * dYlog;
    return new Point2D.Double(dAxis.getLowerBound() + dX * fracaoX, Math.pow(10, ylog));
}

From source file:grafix.telas.MolduraAreaDados.java

private Point2D converterPontoNoPlotParaMoldura_EixoLinear(final Point2D pontoPlot) {
    XYPlot plot = getPlot();
    ValueAxis vAxis = plot.getRangeAxis();
    ValueAxis dAxis = plot.getDomainAxis();
    double dX = dAxis.getUpperBound() - dAxis.getLowerBound();
    double dY = vAxis.getUpperBound() - vAxis.getLowerBound();
    double proporcaoX = this.getWidth() / dX;
    double proporcaoY = this.getHeight() / dY;
    double fracaoX = pontoPlot.getX() - dAxis.getLowerBound();
    double fracaoY = pontoPlot.getY() - vAxis.getLowerBound();
    return new Point2D.Double(fracaoX * proporcaoX, this.getHeight() - (fracaoY * proporcaoY));
}

From source file:grafix.telas.MolduraAreaDados.java

private Point2D converterPontoNoPlotParaMoldura_EixoLog(final Point2D pontoPlot) {
    XYPlot plot = getPlot();
    ValueAxis vAxis = plot.getRangeAxis();
    ValueAxis dAxis = plot.getDomainAxis();
    double dX = dAxis.getUpperBound() - dAxis.getLowerBound();
    double dYlog = Math.log10(vAxis.getUpperBound()) - Math.log10(vAxis.getLowerBound());
    double proporcaoX = this.getWidth() / dX;
    double fracaoX = pontoPlot.getX() - dAxis.getLowerBound();
    double fracaoYlog = Math.log10(pontoPlot.getY()) - Math.log10(vAxis.getLowerBound());
    double coefYlog = fracaoYlog / dYlog;
    return new Point2D.Double(fracaoX * proporcaoX, this.getHeight() - (coefYlog * this.getHeight()));
}

From source file:gsn.charts.GsnChartJfreechart.java

public JFreeChart createChart(Collection<Data> datas) {
    TimeSeries t1 = new TimeSeries("S1");
    Iterator<Data> iter = datas.iterator();
    Data data;/*from w  w w  .j  a  v a2  s  . co  m*/
    while (iter.hasNext()) {
        data = iter.next();
        t1.addOrUpdate(RegularTimePeriod.createInstance(Millisecond.class, new Date((Long) data.getP2()),
                TimeZone.getDefault()), data.getValue());
    }
    XYDataset dataset = new TimeSeriesCollection(t1);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, false, false);
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);
    //
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("No Data to Display");
    plot.setDomainGridlinesVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setInsets(new RectangleInsets(5, 14, 0, 5));
    //
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(ssdf);
    axis.setTickLabelFont(TICK_FONT);
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelFont(TICK_FONT);
    //
    return chart;
}

From source file:c.depthchart.ViewerPanel.java

private void initChart()
// create the dataset, chart, panel, and window
{
    // create an empty data set
    series = new XYSeries("Depth Counts Histogram");
    for (int i = 0; i <= CHART_MAX_DEPTH; i++)
        series.add(i, 0); // depth with a zero count
    XYSeriesCollection dataset = new XYSeriesCollection(series);

    // put the data into a chart
    JFreeChart chart = ChartFactory.createXYBarChart("Depth Histogram", "Depth (mm)", false, "Depth Count",
            dataset, PlotOrientation.VERTICAL, false, true, false); // legend, tooltips, urls

    // modify the chart axes
    XYPlot plot = (XYPlot) chart.getPlot();

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // x-axis
    domainAxis.setVerticalTickLabels(true);
    domainAxis.setRange(0, CHART_MAX_DEPTH);
    domainAxis.setTickUnit(new NumberTickUnit(100));

    ValueAxis rangeAxis = plot.getRangeAxis(); // y-axis
    rangeAxis.setRange(0, 15000); // a bit of a guess

    // add the chart to a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(1000, 500));

    // add the panel to a window
    JFrame chartFrame = new JFrame("Depth Histogram");
    chartFrame.setContentPane(chartPanel);
    chartFrame.pack();/* w  w  w .j  a  va2 s. c  o  m*/
    chartFrame.setVisible(true);
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseReleased(MouseEvent e) {
    try {//from   ww  w  . jav  a  2 s  .c o  m
        if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
            //            Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea(
            //                    (int) this.coElutionStart.getX(), (int) this.coElutionStart.getY());
            JFreeChart jfc = _cp.getChart();
            XYPlot p = jfc.getXYPlot();
            CenterZoomNumberAxis czna = (CenterZoomNumberAxis) p.getDomainAxis();
            Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY());
            Rectangle2D plotboundaries = _cp.getChartRenderingInfo().getPlotInfo().getPlotArea();

            double leftmostOnAxis = czna.getLowerBound();
            double rightmostOnAxis = czna.getUpperBound();
            double leftmostOnRange = this.coElutionRegion.getX();
            double rightmostOnRange = this.coElutionRegion.getX() + this.coElutionRegion.getWidth();
            double leftmostonscreen = screenDataArea.getX();
            double rightmostonscreen = leftmostonscreen + screenDataArea.getWidth();
            double slope = (rightmostOnAxis - leftmostOnAxis) / (rightmostonscreen - leftmostonscreen);
            double transformedLeftRange = (slope * (leftmostOnRange - leftmostonscreen)) + leftmostOnAxis;
            double transformedRightRange = (slope * (rightmostOnRange - leftmostonscreen)) + leftmostOnAxis;
            shifted = false;
            MRMDialog ultimateParent = (MRMDialog) MRMAncestor();
            if (ultimateParent != null) {
                MRMTransition transition = ultimateParent.transitionOnPlot;
                MRMTransition mrmt = transition;
                if (mrmt != null) {
                    int row = mrmt.getTableRow();
                    _ptm.data[row][MRMDialog.peaksData.CoStart.colno] = new Float(0f);
                    _ptm.data[row][MRMDialog.peaksData.CoEnd.colno] = new Float(10000000f);
                    _ptm.setValueAt(new Float(transformedRightRange), row, MRMDialog.peaksData.CoEnd.colno);
                    _ptm.setValueAt(new Float(transformedLeftRange), row, MRMDialog.peaksData.CoStart.colno);
                }
            }
            Graphics2D g2 = (Graphics2D) _cp.getGraphics();
            if (this.coElutionRegion != null)
                drawCoElutionRegion(g2);
            this.coElutionRegion = null;
            this.coElutionStart = null;
        } else {
            _cp.mouseReleased(e);
        }
    } catch (Exception ee) {
    }
}

From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java

private void configureDomainAxis(XYPlot plot) {
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelFont(LabelConstants.FONT_LABEL);
    domainAxis.setLabelFont(LabelConstants.FONT_LABEL);
    domainAxis.setTickLabelPaint(LabelConstants.COLOR);
    domainAxis.setLabelPaint(LabelConstants.COLOR);
}

From source file:CorrelationLambdaTest.java

@Test

public void crossCorrelationGraphicTest() {

    CategoryTableXYDataset serie = new CategoryTableXYDataset();
    serie.setNotify(false);//w  ww .  j  ava  2 s .c  om
    double step = 1.0 / discretization;
    double startPosition = step * framePosition;
    //100 ? - 100 , 50 ? - 50 , 25 ?- 25 
    Transform t = new Transform(new FastWaveletTransform(new Haar1()));
    double[] signal = testData.get1DSimpleSignal(1.5, 500, 32768, 5000);
    double[] data = crossCorrelationCoefficient(signal, window);

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128));

    //        double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32));
    //        double[] data = testData.get1DSignal(100, 200, frameWidth, discretization);
    //        double[] data = math.lpf(70, step,128);
    for (int i = 0; i < data.length; i++) {
        serie.add(startPosition, data[i], "");
        startPosition += step;
    }
    JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "wave", serie);
    chart.removeLegend();
    chart.setAntiAlias(false);

    XYPlot plot = chart.getXYPlot();
    //plot.setRangeGridlinePaint(Color.BLACK);
    org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis();
    org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis();
    double start = framePosition * 1.0 / discretization;
    double max = start + frameWidth * 1.0 / discretization;
    xAxis.setRange(start, max);
    ChartPanel chartPanel = new ChartPanel(chart);

    JPanel p = new JPanel(new BorderLayout());

    p.removeAll();
    p.add(chartPanel);
    p.validate();
    //1. Create the frame.
    JFrame frame = new JFrame("FrameDemo");

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //3. Create components and put them in the frame.
    //...create emptyLabel...
    frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER);
    frame.getContentPane().add(p, BorderLayout.CENTER);

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
}

From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java

/**
 * /*from  w  w  w  .j  ava2  s  .c  o m*/
 * Domain and Range axes need to share the same unit (e.g. mm)
 * 
 * @param myChart
 * @return
 */
public static double calcWidthToHeight(ChartViewer myChart, double chartHeight) {
    makeChartResizable(myChart);

    myChart.getCanvas().draw();

    XYPlot plot = (XYPlot) myChart.getChart().getPlot();
    ChartRenderingInfo info = myChart.getRenderingInfo();
    Rectangle2D dataArea = info.getPlotInfo().getDataArea();
    Rectangle2D chartArea = info.getChartArea();

    // calc title space: will be added later to the right plot size
    double titleWidth = chartArea.getWidth() - dataArea.getWidth();
    double titleHeight = chartArea.getHeight() - dataArea.getHeight();

    // calc right plot size with axis dim.
    // real plot width is given by factor;
    double realPH = chartHeight - titleHeight;

    // ranges
    ValueAxis domainAxis = plot.getDomainAxis();
    org.jfree.data.Range x = domainAxis.getRange();
    ValueAxis rangeAxis = plot.getRangeAxis();
    org.jfree.data.Range y = rangeAxis.getRange();

    // real plot height can be calculated by
    double realPW = realPH / y.getLength() * x.getLength();

    double width = realPW + titleWidth;

    return width;
}