@Test public void testPaintRow() { System.out.println("paintRow"); Graphics2DEmul g2d = new Graphics2DEmul(); Color color = Color.red; double zoomFactor = 1.0; int limitPointFactor = 1; AbstractRowPlotter instance = new AbstractRowPlotterImpl(); instance.setBoundsValues(g2d.getBounds(), minXVal, maxXVal, minYVal, maxYVal); instance.paintRow(g2d, testRow, color, zoomFactor, limitPointFactor); String expResult = "setStroke|setColor: java.awt.Color[r=255,g=0,b=0]|fillOval: (7;607) - w:6 h:6|drawLine: (10;610) - (410;378)|fillOval: (407;375) - w:6 h:6|drawLine: (410;378) - (810;10)|fillOval: (807;7) - w:6 h:6|setStroke|"; String result = g2d.getResult(); Assert.assertEquals(expResult, result); }
public synchronized void paintRow(Graphics2D g2d, AbstractGraphRow row, Color color, double zoomFactor, int limitPointFactor) { Iterator<Entry<Long, AbstractGraphPanelChartElement>> it = row.iterator(); Entry<Long, AbstractGraphPanelChartElement> element; Stroke olStroke; prevX = -1; prevY = chartRect.y + chartRect.height; mustDrawFirstZeroingLine = chartSettings.isDrawFinalZeroingLines(); olStroke = g2d.getStroke(); if (row.isDrawThickLines()) { g2d.setStroke(chartSettings.getThickStroke()); } else { g2d.setStroke(getLineStroke()); } g2d.setColor(color); while (it.hasNext()) { if (!row.isDrawOnChart()) { continue; } if (limitPointFactor == 1) { element = it.next(); AbstractGraphPanelChartElement elt = (AbstractGraphPanelChartElement) element.getValue(); if (chartSettings.getHideNonRepValLimit() > 0) { while (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit()) && it.hasNext()) { element = it.next(); elt = (AbstractGraphPanelChartElement) element.getValue(); } if (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit())) { break; } } calcPointX = element.getKey().doubleValue(); calcPointY = elt.getValue(); } else { calcPointX = 0; calcPointY = 0; int nbPointProcessed = 0; for (int i = 0; i < limitPointFactor; i++) { if (it.hasNext()) { element = it.next(); calcPointX = calcPointX + element.getKey().doubleValue(); calcPointY = calcPointY + ((AbstractGraphPanelChartElement) element.getValue()).getValue(); nbPointProcessed++; } } calcPointX = calcPointX / (double) nbPointProcessed; calcPointY = calcPointY / (double) nbPointProcessed; } calcPointY = calcPointY * zoomFactor; x = chartRect.x + (int) ((calcPointX - minXVal) * dxForDVal); int yHeight = (int) ((calcPointY - minYVal) * dyForDVal); y = chartRect.y + chartRect.height - yHeight; processPoint(g2d, row.getGranulationValue()); if (isChartPointValid(x, y)) { if (allowMarkers) { processMarker(g2d, row); } prevX = x; prevY = y; } if (row.isDrawValueLabel() && isChartPointValid(x, y) && y >= chartRect.y) { drawLabels(g2d, row, calcPointY); } } processFinalLines(row, g2d); x = 0; y = 0; prevX = -1; prevY = chartRect.y + chartRect.height; postPaintRow(row, g2d); g2d.setStroke(olStroke); }
AbstractRowPlotter implements Serializable { public synchronized void paintRow(Graphics2D g2d, AbstractGraphRow row, Color color, double zoomFactor, int limitPointFactor) { Iterator<Entry<Long, AbstractGraphPanelChartElement>> it = row.iterator(); Entry<Long, AbstractGraphPanelChartElement> element; Stroke olStroke; prevX = -1; prevY = chartRect.y + chartRect.height; mustDrawFirstZeroingLine = chartSettings.isDrawFinalZeroingLines(); olStroke = g2d.getStroke(); if (row.isDrawThickLines()) { g2d.setStroke(chartSettings.getThickStroke()); } else { g2d.setStroke(getLineStroke()); } g2d.setColor(color); while (it.hasNext()) { if (!row.isDrawOnChart()) { continue; } if (limitPointFactor == 1) { element = it.next(); AbstractGraphPanelChartElement elt = (AbstractGraphPanelChartElement) element.getValue(); if (chartSettings.getHideNonRepValLimit() > 0) { while (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit()) && it.hasNext()) { element = it.next(); elt = (AbstractGraphPanelChartElement) element.getValue(); } if (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit())) { break; } } calcPointX = element.getKey().doubleValue(); calcPointY = elt.getValue(); } else { calcPointX = 0; calcPointY = 0; int nbPointProcessed = 0; for (int i = 0; i < limitPointFactor; i++) { if (it.hasNext()) { element = it.next(); calcPointX = calcPointX + element.getKey().doubleValue(); calcPointY = calcPointY + ((AbstractGraphPanelChartElement) element.getValue()).getValue(); nbPointProcessed++; } } calcPointX = calcPointX / (double) nbPointProcessed; calcPointY = calcPointY / (double) nbPointProcessed; } calcPointY = calcPointY * zoomFactor; x = chartRect.x + (int) ((calcPointX - minXVal) * dxForDVal); int yHeight = (int) ((calcPointY - minYVal) * dyForDVal); y = chartRect.y + chartRect.height - yHeight; processPoint(g2d, row.getGranulationValue()); if (isChartPointValid(x, y)) { if (allowMarkers) { processMarker(g2d, row); } prevX = x; prevY = y; } if (row.isDrawValueLabel() && isChartPointValid(x, y) && y >= chartRect.y) { drawLabels(g2d, row, calcPointY); } } processFinalLines(row, g2d); x = 0; y = 0; prevX = -1; prevY = chartRect.y + chartRect.height; postPaintRow(row, g2d); g2d.setStroke(olStroke); } }
AbstractRowPlotter implements Serializable { public synchronized void paintRow(Graphics2D g2d, AbstractGraphRow row, Color color, double zoomFactor, int limitPointFactor) { Iterator<Entry<Long, AbstractGraphPanelChartElement>> it = row.iterator(); Entry<Long, AbstractGraphPanelChartElement> element; Stroke olStroke; prevX = -1; prevY = chartRect.y + chartRect.height; mustDrawFirstZeroingLine = chartSettings.isDrawFinalZeroingLines(); olStroke = g2d.getStroke(); if (row.isDrawThickLines()) { g2d.setStroke(chartSettings.getThickStroke()); } else { g2d.setStroke(getLineStroke()); } g2d.setColor(color); while (it.hasNext()) { if (!row.isDrawOnChart()) { continue; } if (limitPointFactor == 1) { element = it.next(); AbstractGraphPanelChartElement elt = (AbstractGraphPanelChartElement) element.getValue(); if (chartSettings.getHideNonRepValLimit() > 0) { while (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit()) && it.hasNext()) { element = it.next(); elt = (AbstractGraphPanelChartElement) element.getValue(); } if (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit())) { break; } } calcPointX = element.getKey().doubleValue(); calcPointY = elt.getValue(); } else { calcPointX = 0; calcPointY = 0; int nbPointProcessed = 0; for (int i = 0; i < limitPointFactor; i++) { if (it.hasNext()) { element = it.next(); calcPointX = calcPointX + element.getKey().doubleValue(); calcPointY = calcPointY + ((AbstractGraphPanelChartElement) element.getValue()).getValue(); nbPointProcessed++; } } calcPointX = calcPointX / (double) nbPointProcessed; calcPointY = calcPointY / (double) nbPointProcessed; } calcPointY = calcPointY * zoomFactor; x = chartRect.x + (int) ((calcPointX - minXVal) * dxForDVal); int yHeight = (int) ((calcPointY - minYVal) * dyForDVal); y = chartRect.y + chartRect.height - yHeight; processPoint(g2d, row.getGranulationValue()); if (isChartPointValid(x, y)) { if (allowMarkers) { processMarker(g2d, row); } prevX = x; prevY = y; } if (row.isDrawValueLabel() && isChartPointValid(x, y) && y >= chartRect.y) { drawLabels(g2d, row, calcPointY); } } processFinalLines(row, g2d); x = 0; y = 0; prevX = -1; prevY = chartRect.y + chartRect.height; postPaintRow(row, g2d); g2d.setStroke(olStroke); } AbstractRowPlotter(ChartSettings chartSettings, NumberRenderer labelRenderer); }
AbstractRowPlotter implements Serializable { public synchronized void paintRow(Graphics2D g2d, AbstractGraphRow row, Color color, double zoomFactor, int limitPointFactor) { Iterator<Entry<Long, AbstractGraphPanelChartElement>> it = row.iterator(); Entry<Long, AbstractGraphPanelChartElement> element; Stroke olStroke; prevX = -1; prevY = chartRect.y + chartRect.height; mustDrawFirstZeroingLine = chartSettings.isDrawFinalZeroingLines(); olStroke = g2d.getStroke(); if (row.isDrawThickLines()) { g2d.setStroke(chartSettings.getThickStroke()); } else { g2d.setStroke(getLineStroke()); } g2d.setColor(color); while (it.hasNext()) { if (!row.isDrawOnChart()) { continue; } if (limitPointFactor == 1) { element = it.next(); AbstractGraphPanelChartElement elt = (AbstractGraphPanelChartElement) element.getValue(); if (chartSettings.getHideNonRepValLimit() > 0) { while (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit()) && it.hasNext()) { element = it.next(); elt = (AbstractGraphPanelChartElement) element.getValue(); } if (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit())) { break; } } calcPointX = element.getKey().doubleValue(); calcPointY = elt.getValue(); } else { calcPointX = 0; calcPointY = 0; int nbPointProcessed = 0; for (int i = 0; i < limitPointFactor; i++) { if (it.hasNext()) { element = it.next(); calcPointX = calcPointX + element.getKey().doubleValue(); calcPointY = calcPointY + ((AbstractGraphPanelChartElement) element.getValue()).getValue(); nbPointProcessed++; } } calcPointX = calcPointX / (double) nbPointProcessed; calcPointY = calcPointY / (double) nbPointProcessed; } calcPointY = calcPointY * zoomFactor; x = chartRect.x + (int) ((calcPointX - minXVal) * dxForDVal); int yHeight = (int) ((calcPointY - minYVal) * dyForDVal); y = chartRect.y + chartRect.height - yHeight; processPoint(g2d, row.getGranulationValue()); if (isChartPointValid(x, y)) { if (allowMarkers) { processMarker(g2d, row); } prevX = x; prevY = y; } if (row.isDrawValueLabel() && isChartPointValid(x, y) && y >= chartRect.y) { drawLabels(g2d, row, calcPointY); } } processFinalLines(row, g2d); x = 0; y = 0; prevX = -1; prevY = chartRect.y + chartRect.height; postPaintRow(row, g2d); g2d.setStroke(olStroke); } AbstractRowPlotter(ChartSettings chartSettings, NumberRenderer labelRenderer); void setBoundsValues(Rectangle chartRect, long minXVal, long maxXVal, double minYVal, double maxYVal); synchronized void paintRow(Graphics2D g2d, AbstractGraphRow row, Color color, double zoomFactor, int limitPointFactor); }
AbstractRowPlotter implements Serializable { public synchronized void paintRow(Graphics2D g2d, AbstractGraphRow row, Color color, double zoomFactor, int limitPointFactor) { Iterator<Entry<Long, AbstractGraphPanelChartElement>> it = row.iterator(); Entry<Long, AbstractGraphPanelChartElement> element; Stroke olStroke; prevX = -1; prevY = chartRect.y + chartRect.height; mustDrawFirstZeroingLine = chartSettings.isDrawFinalZeroingLines(); olStroke = g2d.getStroke(); if (row.isDrawThickLines()) { g2d.setStroke(chartSettings.getThickStroke()); } else { g2d.setStroke(getLineStroke()); } g2d.setColor(color); while (it.hasNext()) { if (!row.isDrawOnChart()) { continue; } if (limitPointFactor == 1) { element = it.next(); AbstractGraphPanelChartElement elt = (AbstractGraphPanelChartElement) element.getValue(); if (chartSettings.getHideNonRepValLimit() > 0) { while (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit()) && it.hasNext()) { element = it.next(); elt = (AbstractGraphPanelChartElement) element.getValue(); } if (!elt.isPointRepresentative(chartSettings.getHideNonRepValLimit())) { break; } } calcPointX = element.getKey().doubleValue(); calcPointY = elt.getValue(); } else { calcPointX = 0; calcPointY = 0; int nbPointProcessed = 0; for (int i = 0; i < limitPointFactor; i++) { if (it.hasNext()) { element = it.next(); calcPointX = calcPointX + element.getKey().doubleValue(); calcPointY = calcPointY + ((AbstractGraphPanelChartElement) element.getValue()).getValue(); nbPointProcessed++; } } calcPointX = calcPointX / (double) nbPointProcessed; calcPointY = calcPointY / (double) nbPointProcessed; } calcPointY = calcPointY * zoomFactor; x = chartRect.x + (int) ((calcPointX - minXVal) * dxForDVal); int yHeight = (int) ((calcPointY - minYVal) * dyForDVal); y = chartRect.y + chartRect.height - yHeight; processPoint(g2d, row.getGranulationValue()); if (isChartPointValid(x, y)) { if (allowMarkers) { processMarker(g2d, row); } prevX = x; prevY = y; } if (row.isDrawValueLabel() && isChartPointValid(x, y) && y >= chartRect.y) { drawLabels(g2d, row, calcPointY); } } processFinalLines(row, g2d); x = 0; y = 0; prevX = -1; prevY = chartRect.y + chartRect.height; postPaintRow(row, g2d); g2d.setStroke(olStroke); } AbstractRowPlotter(ChartSettings chartSettings, NumberRenderer labelRenderer); void setBoundsValues(Rectangle chartRect, long minXVal, long maxXVal, double minYVal, double maxYVal); synchronized void paintRow(Graphics2D g2d, AbstractGraphRow row, Color color, double zoomFactor, int limitPointFactor);  }