List of usage examples for org.jfree.data Range getUpperBound
public double getUpperBound()
From source file:org.jfree.data.RangeTest.java
/** * Some checks for the combine method.//from w w w .j a va 2 s . co m */ @Test public void testCombine() { Range r1 = new Range(1.0, 2.0); Range r2 = new Range(1.5, 2.5); assertNull(Range.combine(null, null)); assertEquals(r1, Range.combine(r1, null)); assertEquals(r2, Range.combine(null, r2)); assertEquals(new Range(1.0, 2.5), Range.combine(r1, r2)); Range r3 = new Range(Double.NaN, 1.3); Range rr = Range.combine(r1, r3); assertTrue(Double.isNaN(rr.getLowerBound())); assertEquals(2.0, rr.getUpperBound(), EPSILON); Range r4 = new Range(1.7, Double.NaN); rr = Range.combine(r4, r1); assertEquals(1.0, rr.getLowerBound(), EPSILON); assertTrue(Double.isNaN(rr.getUpperBound())); }
From source file:org.jfree.data.RangeTest.java
/** * A simple test for the scale() method. *//* ww w . ja v a 2 s . c o m*/ @Test public void testScale() { Range r1 = new Range(0.0, 100.0); Range r2 = Range.scale(r1, 0.10); assertEquals(0.0, r2.getLowerBound(), 0.001); assertEquals(10.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 100.0); r2 = Range.scale(r1, 2.0); assertEquals(-20.0, r2.getLowerBound(), 0.001); assertEquals(200.0, r2.getUpperBound(), 0.001); // Scaling with a factor of 1 does not change the range r2 = Range.scale(r1, 1.0); assertEquals(r1, r2); try { Range.scale(null, 0.1); fail("Null value is accepted"); } catch (Exception e) { } try { Range.scale(r1, -0.5); fail("Negative factor accepted"); } catch (Exception e) { } }
From source file:org.jfree.data.RangeTest.java
/** * A simple test for the expand() method. *///from w w w .j a v a 2 s . c om @Test public void testExpand() { Range r1 = new Range(0.0, 100.0); Range r2 = Range.expand(r1, 0.10, 0.10); assertEquals(-10.0, r2.getLowerBound(), 0.001); assertEquals(110.0, r2.getUpperBound(), 0.001); // Expand by 0% does not change the range r2 = Range.expand(r1, 0.0, 0.0); assertEquals(r1, r2); try { Range.expand(null, 0.1, 0.1); fail("Null value is accepted"); } catch (Exception e) { } // Lower > upper: mid point is used r2 = Range.expand(r1, -0.8, -0.5); assertEquals(65.0, r2.getLowerBound(), 0.001); assertEquals(65.0, r2.getUpperBound(), 0.001); }
From source file:org.jfree.data.RangeTest.java
/** * Some checks for the combineIgnoringNaN() method. *//* w w w. j a v a2 s. c o m*/ @Test public void testCombineIgnoringNaN() { Range r1 = new Range(1.0, 2.0); Range r2 = new Range(1.5, 2.5); assertNull(Range.combineIgnoringNaN(null, null)); assertEquals(r1, Range.combineIgnoringNaN(r1, null)); assertEquals(r2, Range.combineIgnoringNaN(null, r2)); assertEquals(new Range(1.0, 2.5), Range.combineIgnoringNaN(r1, r2)); Range r3 = new Range(Double.NaN, 1.3); Range rr = Range.combineIgnoringNaN(r1, r3); assertEquals(1.0, rr.getLowerBound(), EPSILON); assertEquals(2.0, rr.getUpperBound(), EPSILON); Range r4 = new Range(1.7, Double.NaN); rr = Range.combineIgnoringNaN(r4, r1); assertEquals(1.0, rr.getLowerBound(), EPSILON); assertEquals(2.0, rr.getUpperBound(), EPSILON); }
From source file:org.jfree.data.RangeTest.java
/** * A simple test for the scale() method. *///from ww w. ja v a2 s .c o m @Test public void testShift() { Range r1 = new Range(10.0, 20.0); Range r2 = Range.shift(r1, 20.0); assertEquals(30.0, r2.getLowerBound(), 0.001); assertEquals(40.0, r2.getUpperBound(), 0.001); r1 = new Range(0.0, 100.0); r2 = Range.shift(r1, -50.0, true); assertEquals(-50.0, r2.getLowerBound(), 0.001); assertEquals(50.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 20.0); r2 = Range.shift(r1, 20.0, true); assertEquals(10.0, r2.getLowerBound(), 0.001); assertEquals(40.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 20.0); r2 = Range.shift(r1, -30.0, true); assertEquals(-40.0, r2.getLowerBound(), 0.001); assertEquals(-10.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 20.0); r2 = Range.shift(r1, 20.0, false); assertEquals(0.0, r2.getLowerBound(), 0.001); assertEquals(40.0, r2.getUpperBound(), 0.001); r1 = new Range(-10.0, 20.0); r2 = Range.shift(r1, -30.0, false); assertEquals(-40.0, r2.getLowerBound(), 0.001); assertEquals(0.0, r2.getUpperBound(), 0.001); // Shifting with a delta of 0 does not change the range r2 = Range.shift(r1, 0.0); assertEquals(r1, r2); try { Range.shift(null, 0.1); fail("Null value is accepted"); } catch (Exception e) { } }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapWorker.java
protected Void doInBackground() throws Exception { // this is a SwingWorker thread from its pool, give it a recognizable name Thread.currentThread().setName("PortHeatMapWorker"); JFreeChart Chart = PlotPanel.getHeatChart(); logger.info("Worker Building HeatMapPlot"); MessageManager.getInstance()/*from w w w .j a va2s . c om*/ .postMessage(new SmtMessage(SmtMessageType.SMT_MSG_INFO, "Worker Building HeatMapPlot")); PortHeatMapDataSet pHeatMap = null; if (UseService) { SMT_UpdateService updateService = SMT_UpdateService.getInstance(); History = updateService.getCollection(); if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet(History, IncludedNodes); else pHeatMap = new PortHeatMapDataSet(History, IncludedDepths); } else if (History != null) { if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet(History, IncludedNodes); else pHeatMap = new PortHeatMapDataSet(History, IncludedDepths); } else { // FIXME - eliminate this, for test purposes only if (IncludedNodes != null) pHeatMap = new PortHeatMapDataSet("%h/scripts/OsmScripts/SmtScripts/sierra3H.his", IncludedNodes); else pHeatMap = new PortHeatMapDataSet("%h/scripts/OsmScripts/SmtScripts/sierra3H.his", IncludedDepths); } // logger.fine("Finished creating dataset"); // logger.fine("Max X: " + pHeatMap.getMaximumXValue()); // logger.fine("Max Y: " + pHeatMap.getMaximumYValue()); // logger.fine("Max Z: " + pHeatMap.getMaximumZValue()); // // if any of these "maximum" values are illegal, stop here and return null if (!pHeatMap.isValid()) { logger.severe("Invalid HeatMap, check OMS Collection or Depth filter (empty or null)"); MessageManager.getInstance().postMessage(new SmtMessage(SmtMessageType.SMT_MSG_SEVERE, "Invalid HeatMap, check OMS Collection or Depth filter (empty or null)")); PlotPanel.setHeatMapDataSet(null); return null; } PlotPanel.setHeatMapDataSet(pHeatMap); Range fixedXRange = new Range(0, pHeatMap.getMaximumXValue()); // time # Range fixedYRange = new Range(0, pHeatMap.getMaximumYValue()); // port # Range fixedZRange = new Range(0, pHeatMap.getMaximumZValue()); // % Util // there are 3 valid paint scales, 0, 1, & 2 LookupPaintScale paintScale = PaintScaleFactory.getLookupPaintScale(1, 0, fixedZRange.getUpperBound(), fixedZRange.getUpperBound()); ValueAxis paintAxis = PaintScaleFactory.getPaintScaleAxis(0, fixedZRange.getUpperBound(), PortHeatMapPlotPanel.UtilizationAxisLabel); BufferedImage image = HeatMapUtilities.createHeatMapImage(pHeatMap, paintScale); XYDataImageAnnotation ann = new XYDataImageAnnotation(image, fixedXRange.getLowerBound(), fixedYRange.getLowerBound(), fixedXRange.getUpperBound(), fixedYRange.getUpperBound(), true); XYPlot plot = (XYPlot) Chart.getPlot(); plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND); // finally, show the heatmap PaintScaleLegend psLegend = new PaintScaleLegend(paintScale, paintAxis); psLegend.setMargin(new RectangleInsets(3, 40, 3, 10)); psLegend.setPosition(RectangleEdge.TOP); // location (within NORTH) of // heatmap legend psLegend.setAxisOffset(4.0); psLegend.setFrame(new BlockBorder(Color.GRAY)); Chart.addSubtitle(psLegend); // fix the sliders ranges, and set them for the middle if ((pHeatMap != null) && (PlotPanel != null)) { PlotPanel.getTimeSlider().setMinimum((int) fixedXRange.getLowerBound()); PlotPanel.getTimeSlider().setMaximum((int) fixedXRange.getUpperBound()); PlotPanel.getTimeSlider().setValue((int) fixedXRange.getCentralValue()); PlotPanel.getPortSlider().setMinimum((int) fixedYRange.getLowerBound()); PlotPanel.getPortSlider().setMaximum((int) fixedYRange.getUpperBound()); PlotPanel.getPortSlider().setValue((int) fixedYRange.getCentralValue()); HeatMapDepthPanel hmdp = new HeatMapDepthPanel(pHeatMap); PlotPanel.replaceDepthPanel(hmdp); } return null; }
From source file:gov.nih.nci.cma.web.graphing.CMAPrincipalComponentAnalysisPlot.java
/** * This chart uses the XYAnnotation as a glyph to represent * a single pca data point. Glyph shape is determined by survival time. * Survival of more than 10 months is represented by a circle. 10 months or less * is represented by a square. Component1 values are represented by X * Component2 values are represented by Y *//*from ww w . j a va2s . c o m*/ private void createGlyphsAndAddToPlot(XYPlot plot) { //, double glyphScaleFactor) { XYShapeAnnotation glyph; Shape glyphShape = null; Color glyphColor; NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); Range r = domainAxis.getRange(); double upperBound = r.getUpperBound(); double dotSize = 0.7; if (upperBound >= 50 && upperBound <= 100) dotSize = 1d; else if (upperBound > 100 && upperBound <= 150) dotSize = 2d; else if (upperBound > 150 && upperBound <= 200) dotSize = 3d; else if (upperBound > 200) dotSize = 5d; //PrincipalComponentAnalysisDataPoint pcaPoint; double x, y; //for (Iterator i=dataPoints.iterator(); i.hasNext(); ) { for (CMAPCADataPoint pcaPoint : dataPoints) { x = pcaPoint.getComponentValue(component1); y = pcaPoint.getComponentValue(component2); String sampleGroupName = pcaPoint.getSampleGroupName(); String order = sampleGroupNames.get(sampleGroupName); glyphShape = getShapeForDataPoint(order, x, y, dotSize); glyphColor = colorMap.get(order); if (glyphColor == null) glyphColor = Color.black; glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor); String tooltip = ""; tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getSampleGroupName(); glyph.setToolTipText(tooltip); plot.addAnnotation(glyph); } }
From source file:org.jfree.data.Range.java
/** * Returns <code>true</code> if the range intersects with the specified * range, and <code>false</code> otherwise. * * @param range another range (<code>null</code> not permitted). * * @return A boolean./* w ww . j a v a 2s . co m*/ * * @since 1.0.9 */ public boolean intersects(Range range) { return intersects(range.getLowerBound(), range.getUpperBound()); }
From source file:com.rapidminer.gui.plotter.RangeablePlotterAdapter.java
public void setRange(String columnName, Range range) { // inserting in map nameRangeMap.put(PlotterAdapter.transformParameterName(columnName), range); // translating current ranges to string List<String[]> entryList = new LinkedList<>(); for (String dimensionName : nameRangeMap.keySet()) { Range currentRange = nameRangeMap.get(dimensionName); String[] entry = new String[2]; entry[0] = dimensionName;/*w w w.j a va2s . c o m*/ entry[1] = ParameterTypeTupel.transformTupel2String( new Pair<>(currentRange.getLowerBound() + "", currentRange.getUpperBound() + "")); entryList.add(entry); } // finally set it in the settings settings.setParameterAsString(PARAMETER_PREFIX_RANGE_LIST, ParameterTypeList.transformList2String(entryList)); }
From source file:org.jfree.data.time.TimePeriodValuesCollection.java
/** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value.//ww w. j a v a2s .c om */ @Override public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; }