Now, while we're discussing the API for SVG icons, one thing that seems
painfully missing from VectorIcon - I did some considerable work on Imagine
this winter - it now is more a vector editor than image editor, and loads
and saves SVG - though it needs some more work whenever I get back to it.
And in the spirit of eating my own dogfood, it now has mostly SVG icons
(created in it, of course :-)).
Anyway, this is the issue: There is no way to specify a custom size for an
icon and get an instance of it. Something like
someVectorIcon.getScaledInstance (width, height). So we have scalable
icons...that are only available at *one fixed size?!*
The hideous workaround is to do something like:
class DoubleScaledIcon implements Icon {
private final Icon original;
public void paintIcon (Graphics g, Component c, int x, int y) {
Graphics2D gg = (Graphics2d) g.create();
try {
gg.setTransform(AffineTransform.getScaleInstance(2, 2));
original.paintIcon(gg, c, x, y);
} finally {
gg.dispose();
}
}
public int getIconWidth() { return original.getIconWidth() * 2; }
// ...
}
which is kind of ridiculous. Yes, the idea is to have icons that scale to
the toolkit's scale. But if you're going to have resolution-independent,
scalable icon objects in the first place, it seems bizarre to provide no
way other than hacks to scale them.
-Tim