@Override public void paint(Graphics2D g2) { if (!visible) return; Composite old = g2.getComposite(); g2.setComposite(HINT_ALPHA_COMPOSITE); int sqSize = getSquareSize(); Double scale = sqSize == FULL_SIZE ? null : (double) sqSize / FULL_SIZE; TextureFactory textures = new TextureFactory(sqSize); if (doRefreshHints) { doRefreshHints = false; fillHints(); } for (FarmHint fh : hints) { if (fh.scaledArea == null) { if (scale == null) { fh.scaledArea = fh.area; } else { fh.scaledArea = fh.area.createTransformedArea(AffineTransform.getScaleInstance(scale, scale)); } } Area area = transformArea(fh.scaledArea, fh.position); if (fh.colors.length > 1) { g2.setPaint(textures.createMultiColor(fh.colors)); g2.fill(area); } else { g2.setPaint(textures.create(fh.colors[0])); g2.fill(area); } } g2.setPaint(null); g2.setComposite(old); }
@Override public void zoomChanged(int squareSize) { for (FarmHint fh : hints) { fh.scaledArea = null; } }