use of org.opennms.features.topology.app.internal.gwt.client.d3.D3 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.d3.D3 in project opennms by OpenNMS.
the class VTopologyComponent method setupDragBehavior.
private void setupDragBehavior(final Element panElem, final DragHandlerManager handlerManager) {
D3Drag d3Pan = D3.getDragBehavior();
d3Pan.on(D3Events.DRAG_START.event(), new Handler<Element>() {
@Override
public void call(Element elem, int index) {
handlerManager.onDragStart(elem);
}
});
d3Pan.on(D3Events.DRAG.event(), new Handler<Element>() {
@Override
public void call(Element elem, int index) {
handlerManager.onDrag(elem);
}
});
d3Pan.on(D3Events.DRAG_END.event(), new Handler<Element>() {
@Override
public void call(Element elem, int index) {
handlerManager.onDragEnd(elem);
}
});
D3 select = D3.d3().select(panElem);
select.call(d3Pan);
}
Aggregations