/** * @param points * @param color * @param g */ private void paintSequence( Slot type, List<List<ValuePointColored>> points, Color color, Graphics2D g) { int i = 0; int size = points.size(); if (size > 0) { double increment = 200 / size; for (List<ValuePointColored> valuePoints : points) { int alpha = (int) (i * increment) + 55; Color c = new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); for (ValuePointColored valuePoint : valuePoints) { double[] coordinates = valuePoint.getPoint().toArray(); int x = xToPix(coordinates[0]); int y = yToPix(coordinates[1]); // if minimum then red, else black if (valuePoint.getBest() == true) { g.setColor(Color.red); } else { g.setColor(c); } g.setStroke(LINE); switch (type) { case CIRCLE: g.drawOval(x - RADIUS / 2 - 3, y - RADIUS / 2 - 3, RADIUS * 2, RADIUS * 2); break; case SQUARE: g.drawRect(x - RADIUS / 2 - 2, y - RADIUS / 2 - 2, RADIUS * 2 - 2, RADIUS * 2 - 2); break; case TRIANGLE: GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 3); polyline.moveTo(x, y - RADIUS / 2 - 4); polyline.lineTo(x + RADIUS / 2 + 3, y + RADIUS / 2 + 1); polyline.lineTo(x - RADIUS / 2 - 3, y + RADIUS / 2 + 1); polyline.closePath(); g.draw(polyline); break; case CROSS: int xLow = x - RADIUS / 2 - 1; int xHigh = x + RADIUS / 2 + 1; int yLow = y - RADIUS / 2 - 1; int yHigh = y + RADIUS / 2 + 1; g.drawLine(xLow, yLow, xHigh, yHigh); g.drawLine(xHigh, yLow, xLow, yHigh); break; } } i++; } } }
public int compare(ValuePointColored o1, ValuePointColored o2) { double yCoordinate1 = o1.getPoint().toArray()[1]; double yCoordinate2 = o2.getPoint().toArray()[1]; if (yCoordinate1 == yCoordinate2) { return 0; } else { if (yCoordinate1 < yCoordinate2) { return -1; } else { return 1; } } }