List of usage examples for org.jfree.data Range Range
public Range(double lower, double upper)
From source file:org.jfree.data.time.TimeSeriesCollection.java
/** * Returns the range of the values in this dataset's domain. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The range.//from w w w . ja va 2s. c om */ @Override public Range getDomainBounds(boolean includeInterval) { Range result = null; Iterator iterator = this.data.iterator(); while (iterator.hasNext()) { TimeSeries series = (TimeSeries) iterator.next(); int count = series.getItemCount(); if (count > 0) { RegularTimePeriod start = series.getTimePeriod(0); RegularTimePeriod end = series.getTimePeriod(count - 1); Range temp; if (!includeInterval) { temp = new Range(getX(start), getX(end)); } else { temp = new Range(start.getFirstMillisecond(this.workingCalendar), end.getLastMillisecond(this.workingCalendar)); } result = Range.combine(result, temp); } } return result; }
From source file:com.att.aro.main.GraphPanel.java
/** * Initializes a new instance of the GraphPanel class. *//*from w ww . ja v a2 s. com*/ public GraphPanel() { subplotMap.put(ChartPlotOptions.GPS, new GraphPanelPlotLabels(rb.getString("chart.gps"), createBarPlot(Color.gray), 1)); subplotMap.put(ChartPlotOptions.RADIO, new GraphPanelPlotLabels(rb.getString("chart.radio"), createRadioPlot(), 2)); subplotMap.put(ChartPlotOptions.BLUETOOTH, new GraphPanelPlotLabels(rb.getString("chart.bluetooth"), createBarPlot(Color.gray), 1)); subplotMap.put(ChartPlotOptions.CAMERA, new GraphPanelPlotLabels(rb.getString("chart.camera"), createBarPlot(Color.gray), 1)); subplotMap.put(ChartPlotOptions.SCREEN, new GraphPanelPlotLabels(rb.getString("chart.screen"), createBarPlot(new Color(34, 177, 76)), 1)); subplotMap.put(ChartPlotOptions.BATTERY, new GraphPanelPlotLabels(rb.getString("chart.battery"), createBatteryPlot(), 2)); subplotMap.put(ChartPlotOptions.WIFI, new GraphPanelPlotLabels(rb.getString("chart.wifi"), createBarPlot(Color.gray), 1)); subplotMap.put(ChartPlotOptions.NETWORK_TYPE, new GraphPanelPlotLabels(rb.getString("chart.networkType"), createBarPlot(Color.gray), 1)); subplotMap.put(ChartPlotOptions.THROUGHPUT, new GraphPanelPlotLabels(rb.getString("chart.throughput"), createThroughputPlot(), 2)); subplotMap.put(ChartPlotOptions.BURSTS, new GraphPanelPlotLabels(rb.getString("chart.bursts"), createBurstPlot(), 1)); subplotMap.put(ChartPlotOptions.USER_INPUT, new GraphPanelPlotLabels(rb.getString("chart.userInput"), createUserEventPlot(), 1)); subplotMap.put(ChartPlotOptions.RRC, new GraphPanelPlotLabels(rb.getString("chart.rrc"), createRrcPlot(), 1)); subplotMap.put(ChartPlotOptions.CPU, new GraphPanelPlotLabels(rb.getString("chart.cpu"), createCpuPlot(), 1)); this.pp = new PacketPlots(); subplotMap.put(ChartPlotOptions.UL_PACKETS, new GraphPanelPlotLabels(rb.getString("chart.ul"), pp.getUlPlot(), 1)); subplotMap.put(ChartPlotOptions.DL_PACKETS, new GraphPanelPlotLabels(rb.getString("chart.dl"), pp.getDlPlot(), 1)); this.axis = new NumberAxis(); this.axis.setStandardTickUnits(UNITS); this.axis.setRange(new Range(0, DEFAULT_TIMELINE)); this.axis.setLowerBound(0); this.axis.setAutoTickUnitSelection(true); this.axis.setTickMarkInsideLength(1); this.axis.setTickMarkOutsideLength(1); this.axis.setMinorTickMarksVisible(true); this.axis.setMinorTickMarkInsideLength(2f); this.axis.setMinorTickMarkOutsideLength(2f); this.axis.setTickMarkInsideLength(4f); this.axis.setTickMarkOutsideLength(4f); this.axisLabel = new JLabel(rb.getString("chart.timeline")); this.axisLabel.setHorizontalAlignment(SwingConstants.CENTER); this.setLayout(new BorderLayout()); this.setPreferredSize(new Dimension(200, 310)); this.add(getZoomSavePanel(), BorderLayout.EAST); this.add(getPane(), BorderLayout.CENTER); this.add(getLabelsPanel(), BorderLayout.WEST); setChartOptions(UserPreferences.getInstance().getChartPlotOptions()); }
From source file:org.proteosuite.FastScatterPlot.java
/** * Calculates the Y data range./* w ww .j a v a 2s .co m*/ * * @param data the data. * * @return The range. */ private Range calculateYDataRange(float[][] data) { Range result = null; if (data != null) { float lowest = Float.POSITIVE_INFINITY; float highest = Float.NEGATIVE_INFINITY; for (int i = 0; i < data[0].length; i++) { float v = data[1][i]; if (v < lowest) { lowest = v; } if (v > highest) { highest = v; } } if (lowest <= highest) { result = new Range(lowest, highest); } } return result; }
From source file:net.sf.mzmine.chartbasics.ChartLogics.java
/** * Apply an absolute offset to an axis and move it * /* w w w. j a v a2s . c om*/ * @param myChart * @param offset */ public static void offsetAxisAbsolute(ValueAxis axis, double offset) { Range range = new Range(axis.getLowerBound() + offset, axis.getUpperBound() + offset); setZoomAxis(axis, keepRangeWithinAutoBounds(axis, range)); }
From source file:org.jfree.data.statistics.DefaultStatisticalCategoryDataset.java
/** * Returns the bounds of the values in this dataset's y-values. * * @param includeInterval a flag that determines whether or not the * y-interval is taken into account. * * @return The range./* ww w . ja va2s . c om*/ */ @Override public Range getRangeBounds(boolean includeInterval) { double lower = getRangeLowerBound(includeInterval); double upper = getRangeUpperBound(includeInterval); if (Double.isNaN(lower) && Double.isNaN(upper)) { return null; } return new Range(lower, upper); }
From source file:net.sf.mzmine.chartbasics.ChartLogics.java
/** * Apply an relative offset to an axis and move it. LowerBound and UpperBound are defined by * {@link ValueAxis#getDefaultAutoRange()} * //from www . j a va 2 s. c o m * @param myChart * @param offset percentage */ public static void offsetAxis(ValueAxis axis, double offset) { double distance = (axis.getUpperBound() - axis.getLowerBound()) * offset; Range range = new Range(axis.getLowerBound() + distance, axis.getUpperBound() + distance); setZoomAxis(axis, keepRangeWithinAutoBounds(axis, range)); }
From source file:utilesChart.util.TimeSeriesCollection.java
/** * Returns the bounds for the y-values in the dataset. * * @param visibleSeriesKeys the visible series keys. * @param xRange the x-range (null not permitted). * @param includeInterval ignored.//from w ww . j a v a 2s.co m * * @return The bounds. * * @since 1.0.14 */ public Range getRangeBounds(List visibleSeriesKeys, Range xRange, boolean includeInterval) { Range result = null; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); TimeSeries series = getSeries(seriesKey); Range r = null; r = new Range(series.getMinY(), series.getMaxY()); // FIXME: Here we are ignoring the xRange result = Range.combine(result, r); } return result; }
From source file:net.sf.mzmine.chartbasics.HistogramChartFactory.java
public static Range getBounds(double[] data) { double min = Double.MAX_VALUE; double max = Double.NEGATIVE_INFINITY; for (double d : data) { if (d < min) min = d;/*from ww w .j a v a 2s . c om*/ if (d > max) max = d; } return new Range(min, max); }
From source file:org.jfree.data.time.TimeSeriesCollection.java
/** * Returns the bounds of the domain values for the specified series. * * @param visibleSeriesKeys a list of keys for the visible series. * @param includeInterval include the x-interval? * * @return A range./* w w w . ja v a 2 s . c om*/ * * @since 1.0.13 */ @Override public Range getDomainBounds(List visibleSeriesKeys, boolean includeInterval) { Range result = null; Iterator iterator = visibleSeriesKeys.iterator(); while (iterator.hasNext()) { Comparable seriesKey = (Comparable) iterator.next(); TimeSeries series = getSeries(seriesKey); int count = series.getItemCount(); if (count > 0) { RegularTimePeriod start = series.getTimePeriod(0); RegularTimePeriod end = series.getTimePeriod(count - 1); Range temp; if (!includeInterval) { temp = new Range(getX(start), getX(end)); } else { temp = new Range(start.getFirstMillisecond(this.workingCalendar), end.getLastMillisecond(this.workingCalendar)); } result = Range.combine(result, temp); } } return result; }
From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java
/** * Rescales the axis to ensure that all data is visible. *//*from ww w.j av a2s. c o m*/ public void autoAdjustLogRange() { Plot plot = getPlot(); if (plot == null) { return; // no plot, no data. } if (plot instanceof ValueAxisPlot) { ValueAxisPlot vap = (ValueAxisPlot) plot; double lower; Range r = vap.getDataRange(this); if (r == null) { //no real data present r = getDefaultAutoRange(); lower = r.getLowerBound(); //get lower bound value } else { //actual data is present lower = r.getLowerBound(); //get lower bound value if (this.strictValuesFlag && !this.allowNegativesFlag && lower <= 0.0) { //strict flag set, allow-negatives not set and values <= 0 throw new RuntimeException( "Values less than or equal to " + "zero not allowed with logarithmic axis"); } } //apply lower margin by decreasing lower bound: final double lowerMargin; if (lower > 0.0 && (lowerMargin = getLowerMargin()) > 0.0) { //lower bound and margin OK; get log10 of lower bound final double logLower = (Math.log(lower) / LOG10_VALUE); double logAbs; //get absolute value of log10 value if ((logAbs = Math.abs(logLower)) < 1.0) { logAbs = 1.0; //if less than 1.0 then make it 1.0 } //subtract out margin and get exponential value: lower = Math.pow(10, (logLower - (logAbs * lowerMargin))); } // skip values = 0 for log scale. if (lower < 10.0 && lower == 0) { double minPositive = Double.NaN; if (plot instanceof XYPlot) { XYDataset dataset = ((XYPlot) plot).getDataset(); if (dataset instanceof XYErrorDataset) { minPositive = ((XYErrorDataset) dataset).getMinPositiveValue(); } } if (!Double.isNaN(minPositive)) { lower = minPositive < SMALL_LOG_VALUE ? SMALL_LOG_VALUE : minPositive; final double margin; if (lower > 0.0 && (margin = getLowerMargin()) > 0.0) { //lower bound and margin OK; get log10 of lower bound final double logLower = (Math.log(lower) / LOG10_VALUE); double logAbs; //get absolute value of log10 value if ((logAbs = Math.abs(logLower)) < 1.0) { logAbs = 1.0; //if less than 1.0 then make it 1.0 } //subtract out margin and get exponential value: lower = Math.pow(10, (logLower - (logAbs * margin))); } } } //if flag then change to log version of lowest value // to make range begin at a 10^n value: if (this.autoRangeNextLogFlag) { lower = computeLogFloor(lower); } if (!this.allowNegativesFlag && lower >= 0.0 && lower < SMALL_LOG_VALUE) { //negatives not allowed and lower range bound is zero lower = r.getLowerBound(); //use data range bound instead } double upper = r.getUpperBound(); //apply upper margin by increasing upper bound: final double upperMargin; if (upper > 0.0 && (upperMargin = getUpperMargin()) > 0.0) { //upper bound and margin OK; get log10 of upper bound final double logUpper = (Math.log(upper) / LOG10_VALUE); double logAbs; //get absolute value of log10 value if ((logAbs = Math.abs(logUpper)) < 1.0) { logAbs = 1.0; //if less than 1.0 then make it 1.0 } //add in margin and get exponential value: upper = Math.pow(10, (logUpper + (logAbs * upperMargin))); } if (!this.allowNegativesFlag && upper < 1.0 && upper > 0.0 && lower > 0.0) { //negatives not allowed and upper bound between 0 & 1 //round up to nearest significant digit for bound: //get negative exponent: double expVal = Math.log(upper) / LOG10_VALUE; expVal = Math.ceil(-expVal + 0.001); //get positive exponent expVal = Math.pow(10, expVal); //create multiplier value //multiply, round up, and divide for bound value: upper = (expVal > 0.0) ? Math.ceil(upper * expVal) / expVal : Math.ceil(upper); } else if (upper < 1.0 && upper > 0.0) { double expVal = Math.log(upper) / LOG10_VALUE; expVal = Math.ceil(-expVal + 0.001); //get positive exponent expVal = Math.pow(10, expVal); //create multiplier value //multiply, round up, and divide for bound value: upper = (expVal > 0.0) ? Math.round(upper * expVal) / expVal : Math.ceil(upper); } else { //negatives allowed or upper bound not between 0 & 1 //if flag then change to log version of highest value to // make range begin at a 10^n value; else use nearest int upper = (this.autoRangeNextLogFlag) ? computeLogCeil(upper) : Math.ceil(upper); } // ensure the autorange is at least <minRange> in size... double minRange = getAutoRangeMinimumSize(); if (upper - lower < minRange) { upper = (upper + lower + minRange) / 2; lower = (upper + lower - minRange) / 2; //if autorange still below minimum then adjust by 1% // (can be needed when minRange is very small): if (upper - lower < minRange) { double absUpper = Math.abs(upper); //need to account for case where upper==0.0 double adjVal = (absUpper > SMALL_LOG_VALUE) ? absUpper / 100.0 : 0.01; upper = (upper + lower + adjVal) / 2; lower = (upper + lower - adjVal) / 2; } } // setRange(new Range(Math.min(lower, upper), Math.max(lower, upper)), false, false); if (lower <= upper) { setRange(new Range(lower, upper), false, false); } setupSmallLogFlag(); //setup flag based on bounds values } }