예제 #1
0
  public void FocusNodes(Set<Functionality.Node> nodes, boolean adjustVertexFilter) {
    PickedState<Functionality.Node> ps = vv.getPickedVertexState();
    List<Functionality.Node> ln = DataModule.displayedGraph.getNodes();
    List<Functionality.Node> pickedList = new ArrayList<Functionality.Node>();
    for (int i = 0; i < ln.size(); i++) {
      if (nodes.contains(ln.get(i))) {
        ps.pick(ln.get(i), true);
        pickedList.add(ln.get(i));
      } else {
        ps.pick(ln.get(i), false);
      }
    }
    VertexColorTransformer.vctInstance.setSelectedNodes(nodes);
    CastroGUI.setSelectedNodesDetail(pickedList);

    vv.setPickedVertexState(ps);

    // DataModule.displayedGraph.setCenter(n);

    if (vdp instanceof VertexDisplayPredicateDistance && adjustVertexFilter) {
      ((VertexDisplayPredicateDistance) vdp).setCentralNodes(ps.getPicked());
    }

    // vv.repaint();*/
    // vv.getRenderContext().setVertexFillPaintTransformer(previousTransformer);

  }
예제 #2
0
 public void setEdgeWeightStrokeFunction() {
   double _normalEdgeThreshold = DataModule.displayedGraph.getNormalEdgeThreshold();
   double _thickEdgeThreshold = DataModule.displayedGraph.getThickEdgeThreshold();
   EdgeWeightStrokeFunction<Functionality.Edge> ewsf =
       new EdgeWeightStrokeFunction<Functionality.Edge>(_normalEdgeThreshold, _thickEdgeThreshold);
   vv.getRenderContext().setEdgeStrokeTransformer(ewsf);
   vv.repaint();
   // System.err.println("edge stroke fc: " + _normalEdgeThreshold + ", " + _thickEdgeThreshold);
 }
예제 #3
0
  public void setDistanceFilter(
      int _depth, VertexDisplayPredicateMode _vdpm, EdgeTypeEnum coreEdgeType) {

    vdp =
        new VertexDisplayPredicateDistance(
            _depth, _vdpm, vv.getPickedVertexState().getPicked(), coreEdgeType);
    vv.getRenderContext().setVertexIncludePredicate(vdp);

    // filter_setting_depth = _depth;
    // filter_setting_filter = _filter;
    vv.repaint();
    System.err.println("SetDistanceFilter");
  }
예제 #4
0
  public void CenterGraph(int borderSpacing, boolean _repaint) {
    List<Functionality.Node> ln = myGraph.getNodes();

    double xsum = 0;
    double ysum = 0;

    for (int i = 0; i < ln.size(); i++) {
      xsum += layout.getX(ln.get(i));
      ysum += layout.getY(ln.get(i));
    }

    double xmean = xsum / ln.size();
    double ymean = ysum / ln.size();

    double xcoef = (layout_width - borderSpacing * 2) / (double) layout_width;
    double ycoef = (layout_height - borderSpacing * 2) / (double) layout_height;

    for (int i = 0; i < ln.size(); i++) {
      double xnew = layout.getX(ln.get(i)) + (layout_width / 2 - xmean);
      double ynew = layout.getY(ln.get(i)) + (layout_height / 2 - ymean);

      layout.setLocation(ln.get(i), xnew, ynew);
    }

    for (int i = 0; i < ln.size(); i++) {
      double xnew = borderSpacing + layout.getX(ln.get(i)) * xcoef;
      double ynew = borderSpacing + layout.getY(ln.get(i)) * ycoef;

      layout.setLocation(ln.get(i), xnew, ynew);
    }

    if (_repaint == true) vv.repaint();
  }
예제 #5
0
  public void mouseClicked(MouseEvent arg0) {
    PickedState<Functionality.Node> pickedState = vv.getPickedVertexState();
    Set<Functionality.Node> ns = pickedState.getPicked();

    Functionality.Node n;
    for (Iterator<Node> it = ns.iterator(); it.hasNext(); ) {
      n = it.next();
      // FocusNode(n.getSpeech_id());
      break;
    }

    GUI.CastroGUI.updateTableSelection(ns);
  }
예제 #6
0
  public JComponent actualizeGraph(boolean lockLayout) {
    // myGraph = g;

    System.err.println("Location: x = " + vv.getLocation().x + ", y = " + vv.getLocation().y);

    MultiLayerTransformer mlt = vv.getRenderContext().getMultiLayerTransformer();
    Map<Functionality.Node, Point2d> locSet = new HashMap<Functionality.Node, Point2d>();

    PickedState<Node> psn = vv.getPickedVertexState();

    List<Functionality.Node> ln = DataModule.displayedGraph.getNodes();
    for (int i = 0; i < ln.size(); i++) {
      locSet.put(ln.get(i), new Point2d(layout.getX(ln.get(i)), layout.getY(ln.get(i))));
    }

    init(DataModule.displayedGraph, layout_width, layout_height);
    drawGraph();

    for (int i = 0; i < ln.size(); i++) {
      layout.setLocation(ln.get(i), locSet.get(ln.get(i)).x, locSet.get(ln.get(i)).y);
    }

    PickedState<Node> newPsn = vv.getPickedVertexState();

    for (int i = 0; i < ln.size(); i++) {
      newPsn.pick(ln.get(i), psn.isPicked(ln.get(i)));
    }

    if (vdp instanceof VertexDisplayPredicateDistance) {
      ((VertexDisplayPredicateDistance) vdp).Actualise();
    }
    vv.getRenderContext().setVertexIncludePredicate(vdp);
    vv.getRenderContext().setEdgeIncludePredicate(eip);

    vv.setPickedVertexState(newPsn);
    vv.getRenderContext().setMultiLayerTransformer(mlt);
    vv.getRenderContext().setVertexFillPaintTransformer(VertexColorTransformer.vctInstance);
    layout.lock(lockLayout);

    MyGraphZoomScrollPane graphPane = new MyGraphZoomScrollPane(vv);

    return graphPane;
  }
예제 #7
0
 public void setNoneFilter() {
   vdp = new VertexDisplayPredicateNone();
   vv.getRenderContext().setVertexIncludePredicate(vdp);
   vv.repaint();
 }
예제 #8
0
 public void setEdgeFilter(boolean dotted, boolean normal, boolean thick) {
   eip = new EdgeIncludePredicate(dotted, normal, thick);
   vv.getRenderContext().setEdgeIncludePredicate(eip);
   vv.repaint();
 }
예제 #9
0
  public JComponent drawGraph() {
    // System.out.println("The graph qt"+qt.toString()); // DEBUG
    // ISOMLayout
    layout = new SpringLayoutWeighted(this.qt);
    layout.setSize(new Dimension(layout_width, layout_height));
    // layout.setSize(new Dimension(layout_width, layout_height));

    vv = new MyVisualizationViewer<Functionality.Node, Functionality.Edge>(layout);
    vv.setBackground(Color.WHITE);
    vv.setPreferredSize(new Dimension(layout_width, layout_height));
    vv.setIgnoreRepaint(true);

    // Show vertex and edge labels
    vv.getRenderContext().setVertexLabelTransformer(new DefaultToStringLabeller());
    // BasicVertexLabelRenderer<Functionality.Node, Functionality.Edge> bvlr =  new
    // (BasicVertexLabelRenderer<Functionality.Node,
    // Functionality.Edge>)(vv.getRenderContext().getVertexLabelRenderer());

    BasicRenderer<Functionality.Node, Functionality.Edge> br = new BasicRenderer<Node, Edge>();
    // br.setVertexLabelRenderer(new BasicVertexLabelRenderer<Functionality.Node,
    // Functionality.Edge>(Position.CNTR));

    vv.setRenderer(br);

    // MyVertexLabelRenderer dvlr = new MyVertexLabelRenderer(Color.red);

    // vv.getRenderContext().setVertexLabelRenderer(dvlr);

    // bvlr.setPosition(Position.CNTR);

    // vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
    vv.setDoubleBuffered(true);

    // layout = new SpringLayout2<Functionality.Node, Functionality.Edge>(this.qt);
    layout.initialize();

    if (myGraph.GetNumberOfClusters() > 1) {
      InitializeClusterGraphLayout();
    }

    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.step();
    layout.lock(true);
    CenterGraph(10, false);

    // Create a graph mouse and add it to the visualization component
    // DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    gm.setMode(ModalGraphMouse.Mode.PICKING);
    vv.addMouseListener(this);
    VertexMouseMenu vMouseMenu = new VertexMouseMenu();
    JPopupMenu vertexMenu = new MyVertexMenu();
    vMouseMenu.setVertexPopup(vertexMenu);
    gm.add(vMouseMenu);

    vv.setGraphMouse(gm);

    setEdgeWeightStrokeFunction();
    vv.getRenderContext()
        .setVertexShapeTransformer(
            new VertexShapeSizeAspect<Functionality.Node, Functionality.Edge>(myGraph));
    vv.getRenderContext().setVertexFillPaintTransformer(VertexColorTransformer.vctInstance);

    MyGraphZoomScrollPane graphPane = new MyGraphZoomScrollPane(vv);

    return graphPane;
  }
예제 #10
0
 public void LayoutStop() {
   layout.lock(true);
   vv.setRedrawing(false);
 }
예제 #11
0
 public void graphTranslation(int _x, int _y) {
   MutableTransformer modelTransformer =
       vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
   modelTransformer.translate(_x, _y);
 }