Example usage for org.jfree.chart.axis LogarithmicAxis setAutoRange

List of usage examples for org.jfree.chart.axis LogarithmicAxis setAutoRange

Introduction

In this page you can find the example usage for org.jfree.chart.axis LogarithmicAxis setAutoRange.

Prototype

public void setAutoRange(boolean auto) 

Source Link

Document

Sets a flag that determines whether or not the axis range is automatically adjusted to fit the data, and notifies registered listeners that the axis has been modified.

Usage

From source file:org.amanzi.awe.distribution.ui.widgets.DistributionChartWidget.java

public void updateChartType(final ChartType chartType) {
    final CategoryPlot plot = (CategoryPlot) distributionChart.getPlot();

    switch (chartType) {
    case LOGARITHMIC:
        final LogarithmicAxis logAxis = new LogarithmicAxis("Logarithmic");
        logAxis.setAllowNegativesFlag(true);
        plot.setRangeAxis(logAxis);//w  w w  .  j  a va 2 s.c o m

        logAxis.setAutoRange(true);
        break;
    case COUNTS:
        final NumberAxis countAxis = new NumberAxis("Counts");
        countAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

        plot.setRangeAxis(countAxis);
        countAxis.setAutoRange(true);
        break;
    case PERCENTS:
        final NumberAxis percentageAxis = new NumberAxis("Percentage");
        percentageAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        percentageAxis.setRange(0, 100);

        plot.setRangeAxis(percentageAxis);
        break;
    }

    dataset.updateDelegate(chartType);

    update();
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.LogLinChartUIComponent.java

/***********************************************************************************************
 * Customise the XYPlot of a new chart, e.g. for fixed range axes.
 *
 * @param datasettype/*w ww . j  av a2s . co m*/
 * @param primarydataset
 * @param secondarydatasets
 * @param updatetype
 * @param displaylimit
 * @param channelselector
 * @param debug
 *
 * @return JFreeChart
 */

public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset,
        final List<XYDataset> secondarydatasets, final DataUpdateType updatetype, final int displaylimit,
        final ChannelSelectorUIComponentInterface channelselector, final boolean debug) {
    final String SOURCE = "LogLinChartUIComponent.createCustomisedChart ";
    final JFreeChart jFreeChart;

    LOGGER.debug(debug, SOURCE + "--> ChartHelper.createChart()");

    MetadataHelper.showMetadataList(getMetadata(), SOURCE + " CHART METADATA --> ChartHelper.createChart()",
            LOADER_PROPERTIES.isMetadataDebug());

    channelselector.debugSelector(debug, SOURCE);

    // Creates TimeSeriesChart or XYLineChart to suit the dataset
    // The default renderer is an XYLineAndShapeRenderer
    jFreeChart = ChartHelper.createChart(primarydataset,
            ObservatoryInstrumentHelper.getCurrentObservatoryTimeZone(REGISTRY.getFramework(), getDAO(), debug),
            getMetadata(), getChannelCount(), hasTemperatureChannel(), updatetype, displaylimit,
            channelselector, debug);
    if (jFreeChart != null) {
        // Customise the Chart for LogLin data if possible
        if ((hasLogarithmicMode()) && (!channelselector.isLinearMode())) {
            final XYPlot plot;
            final LogarithmicAxis axisLog;
            final String strAxisLabel;

            LOGGER.debug(debug, SOURCE + "Customise the Chart for LogLin data");

            // The set of Metadata available should include the Instrument
            // and any items from the current observation
            strAxisLabel = MetadataHelper.getMetadataValueByKey(getMetadata(),
                    MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_Y.getKey()
                            + MetadataDictionary.SUFFIX_SERIES_ZERO);

            // Replace the RangeAxis at index 0 NumberAxis with a LogarithmicAxis
            axisLog = new LogarithmicAxis(strAxisLabel);

            axisLog.setAllowNegativesFlag(true);
            axisLog.setLog10TickLabelsFlag(true);

            if ((canAutorange()) && (channelselector.isAutoranging())) {
                axisLog.setAutoRange(true);
                axisLog.configure();
                axisLog.autoAdjustRange();
            } else {
                axisLog.setRange(getLogarithmicFixedMinY(), getLogarithmicFixedMaxY());
                axisLog.configure();
                axisLog.autoAdjustRange();
            }

            plot = jFreeChart.getXYPlot();
            plot.setRangeAxis(INDEX_AXIS, axisLog);
            plot.setRangeAxisLocation(INDEX_AXIS, AxisLocation.BOTTOM_OR_LEFT);

            // Map the dataset to the axis
            plot.setDataset(INDEX_DATA, primarydataset);
            plot.mapDatasetToRangeAxis(INDEX_DATA, INDEX_AXIS);

            // Change the DateAxis format
            if (DatasetType.TIMESTAMPED.equals(datasettype)) {
                final DateAxis axisDate;

                // Customise the DomainAxis at index 0
                axisDate = (DateAxis) plot.getDomainAxis();

                // Showing the YYYY-MM-DD makes a very long label...
                axisDate.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));
            }

            // Now customise the data renderer to improve legend visibility
            ChartUIHelper.customisePlotRenderer(plot, 0);
        } else {
            final XYPlot plot;

            LOGGER.debug(debug, SOURCE + "Customise the Chart for Linear data");

            // Linear Mode

            // A default range suitable for display of dB
            ChartHelper.handleAutorangeForLinearMode(jFreeChart, channelselector, canAutorange(),
                    getLinearFixedMinY(), getLinearFixedMaxY(), debug);

            // Now customise the data renderer to improve legend visibility
            plot = jFreeChart.getXYPlot();
            ChartUIHelper.customisePlotRenderer(plot, 0);
        }
    } else {
        LOGGER.debug(debug, SOURCE + "Chart is NULL");
    }

    return (jFreeChart);
}

From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java

/**
 * Erzeuge eine Grafik fr die Nullzeitanzeige Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * //www  . ja v a  2  s  . co m
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 02.08.2012
 * @param diveList
 * @param thePlot
 */
private void makeNulltimeGraph(Vector<Integer[]> diveList, XYPlot thePlot) {
    XYDataset nullTimeDataSet;
    //
    lg.debug("create nulltime dataset");
    nullTimeDataSet = createXYDataset(LangStrings.getString("spx42LogGraphPanel.graph.nulltimeScalaTitle"),
            diveList, ProjectConst.UNITS_DEFAULT, 0, LogDerbyDatabaseUtil.NULLTIME);
    final XYLineAndShapeRenderer lineNullTimeRenderer = new XYLineAndShapeRenderer(true, true);
    final LogarithmicAxis nullTimeAxis = new LogarithmicAxis(
            LangStrings.getString("spx42LogGraphPanel.graph.nulltimeAxisTitle"));
    nullTimeAxis.setNumberFormatOverride(new DecimalFormat("#.###"));
    lineNullTimeRenderer.setSeriesPaint(0, new Color(ProjectConst.GRAPH_NULLTIME_ACOLOR));
    lineNullTimeRenderer.setSeriesShapesVisible(0, false);
    lineNullTimeRenderer.setDrawSeriesLineAsPath(true);
    nullTimeAxis.setAutoRange(false);
    nullTimeAxis.setRange(0.0D, 200.0D); // Lege die Nullzeit Axenreichweite auf ein bersichtliches Ma fest
    // nullTimeAxis.setAutoRangeIncludesZero( true );
    thePlot.setRangeAxis(GRAPH_NULLTIME, nullTimeAxis);
    thePlot.mapDatasetToRangeAxis(GRAPH_NULLTIME, GRAPH_NULLTIME);
    thePlot.setDataset(GRAPH_NULLTIME, nullTimeDataSet);
    thePlot.setRenderer(GRAPH_NULLTIME, lineNullTimeRenderer);
}