Search in sources :

Example 1 with SVGElement

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

the class DragObject method getEventPoint.

protected SVGPoint getEventPoint(NativeEvent event) {
    SVGElement svg = getTopologyView().getSVGElement().cast();
    SVGPoint p = svg.createSVGPoint();
    p.setX(event.getClientX());
    p.setY(event.getClientY());
    return p;
}
Also used : SVGPoint(org.opennms.features.topology.app.internal.gwt.client.svg.SVGPoint) SVGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGElement)

Example 2 with SVGElement

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

the class MarqueeSelectHandler method selectVertices.

private void selectVertices() {
    // We use the svgIconOverlay to determine the selection and ignore the status border, the label
    // and possible invisible elements, such as status badge, navigate to target etc, as the vertex is
    // slightly greater than the svgIconOverlay and the user probably uses the icon itself to make the selection.
    D3 iconOverlay = m_svgTopologyMap.selectAllVertexElements().select(".svgIconOverlay");
    JsArray<JsArray<SVGElement>> selection = iconOverlay.cast();
    final JsArray<SVGElement> elemArray = selection.get(0);
    iconOverlay.each(new Handler<GWTVertex>() {

        @Override
        public void call(GWTVertex vertex, int index) {
            SVGElement elem = elemArray.get(index).cast();
            boolean selected = inSelection(elem);
            vertex.setSelected(selected);
        }
    });
}
Also used : JsArray(com.google.gwt.core.client.JsArray) SVGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGElement) GWTVertex(org.opennms.features.topology.app.internal.gwt.client.GWTVertex) D3(org.opennms.features.topology.app.internal.gwt.client.d3.D3)

Example 3 with SVGElement

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

the class TopologyViewImpl method calculateNewTransform.

@Override
public SVGMatrix calculateNewTransform(GWTBoundingBox bounds) {
    int iconMargin = 50;
    int iconLeftMargin = iconMargin + 50;
    int topMargin = iconMargin + 50;
    SVGElement svg = getSVGElement().cast();
    final int svgWidth = getPhysicalWidth();
    final int svgHeight = getPhysicalHeight();
    double scale = Math.min(svgWidth / ((double) bounds.getWidth() + iconLeftMargin), svgHeight / ((double) bounds.getHeight() + topMargin));
    scale = scale > 2 ? 2 : scale;
    double translateX = -bounds.getX();
    double translateY = -bounds.getY();
    double calcY = (svgHeight - (bounds.getHeight() * scale)) / 2;
    double calcX = (svgWidth - ((bounds.getWidth()) * scale)) / 2 + getLeftMargin();
    SVGMatrix transform = svg.createSVGMatrix().translate(calcX, calcY).scale(scale).translate(translateX, translateY);
    return transform;
}
Also used : SVGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGElement) SVGMatrix(org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix) SVGPoint(org.opennms.features.topology.app.internal.gwt.client.svg.SVGPoint)

Example 4 with SVGElement

use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGElement 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());
}
Also used : SVGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGElement) ClientRect(org.opennms.features.topology.app.internal.gwt.client.svg.ClientRect) SVGRect(org.opennms.features.topology.app.internal.gwt.client.svg.SVGRect)

Example 5 with SVGElement

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

the class MarqueeSelectHandler method onDragStart.

@Override
public void onDragStart(Element elem) {
    SVGElement svg = m_topologyView.getSVGElement().cast();
    SVGMatrix rect = svg.getScreenCTM();
    m_offsetX = (int) rect.getE();
    m_offsetY = (int) rect.getF();
    consoleDebug(rect);
    consoleDebug("m_offsetX: " + m_offsetX + " m_offsetY: " + m_offsetY);
    m_x1 = D3.getEvent().getClientX() - m_offsetX;
    m_y1 = D3.getEvent().getClientY() - m_offsetY;
    setMarquee(m_x1, m_y1, 0, 0);
    D3.d3().select(m_topologyView.getMarqueeElement()).attr("display", "inline");
    D3.getEvent().stopPropagation();
    D3.getEvent().preventDefault();
}
Also used : SVGElement(org.opennms.features.topology.app.internal.gwt.client.svg.SVGElement) SVGMatrix(org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix)

Aggregations

SVGElement (org.opennms.features.topology.app.internal.gwt.client.svg.SVGElement)5 SVGMatrix (org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix)2 SVGPoint (org.opennms.features.topology.app.internal.gwt.client.svg.SVGPoint)2 JsArray (com.google.gwt.core.client.JsArray)1 GWTVertex (org.opennms.features.topology.app.internal.gwt.client.GWTVertex)1 D3 (org.opennms.features.topology.app.internal.gwt.client.d3.D3)1 ClientRect (org.opennms.features.topology.app.internal.gwt.client.svg.ClientRect)1 SVGRect (org.opennms.features.topology.app.internal.gwt.client.svg.SVGRect)1