@Override public void paintComponent(Graphics graphics) { super.paintComponent(graphics); Graphics2D g = (Graphics2D) graphics; g.setStroke(new BasicStroke(3)); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (image != null) { for (Blob blob : this.image.getBlobs()) { for (Point point : blob.getPoints()) { g.setColor(new Color(100, 100, 200, 20)); int length = blob.getPoints().size(); int[] xs = new int[length]; int[] ys = new int[length]; for (int i = 0; i < length; i++) { Point p = blob.getPoints().get(i); xs[i] = p.getX(); ys[i] = p.getY(); } g.fillPolygon(xs, ys, length); g.setColor(Color.green); if (blob == selectedBlob) { g.setColor(Color.red); } g.fillOval(point.getX() - 5, point.getY() - 5, 10, 10); int currentIndex = blob.getPoints().indexOf(point); Point lastPoint; if (currentIndex == 0) { lastPoint = blob.getPoints().get(blob.getPoints().size() - 1); } else { lastPoint = blob.getPoints().get(currentIndex - 1); } g.drawLine(point.getX(), point.getY(), lastPoint.getX(), lastPoint.getY()); } } if (tempPoints == null) { return; } g.setColor(Color.green); for (Point point : tempPoints) { g.fillOval(point.getX() - 5, point.getY() - 5, 10, 10); int currentIndex = tempPoints.indexOf(point); if (currentIndex > 0) { Point lastPoint = tempPoints.get(currentIndex - 1); g.setColor(Color.green); g.drawLine(point.getX(), point.getY(), lastPoint.getX(), lastPoint.getY()); } } } }