List of usage examples for org.jfree.chart.axis LogarithmicAxis setRange
public void setRange(double lower, double upper)
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 w w. jav a 2 s.c o 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:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.GOESChartUIComponent.java
/*********************************************************************************************** * Customise the XYPlot of a new chart, e.g. for fixed range axes. * * @param datasettype/* w w w . j ava 2 s . c o 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 JFreeChart jFreeChart; // A plain Chart is an XYPlot // with a DateAxis for the x-axis (index 0) and a NumberAxis for the y-axis (index 0). // The default renderer is an XYLineAndShapeRenderer jFreeChart = ChartHelper.createChart(primarydataset, ObservatoryInstrumentHelper.getCurrentObservatoryTimeZone(REGISTRY.getFramework(), getDAO(), debug), getMetadata(), getChannelCount(), hasTemperatureChannel(), updatetype, displaylimit, channelselector, debug); // Customise the Chart for GOES data // Channels 0 & 1 are Data on a LogarithmicAxis, // Channel 2 is Ratio on a NumberAxis if (jFreeChart != null) { final String strLabelFlux; final String strLabelRatio; final XYPlot plot; final LogarithmicAxis axisFlux; final DateAxis axisDate; // The set of Metadata available should include the Instrument // and any items from the current observation strLabelFlux = MetadataHelper.getMetadataValueByKey(getMetadata(), MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_Y.getKey() + MetadataDictionary.SUFFIX_SERIES_ZERO); strLabelRatio = MetadataHelper.getMetadataValueByKey(getMetadata(), MetadataDictionary.KEY_OBSERVATION_AXIS_LABEL_Y.getKey() + MetadataDictionary.SUFFIX_SERIES_ONE); plot = jFreeChart.getXYPlot(); //---------------------------------------------------------------------------------- // Replace the RangeAxis at index 0 NumberAxis with a LogarithmicAxis // The RangeAxis at index 0 is the LogarithmicAxis, to be used by Channels 0 & 1 (Data) axisFlux = new LogarithmicAxis(strLabelFlux); axisFlux.setRange(1.0E-09, 1.0E-02); axisFlux.setAllowNegativesFlag(false); axisFlux.setLog10TickLabelsFlag(true); plot.setRangeAxis(0, axisFlux); // Map the dataset to the axis plot.setDataset(INDEX_FLUX, primarydataset); plot.mapDatasetToRangeAxis(0, 0); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); //---------------------------------------------------------------------------------- // Customise the DomainAxis at index 0 axisDate = (DateAxis) plot.getDomainAxis(); // Showing the YYYY-MM-DD makes a very long label... // ToDo Consider ThreadLocal axisDate.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); // Now customise the Flux renderer to improve legend visibility // Use the same colours as on http://www.swpc.noaa.gov/ // blue=0.5 - 4.0A red=1.0 - 8.0A ChartUIHelper.customisePlotRenderer(plot, INDEX_FLUX); //---------------------------------------------------------------------------------- // Set the RangeAxis at index 1 to a new NumberAxis, to be used by Channel 2 (Ratio) if ((secondarydatasets != null) && (secondarydatasets.size() == 1)) { final NumberAxis axisRatio; final XYLineAndShapeRenderer rendererRatio; axisRatio = new NumberAxis(strLabelRatio); plot.setRangeAxis(1, axisRatio); // The RangeAxis at index 1 is the NumberAxis, to be used by Channel 2 plot.setDataset(INDEX_RATIO, secondarydatasets.get(0)); plot.mapDatasetToRangeAxis(1, 1); plot.setRangeAxisLocation(1, AxisLocation.TOP_OR_RIGHT); rendererRatio = new XYLineAndShapeRenderer(); rendererRatio.setLinesVisible(true); rendererRatio.setShapesVisible(false); // Channel 2 is Ratio rendererRatio.setSeriesPaint(0, ChartUIHelper.getStandardColour(2).getColor()); rendererRatio.setLegendLine(SHAPE_LEGEND); plot.setRenderer(INDEX_RATIO, rendererRatio); //ChartHelper.customisePlotRenderer(plot, INDEX_RATIO); } } 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 * //from w ww. j a va 2s . c o 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); }