I hope you find the following workaround (rewrite) to be useful. It doesn't require all the map setting. I'm sure it's not too hard to rewrite this to be smarter about ImageIcons (Lombok annotations should produce the obvious boilerplate)
@RequiredArgsConstructor
public class VertexIconShapeTransformerFixed<V> implements Transformer<V, Shape> {
private final Transformer<V, Icon> vertexIconTransformer;
// https://sourceforge.net/tracker/?func=detail&aid=3552131&group_id=73840&atid=539119
@Override
public Shape transform(final V v) {
Icon icon = vertexIconTransformer.transform(v);
int width = icon.getIconWidth();
int height = icon.getIconHeight();
Rectangle shape = new Rectangle(width, height);
// fommil: I don't understand why this transformation is needed
AffineTransform transform = AffineTransform.getTranslateInstance(-width / 2, -height / 2);
return transform.createTransformedShape(shape);
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
(of course, it is only simpler if the Icon is to be assumed to be a Rectangle)
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
conversion of an Icon to an Image, e.g.
http://stackoverflow.com/questions/5830533
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Also, the caching looks like it is assuming that the Icon for a vertex is never going to change. Not sure that is true...
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
I hope you find the following workaround (rewrite) to be useful. It doesn't require all the map setting. I'm sure it's not too hard to rewrite this to be smarter about ImageIcons (Lombok annotations should produce the obvious boilerplate)
@RequiredArgsConstructor
public class VertexIconShapeTransformerFixed<V> implements Transformer<V, Shape> {
private final Transformer<V, Icon> vertexIconTransformer;
// https://sourceforge.net/tracker/?func=detail&aid=3552131&group_id=73840&atid=539119
@Override
public Shape transform(final V v) {
Icon icon = vertexIconTransformer.transform(v);
int width = icon.getIconWidth();
int height = icon.getIconHeight();
Rectangle shape = new Rectangle(width, height);
// fommil: I don't understand why this transformation is needed
AffineTransform transform = AffineTransform.getTranslateInstance(-width / 2, -height / 2);
return transform.createTransformedShape(shape);
}
}
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
isn't sourceforge so developer friendly the way it formats all my Java workarounds ;-) Happy to send you original .java if you e-mail me.