void (@NotNull Graphics2D g2, @NotNull Collection<? extends PrintElement> printElements) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); List<PrintElement> selected = new SmartList<>(); for (PrintElement printElement : printElements) { if (printElement.isSelected()) { selected.add(printElement); // to draw later } else { drawElement(g2, printElement, false); } } // draw selected elements for (PrintElement printElement : selected) { drawElement(g2, printElement, true); } for (PrintElement printElement : selected) { drawElement(g2, printElement, false); } }