@Test public void allZeros() throws Exception { Point3DWithLabelDataset data = zerosDataset(); BufferedImage image = new BufferedImage(600, 400, BufferedImage.TYPE_3BYTE_BGR); BubbleGraph2DRenderer renderer = new BubbleGraph2DRenderer(600, 399); Graphics2D graphics = (Graphics2D) image.getGraphics(); renderer.draw(graphics, data); ImageAssert.compareImages("bubbleGraph2D.allZeros", image); }
public void draw(Graphics2D g, Point3DWithLabelDataset data) { if(g == null) throw new NullPointerException("g is null"); this.g = g; calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange(), data.getZStatistics().getRange(), data.getZDisplayRange()); drawBackground(); calculateLabels(); calculateGraphArea(); drawGraphArea(); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); LabelColorScheme labelColor = LabelColorSchemes.orderedHueColor(data.getLabels()); ListInt indexes = org.diirt.util.array.ListNumbers.sortedView(data.getZValues()).getIndexes(); focusValueIndex = null; final boolean isFocusValuePresent = focusPixelX != null && focusPixelY != null; Shape focusShape = null; setClip(g); Range absZPlotRange = Ranges.absRange(zPlotRange); for (int j = indexes.size() - 1; j >= 0; j--) { int i = indexes.getInt(j); double zValue = data.getZValues().getDouble(i); double diameter = radiusScale(absZPlotRange.getMinimum(), Math.abs(zValue), absZPlotRange.getMaximum(), 3, 15); double x = scaledX(data.getXValues().getDouble(i)); double y = scaledY(data.getYValues().getDouble(i)); Shape bubble = createShape(x, y, diameter, zValue >= 0); newValue(x, y, diameter, i); g.setColor(new Color(labelColor.getColor(data.getLabels().get(i)))); g.fill(bubble); g.setColor(Color.BLACK); g.draw(bubble); if (isFocusValuePresent) { double deltaX = focusPixelX - x; double deltaY = focusPixelY - y; if (Math.sqrt(deltaX*deltaX + deltaY*deltaY) < diameter / 2) { focusValueIndex = i; focusShape = bubble; } } } if (highlightFocusValue && focusShape != null) { g.setColor(Color.WHITE); g.fill(focusShape); g.setColor(Color.BLACK); g.draw(focusShape); } }
BubbleGraph2DRenderer extends Graph2DRenderer<BubbleGraph2DRendererUpdate> { public void draw(Graphics2D g, Point3DWithLabelDataset data) { if(g == null) throw new NullPointerException("g is null"); this.g = g; calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange(), data.getZStatistics().getRange(), data.getZDisplayRange()); drawBackground(); calculateLabels(); calculateGraphArea(); drawGraphArea(); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); LabelColorScheme labelColor = LabelColorSchemes.orderedHueColor(data.getLabels()); ListInt indexes = org.diirt.util.array.ListNumbers.sortedView(data.getZValues()).getIndexes(); focusValueIndex = null; final boolean isFocusValuePresent = focusPixelX != null && focusPixelY != null; Shape focusShape = null; setClip(g); Range absZPlotRange = Ranges.absRange(zPlotRange); for (int j = indexes.size() - 1; j >= 0; j--) { int i = indexes.getInt(j); double zValue = data.getZValues().getDouble(i); double diameter = radiusScale(absZPlotRange.getMinimum(), Math.abs(zValue), absZPlotRange.getMaximum(), 3, 15); double x = scaledX(data.getXValues().getDouble(i)); double y = scaledY(data.getYValues().getDouble(i)); Shape bubble = createShape(x, y, diameter, zValue >= 0); newValue(x, y, diameter, i); g.setColor(new Color(labelColor.getColor(data.getLabels().get(i)))); g.fill(bubble); g.setColor(Color.BLACK); g.draw(bubble); if (isFocusValuePresent) { double deltaX = focusPixelX - x; double deltaY = focusPixelY - y; if (Math.sqrt(deltaX*deltaX + deltaY*deltaY) < diameter / 2) { focusValueIndex = i; focusShape = bubble; } } } if (highlightFocusValue && focusShape != null) { g.setColor(Color.WHITE); g.fill(focusShape); g.setColor(Color.BLACK); g.draw(focusShape); } } }
BubbleGraph2DRenderer extends Graph2DRenderer<BubbleGraph2DRendererUpdate> { public void draw(Graphics2D g, Point3DWithLabelDataset data) { if(g == null) throw new NullPointerException("g is null"); this.g = g; calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange(), data.getZStatistics().getRange(), data.getZDisplayRange()); drawBackground(); calculateLabels(); calculateGraphArea(); drawGraphArea(); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); LabelColorScheme labelColor = LabelColorSchemes.orderedHueColor(data.getLabels()); ListInt indexes = org.diirt.util.array.ListNumbers.sortedView(data.getZValues()).getIndexes(); focusValueIndex = null; final boolean isFocusValuePresent = focusPixelX != null && focusPixelY != null; Shape focusShape = null; setClip(g); Range absZPlotRange = Ranges.absRange(zPlotRange); for (int j = indexes.size() - 1; j >= 0; j--) { int i = indexes.getInt(j); double zValue = data.getZValues().getDouble(i); double diameter = radiusScale(absZPlotRange.getMinimum(), Math.abs(zValue), absZPlotRange.getMaximum(), 3, 15); double x = scaledX(data.getXValues().getDouble(i)); double y = scaledY(data.getYValues().getDouble(i)); Shape bubble = createShape(x, y, diameter, zValue >= 0); newValue(x, y, diameter, i); g.setColor(new Color(labelColor.getColor(data.getLabels().get(i)))); g.fill(bubble); g.setColor(Color.BLACK); g.draw(bubble); if (isFocusValuePresent) { double deltaX = focusPixelX - x; double deltaY = focusPixelY - y; if (Math.sqrt(deltaX*deltaX + deltaY*deltaY) < diameter / 2) { focusValueIndex = i; focusShape = bubble; } } } if (highlightFocusValue && focusShape != null) { g.setColor(Color.WHITE); g.fill(focusShape); g.setColor(Color.BLACK); g.draw(focusShape); } } BubbleGraph2DRenderer(int width, int height); }
BubbleGraph2DRenderer extends Graph2DRenderer<BubbleGraph2DRendererUpdate> { public void draw(Graphics2D g, Point3DWithLabelDataset data) { if(g == null) throw new NullPointerException("g is null"); this.g = g; calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange(), data.getZStatistics().getRange(), data.getZDisplayRange()); drawBackground(); calculateLabels(); calculateGraphArea(); drawGraphArea(); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); LabelColorScheme labelColor = LabelColorSchemes.orderedHueColor(data.getLabels()); ListInt indexes = org.diirt.util.array.ListNumbers.sortedView(data.getZValues()).getIndexes(); focusValueIndex = null; final boolean isFocusValuePresent = focusPixelX != null && focusPixelY != null; Shape focusShape = null; setClip(g); Range absZPlotRange = Ranges.absRange(zPlotRange); for (int j = indexes.size() - 1; j >= 0; j--) { int i = indexes.getInt(j); double zValue = data.getZValues().getDouble(i); double diameter = radiusScale(absZPlotRange.getMinimum(), Math.abs(zValue), absZPlotRange.getMaximum(), 3, 15); double x = scaledX(data.getXValues().getDouble(i)); double y = scaledY(data.getYValues().getDouble(i)); Shape bubble = createShape(x, y, diameter, zValue >= 0); newValue(x, y, diameter, i); g.setColor(new Color(labelColor.getColor(data.getLabels().get(i)))); g.fill(bubble); g.setColor(Color.BLACK); g.draw(bubble); if (isFocusValuePresent) { double deltaX = focusPixelX - x; double deltaY = focusPixelY - y; if (Math.sqrt(deltaX*deltaX + deltaY*deltaY) < diameter / 2) { focusValueIndex = i; focusShape = bubble; } } } if (highlightFocusValue && focusShape != null) { g.setColor(Color.WHITE); g.fill(focusShape); g.setColor(Color.BLACK); g.draw(focusShape); } } BubbleGraph2DRenderer(int width, int height); @Override void update(BubbleGraph2DRendererUpdate update); void draw(Graphics2D g, Point3DWithLabelDataset data); @Override BubbleGraph2DRendererUpdate newUpdate(); Integer getFocusValueIndex(); }
BubbleGraph2DRenderer extends Graph2DRenderer<BubbleGraph2DRendererUpdate> { public void draw(Graphics2D g, Point3DWithLabelDataset data) { if(g == null) throw new NullPointerException("g is null"); this.g = g; calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange(), data.getZStatistics().getRange(), data.getZDisplayRange()); drawBackground(); calculateLabels(); calculateGraphArea(); drawGraphArea(); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); LabelColorScheme labelColor = LabelColorSchemes.orderedHueColor(data.getLabels()); ListInt indexes = org.diirt.util.array.ListNumbers.sortedView(data.getZValues()).getIndexes(); focusValueIndex = null; final boolean isFocusValuePresent = focusPixelX != null && focusPixelY != null; Shape focusShape = null; setClip(g); Range absZPlotRange = Ranges.absRange(zPlotRange); for (int j = indexes.size() - 1; j >= 0; j--) { int i = indexes.getInt(j); double zValue = data.getZValues().getDouble(i); double diameter = radiusScale(absZPlotRange.getMinimum(), Math.abs(zValue), absZPlotRange.getMaximum(), 3, 15); double x = scaledX(data.getXValues().getDouble(i)); double y = scaledY(data.getYValues().getDouble(i)); Shape bubble = createShape(x, y, diameter, zValue >= 0); newValue(x, y, diameter, i); g.setColor(new Color(labelColor.getColor(data.getLabels().get(i)))); g.fill(bubble); g.setColor(Color.BLACK); g.draw(bubble); if (isFocusValuePresent) { double deltaX = focusPixelX - x; double deltaY = focusPixelY - y; if (Math.sqrt(deltaX*deltaX + deltaY*deltaY) < diameter / 2) { focusValueIndex = i; focusShape = bubble; } } } if (highlightFocusValue && focusShape != null) { g.setColor(Color.WHITE); g.fill(focusShape); g.setColor(Color.BLACK); g.draw(focusShape); } } BubbleGraph2DRenderer(int width, int height); @Override void update(BubbleGraph2DRendererUpdate update); void draw(Graphics2D g, Point3DWithLabelDataset data); @Override BubbleGraph2DRendererUpdate newUpdate(); Integer getFocusValueIndex();  }