List of usage examples for org.jfree.data Range getLowerBound
public double getLowerBound()
From source file:org.tsho.dmc2.core.chart.LyapunovRenderer.java
public void initializeVsTime(VariableDoubles parameters, VariableDoubles initialValues, Range timeRange, double stepSize) { this.parameters.putAll(parameters); this.initialPoint.putAll(initialValues); this.lower = (int) timeRange.getLowerBound(); this.upper = (int) timeRange.getUpperBound(); this.stepSize = stepSize; this.type = TYPE_VSTIME; }
From source file:de.bund.bfr.knime.pmmlite.views.chart.ChartCreator.java
public ChartCreator(Map<String, Plotable> plotables, Map<String, String> legend) { this.plotables = plotables; this.legend = legend; colors = new LinkedHashMap<>(); shapes = new LinkedHashMap<>(); colorLists = new LinkedHashMap<>(); shapeLists = new LinkedHashMap<>(); chartPanel = new ChartPanel(new JFreeChart(new XYPlot())) { private static final long serialVersionUID = 1L; @Override//from w w w . ja va2s.c o m public void mouseReleased(MouseEvent e) { ValueAxis domainAxis = ((XYPlot) getChart().getPlot()).getDomainAxis(); ValueAxis rangeAxis = ((XYPlot) getChart().getPlot()).getRangeAxis(); Range xRange1 = domainAxis.getRange(); Range yRange1 = rangeAxis.getRange(); super.mouseReleased(e); Range xRange2 = domainAxis.getRange(); Range yRange2 = rangeAxis.getRange(); if (!xRange1.equals(xRange2) || !yRange1.equals(yRange2)) { minX = xRange2.getLowerBound(); maxX = xRange2.getUpperBound(); minY = yRange2.getLowerBound(); maxY = yRange2.getUpperBound(); fireZoomChanged(); } } }; chartPanel.getPopupMenu().removeAll(); setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); }
From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java
/** * *//* ww w .j ava 2 s . c o m*/ protected JFreeChart createThermometerChart() throws JRException { JRThermometerPlot jrPlot = (JRThermometerPlot) getPlot(); // Create the plot that will hold the thermometer. ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset) getDataset()); // Build a chart around this plot JFreeChart jfreeChart = new JFreeChart(chartPlot); // Set the generic options configureChart(jfreeChart, getPlot()); jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); jfreeChart.setBorderVisible(false); Range range = convertRange(jrPlot.getDataRange()); if (range != null) { // Set the boundary of the thermomoter chartPlot.setLowerBound(range.getLowerBound()); chartPlot.setUpperBound(range.getUpperBound()); } chartPlot.setGap(0); // 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. List seriesPaints = (List) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS); Paint paint = (jrPlot.getMercuryColor() != null ? (Paint) jrPlot.getMercuryColor() : (Paint) seriesPaints.get(0)); chartPlot.setMercuryPaint(paint); chartPlot.setThermometerPaint(THERMOMETER_COLOR); chartPlot.setThermometerStroke(new BasicStroke(2f)); chartPlot.setOutlineVisible(false); chartPlot.setValueFont(chartPlot.getValueFont().deriveFont(Font.BOLD)); // 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())); } if (display.getFont() != null) { // chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()).deriveFont(Font.BOLD)); } } // Set the location of where the value is displayed // 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()); } return jfreeChart; }
From source file:org.tsho.dmc2.core.chart.LyapunovRenderer.java
public void initializeVsParameter(VariableDoubles parameters, VariableDoubles initialValues, String parLabel, Range parameterRange, int iterations) { this.parameters.putAll(parameters); this.initialPoint.putAll(initialValues); this.firstParLabel = parLabel; this.lower = parameterRange.getLowerBound(); this.upper = parameterRange.getUpperBound(); this.iterations = iterations; this.type = TYPE_VSPAR; }
From source file:org.gumtree.vis.plot1d.KLogarithmicAxis.java
@Override protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { // TODO Auto-generated method stub List ticks = new java.util.ArrayList(); Range range = getRange(); //get lower bound value: double lowerBoundVal = range.getLowerBound(); //if small log values and lower bound value too small // then set to a small value (don't allow <= 0): if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) { lowerBoundVal = SMALL_LOG_VALUE; }/*from w w w .j a v a 2 s . com*/ //get upper bound value double upperBoundVal = range.getUpperBound(); //get log10 version of lower bound and round to integer: int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal)); //get log10 version of upper bound and round to integer: int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal)); // if (iBegCount == iEndCount && iBegCount >= 0 if (iBegCount == iEndCount && Math.pow(10, iBegCount) > lowerBoundVal) { //only 1 power of 10 value, it's > 0 and its resulting // tick value will be larger than lower bound of data --iBegCount; //decrement to generate more ticks } int numberOfGrids = 0; int numberOfTicks = 0; NumberTick lastTick = null; double currentTickValue; String tickLabel; boolean zeroTickFlag = false; for (int i = iBegCount; i <= iEndCount; i++) { //for each power of 10 value; create ten ticks for (int j = 0; j < 10; ++j) { //for each tick to be displayed if (this.smallLogFlag) { //small log values in use; create numeric value for tick currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j); if (this.expTickLabelsFlag || (i < 0 && currentTickValue > 0.0 && currentTickValue < 1.0)) { //showing "1e#"-style ticks or negative exponent // generating tick value between 0 & 1; show fewer if (j == 0 || (i > -4 && (j < 2 || j == 4)) || currentTickValue >= upperBoundVal) { //first tick of series, or not too small a value and // one of first 3 ticks, or last tick to be displayed // set exact number of fractional digits to be shown // (no effect if showing "1e#"-style ticks): this.numberFormatterObj.setMaximumFractionDigits(-i); //create tick label (force use of fmt obj): tickLabel = makeTickLabel(currentTickValue, true); } else { //no tick label to be shown // tickLabel = ""; if (numberOfTicks == 0) { tickLabel = makeTickLabel(currentTickValue, true); } else tickLabel = ""; } } else { //tick value not between 0 & 1 //show tick label if it's the first or last in // the set, or if it's 1-5; beyond that show // fewer as the values get larger: tickLabel = (j < 1 || (i < 1 && j < 5) || (j < 4 - i) || currentTickValue >= upperBoundVal || numberOfTicks == 0) ? makeTickLabel(currentTickValue) : ""; } } else { //not small log values in use; allow for values <= 0 if (zeroTickFlag) { //if did zero tick last iter then --j; //decrement to do 1.0 tick now } //calculate power-of-ten value for tick: currentTickValue = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j) : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j)); if (!zeroTickFlag) { // did not do zero tick last iteration if (Math.abs(currentTickValue - 1.0) < 0.0001 && lowerBoundVal <= 0.0 && upperBoundVal >= 0.0) { //tick value is 1.0 and 0.0 is within data range currentTickValue = 0.0; //set tick value to zero zeroTickFlag = true; //indicate zero tick } } else { //did zero tick last iteration zeroTickFlag = false; //clear flag } //create tick label string: //show tick label if "1e#"-style and it's one // of the first two, if it's the first or last // in the set, or if it's 1-5; beyond that // show fewer as the values get larger: tickLabel = ((this.expTickLabelsFlag && j < 2) || j < 1 || (i < 1 && j < 5) || (j < 4 - i) || currentTickValue >= upperBoundVal || numberOfTicks == 0) ? makeTickLabel(currentTickValue) : ""; } if (currentTickValue > upperBoundVal) { if (lastTick != null) { String lastTickText = lastTick.getText(); if (lastTickText == null || lastTickText.trim().length() == 0) { ticks.remove(lastTick); ticks.add(new NumberTick(lastTick.getValue(), createTickLabel(lastTick.getValue(), i - 1), lastTick.getTextAnchor(), lastTick.getRotationAnchor(), lastTick.getAngle())); } } if (numberOfTicks < 4) { return getAllTicksHorizontal(g2, dataArea, edge); } return ticks; // if past highest data value then exit // method } if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) { //tick value not below lowest data value TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } lastTick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(lastTick); if (tickLabel != null && tickLabel.trim().length() > 0) numberOfTicks++; numberOfGrids++; } } } if (numberOfTicks < 4) { return getAllTicksHorizontal(g2, dataArea, edge); } return ticks; }
From source file:org.tsho.dmc2.core.chart.LyapunovRenderer.java
public void initializeVsParameter(VariableDoubles parameters, VariableDoubles initialValues, String parLabel, Range parameterRange, double timePeriod, double stepSize) { this.parameters.putAll(parameters); this.initialPoint.putAll(initialValues); this.firstParLabel = parLabel; this.lower = parameterRange.getLowerBound(); this.upper = parameterRange.getUpperBound(); this.timePeriod = timePeriod; this.stepSize = stepSize; this.type = TYPE_VSPAR; }
From source file:com.rapidminer.gui.new_plotter.gui.dialog.ManageZoomDialog.java
/** * Updates the x and y axes range values. *//* www . ja v a2 s . co m*/ private void updateValueRange() { PlotConfiguration plotConfig = engine.getPlotInstance().getMasterPlotConfiguration(); Plot plot = engine.getChartPanel().getChart().getPlot(); int index = rangeAxisSelectionCombobox.getSelectedIndex(); if (index == -1) { index = 0; } // should be always true.. if (plotConfig.getRangeAxisConfigs().size() > index) { RangeAxisConfig config = plotConfig.getRangeAxisConfigs().get(index); double valueLowerBound; double valueUpperBound; if (plot instanceof XYPlot) { ValueAxis rangeAxis = ((XYPlot) plot).getRangeAxis(index); if (rangeAxis != null) { // this is the actual visible axis Range range = rangeAxis.getRange(); valueLowerBound = range.getLowerBound(); valueUpperBound = range.getUpperBound(); } else { valueLowerBound = engine.getPlotInstance().getPlotData().getRangeAxisData(config) .getLowerViewBound(); valueUpperBound = engine.getPlotInstance().getPlotData().getRangeAxisData(config) .getUpperViewBound(); } } else if (plot instanceof CategoryPlot) { ValueAxis rangeAxis = ((CategoryPlot) plot).getRangeAxis(index); if (rangeAxis != null) { Range range = rangeAxis.getRange(); valueLowerBound = range.getLowerBound(); valueUpperBound = range.getUpperBound(); } else { valueLowerBound = engine.getPlotInstance().getPlotData().getRangeAxisData(config) .getLowerViewBound(); valueUpperBound = engine.getPlotInstance().getPlotData().getRangeAxisData(config) .getUpperViewBound(); } } else { // data bounds, a bit smaller than the visible axis valueLowerBound = engine.getPlotInstance().getPlotData().getRangeAxisData(config) .getLowerViewBound(); valueUpperBound = engine.getPlotInstance().getPlotData().getRangeAxisData(config) .getUpperViewBound(); } valueRangeLowerBoundField.setText(String.valueOf(valueLowerBound)); valueRangeUpperBoundField.setText(String.valueOf(valueUpperBound)); } }
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java
private void recalcScrollBar(Plot plot) { if (plot instanceof XYPlot) { XYPlot hvp = (XYPlot) plot;/*from ww w . j a v a2s . com*/ ValueAxis axis = hvp.getDomainAxis(); axis.setLowerMargin(0); axis.setUpperMargin(0); Range rng = axis.getRange(); BoundedRangeModel scrollBarModel = this.chartScrollBar.getModel(); int len = scrollBarModel.getMaximum() - scrollBarModel.getMinimum(); if (rng.getLength() > 0) { scrollFactor = len / rng.getLength(); } double dblow = rng.getLowerBound(); int ilow = (int) (dblow * scrollFactor); scrollBarModel.setMinimum(ilow); int val = ilow; scrollBarModel.setValue(val); double dbup = rng.getUpperBound(); int iup = (int) (dbup * scrollFactor); scrollBarModel.setMaximum(iup); int ext = iup - ilow; scrollBarModel.setExtent(ext); scrollBarModel.addChangeListener(this); } }
From source file:org.gumtree.vis.plot1d.KLogarithmicAxis.java
private List getAllTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { // TODO Auto-generated method stub List ticks = new java.util.ArrayList(); Range range = getRange(); //get lower bound value: double lowerBoundVal = range.getLowerBound(); //if small log values and lower bound value too small // then set to a small value (don't allow <= 0): if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) { lowerBoundVal = SMALL_LOG_VALUE; }//from ww w . j av a 2 s .c o m //get upper bound value double upperBoundVal = range.getUpperBound(); //get log10 version of lower bound and round to integer: int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal)); //get log10 version of upper bound and round to integer: int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal)); // if (iBegCount == iEndCount && iBegCount >= 0 if (iBegCount == iEndCount && Math.pow(10, iBegCount) > lowerBoundVal) { //only 1 power of 10 value, it's > 0 and its resulting // tick value will be larger than lower bound of data --iBegCount; //decrement to generate more ticks } int numberOfGrids = 0; int numberOfTicks = 0; NumberTick lastTick = null; double currentTickValue; String tickLabel; boolean zeroTickFlag = false; for (int i = iBegCount; i <= iEndCount; i++) { //for each power of 10 value; create ten ticks for (int j = 0; j < 10; ++j) { //for each tick to be displayed if (this.smallLogFlag) { //small log values in use; create numeric value for tick currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j); if (this.expTickLabelsFlag || (i < 0 && currentTickValue > 0.0 && currentTickValue < 1.0)) { //showing "1e#"-style ticks or negative exponent // generating tick value between 0 & 1; show fewer //first tick of series, or not too small a value and // one of first 3 ticks, or last tick to be displayed // set exact number of fractional digits to be shown // (no effect if showing "1e#"-style ticks): this.numberFormatterObj.setMaximumFractionDigits(-i); //create tick label (force use of fmt obj): tickLabel = makeTickLabel(currentTickValue, true); } else { //tick value not between 0 & 1 //show tick label if it's the first or last in // the set, or if it's 1-5; beyond that show // fewer as the values get larger: tickLabel = makeTickLabel(currentTickValue); } } else { //not small log values in use; allow for values <= 0 if (zeroTickFlag) { //if did zero tick last iter then --j; //decrement to do 1.0 tick now } //calculate power-of-ten value for tick: currentTickValue = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j) : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j)); if (!zeroTickFlag) { // did not do zero tick last iteration if (Math.abs(currentTickValue - 1.0) < 0.0001 && lowerBoundVal <= 0.0 && upperBoundVal >= 0.0) { //tick value is 1.0 and 0.0 is within data range currentTickValue = 0.0; //set tick value to zero zeroTickFlag = true; //indicate zero tick } } else { //did zero tick last iteration zeroTickFlag = false; //clear flag } //create tick label string: //show tick label if "1e#"-style and it's one // of the first two, if it's the first or last // in the set, or if it's 1-5; beyond that // show fewer as the values get larger: tickLabel = makeTickLabel(currentTickValue); } if (currentTickValue > upperBoundVal) { if (lastTick != null) { String lastTickText = lastTick.getText(); if (lastTickText == null || lastTickText.trim().length() == 0) { ticks.remove(lastTick); ticks.add(new NumberTick(lastTick.getValue(), createTickLabel(lastTick.getValue(), i - 1), lastTick.getTextAnchor(), lastTick.getRotationAnchor(), lastTick.getAngle())); } } if (ticks.size() < 2) { double definition = Math.abs(lowerBoundVal - upperBoundVal); int numberOfDigits = 0; if (definition >= 1) numberOfDigits = 0; else { numberOfDigits = (int) Math.ceil((-Math.log10(definition))); } if (definition < 2 * Math.pow(10, -numberOfDigits)) { numberOfDigits++; } double tickVal; tickVal = lowerBoundVal; if (definition > 1) tickLabel = Long.toString((long) Math.rint(tickVal)); else tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString(); ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER, TextAnchor.TOP_CENTER, 0.0)); tickVal = upperBoundVal; if (definition > 1) tickLabel = Long.toString((long) Math.rint(tickVal)); else tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString(); ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER, TextAnchor.TOP_CENTER, 0.0)); } return ticks; // if past highest data value then exit // method } if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) { //tick value not below lowest data value TextAnchor anchor = null; TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } lastTick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(lastTick); if (tickLabel != null && tickLabel.trim().length() > 0) numberOfTicks++; numberOfGrids++; } } } if (ticks.size() < 2) { double definition = Math.abs(lowerBoundVal - upperBoundVal); int numberOfDigits = 0; if (definition >= 1) numberOfDigits = 0; else { numberOfDigits = (int) Math.ceil((-Math.log10(definition))); } double tickVal; tickVal = lowerBoundVal; if (definition > 1) tickLabel = Long.toString((long) Math.rint(tickVal)); else tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString(); ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER, TextAnchor.TOP_CENTER, 0.0)); tickVal = upperBoundVal; if (definition > 1) tickLabel = Long.toString((long) Math.rint(tickVal)); else tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString(); ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER, TextAnchor.TOP_CENTER, 0.0)); } return ticks; }
From source file:com.rapidminer.gui.new_plotter.gui.dialog.ManageZoomDialog.java
/** * Sets the current {@link PlotConfiguration} for this dialog. * //from ww w . jav a2 s. c om * @param plotConfig */ private void setPlotConfiguration(PlotConfiguration plotConfig) { if (plotConfig == null) { throw new IllegalArgumentException("plotConfig must not be null!"); } Vector<RangeAxisConfig> rangeConfigsVector = new Vector<RangeAxisConfig>(); String selectedItem = String.valueOf(rangeAxisSelectionCombobox.getSelectedItem()); for (RangeAxisConfig config : plotConfig.getRangeAxisConfigs()) { rangeConfigsVector.add(config); } rangeAxisSelectionCombobox.setModel(new DefaultComboBoxModel(rangeConfigsVector)); // reselect the previously selected RangeAxisConfig (if it is still there) if (selectedItem != null) { for (int i = 0; i < rangeAxisSelectionCombobox.getItemCount(); i++) { if (String.valueOf(rangeAxisSelectionCombobox.getItemAt(i)).equals(selectedItem)) { rangeAxisSelectionCombobox.setSelectedIndex(i); break; } } } // fill in values of current chart Plot plot = engine.getChartPanel().getChart().getPlot(); double domainLowerBound = 0; double domainUpperBound = 0; boolean disableDomainZoom = false; NumericalValueRange effectiveRange = engine.getPlotInstance().getPlotData().getDomainConfigManagerData() .getEffectiveRange(); if (plot instanceof XYPlot) { ValueAxis domainAxis = ((XYPlot) plot).getDomainAxis(); if (domainAxis != null) { Range range = domainAxis.getRange(); domainLowerBound = range.getLowerBound(); domainUpperBound = range.getUpperBound(); } else { if (effectiveRange != null) { domainLowerBound = effectiveRange.getLowerBound(); domainUpperBound = effectiveRange.getUpperBound(); } else { disableDomainZoom = true; } } } else { if (effectiveRange != null) { domainLowerBound = effectiveRange.getLowerBound(); domainUpperBound = effectiveRange.getUpperBound(); } else { disableDomainZoom = true; } } domainRangeLowerBoundField.setText(String.valueOf(domainLowerBound)); domainRangeUpperBoundField.setText(String.valueOf(domainUpperBound)); // happens on nominal domain axis domainRangeLowerBoundField.setEnabled(!disableDomainZoom); domainRangeUpperBoundField.setEnabled(!disableDomainZoom); updateValueRange(); updateColorValues(); }