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;
}
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);
}
});
}
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;
}
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());
}
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();
}
Aggregations