@Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2d.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); for (Slot slot : Slot.values()) { if (slot.isShow() || slot == useSlot) { paintSequence(slot, slot.getPoints(), Color.BLACK, g2d); } } }
/** * @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++; } } }