Ejemplo n.º 1
0
  private void drawGraph(GWTGraph g, boolean now) {

    if (now) {
      m_graphDrawerNoTransition.updateGraph(g);
    } else {
      m_graphDrawer.updateGraph(g);
    }

    // TODO: working here
    SVGRect bbox = getSVGElement().getBBox();
    SVGGElement map = m_svgViewPort.cast();
    SVGRect mapBbox = map.getBBox();
    double referenceScale = 0.4;
    int x = bbox.getX();
    int y = bbox.getY();
    int width = (int) (mapBbox.getWidth() * referenceScale);
    int height = (int) (mapBbox.getHeight() * referenceScale);

    int viewPortWidth = (int) (m_svg.getOffsetWidth() * referenceScale);
    int viewPortHeight = (int) (m_svg.getOffsetHeight() * referenceScale);

    m_referenceMapViewport.setAttribute("width", "" + viewPortWidth);
    m_referenceMapViewport.setAttribute("height", "" + viewPortHeight);

    m_referenceMap.setAttribute(
        "transform",
        "translate("
            + (m_svg.getOffsetWidth() - width)
            + " "
            + (m_svg.getOffsetHeight() - height)
            + ")");

    // TODO: Fix this calc

    m_scaledMap.setAttribute(
        "viewBox", x + " " + y + " " + mapBbox.getWidth() + " " + mapBbox.getHeight());
  }
Ejemplo n.º 2
0
    @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));
    }