Esempio n. 1
0
 protected SVGPoint getEventPoint(NativeEvent event) {
   SVGElement svg = m_svg.cast();
   SVGPoint p = svg.createSVGPoint();
   p.setX(event.getClientX());
   p.setY(event.getClientY());
   return p;
 }
Esempio n. 2
0
  private void updateScale(double oldScale, double newScale, SVGElement svg, int cx, int cy) {

    double zoomFactor = newScale / oldScale;
    // (x in new coord system - x in old coord system)/x coordinate
    SVGGElement g = m_svgViewPort.cast();

    if (cx == 0) {
      cx = (int) (Math.ceil(svg.getOffsetWidth() / 2.0) - 1);
    }

    if (cy == 0) {
      cy = (int) (Math.ceil(svg.getOffsetHeight() / 2.0) - 1);
    }

    SVGPoint p = svg.createSVGPoint();
    p.setX(cx);
    p.setY(cy);
    p = p.matrixTransform(g.getCTM().inverse());

    SVGMatrix m =
        svg.createSVGMatrix()
            .translate(p.getX(), p.getY())
            .scale(zoomFactor)
            .translate(-p.getX(), -p.getY());
    SVGMatrix ctm = g.getCTM().multiply(m);

    consoleLog("zoomFactor: " + zoomFactor + " oldScale: " + oldScale + " newScale:" + newScale);
    D3.d3()
        .select(m_svgViewPort)
        .transition()
        .duration(1000)
        .attr("transform", matrixTransform(ctm));
  }
Esempio n. 3
0
 private SVGPoint getPoint(int x, int y) {
   SVGPoint p = getSVGElement().createSVGPoint();
   p.setX(x);
   p.setY(y);
   return p;
 }