@Test public void maxAndLastOverlap() throws Exception { Point2DDataset data = maxLastOverlapDataset(); BufferedImage image = new BufferedImage(100, 25, BufferedImage.TYPE_3BYTE_BGR); Graphics2D g = (Graphics2D) image.getGraphics(); SparklineGraph2DRenderer renderer = new SparklineGraph2DRenderer(100, 25); renderer.draw(g, data); ImageAssert.compareImages("sparklineGraph2D.maxAndLastOverlap", image); }
public void draw(Graphics2D g, Point2DDataset data) { this.g = g; if(aspectRatio != null){ adjustGraphToAspectRatio(); } calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange()); calculateGraphArea(); drawBackground(); g.setColor(Color.BLACK); SortedListView xValues = org.diirt.util.array.ListNumbers.sortedView(data.getXValues()); ListNumber yValues = org.diirt.util.array.ListNumbers.sortedView(data.getYValues(), xValues.getIndexes()); setClip(g); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawValueExplicitLine(xValues, yValues, interpolation, ReductionScheme.FIRST_MAX_MIN_LAST); if(drawCircles){ g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); AlphaComposite ac = java.awt.AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7F); g.setComposite(ac); if (!hasOverlapMinimum()){ drawCircle(g, data, minIndex, minValueColor); } if (!hasOverlapMaximum()){ drawCircle(g, data, maxIndex, maxValueColor); } drawCircle(g, data, firstIndex, firstValueColor); drawCircle(g, data, lastIndex, lastValueColor); } }
SparklineGraph2DRenderer extends Graph2DRenderer<SparklineGraph2DRendererUpdate> { public void draw(Graphics2D g, Point2DDataset data) { this.g = g; if(aspectRatio != null){ adjustGraphToAspectRatio(); } calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange()); calculateGraphArea(); drawBackground(); g.setColor(Color.BLACK); SortedListView xValues = org.diirt.util.array.ListNumbers.sortedView(data.getXValues()); ListNumber yValues = org.diirt.util.array.ListNumbers.sortedView(data.getYValues(), xValues.getIndexes()); setClip(g); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawValueExplicitLine(xValues, yValues, interpolation, ReductionScheme.FIRST_MAX_MIN_LAST); if(drawCircles){ g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); AlphaComposite ac = java.awt.AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7F); g.setComposite(ac); if (!hasOverlapMinimum()){ drawCircle(g, data, minIndex, minValueColor); } if (!hasOverlapMaximum()){ drawCircle(g, data, maxIndex, maxValueColor); } drawCircle(g, data, firstIndex, firstValueColor); drawCircle(g, data, lastIndex, lastValueColor); } } }
SparklineGraph2DRenderer extends Graph2DRenderer<SparklineGraph2DRendererUpdate> { public void draw(Graphics2D g, Point2DDataset data) { this.g = g; if(aspectRatio != null){ adjustGraphToAspectRatio(); } calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange()); calculateGraphArea(); drawBackground(); g.setColor(Color.BLACK); SortedListView xValues = org.diirt.util.array.ListNumbers.sortedView(data.getXValues()); ListNumber yValues = org.diirt.util.array.ListNumbers.sortedView(data.getYValues(), xValues.getIndexes()); setClip(g); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawValueExplicitLine(xValues, yValues, interpolation, ReductionScheme.FIRST_MAX_MIN_LAST); if(drawCircles){ g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); AlphaComposite ac = java.awt.AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7F); g.setComposite(ac); if (!hasOverlapMinimum()){ drawCircle(g, data, minIndex, minValueColor); } if (!hasOverlapMaximum()){ drawCircle(g, data, maxIndex, maxValueColor); } drawCircle(g, data, firstIndex, firstValueColor); drawCircle(g, data, lastIndex, lastValueColor); } } SparklineGraph2DRenderer(int imageWidth, int imageHeight); }
SparklineGraph2DRenderer extends Graph2DRenderer<SparklineGraph2DRendererUpdate> { public void draw(Graphics2D g, Point2DDataset data) { this.g = g; if(aspectRatio != null){ adjustGraphToAspectRatio(); } calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange()); calculateGraphArea(); drawBackground(); g.setColor(Color.BLACK); SortedListView xValues = org.diirt.util.array.ListNumbers.sortedView(data.getXValues()); ListNumber yValues = org.diirt.util.array.ListNumbers.sortedView(data.getYValues(), xValues.getIndexes()); setClip(g); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawValueExplicitLine(xValues, yValues, interpolation, ReductionScheme.FIRST_MAX_MIN_LAST); if(drawCircles){ g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); AlphaComposite ac = java.awt.AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7F); g.setComposite(ac); if (!hasOverlapMinimum()){ drawCircle(g, data, minIndex, minValueColor); } if (!hasOverlapMaximum()){ drawCircle(g, data, maxIndex, maxValueColor); } drawCircle(g, data, firstIndex, firstValueColor); drawCircle(g, data, lastIndex, lastValueColor); } } SparklineGraph2DRenderer(int imageWidth, int imageHeight); void draw(Graphics2D g, Point2DDataset data); @Override void update(SparklineGraph2DRendererUpdate update); @Override SparklineGraph2DRendererUpdate newUpdate(); InterpolationScheme getInterpolation(); int getMaxIndex(); int getMinIndex(); int getFirstIndex(); int getLastIndex(); double getMaxValue(); double getMinValue(); double getFirstValue(); double getLastValue(); boolean getDrawCircles(); Color getMinValueColor(); Color getMaxValueColor(); Color getLastValueColor(); int getCircleDiameter(); double getAspectRatio(); }
SparklineGraph2DRenderer extends Graph2DRenderer<SparklineGraph2DRendererUpdate> { public void draw(Graphics2D g, Point2DDataset data) { this.g = g; if(aspectRatio != null){ adjustGraphToAspectRatio(); } calculateRanges(data.getXStatistics().getRange(), data.getXDisplayRange(), data.getYStatistics().getRange(), data.getYDisplayRange()); calculateGraphArea(); drawBackground(); g.setColor(Color.BLACK); SortedListView xValues = org.diirt.util.array.ListNumbers.sortedView(data.getXValues()); ListNumber yValues = org.diirt.util.array.ListNumbers.sortedView(data.getYValues(), xValues.getIndexes()); setClip(g); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawValueExplicitLine(xValues, yValues, interpolation, ReductionScheme.FIRST_MAX_MIN_LAST); if(drawCircles){ g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); AlphaComposite ac = java.awt.AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7F); g.setComposite(ac); if (!hasOverlapMinimum()){ drawCircle(g, data, minIndex, minValueColor); } if (!hasOverlapMaximum()){ drawCircle(g, data, maxIndex, maxValueColor); } drawCircle(g, data, firstIndex, firstValueColor); drawCircle(g, data, lastIndex, lastValueColor); } } SparklineGraph2DRenderer(int imageWidth, int imageHeight); void draw(Graphics2D g, Point2DDataset data); @Override void update(SparklineGraph2DRendererUpdate update); @Override SparklineGraph2DRendererUpdate newUpdate(); InterpolationScheme getInterpolation(); int getMaxIndex(); int getMinIndex(); int getFirstIndex(); int getLastIndex(); double getMaxValue(); double getMinValue(); double getFirstValue(); double getLastValue(); boolean getDrawCircles(); Color getMinValueColor(); Color getMaxValueColor(); Color getLastValueColor(); int getCircleDiameter(); double getAspectRatio(); static java.util.List<InterpolationScheme> supportedInterpolationScheme; }