Example usage for org.jfree.chart.axis ValueAxis setRange

List of usage examples for org.jfree.chart.axis ValueAxis setRange

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis setRange.

Prototype

public void setRange(double lower, double upper) 

Source Link

Document

Sets the range for the axis and sends a change event to all registered listeners.

Usage

From source file:mls.FramePlot.java

private JFreeChart createChartMedia(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createXYLineChart("Media campionaria", "n", "en", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    plotMedia = result.getXYPlot();//  w ww  .j a va 2  s .c  o m
    ValueAxis axis = plotMedia.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(1500);

    axis = plotMedia.getRangeAxis();
    axis.setAutoRange(true);
    axis.setRange(75, 160);
    plotMedia.getRenderer().setSeriesPaint(0, Color.BLUE);
    return result;
}

From source file:carfuzzy.Operations.java

public JFreeChart drawAggregation(FIS[] fis) {

    XYSeriesCollection aggregationDataset = new XYSeriesCollection();
    for (int i = 0; i < 4; i++) {
        aggregationDataset.addSeries(fis[i].getImplication());
    }/*w w  w .jav a2 s . c om*/
    //aggregationDataset.getSeries(0).setKey("Agjujugregation");
    JFreeChart chart = setToChart(aggregationDataset, "Aggregation");

    XYPlot plot = chart.getXYPlot();
    XYAreaRenderer renderer = new XYAreaRenderer();
    renderer.setSeriesVisibleInLegend(false, true);
    renderer.setSeriesItemLabelsVisible(0, false, true);
    renderer.setSeriesItemLabelsVisible(3, true);
    renderer.setPaint(Color.RED.darker(), true);
    plot.setRenderer(renderer);
    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setRange(0, 10);
    return chart;
}

From source file:experiments.SimpleExample.java

public JFreeChart createChart() {
    XYSeries xyseries = new XYSeries("Fitness Line");
    xyseries.add(0.0D, 0.0D);//from w w w .  java  2s  .c  o  m
    for (int i = 1; i <= fitlist.size(); i++) {
        xyseries.add(i, fitlist.get(i - 1));
    }
    XYSeriesCollection xyseriescollection = new XYSeriesCollection(); //?XYSeriesCollectionXYSeries  
    xyseriescollection.addSeries(xyseries);
    //?  
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Line Chart Demo", //      
            "Iteration", // categoryAxisLabel categoryX     
            "FitnessValue", // valueAxisLabelvalueY     
            xyseriescollection, // dataset     
            PlotOrientation.VERTICAL, true, // legend     
            false, // tooltips     
            false); // URLs     

    // CategoryPlot?????     
    XYPlot plot = jfreechart.getXYPlot();
    // ? ?     
    plot.setBackgroundAlpha(0.5f);
    plot.setForegroundAlpha(0.5f);
    //        XYPlot xyplot = jfreechart.getXYPlot();  
    //??  
    ValueAxis xx = plot.getDomainAxis();
    //??  
    xx.setAutoRange(true);
    //        xx.setRange(0.0, 2000);

    ValueAxis yy = plot.getRangeAxis();
    yy.setRange(600.0, 1000);

    return jfreechart;
}

From source file:com.anji.floatingeye.FloatingEyeDisplay.java

private void init(Java2DSurface surface, FloatingEye anEye) {
    eye = anEye;/*from w  w  w.j  ava  2  s.  c  om*/

    // this frame has 3 sections - status, surface canvas, and eye canvas
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            setVisible(false);
            dispose();
        }
    });
    GridLayout mainLayout = new GridLayout(2, 1);
    mainLayout.setHgap(10);
    mainLayout.setVgap(10);
    getContentPane().setLayout(mainLayout);
    GridLayout topPanelLayout = new GridLayout(2, 1);
    topPanelLayout.setHgap(10);
    topPanelLayout.setVgap(10);
    Panel topPanel = new Panel(topPanelLayout);
    GridLayout bottomPanelLayout = new GridLayout(1, 2);
    bottomPanelLayout.setHgap(10);
    bottomPanelLayout.setVgap(10);
    Panel bottomPanel = new Panel(bottomPanelLayout);

    // 1 - status area
    statusArea = new TextArea("", 1, 1, TextArea.SCROLLBARS_VERTICAL_ONLY);
    statusArea.setEditable(false);
    statusArea.setFont(new Font("Dialog", Font.PLAIN, 10));
    statusArea.setSize(new Dimension(IMG_WIDTH * 2, IMG_HEIGHT / 2));

    // 2 - affinity history chart
    XYSeriesCollection seriesCollection = new XYSeriesCollection(affinitySeries);
    JFreeChart chart = ChartFactory.createXYLineChart("affinity history", "step", "affinity", seriesCollection,
            PlotOrientation.VERTICAL, false, false, false);
    ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
    rangeAxis.setAutoRange(false);
    rangeAxis.setRange(0d, 1d);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(IMG_WIDTH * 2, IMG_HEIGHT / 2));

    // 3 - surface canvas
    surfaceCanvas = new SurfaceCanvas(surface, eye, IMG_WIDTH, IMG_HEIGHT);
    surfaceCanvas.setBackground(Color.WHITE);

    // 4 - eye canvas
    eyeCanvas = new EyeCanvas(eye, IMG_WIDTH, IMG_HEIGHT);
    eyeCanvas.setBackground(Color.WHITE);

    topPanel.add(statusArea);
    topPanel.add(chartPanel);
    bottomPanel.add(surfaceCanvas);
    bottomPanel.add(eyeCanvas);
    getContentPane().add(topPanel);
    getContentPane().add(bottomPanel);

    pack();
}

From source file:carfuzzy.Operations.java

public JFreeChart setYAxisForImplication(double imp, XYSeries series, XYSeriesCollection collection,
        Output out) {/*from w  w w  .j  a v  a2s .  c o m*/
    JFreeChart chart;
    if (out == Output.stop) {
        series.updateByIndex(0, imp);
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
    } else if (out == Output.speedUp) {
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
        series.updateByIndex(3, imp);
    } else {
        series.updateByIndex(1, imp);
        series.updateByIndex(2, imp);
    }
    collection.addSeries(series);
    String x_axis = "Implication";

    chart = XYGraph.drawChart(collection, x_axis, "Membership");
    XYPlot plot = chart.getXYPlot();
    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setRange(0, 10);
    XYItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesStroke(0, new BasicStroke(3.5f));
    return chart;
}

From source file:DynamicDataDemo.java

/**
 * Creates a sample chart./*from  www.j  a v  a 2s .co m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset, String title, String xcoor, String ycoor) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(title, xcoor, ycoor, dataset, true, true,
            false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(0.0, 500.0);
    return result;
}

From source file:com.experiments.DynamicDataDemo.java

/**
 * Creates a sample chart./*w w w. j av a2s  .  c o m*/
 * 
 * @param dataset
 *            the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Dynamic Data Demo", "Time", "Value", dataset,
            true, true, false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(0.0, 200.0);
    axis.setVisible(false);
    return result;
}

From source file:com.okmich.twitanalysis.gui.ApplicationFrame.java

/**
 * Creates a sample chart./*from  w  w w  . j  ava2 s  .  c om*/
 *
 * @param dataset the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Twitter Sentiments Analysis", "Time",
            "Sentiment score", dataset, true, true, false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(0.0, 50.0);
    return result;
}

From source file:net.sf.jasperreports.customizers.axis.AbstractAxisCustomizer.java

protected void configValueAxis(ValueAxis valueAxis, String minProp, String maxProp) {
    if (valueAxis != null) {
        Double rangeMin = getDoubleProperty(minProp);
        Double rangeMax = getDoubleProperty(maxProp);
        if (rangeMin != null || rangeMax != null) {
            valueAxis.setRange(rangeMin == null ? valueAxis.getRange().getLowerBound() : rangeMin,
                    rangeMax == null ? valueAxis.getRange().getUpperBound() : rangeMax);
        }/*  w w w .  j  ava 2  s.c  om*/
    }
}

From source file:LowPassFilterTest.java

@Test
public void test() throws InterruptedException {
    CategoryTableXYDataset serie = new CategoryTableXYDataset();
    serie.setNotify(false);/*www .  ja v a 2  s  . com*/
    double step = 1.0 / discretization;
    double startPosition = step * framePosition;
    //100 ? - 100 , 50 ? - 50 , 25 ?- 25 
    double[] data = math.convolve(
            math.HammingWindow(testData.get1DPolyharmSignal(4, 200, frameWidth, discretization), frameWidth),
            math.lpf(60, step, 1024));
    //        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", "g, /c^2", 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);
}