List of usage examples for org.jfree.data Range getUpperBound
public double getUpperBound()
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * Build and run a thermometer chart. JFreeChart thermometer charts have some * limitations. They always have a maximum of three ranges, and the colors of those * ranges seems to be fixed./* ww w . j a v a2 s. co m*/ */ protected JFreeChart createThermometerChart() throws JRException { JRThermometerPlot jrPlot = (JRThermometerPlot) getPlot(); // Create the plot that will hold the thermometer. ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset) getDataset()); ChartUtil chartUtil = ChartUtil.getInstance(getChartContext().getJasperReportsContext()); // setting localized range axis formatters chartPlot.getRangeAxis().setStandardTickUnits(chartUtil.createIntegerTickUnits(getLocale())); Range range = convertRange(jrPlot.getDataRange()); // Set the boundary of the thermomoter chartPlot.setLowerBound(range.getLowerBound()); chartPlot.setUpperBound(range.getUpperBound()); // Units can only be Fahrenheit, Celsius or none, so turn off for now. chartPlot.setUnits(ThermometerPlot.UNITS_NONE); // Set the color of the mercury. Only used when the value is outside of // any defined ranges. Color color = jrPlot.getMercuryColor(); if (color != null) { chartPlot.setMercuryPaint(color); chartPlot.setUseSubrangePaint(false); } // localizing the default format, can be overridden by display.getMask() chartPlot.setValueFormat(NumberFormat.getNumberInstance(getLocale())); // Set the formatting of the value display JRValueDisplay display = jrPlot.getValueDisplay(); if (display != null) { if (display.getColor() != null) { chartPlot.setValuePaint(display.getColor()); } if (display.getMask() != null) { chartPlot.setValueFormat( new DecimalFormat(display.getMask(), DecimalFormatSymbols.getInstance(getLocale()))); } if (display.getFont() != null) { // chartPlot.setValueFont(getFontUtil().getAwtFont(display.getFont())); } } // Set the location of where the value is displayed ValueLocationEnum valueLocation = jrPlot.getValueLocationValue(); switch (valueLocation) { case NONE: chartPlot.setValueLocation(ThermometerPlot.NONE); break; case LEFT: chartPlot.setValueLocation(ThermometerPlot.LEFT); break; case RIGHT: chartPlot.setValueLocation(ThermometerPlot.RIGHT); break; case BULB: default: chartPlot.setValueLocation(ThermometerPlot.BULB); break; } // Define the three ranges range = convertRange(jrPlot.getLowRange()); if (range != null) { chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound()); } range = convertRange(jrPlot.getMediumRange()); if (range != null) { chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound()); } range = convertRange(jrPlot.getHighRange()); if (range != null) { chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound()); } // Build a chart around this plot JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null, chartPlot, isShowLegend()); // Set the generic options configureChart(jfreeChart, getPlot()); return jfreeChart; }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
protected void updatePrecursorChart(boolean clear, graphZone gz) { XYSeriesCollection precursorDatasets = new XYSeriesCollection(); if (clear) {/*w w w .j a v a 2 s. c o m*/ transitionOnPlot = null; } else { if (transitionOnPlot.getGraphData() == null) //transitionOnPlot.setGraphData(makeParentSeries(transitionOnPlot)); ApplicationContext .infoMessage("Precursor data for '" + transitionOnPlot.toString() + "' wasn't initialized"); precursorDatasets.addSeries(transitionOnPlot.getGraphData()); } //Center daughter data on graph by finding the time associated //with the most data (a centroid or center of mass), centering //this time on the plot, and scaling to assure the extreme //timepoints are included /* double weightedAverageTime = getWeightedAverageDaughtersTime(makeDaughterCollection()); double extremeHalf = Math.max(weightedAverageTime-getMinRetentionTimeForPlot(transitionsOnPlot),getMaxRetentionTimeForPlot(transitionsOnPlot)-weightedAverageTime); double left = weightedAverageTime-extremeHalf; double right = weightedAverageTime+extremeHalf; */ Range r = null; if (transitionOnPlot != null) r = gz.getRange(transitionOnPlot); if (r == null) r = new Range(0, 100); createChartInPanel(precursorContainerPanel, precursorDatasets, r.getLowerBound(), r.getUpperBound(), null, whichGraph.Precursor); }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
protected void updateDaughterCharts(boolean clear, graphZone gz) { XYSeriesCollection daughterDatasets = new XYSeriesCollection(); if (clear) {//from www .j ava 2 s . com transitionOnPlot = null; } else { daughterDatasets = makeDaughterCollection(); } //Center daughter data on graph by finding the time associated //with the most data (a centroid or center of mass), centering //this time on the plot, and scaling to assure the extreme //timepoints are included /* double weightedAverageTime = getWeightedAverageDaughtersTime(daughterDatasets); double extremeHalf = Math.max(weightedAverageTime-getMinRetentionTimeForPlot(transitionOnPlot),getMaxRetentionTimeForPlot(transitionsOnPlot)-weightedAverageTime); double left = weightedAverageTime-extremeHalf; double right = weightedAverageTime+extremeHalf; */ Range r = null; if (transitionOnPlot != null) r = gz.getRange(transitionOnPlot); if (r == null) { r = new Range(transitionOnPlot.getMinTimeOfAllDaughters(), transitionOnPlot.getMaxTimeOfAllDaughters()); } createChartInPanel(daughterContainerPanel, daughterDatasets, r.getLowerBound(), r.getUpperBound(), getDrawingSupplierForPlot(transitionOnPlot), whichGraph.Daughter); }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
/** * *///www. j a va2s. c o m protected JFreeChart createDialChart() throws JRException { JRMeterPlot jrPlot = (JRMeterPlot) getPlot(); // get data for diagrams DialPlot dialPlot = new DialPlot(); dialPlot.setDataset((ValueDataset) getDataset()); StandardDialFrame dialFrame = new StandardDialFrame(); dialPlot.setDialFrame(dialFrame); DialBackground db = new DialBackground(jrPlot.getBackcolor()); dialPlot.setBackground(db); Range range = convertRange(jrPlot.getDataRange()); //double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound())); int tickCount = jrPlot.getTickCount() != null && jrPlot.getTickCount() > 1 ? jrPlot.getTickCount() : 7; StandardDialScale scale = new StandardDialScale(range.getLowerBound(), range.getUpperBound(), 225, -270, (range.getUpperBound() - range.getLowerBound()) / (tickCount - 1), 15); scale.setTickRadius(0.9); scale.setTickLabelOffset(0.16); JRFont tickLabelFont = jrPlot.getTickLabelFont(); Integer defaultBaseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_TICK_LABEL_FONT), tickLabelFont, defaultBaseFontSize); scale.setTickLabelFont(themeTickLabelFont); scale.setMajorTickStroke(new BasicStroke(1f)); scale.setMinorTickStroke(new BasicStroke(0.3f)); scale.setMajorTickPaint(jrPlot.getTickColor()); scale.setMinorTickPaint(jrPlot.getTickColor()); scale.setTickLabelsVisible(true); scale.setFirstTickLabelVisible(true); // localizing the default tick label formatter scale.setTickLabelFormatter(new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(getLocale()))); dialPlot.addScale(0, scale); List<JRMeterInterval> intervals = jrPlot.getIntervals(); if (intervals != null && intervals.size() > 0) { int size = Math.min(3, intervals.size()); int colorStep = 0; if (size > 0) colorStep = 255 / size; for (int i = 0; i < size; i++) { JRMeterInterval interval = intervals.get(i); Range intervalRange = convertRange(interval.getDataRange()); Color color = new Color(255 - colorStep * i, 0 + colorStep * i, 0); StandardDialRange dialRange = new StandardDialRange(intervalRange.getLowerBound(), intervalRange.getUpperBound(), interval.getBackgroundColor() == null ? color : interval.getBackgroundColor()); dialRange.setInnerRadius(0.41); dialRange.setOuterRadius(0.41); dialPlot.addLayer(dialRange); } } JRValueDisplay display = jrPlot.getValueDisplay(); String displayVisibility = display != null && getChart().hasProperties() ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_VALUE_DISPLAY_VISIBLE) : "false"; if (Boolean.parseBoolean(displayVisibility)) { DialValueIndicator dvi = new DialValueIndicator(0); dvi.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); // dvi.setFont(getFontUtil().getAwtFont(jrFont).deriveFont(10f).deriveFont(Font.BOLD)); dvi.setOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT); dvi.setPaint(Color.WHITE); String pattern = display.getMask() != null ? display.getMask() : "#,##0.####"; if (pattern != null) dvi.setNumberFormat(new DecimalFormat(pattern, DecimalFormatSymbols.getInstance(getLocale()))); dvi.setRadius(0.15); dvi.setValueAnchor(RectangleAnchor.CENTER); dvi.setTextAnchor(TextAnchor.CENTER); //dvi.setTemplateValue(Double.valueOf(getDialTickValue(dialPlot.getValue(0),dialUnitScale))); dialPlot.addLayer(dvi); } String label = getChart().hasProperties() ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL) : null; if (label != null) { JRFont displayFont = jrPlot.getValueDisplay().getFont(); Font themeDisplayFont = getFont( (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT), displayFont, defaultBaseFontSize); String[] textLines = label.split("\\n"); for (int i = 0; i < textLines.length; i++) { DialTextAnnotation dialAnnotation = new DialTextAnnotation(textLines[i]); dialAnnotation.setFont(themeDisplayFont); dialAnnotation.setPaint(jrPlot.getValueDisplay().getColor()); dialAnnotation.setRadius(Math.sin(Math.PI / 4.0) + i / 10.0); dialAnnotation.setAnchor(TextAnchor.CENTER); dialPlot.addLayer(dialAnnotation); } } DialPointer needle = new DialPointer.Pointer(); needle.setVisible(true); needle.setRadius(0.91); dialPlot.addLayer(needle); DialCap cap = new DialCap(); cap.setRadius(0.05); cap.setFillPaint(Color.DARK_GRAY); cap.setOutlinePaint(Color.GRAY); cap.setOutlineStroke(new BasicStroke(0.5f)); dialPlot.setCap(cap); JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null, dialPlot, isShowLegend()); // Set all the generic options configureChart(jfreeChart, getPlot()); return jfreeChart; }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
protected void createChartInPanelDaughterTasksOnly(XYPlot xyp) { XYSeries coloredDataset = transitionOnPlot.getCurrentDaughter().getGraphData(); Paint daughterColor = Utils.paleColor((Color) transitionOnPlot.getCurrentDaughter().getGraphColor()); ArrayList<XYLineAnnotation> coloredDaughters = new ArrayList<XYLineAnnotation>(); //Trace calculated elution curves over data spikes if (transitionOnPlot.getElutionCurves() != null && !transitionOnPlot.getElutionCurves().isEmpty()) { MRMDaughter curDaughter = transitionOnPlot.getCurrentDaughter(); ElutionCurveStrategy ecs = transitionOnPlot.getElutionCurves().get(curDaughter); //Is current daughter rejected? Boolean accepted = (Boolean) ((PeaksTableModel) peaksTable.getModel()).data[curDaughter .getElutionDataTableRow()][peaksData.Accept.colno]; if (accepted == null || !accepted) { xyp.setBackgroundPaint(new Color(255, 230, 230)); }// ww w . j a v a 2 s . co m List<ElutionCurve> ecl = ecs.getDaughterCurves(); if (ecl != null) { for (ElutionCurve e : ecl) { List<Line2D.Double> ll2dd = e.getSegments(); for (Line2D.Double l2dd : ll2dd) { xyp.addAnnotation(Utils.line2Annotation(l2dd, new BasicStroke(2.0f), ecs.isBestDaughterCurve(e) ? Color.BLACK : Color.LIGHT_GRAY)); } } } } // If there is a valid "current" daughter draw the spikes in the daughter's color // as annotations (sensu JFree) if (coloredDataset != null) { int nOfPoints = coloredDataset.getItemCount(); for (int i = 0; i < (nOfPoints - 1); i++) { XYDataItem p1 = coloredDataset.getDataItem(i); XYDataItem p2 = coloredDataset.getDataItem(i + 1); coloredDaughters.add(new XYLineAnnotation(p1.getX().doubleValue(), p1.getY().doubleValue(), p2.getX().doubleValue(), p2.getY().doubleValue(), new BasicStroke(1.5f), transitionOnPlot.getCurrentDaughter().getGraphColor()) // new XYLineAnnotation(p1.getX().doubleValue(),p1.getY().doubleValue(),p2.getX().doubleValue(),p2.getY().doubleValue(),new BasicStroke(1.5f),daughterColor) ); } } if (_traceAllFragments) { for (MRMDaughter d : transitionOnPlot.getDaughters().values()) { if (d == transitionOnPlot.getCurrentDaughter()) continue; XYSeries curXYSeries = d.getContinDaughterData(); if (curXYSeries == null || curXYSeries.getItemCount() == 0) continue; if (d.getBestElutionCurve() == null) continue; int nOfPoints = curXYSeries.getItemCount(); for (int i = 0; i < (nOfPoints - 1); i++) { XYDataItem p1 = curXYSeries.getDataItem(i); XYDataItem p2 = curXYSeries.getDataItem(i + 1); coloredDaughters.add( // new XYLineAnnotation(p1.getX().doubleValue(),p1.getY().doubleValue(),p2.getX().doubleValue(),p2.getY().doubleValue(),new BasicStroke(1f),Utils.paleColor((Color)d.getGraphColor())) new XYLineAnnotation(p1.getX().doubleValue(), p1.getY().doubleValue(), p2.getX().doubleValue(), p2.getY().doubleValue(), new BasicStroke(1f), d.getGraphColor())); } } } if (coloredDaughters != null) { for (XYLineAnnotation xyla : coloredDaughters) { xyp.addAnnotation(xyla); } } coloredDaughters.clear(); //Display L or H label in upper left hand corner Range xRange = xyp.getDomainAxis().getRange(); Range yRange = xyp.getRangeAxis().getRange(); XYTextAnnotation lab = new XYTextAnnotation( (String) ((PeaksTableModel) peaksTable.getModel()).data[transitionOnPlot.getCurrentDaughter() .getElutionDataTableRow()][peaksData.Label.colno], xRange.getUpperBound() - (0.05 * xRange.getLength()), yRange.getUpperBound() - (0.05 * yRange.getLength())); lab.setFont(lab.getFont().deriveFont(Font.BOLD, 40.0F)); xyp.addAnnotation(lab); XYTextAnnotation midMarker = new XYTextAnnotation("\u25BC", ((MRMTransition) transitionOnPlot).getCalcXatMaxYAllDaughters(), ((MRMTransition) transitionOnPlot).getCalcMaxYAllDaughters()); midMarker.setPaint(Color.RED); midMarker.setFont(midMarker.getFont().deriveFont(Font.BOLD, 20F)); XYTextAnnotation midMarkerOutline = new XYTextAnnotation("\u25BC", ((MRMTransition) transitionOnPlot).getCalcXatMaxYAllDaughters(), ((MRMTransition) transitionOnPlot).getCalcMaxYAllDaughters()); midMarkerOutline.setPaint(Color.BLACK); midMarkerOutline.setFont(midMarker.getFont().deriveFont(Font.BOLD, 23F)); xyp.addAnnotation(midMarkerOutline); xyp.addAnnotation(midMarker); }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * */// ww w . j a v a2s.c o m protected JFreeChart createDialChart() throws JRException { JRMeterPlot jrPlot = (JRMeterPlot) getPlot(); // get data for diagrams DialPlot dialPlot = new DialPlot(); dialPlot.setDataset((ValueDataset) getDataset()); StandardDialFrame dialFrame = new StandardDialFrame(); dialPlot.setDialFrame(dialFrame); DialBackground db = new DialBackground(jrPlot.getBackcolor()); dialPlot.setBackground(db); Range range = convertRange(jrPlot.getDataRange()); //double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound())); int tickCount = jrPlot.getTickCount() != null && jrPlot.getTickCount() > 1 ? jrPlot.getTickCount() : 7; StandardDialScale scale = new StandardDialScale(range.getLowerBound(), range.getUpperBound(), 225, -270, (range.getUpperBound() - range.getLowerBound()) / (tickCount - 1), 15); scale.setTickRadius(0.9); scale.setTickLabelOffset(0.16); JRBaseFont font = new JRBaseFont(); FontUtil.copyNonNullOwnProperties(getPlotSettings().getTickLabelFont(), font); FontUtil.copyNonNullOwnProperties(jrPlot.getTickLabelFont(), font); font = new JRBaseFont(getChart(), font); scale.setTickLabelFont(getFontUtil().getAwtFont(font, getLocale())); scale.setMajorTickStroke(new BasicStroke(1f)); scale.setMinorTickStroke(new BasicStroke(0.3f)); scale.setMajorTickPaint(jrPlot.getTickColor()); scale.setMinorTickPaint(jrPlot.getTickColor()); scale.setTickLabelsVisible(true); scale.setFirstTickLabelVisible(true); // localizing the default tick label formatter scale.setTickLabelFormatter(new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(getLocale()))); dialPlot.addScale(0, scale); List<JRMeterInterval> intervals = jrPlot.getIntervals(); if (intervals != null && intervals.size() > 0) { int size = Math.min(3, intervals.size()); int colorStep = 0; if (size > 0) colorStep = 255 / size; for (int i = 0; i < size; i++) { JRMeterInterval interval = intervals.get(i); Range intervalRange = convertRange(interval.getDataRange()); Color color = new Color(255 - colorStep * i, 0 + colorStep * i, 0); StandardDialRange dialRange = new StandardDialRange(intervalRange.getLowerBound(), intervalRange.getUpperBound(), interval.getBackgroundColor() == null ? color : interval.getBackgroundColor()); dialRange.setInnerRadius(0.41); dialRange.setOuterRadius(0.41); dialPlot.addLayer(dialRange); } } JRValueDisplay display = jrPlot.getValueDisplay(); String displayVisibility = display != null && getChart().hasProperties() ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_VALUE_DISPLAY_VISIBLE) : "false"; if (Boolean.parseBoolean(displayVisibility)) { DialValueIndicator dvi = new DialValueIndicator(0); dvi.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); // dvi.setFont(getFontUtil().getAwtFont(jrFont).deriveFont(10f).deriveFont(Font.BOLD)); dvi.setOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT); dvi.setPaint(Color.WHITE); String pattern = display.getMask() != null ? display.getMask() : "#,##0.####"; if (pattern != null) dvi.setNumberFormat(new DecimalFormat(pattern, DecimalFormatSymbols.getInstance(getLocale()))); dvi.setRadius(0.15); dvi.setValueAnchor(RectangleAnchor.CENTER); dvi.setTextAnchor(TextAnchor.CENTER); //dvi.setTemplateValue(Double.valueOf(getDialTickValue(dialPlot.getValue(0),dialUnitScale))); dialPlot.addLayer(dvi); } String label = getChart().hasProperties() ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL) : null; if (label != null) { JRFont displayFont = new JRBaseFont(); FontUtil.copyNonNullOwnProperties(getPlotSettings().getDisplayFont(), displayFont); FontUtil.copyNonNullOwnProperties(jrPlot.getValueDisplay().getFont(), displayFont); displayFont = new JRBaseFont(getChart(), displayFont); Font themeDisplayFont = getFontUtil().getAwtFont(displayFont, getLocale()); String[] textLines = label.split("\\n"); for (int i = 0; i < textLines.length; i++) { DialTextAnnotation dialAnnotation = new DialTextAnnotation(textLines[i]); dialAnnotation.setFont(themeDisplayFont); dialAnnotation.setPaint(jrPlot.getValueDisplay().getColor()); dialAnnotation.setRadius(Math.sin(Math.PI / 4.0) + i / 10.0); dialAnnotation.setAnchor(TextAnchor.CENTER); dialPlot.addLayer(dialAnnotation); } } DialPointer needle = new DialPointer.Pointer(); needle.setVisible(true); needle.setRadius(0.91); dialPlot.addLayer(needle); DialCap cap = new DialCap(); cap.setRadius(0.05); cap.setFillPaint(Color.DARK_GRAY); cap.setOutlinePaint(Color.GRAY); cap.setOutlineStroke(new BasicStroke(0.5f)); dialPlot.setCap(cap); JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null, dialPlot, isShowLegend()); // Set all the generic options configureChart(jfreeChart, getPlot()); return jfreeChart; }
From source file:gda.plots.SimplePlot.java
private void setDependentXAxisRange() { Range r = linearXAxis.getRange(); Range newR = new Range(r.getLowerBound() * emForXAxis + seeForXAxis, r.getUpperBound() * emForXAxis + seeForXAxis); dependentXAxis.setRange(newR);//w w w . j a va 2 s.c o m }
From source file:gda.plots.SimplePlot.java
private void setDependentYAxisRange() { Range r = linearYAxis.getRange(); Range newR = new Range(r.getLowerBound() * emForYAxis + seeForYAxis, r.getUpperBound() * emForYAxis + seeForYAxis); dependentYAxis.setRange(newR);//from w ww . j a v a 2 s . co m }
From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java
/** * Rescales the axis to ensure that all data is visible. *///from ww w.j a va 2 s . co 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 } }