Search in sources :

Example 1 with SVGGElement

use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement in project opennms by OpenNMS.

the class VTopologyComponent method vertexClickHandler.

private Handler<GWTVertex> vertexClickHandler() {
    return new D3Events.Handler<GWTVertex>() {

        @Override
        public void call(GWTVertex vertex, int index) {
            if (D3.eventDefaultPrevented()) {
                return;
            }
            NativeEvent event = D3.getEvent();
            SVGGElement vertexElement = event.getCurrentEventTarget().cast();
            vertexElement.getParentElement().appendChild(vertexElement);
            event.preventDefault();
            event.stopPropagation();
            final MouseEventDetails mouseDetails = MouseEventDetailsBuilder.buildMouseEventDetails(event, getElement());
            m_serverRpc.vertexClicked(vertex.getId(), mouseDetails, Navigator.getPlatform());
        }
    };
}
Also used : SVGGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement) MouseEventDetails(com.vaadin.shared.MouseEventDetails) MarqueeSelectHandler(org.opennms.features.topology.app.internal.gwt.client.handler.MarqueeSelectHandler) PanHandler(org.opennms.features.topology.app.internal.gwt.client.handler.PanHandler) Handler(org.opennms.features.topology.app.internal.gwt.client.d3.D3Events.Handler) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 2 with SVGGElement

use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement 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;
        }
    };
}
Also used : D3Events(org.opennms.features.topology.app.internal.gwt.client.d3.D3Events) SVGGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) D3Behavior(org.opennms.features.topology.app.internal.gwt.client.d3.D3Behavior) SVGRect(org.opennms.features.topology.app.internal.gwt.client.svg.SVGRect) D3(org.opennms.features.topology.app.internal.gwt.client.d3.D3) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 3 with SVGGElement

use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement in project opennms by OpenNMS.

the class TopologyViewImpl method getCenterPos.

@Override
public SVGPoint getCenterPos(GWTBoundingBox box) {
    SVGGElement g = getSVGViewPort().cast();
    SVGMatrix stateTF = g.getCTM().inverse();
    SVGPoint p = getSVGElement().createSVGPoint();
    p.setX(getPhysicalWidth() / 2 + getLeftMargin());
    p.setY(getPhysicalHeight() / 2);
    SVGPoint center = p.matrixTransform(stateTF);
    return center;
}
Also used : SVGPoint(org.opennms.features.topology.app.internal.gwt.client.svg.SVGPoint) SVGGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement) SVGMatrix(org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix)

Example 4 with SVGGElement

use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement in project opennms by OpenNMS.

the class TopologyViewImpl method getPoint.

@Override
public SVGPoint getPoint(int clientX, int clientY) {
    SVGGElement g = getSVGViewPort().cast();
    SVGMatrix stateTF = g.getCTM().inverse();
    SVGPoint p = getSVGElement().createSVGPoint();
    p.setX(clientX + getLeftMargin());
    p.setY(clientY);
    SVGPoint center = p.matrixTransform(stateTF);
    return center;
}
Also used : SVGPoint(org.opennms.features.topology.app.internal.gwt.client.svg.SVGPoint) SVGGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement) SVGMatrix(org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix)

Aggregations

SVGGElement (org.opennms.features.topology.app.internal.gwt.client.svg.SVGGElement)4 NativeEvent (com.google.gwt.dom.client.NativeEvent)2 SVGMatrix (org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix)2 SVGPoint (org.opennms.features.topology.app.internal.gwt.client.svg.SVGPoint)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 MouseEventDetails (com.vaadin.shared.MouseEventDetails)1 D3 (org.opennms.features.topology.app.internal.gwt.client.d3.D3)1 D3Behavior (org.opennms.features.topology.app.internal.gwt.client.d3.D3Behavior)1 D3Events (org.opennms.features.topology.app.internal.gwt.client.d3.D3Events)1 Handler (org.opennms.features.topology.app.internal.gwt.client.d3.D3Events.Handler)1 MarqueeSelectHandler (org.opennms.features.topology.app.internal.gwt.client.handler.MarqueeSelectHandler)1 PanHandler (org.opennms.features.topology.app.internal.gwt.client.handler.PanHandler)1 SVGRect (org.opennms.features.topology.app.internal.gwt.client.svg.SVGRect)1