Example #1
0
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Load Graph")) {
      Explorer explorer = new Explorer();
      String path = explorer.showDialog(this);
      System.out.println("DEBUG: The graph selected is: " + path);
      if (!(path.equals(""))) {
        Vector graphNodes = utils.parseFile(path);
        algorithm_View.setGraphNodes(graphNodes);
        drawer.paintGraph(graphNodes);
        for (int i = 0; i < graphNodes.size(); i++) {
          System.out.print("Service " + (i + 1) + ":    ");
          Vector si = (Vector) graphNodes.elementAt(i);
          for (int j = 0; j < si.size(); j++) {
            String siValue =
                ((ServiceImplementation) si.elementAt(j)).getId()
                    + "-"
                    + ((ServiceImplementation) si.elementAt(j)).getSid();
            System.out.print(siValue);
            System.out.print("    ");
          }
          System.out.println();
        }
        algorithm_View.setGraphPanel(drawer.getGComponent());
      }
    }
    if (e.getActionCommand().equals("Reset View")) {}

    if (e.getActionCommand().equals("About...")) {
      JOptionPane.showMessageDialog(
          frame, "Version v0.2\nPatricia Uriol\nFelipe IbaƱez\nDREQUIEM\nUC3M");
    }
    if (e.getActionCommand().equals("Manual")) {
      JOptionPane.showMessageDialog(frame, helpManual);
    }
  }
  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());
  }