use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix 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.SVGMatrix 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;
}
use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix 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;
}
use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix 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();
}
use of org.opennms.features.topology.app.internal.gwt.client.svg.SVGMatrix in project opennms by OpenNMS.
the class PanObject method move.
@Override
public void move() {
Event event = D3.getEvent().cast();
SVGPoint eventPoint = getEventPoint(event);
SVGPoint p = eventPoint.matrixTransform(m_stateTf);
SVGMatrix m = m_stateTf.inverse().translate(p.getX() - m_stateOrigin.getX(), p.getY() - m_stateOrigin.getY());
String matrixTransform = "matrix(" + m.getA() + ", " + m.getB() + ", " + m.getC() + ", " + m.getD() + ", " + m.getE() + ", " + m.getF() + ")";
getDraggableElement().setAttribute("transform", matrixTransform);
}
Aggregations