@Test public void drawBottomLabels() throws Exception { GraphBuffer graphBuffer = new GraphBuffer(300, 200); graphBuffer.drawBackground(Color.WHITE); List<String> labels = Arrays.asList("0", "50", "100"); ArrayInt positions = new ArrayInt(10, 150, 289); graphBuffer.drawBottomLabels(labels, positions, Color.BLACK, FontUtil.getLiberationSansRegular(), 10, 289, 190); ImageAssert.compareImages("graphBuffer.drawBottomLabels", graphBuffer.getImage()); }
void drawBottomLabels(List<String> labels, ListInt valuePixelPositions, Color labelColor, Font labelFont, int leftPixel, int rightPixel, int topPixel) { if (labels != null && !labels.isEmpty()) { g.setColor(labelColor); g.setFont(labelFont); FontMetrics metrics = g.getFontMetrics(); int[] drawRange = new int[] {leftPixel, rightPixel}; drawLineLabel(g, metrics, labels.get(0), valuePixelPositions.getInt(0), drawRange, topPixel, true, false); drawLineLabel(g, metrics, labels.get(labels.size() - 1), valuePixelPositions.getInt(labels.size() - 1), drawRange, topPixel, false, false); for (int i = 1; i < labels.size() - 1; i++) { drawLineLabel(g, metrics, labels.get(i), valuePixelPositions.getInt(i), drawRange, topPixel, true, false); } } }
GraphBuffer { void drawBottomLabels(List<String> labels, ListInt valuePixelPositions, Color labelColor, Font labelFont, int leftPixel, int rightPixel, int topPixel) { if (labels != null && !labels.isEmpty()) { g.setColor(labelColor); g.setFont(labelFont); FontMetrics metrics = g.getFontMetrics(); int[] drawRange = new int[] {leftPixel, rightPixel}; drawLineLabel(g, metrics, labels.get(0), valuePixelPositions.getInt(0), drawRange, topPixel, true, false); drawLineLabel(g, metrics, labels.get(labels.size() - 1), valuePixelPositions.getInt(labels.size() - 1), drawRange, topPixel, false, false); for (int i = 1; i < labels.size() - 1; i++) { drawLineLabel(g, metrics, labels.get(i), valuePixelPositions.getInt(i), drawRange, topPixel, true, false); } } } }
GraphBuffer { void drawBottomLabels(List<String> labels, ListInt valuePixelPositions, Color labelColor, Font labelFont, int leftPixel, int rightPixel, int topPixel) { if (labels != null && !labels.isEmpty()) { g.setColor(labelColor); g.setFont(labelFont); FontMetrics metrics = g.getFontMetrics(); int[] drawRange = new int[] {leftPixel, rightPixel}; drawLineLabel(g, metrics, labels.get(0), valuePixelPositions.getInt(0), drawRange, topPixel, true, false); drawLineLabel(g, metrics, labels.get(labels.size() - 1), valuePixelPositions.getInt(labels.size() - 1), drawRange, topPixel, false, false); for (int i = 1; i < labels.size() - 1; i++) { drawLineLabel(g, metrics, labels.get(i), valuePixelPositions.getInt(i), drawRange, topPixel, true, false); } } } private  GraphBuffer(BufferedImage image);  GraphBuffer(int width, int height);  GraphBuffer(Graph2DRenderer<?> renderer); }
GraphBuffer { void drawBottomLabels(List<String> labels, ListInt valuePixelPositions, Color labelColor, Font labelFont, int leftPixel, int rightPixel, int topPixel) { if (labels != null && !labels.isEmpty()) { g.setColor(labelColor); g.setFont(labelFont); FontMetrics metrics = g.getFontMetrics(); int[] drawRange = new int[] {leftPixel, rightPixel}; drawLineLabel(g, metrics, labels.get(0), valuePixelPositions.getInt(0), drawRange, topPixel, true, false); drawLineLabel(g, metrics, labels.get(labels.size() - 1), valuePixelPositions.getInt(labels.size() - 1), drawRange, topPixel, false, false); for (int i = 1; i < labels.size() - 1; i++) { drawLineLabel(g, metrics, labels.get(i), valuePixelPositions.getInt(i), drawRange, topPixel, true, false); } } } private  GraphBuffer(BufferedImage image);  GraphBuffer(int width, int height);  GraphBuffer(Graph2DRenderer<?> renderer); void setPixel(int x, int y, int color); BufferedImage getImage(); Graphics2D getGraphicsContext(); void drawDataImage(int xStartPoint, int yStartPoint,
                        int[] xPointToDataMap, int[] yPointToDataMap,
                        Cell2DDataset data, NumberColorMapInstance colorMap); void setXScaleAsCell(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale); void setXScaleAsPoint(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale); int xValueToPixel(double value); double xPixelLeftToValue(int pixelValue); double xPixelRightToValue(int pixelValue); double xPixelCenterToValue(int pixelValue); void setYScaleAsCell(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale); void setYScaleAsPoint(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale); int yValueToPixel(double value); double yPixelTopToValue(int pixelValue); double yPixelCenterToValue(int pixelValue); double yPixelBottomToValue(int pixelValue); void drawValueLine(ListNumber xValues, ListNumber yValues, InterpolationScheme interpolation, ProcessValue pv); void drawValueExplicitLine(Point2DDataset data, InterpolationScheme interpolation, ReductionScheme reduction,ProcessValue pv); }
GraphBuffer { void drawBottomLabels(List<String> labels, ListInt valuePixelPositions, Color labelColor, Font labelFont, int leftPixel, int rightPixel, int topPixel) { if (labels != null && !labels.isEmpty()) { g.setColor(labelColor); g.setFont(labelFont); FontMetrics metrics = g.getFontMetrics(); int[] drawRange = new int[] {leftPixel, rightPixel}; drawLineLabel(g, metrics, labels.get(0), valuePixelPositions.getInt(0), drawRange, topPixel, true, false); drawLineLabel(g, metrics, labels.get(labels.size() - 1), valuePixelPositions.getInt(labels.size() - 1), drawRange, topPixel, false, false); for (int i = 1; i < labels.size() - 1; i++) { drawLineLabel(g, metrics, labels.get(i), valuePixelPositions.getInt(i), drawRange, topPixel, true, false); } } } private  GraphBuffer(BufferedImage image);  GraphBuffer(int width, int height);  GraphBuffer(Graph2DRenderer<?> renderer); void setPixel(int x, int y, int color); BufferedImage getImage(); Graphics2D getGraphicsContext(); void drawDataImage(int xStartPoint, int yStartPoint,
                        int[] xPointToDataMap, int[] yPointToDataMap,
                        Cell2DDataset data, NumberColorMapInstance colorMap); void setXScaleAsCell(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale); void setXScaleAsPoint(Range range, int xMinPixel, int xMaxPixel, ValueScale xValueScale); int xValueToPixel(double value); double xPixelLeftToValue(int pixelValue); double xPixelRightToValue(int pixelValue); double xPixelCenterToValue(int pixelValue); void setYScaleAsCell(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale); void setYScaleAsPoint(Range range, int yMinPixel, int yMaxPixel, ValueScale yValueScale); int yValueToPixel(double value); double yPixelTopToValue(int pixelValue); double yPixelCenterToValue(int pixelValue); double yPixelBottomToValue(int pixelValue); void drawValueLine(ListNumber xValues, ListNumber yValues, InterpolationScheme interpolation, ProcessValue pv); void drawValueExplicitLine(Point2DDataset data, InterpolationScheme interpolation, ReductionScheme reduction,ProcessValue pv);  }