use of org.opennms.features.topology.app.internal.gwt.client.d3.Func in project opennms by OpenNMS.
the class GWTVertex method normalizeSVGIcon.
static Func<String, GWTVertex> normalizeSVGIcon() {
return new Func<String, GWTVertex>() {
@Override
public String call(GWTVertex vertex, int index) {
SVGRect iconRect = getHiddenIconElement(vertex.getSVGIconId());
final int width = iconRect.getWidth();
final int height = iconRect.getHeight();
double primeLength = width >= height ? width : height;
double scaleFactor = primeLength == 0 ? 0.001 : (48 / primeLength);
double newX = (scaleFactor * width) / 2;
double newY = (scaleFactor * height) / 2;
double iconHeight = scaleFactor * height;
vertex.setIconHeight(iconHeight);
vertex.setIconWidth(scaleFactor * width);
if (scaleFactor != Double.POSITIVE_INFINITY) {
vertex.setIconNormalized(true);
}
return "translate(-" + newX + " , -" + newY + ") scale(" + scaleFactor + ")";
}
};
}