Example usage for org.jfree.data RangeType POSITIVE

List of usage examples for org.jfree.data RangeType POSITIVE

Introduction

In this page you can find the example usage for org.jfree.data RangeType POSITIVE.

Prototype

RangeType POSITIVE

To view the source code for org.jfree.data RangeType POSITIVE.

Click Source Link

Document

Positive range.

Usage

From source file:com.bdb.weather.display.axis.RainRangeAxis.java

public static RainRangeAxis create() {
    RainRangeAxis axis = new RainRangeAxis();
    axis.setUpperMargin(UPPER_MARGIN);//from w  ww .j ava2  s  .  com
    axis.setRangeType(RangeType.POSITIVE);
    axis.setNumberFormatOverride(Depth.getDefaultFormatter());
    axis.resetLabel();
    axis.setStandardTickUnits(RainTickUnitSource.create());
    return axis;
}

From source file:com.bdb.weather.display.axis.WindSpeedRangeAxis.java

public static WindSpeedRangeAxis create() {
    WindSpeedRangeAxis axis = new WindSpeedRangeAxis();
    axis.setNumberFormatOverride(Speed.getDefaultFormatter());
    axis.setAutoRangeIncludesZero(true);
    axis.setRangeType(RangeType.POSITIVE);
    return axis;/* ww  w  . j  av a2 s .c  o m*/
}

From source file:org.jfree.data.RangeTypeTest.java

/**
 * Some checks for the equals() method.//  w  w  w.jav a 2s .c  o m
 */
@Test
public void testEquals() {
    assertEquals(RangeType.FULL, RangeType.FULL);
    assertEquals(RangeType.NEGATIVE, RangeType.NEGATIVE);
    assertEquals(RangeType.POSITIVE, RangeType.POSITIVE);
    assertFalse(RangeType.FULL.equals(RangeType.NEGATIVE));
    assertFalse(RangeType.FULL.equals(RangeType.POSITIVE));
    assertFalse(RangeType.FULL.equals(null));
    assertFalse(RangeType.NEGATIVE.equals(RangeType.FULL));
    assertFalse(RangeType.NEGATIVE.equals(RangeType.POSITIVE));
    assertFalse(RangeType.NEGATIVE.equals(null));
    assertFalse(RangeType.POSITIVE.equals(RangeType.NEGATIVE));
    assertFalse(RangeType.POSITIVE.equals(RangeType.FULL));
    assertFalse(RangeType.POSITIVE.equals(null));
}

From source file:io.github.mzmine.modules.plots.chromatogram.ChromatogramPlotWindowController.java

@FXML
public void initialize() {

    final JFreeChart chart = chartNode.getChart();
    final XYPlot plot = chart.getXYPlot();

    // Do not set colors and strokes dynamically. They are instead provided
    // by the dataset and configured in configureRenderer()
    plot.setDrawingSupplier(null);//from   w  ww . j a  v  a  2 s  . co  m
    plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
    plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
    plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setDomainCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor));
    plot.setRangeCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    // chart properties
    chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));

    // legend properties
    LegendTitle legend = chart.getLegend();
    // legend.setItemFont(legendFont);
    legend.setFrame(BlockBorder.NONE);

    // set the X axis (retention time) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setLabel("Retention time (min)");
    xAxis.setUpperMargin(0.03);
    xAxis.setLowerMargin(0.03);
    xAxis.setRangeType(RangeType.POSITIVE);
    xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));

    // set the Y axis (intensity) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setLabel("Intensity");
    yAxis.setRangeType(RangeType.POSITIVE);
    yAxis.setAutoRangeIncludesZero(true);

    // set the fixed number formats, because otherwise JFreeChart sometimes
    // shows exponent, sometimes it doesn't
    DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
    xAxis.setNumberFormatOverride(mzFormat);
    DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
    yAxis.setNumberFormatOverride(intensityFormat);

    chartTitle = chartNode.getChart().getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    chartTitle.setText("Chromatogram");

    chartNode.setCursor(Cursor.CROSSHAIR);

    // Remove the dataset if it is removed from the list
    datasets.addListener((Change<? extends ChromatogramPlotDataSet> c) -> {
        while (c.next()) {
            if (c.wasRemoved()) {
                for (ChromatogramPlotDataSet ds : c.getRemoved()) {
                    int index = plot.indexOf(ds);
                    plot.setDataset(index, null);
                }
            }
        }
    });

    itemLabelsVisible.addListener((prop, oldVal, newVal) -> {
        for (ChromatogramPlotDataSet dataset : datasets) {
            int datasetIndex = plot.indexOf(dataset);
            XYItemRenderer renderer = plot.getRenderer(datasetIndex);
            renderer.setBaseItemLabelsVisible(newVal);
        }
    });

    legendVisible.addListener((prop, oldVal, newVal) -> {
        legend.setVisible(newVal);
    });
}

From source file:net.sf.mzmine.chartbasics.gui.javafx.EChartViewer.java

/**
 * Init ChartPanel Mouse Listener For MouseDraggedOverAxis event For scrolling X-Axis und zooming
 * Y-Axis0/*from  w w w . j  a v a 2 s  . c  o  m*/
 */
private void initChartPanel() {
    final EChartViewer chartPanel = this;

    // remove old init
    if (mouseAdapter != null) {
        this.getCanvas().removeMouseHandler(mouseAdapter);
    }

    if (chartPanel.getChart().getPlot() instanceof XYPlot) {
        // set sticky zero
        if (stickyZeroForRangeAxis) {
            ValueAxis rangeAxis = chartPanel.getChart().getXYPlot().getRangeAxis();
            if (rangeAxis instanceof NumberAxis) {
                NumberAxis axis = (NumberAxis) rangeAxis;
                axis.setAutoRangeIncludesZero(true);
                axis.setAutoRange(true);
                axis.setAutoRangeStickyZero(true);
                axis.setRangeType(RangeType.POSITIVE);
            }
        }

        Plot p = getChart().getPlot();
        if (addZoomHistory && p instanceof XYPlot
                && !(p instanceof CombinedDomainXYPlot || p instanceof CombinedRangeXYPlot)) {
            // zoom history
            zoomHistory = new ZoomHistory(this, 20);

            // axis range changed listener for zooming and more
            ValueAxis rangeAxis = this.getChart().getXYPlot().getRangeAxis();
            ValueAxis domainAxis = this.getChart().getXYPlot().getDomainAxis();
            if (rangeAxis != null) {
                rangeAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {
                    @Override
                    public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR,
                            Range newR) {
                        // notify listeners of changed range
                        if (axesRangeListener != null)
                            for (AxesRangeChangedListener l : axesRangeListener)
                                l.axesRangeChanged(chart, axis, lastR, newR);
                    }
                });
            }
            if (domainAxis != null) {
                domainAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {
                    @Override
                    public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR,
                            Range newR) {
                        // notify listeners of changed range
                        if (axesRangeListener != null)
                            for (AxesRangeChangedListener l : axesRangeListener)
                                l.axesRangeChanged(chart, axis, lastR, newR);
                    }
                });
            }
        }

        // mouse adapter for scrolling and zooming
        mouseAdapter = new ChartGestureMouseAdapterFX("gestures", this);
        addMouseHandler(mouseAdapter);

        // add gestures
        if (standardGestures) {
            addStandardGestures();
        }
        // mouseAdapter.addDebugHandler();
    }
}

From source file:net.sf.mzmine.chartbasics.gui.swing.EChartPanel.java

/**
 * Init ChartPanel Mouse Listener For MouseDraggedOverAxis event For scrolling X-Axis und zooming
 * Y-Axis0//from ww  w .j  a va2s .co m
 */
private void initChartPanel(boolean stickyZeroForRangeAxis) {
    final EChartPanel chartPanel = this;

    // remove old init
    if (mouseAdapter != null) {
        this.removeMouseListener(mouseAdapter);
        this.removeMouseMotionListener(mouseAdapter);
        this.removeMouseWheelListener(mouseAdapter);
    }

    if (chartPanel.getChart().getPlot() instanceof XYPlot) {
        // set sticky zero
        if (stickyZeroForRangeAxis) {
            ValueAxis rangeAxis = chartPanel.getChart().getXYPlot().getRangeAxis();
            if (rangeAxis instanceof NumberAxis) {
                NumberAxis axis = (NumberAxis) rangeAxis;
                axis.setAutoRangeIncludesZero(true);
                axis.setAutoRange(true);
                axis.setAutoRangeStickyZero(true);
                axis.setRangeType(RangeType.POSITIVE);
            }
        }

        Plot p = getChart().getPlot();
        if (addZoomHistory && (p instanceof XYPlot)
                && !(p instanceof CombinedDomainXYPlot || p instanceof CombinedRangeXYPlot)) {
            // zoom history
            zoomHistory = new ZoomHistory(this, 20);

            // axis range changed listener for zooming and more
            ValueAxis rangeAxis = this.getChart().getXYPlot().getRangeAxis();
            ValueAxis domainAxis = this.getChart().getXYPlot().getDomainAxis();
            if (rangeAxis != null) {
                rangeAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {
                    @Override
                    public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR,
                            Range newR) {
                        // notify listeners of changed range
                        if (axesRangeListener != null)
                            for (AxesRangeChangedListener l : axesRangeListener)
                                l.axesRangeChanged(chart, axis, lastR, newR);
                    }
                });
            }
            if (domainAxis != null) {
                domainAxis.addChangeListener(new AxisRangeChangedListener(new ChartViewWrapper(this)) {
                    @Override
                    public void axisRangeChanged(ChartViewWrapper chart, ValueAxis axis, Range lastR,
                            Range newR) {
                        // notify listeners of changed range
                        if (axesRangeListener != null)
                            for (AxesRangeChangedListener l : axesRangeListener)
                                l.axesRangeChanged(chart, axis, lastR, newR);
                    }
                });
            }
        }

        // mouse adapter for scrolling and zooming
        mouseAdapter = new ChartGestureMouseAdapter();
        // mouseAdapter.addDebugHandler();
        this.addMouseListener(mouseAdapter);
        this.addMouseMotionListener(mouseAdapter);
        this.addMouseWheelListener(mouseAdapter);

        // add gestures
        if (standardGestures) {
            addStandardGestures();
        }
    }
}

From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java

public void initialize() {

    final JFreeChart chart = chartNode.getChart();
    final XYPlot plot = chart.getXYPlot();

    // Do not set colors and strokes dynamically. They are instead provided
    // by the dataset and configured in configureRenderer()
    plot.setDrawingSupplier(null);/*from   w w  w  . j  a v  a2  s.com*/
    plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
    plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
    plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    // chart properties
    chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));

    // legend properties
    LegendTitle legend = chart.getLegend();
    // legend.setItemFont(legendFont);
    legend.setFrame(BlockBorder.NONE);

    // set the X axis (m/z) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setLabel("m/z");
    xAxis.setUpperMargin(0.03);
    xAxis.setLowerMargin(0.03);
    xAxis.setRangeType(RangeType.POSITIVE);
    xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));

    // set the Y axis (intensity) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setLabel("Intensity");
    yAxis.setRangeType(RangeType.POSITIVE);
    yAxis.setAutoRangeIncludesZero(true);

    // set the fixed number formats, because otherwise JFreeChart sometimes
    // shows exponent, sometimes it doesn't
    DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
    xAxis.setNumberFormatOverride(mzFormat);
    DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
    yAxis.setNumberFormatOverride(intensityFormat);

    chartTitle = chartNode.getChart().getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);

    chartNode.setCursor(Cursor.CROSSHAIR);

    // Remove the dataset if it is removed from the list
    datasets.addListener((Change<? extends MsSpectrumDataSet> c) -> {
        while (c.next()) {
            if (c.wasRemoved()) {
                for (MsSpectrumDataSet ds : c.getRemoved()) {
                    int index = plot.indexOf(ds);
                    plot.setDataset(index, null);
                }
            }
        }
    });

    itemLabelsVisible.addListener((prop, oldVal, newVal) -> {
        for (MsSpectrumDataSet dataset : datasets) {
            int datasetIndex = plot.indexOf(dataset);
            XYItemRenderer renderer = plot.getRenderer(datasetIndex);
            renderer.setBaseItemLabelsVisible(newVal);
        }
    });

    legendVisible.addListener((prop, oldVal, newVal) -> {
        legend.setVisible(newVal);
    });

}

From source file:de.uka.aifb.com.systemDynamics.gui.ModelExecutionChartPanel.java

/**
 * Creates the XY line chart.//from  ww w . ja v  a 2  s. co m
 * 
 * @return XY line chart
 */
private JFreeChart createChart() {
    levelNodes = new LevelNode[model.getLevelNodes().size()];
    int i = 0;
    for (LevelNode levelNode : model.getLevelNodes()) {
        levelNodes[i++] = levelNode;
    }
    // sort level nodes alphabetically
    Arrays.sort(levelNodes);

    xySeriesArray = new XYSeries[levelNodes.length];
    XYSeriesCollection data = new XYSeriesCollection();
    for (i = 0; i < xySeriesArray.length; i++) {
        XYSeries xySeries = new XYSeries(levelNodes[i].getNodeName());
        xySeries.add(0.0, levelNodes[i].getCurrentValue());
        data.addSeries(xySeries);
        xySeriesArray[i] = xySeries;
    }
    nextRound = 1;

    chart = ChartFactory.createXYLineChart(null, messages.getString("ModelExecutionChartPanel.Round"),
            messages.getString("ModelExecutionChartPanel.Value"), data, PlotOrientation.VERTICAL, true, false,
            false);
    XYPlot plot = chart.getXYPlot();

    // horizontal axis range: 0 ... maximal rounds
    ((NumberAxis) (chart.getXYPlot().getDomainAxis())).setRangeType(RangeType.POSITIVE);
    plot.getDomainAxis().setAutoRangeMinimumSize(20);

    // only integer values as labels for horizontal axis
    plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // number formatting according to current locale
    ((NumberAxis) (plot.getDomainAxis())).setNumberFormatOverride(NumberFormat.getIntegerInstance(locale));
    ((NumberAxis) (plot.getRangeAxis())).setNumberFormatOverride(NumberFormat.getInstance(locale));

    // legend at top position
    chart.getLegend().setPosition(RectangleEdge.TOP);

    return chart;
}

From source file:Main.Interface_Main.java

/**
 * Sets up the graph for voltage./*  ww w  .  j  ava2 s  .  c  o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return Current mA chart.
 */
private JFreeChart createChartCurrent(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Current", "Time", "mA", dataset, false, true,
            false);
    final XYPlot plot = result.getXYPlot();
    XYItemRenderer xyir = plot.getRenderer();
    xyir.setSeriesPaint(0, Color.GREEN);
    xyir.setSeriesPaint(1, Color.RED);
    xyir.setSeriesPaint(2, Color.BLUE);

    plot.setBackgroundPaint(Color.BLACK);
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setAutoRange(true);

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeMinimumSize(500);
    yAxis.setRangeType(RangeType.POSITIVE);
    yAxis.setAutoRangeIncludesZero(true);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setAutoRange(true);
    return result;
}

From source file:Main.Interface_Main.java

private JFreeChart createChartVolt(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Voltage", "Time", "Volts", dataset, false,
            true, false);//w w w  .j  av  a 2  s  .  c o m
    final XYPlot plot = result.getXYPlot();
    XYItemRenderer xyir = plot.getRenderer();
    xyir.setSeriesPaint(0, Color.GREEN);
    xyir.setSeriesPaint(1, Color.RED);
    xyir.setSeriesPaint(2, Color.BLUE);

    plot.setBackgroundPaint(Color.BLACK);
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setAutoRange(true);

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeMinimumSize(5.2);
    yAxis.setRangeType(RangeType.POSITIVE);
    yAxis.setAutoRangeIncludesZero(true);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setAutoRange(true);
    return result;
}