private String matrixTransform(SVGMatrix matrix) { return "matrix(" + matrix.getA() + ", " + matrix.getB() + ", " + matrix.getC() + ", " + matrix.getD() + ", " + matrix.getE() + ", " + matrix.getF() + ")"; }
@Override public void move() { Event event = D3.getEvent().cast(); SVGPoint p = getEventPoint(event).matrixTransform(m_stateTf); SVGElement svg = getContainerElement().cast(); SVGGElement g = getDraggableElement().cast(); SVGRect gBox = g.getBBox(); SVGMatrix m = m_stateTf .inverse() .translate(p.getX() - m_stateOrigin.getX(), p.getY() - m_stateOrigin.getY()); double mapWidth = gBox.getWidth() * m.getA(); double mapHeight = gBox.getHeight() * m.getA(); double boundaryX = calculateBoundsX(mapWidth, svg.getOffsetWidth(), m.getE()); double boundaryY = calculateBoundsY(mapHeight, svg.getOffsetHeight(), m.getF()); String matrixTransform = "matrix(" + m.getA() + ", " + m.getB() + ", " + m.getC() + ", " + m.getD() + ", " + boundaryX + ", " + boundaryY + ")"; getDraggableElement().setAttribute("transform", matrixTransform); // Updating the reference map // TODO: this needs to be reworked a little its off double viewPortWidth = (getContainerElement().getOffsetWidth() / m.getA()) * 0.4; double viewPortHeight = (getContainerElement().getOffsetHeight() / m.getA()) * 0.4; m_referenceMapViewport.setAttribute("width", "" + viewPortWidth); m_referenceMapViewport.setAttribute("height", "" + viewPortHeight); m_referenceMapViewport.setAttribute("x", "" + (-boundaryX * 0.4)); m_referenceMapViewport.setAttribute("y", "" + (-boundaryY * 0.4)); }