Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 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");
  }
Ejemplo n.º 4
0
 public void setNoneFilter() {
   vdp = new VertexDisplayPredicateNone();
   vv.getRenderContext().setVertexIncludePredicate(vdp);
   vv.repaint();
 }
Ejemplo n.º 5
0
 public void setEdgeFilter(boolean dotted, boolean normal, boolean thick) {
   eip = new EdgeIncludePredicate(dotted, normal, thick);
   vv.getRenderContext().setEdgeIncludePredicate(eip);
   vv.repaint();
 }
Ejemplo n.º 6
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;
  }
Ejemplo n.º 7
0
 public void graphTranslation(int _x, int _y) {
   MutableTransformer modelTransformer =
       vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
   modelTransformer.translate(_x, _y);
 }