use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGRect 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 + ")";
}
};
}
use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGRect in project opennms by OpenNMS.
the class GWTVertex method create.
public static D3Behavior create() {
return new D3Behavior() {
@Override
public D3 run(D3 selection) {
D3 vertex = selection.append("g").attr("class", "vertex");
vertex.attr("opacity", 1e-6).style("cursor", "pointer");
vertex.append("svg:rect").attr("class", "status").attr("fill", "none").attr("stroke-width", 5).attr("stroke-location", "outside").attr("stroke", "blue").attr("opacity", 0);
D3 svgIconContainer = vertex.append("g").attr("class", "icon-container").attr("opacity", 0);
D3 svgIcon = svgIconContainer.append("use");
D3 svgIconRollover = svgIconContainer.append("use");
D3 svgIconActive = svgIconContainer.append("use");
D3 statusCounter = vertex.append("g");
D3 statusBadge = vertex.append("g");
D3 textSelection = vertex.append("text");
D3 navigateTo = vertex.append("g").attr("class", "navigate-to");
vertex.append("svg:rect").attr("class", "svgIconOverlay").attr("width", 100).attr("height", 100).attr("opacity", 0).call(new D3Behavior() {
@Override
public D3 run(D3 selection) {
return selection.on("mouseover", new D3Events.Handler<Object>() {
@Override
public void call(Object o, int index) {
NativeEvent event = D3.getEvent();
SVGRect element = event.getCurrentEventTarget().cast();
SVGGElement parent = element.getParentElement().cast();
D3 selection = D3.d3().select(parent);
selection.select(".overIcon").attr("opacity", 1);
}
}).on("mouseout", new D3Events.Handler<Object>() {
@Override
public void call(Object o, int index) {
NativeEvent event = D3.getEvent();
SVGRect element = event.getCurrentEventTarget().cast();
SVGGElement parent = element.getParentElement().cast();
D3 selection = D3.d3().select(parent);
selection.select(".overIcon").attr("opacity", 0);
}
});
}
});
svgIcon.attr("xlink:href", svgIconId("")).attr("class", "upIcon");
svgIconRollover.attr("xlink:href", svgIconId("_rollover")).attr("class", "overIcon").attr("opacity", 0);
svgIconActive.attr("xlink:href", svgIconId("_active")).attr("class", "activeIcon").attr("opacity", 0);
// Status Counter
statusCounter.attr("class", "node-status-counter").append("svg:rect").attr("height", 20).attr("width", 20).attr("rx", 10).attr("ry", 10);
statusCounter.append("text").attr("x", "6px").attr("y", "14px").attr("class", "status-counter");
// Status Badge
statusBadge.attr("class", "status-badge-container");
statusBadge.append("text").attr("x", "0px").attr("y", "0px").attr("class", "status-badge");
// Navigate To indicator
navigateTo.append("text").attr("class", "text").attr("opacity", 1).attr("x", -23).attr("y", 23).text(// ion-record
"");
textSelection.text(label()).attr("class", "vertex-label").attr("x", "0px").attr("text-anchor", "middle").attr("alignment-baseline", "text-before-edge");
vertex.call(draw());
return vertex;
}
};
}
use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGRect in project opennms by OpenNMS.
the class MarqueeSelectHandler method inSelection.
private boolean inSelection(SVGElement elem) {
SVGElement marquee = m_topologyView.getMarqueeElement().cast();
SVGRect mBBox = marquee.getBBox();
ClientRect elemClientRect = elem.getBoundingClientRect();
Interval marqueeX = new Interval(mBBox.getX(), mBBox.getX() + mBBox.getWidth());
Interval marqueeY = new Interval(mBBox.getY(), mBBox.getY() + mBBox.getHeight());
int left = elemClientRect.getLeft() - m_offsetX;
int top = elemClientRect.getTop() - m_offsetY;
Interval vertexX = new Interval(left, left + elemClientRect.getWidth());
Interval vertexY = new Interval(top, top + elemClientRect.getHeight());
return marqueeX.contains(vertexX.getLo()) && marqueeX.contains(vertexX.getHi()) && marqueeY.contains(vertexY.getLo()) && marqueeY.contains(vertexY.getHi());
}
Aggregations