public void initArchitecture() {
    this.engine = VizController.getInstance().getEngine();
    this.drawable = VizController.getInstance().getDrawable();
    this.limits = VizController.getInstance().getLimits();
    this.vizController = VizController.getInstance();

    leaves =
        new ParamAVLTree<Octant>(
            new AVLItemAccessor<Octant>() {

              public int getNumber(Octant item) {
                return item.getNumber();
              }
            });
    visibleLeaves = new ArrayList<Octant>();
    selectedLeaves = new ArrayList<Octant>();

    iteratorQueue = new ConcurrentLinkedQueue<OctreeIterator>();
    iteratorQueue.add(new OctreeIterator());
    iteratorQueue.add(new OctreeIterator());
    iteratorQueue.add(new OctreeIterator());
    iteratorQueue.add(new OctreeIterator());

    float dis = size / (float) Math.pow(2, this.maxDepth + 1);
    root = new Octant(this, 0, dis, dis, dis, size);
  }
Esempio n. 2
0
 @Override
 public void initArchitecture() {
   this.vizConfig = VizController.getInstance().getVizConfig();
   this.engine = VizController.getInstance().getEngine();
   mouseSelectionDiameter = vizConfig.getMouseSelectionDiameter();
   selectionUpdateWhileDragging = vizConfig.isMouseSelectionUpdateWhileDragging();
 }
 @Override
 public void initArchitecture() {
   this.engine = VizController.getInstance().getEngine();
   controller = Lookup.getDefault().lookup(GraphController.class);
   this.vizConfig = VizController.getInstance().getVizConfig();
   this.modeManager = VizController.getInstance().getModeManager();
   this.limits = VizController.getInstance().getLimits();
 }
  public void select(Tool tool) {
    unselect();
    if (tool == null) {
      return;
    }

    // Connect events
    ArrayList<ToolEventHandler> handlers = new ArrayList<ToolEventHandler>();
    for (ToolEventListener toolListener : tool.getListeners()) {
      if (toolListener instanceof NodeClickEventListener) {
        NodeClickEventHandler h = new NodeClickEventHandler(toolListener);
        h.select();
        handlers.add(h);
      } else if (toolListener instanceof NodePressingEventListener) {
        NodePressingEventHandler h = new NodePressingEventHandler(toolListener);
        h.select();
        handlers.add(h);
      } else if (toolListener instanceof MouseClickEventListener) {
        MouseClickEventHandler h = new MouseClickEventHandler(toolListener);
        h.select();
        handlers.add(h);
      } else if (toolListener instanceof NodePressAndDraggingEventListener) {
        NodePressAndDraggingEventHandler h = new NodePressAndDraggingEventHandler(toolListener);
        h.select();
        handlers.add(h);

      } else {
        throw new RuntimeException(
            "The ToolEventListener "
                + toolListener.getClass().getSimpleName()
                + " cannot be recognized");
      }
    }
    currentHandlers = handlers.toArray(new ToolEventHandler[0]);
    switch (tool.getSelectionType()) {
      case NONE:
        VizController.getInstance().getSelectionManager().disableSelection();
        break;
      case SELECTION:
        VizController.getInstance().getSelectionManager().blockSelection(true);
        VizController.getInstance().getSelectionManager().setDraggingEnable(false);
        break;
      case SELECTION_AND_DRAGGING:
        VizController.getInstance().getSelectionManager().blockSelection(true);
        VizController.getInstance().getSelectionManager().setDraggingEnable(true);
        break;
    }
    currentTool = tool;
    unselectTool = currentTool.select();

    if (unselectTool) {
      toolbar.clearSelection();
      unselect();
    }
  }
    public void select() {
      currentListeners = new VizEventListener[2];
      currentListeners[0] =
          new VizEventListener() {

            public void handleEvent(VizEvent event) {
              toolEventListener.pressingNodes((Node[]) event.getData());
            }

            public Type getType() {
              return VizEvent.Type.NODE_LEFT_PRESSING;
            }
          };
      currentListeners[1] =
          new VizEventListener() {

            public void handleEvent(VizEvent event) {
              toolEventListener.released();
            }

            public Type getType() {
              return VizEvent.Type.MOUSE_RELEASED;
            }
          };
      VizController.getInstance().getVizEventManager().addListener(currentListeners);
    }
    public void select() {
      currentListener =
          new VizEventListener() {

            public void handleEvent(VizEvent event) {
              toolEventListener.clickNodes((Node[]) event.getData());
            }

            public Type getType() {
              return VizEvent.Type.NODE_LEFT_CLICK;
            }
          };
      VizController.getInstance().getVizEventManager().addListener(currentListener);
    }
    public void select() {
      currentListener =
          new VizEventListener() {

            public void handleEvent(VizEvent event) {
              float[] data = (float[]) event.getData();
              int[] viewport = new int[] {(int) data[0], (int) data[1]};
              float[] threed = new float[] {data[2], data[3]};
              toolEventListener.mouseClick(viewport, threed);
            }

            public Type getType() {
              return VizEvent.Type.MOUSE_LEFT_CLICK;
            }
          };
      VizController.getInstance().getVizEventManager().addListener(currentListener);
    }
Esempio n. 8
0
  public void createModelClassesCompatibility(CompatibilityEngine engine) {
    // NODE
    nodeClass = new ModelClass(0, "NODE", true, true, true, false);
    NodeSphereModeler modeler3d = new NodeSphereModeler(engine);
    NodeDiskModeler modeler2d = new NodeDiskModeler(engine);
    NodeRectangleModeler modelerRect = new NodeRectangleModeler(engine);
    nodeClass.addModeler(modeler3d);
    nodeClass.addModeler(modeler2d);
    nodeClass.addModeler(modelerRect);
    if (VizController.getInstance().getVizModel().isUse3d()) {
      nodeClass.setCurrentModeler(modeler3d);
    } else {
      nodeClass.setCurrentModeler(modeler2d);
    }

    // EDGE
    edgeClass = new ModelClass(1, "EDGE", false, true, false, true);
    EdgeModeler edgeModeler = new EdgeModeler(engine);
    edgeClass.addModeler(edgeModeler);
    edgeClass.setCurrentModeler(edgeModeler);
  }
    public void select() {
      currentListeners = new VizEventListener[3];
      currentListeners[0] =
          new VizEventListener() {

            public void handleEvent(VizEvent event) {
              toolEventListener.pressNodes((Node[]) event.getData());
            }

            public Type getType() {
              return VizEvent.Type.NODE_LEFT_PRESS;
            }
          };
      currentListeners[1] =
          new VizEventListener() {

            public void handleEvent(VizEvent event) {
              float[] mouseDrag = (float[]) event.getData();
              toolEventListener.drag(mouseDrag[0], mouseDrag[1]);
            }

            public Type getType() {
              return VizEvent.Type.DRAG;
            }
          };
      currentListeners[2] =
          new VizEventListener() {

            public void handleEvent(VizEvent event) {
              toolEventListener.released();
            }

            public Type getType() {
              return VizEvent.Type.MOUSE_RELEASED;
            }
          };
      VizController.getInstance().getVizEventManager().addListener(currentListeners);
    }
 public void selectCluster(Cluster cluster) {
   SelectionManager selectionManager = VizController.getInstance().getSelectionManager();
   selectionManager.resetSelection();
   selectionManager.selectNodes(cluster.getNodes());
 }
 public void unselect() {
   VizController.getInstance().getVizEventManager().removeListener(currentListener);
   toolEventListener = null;
   currentListener = null;
 }
  public JComponent getToolbar() {

    // Get tools ui
    HashMap<ToolUI, Tool> toolMap = new HashMap<ToolUI, Tool>();
    List<ToolUI> toolsUI = new ArrayList<ToolUI>();
    for (Tool tool : tools) {
      ToolUI ui = tool.getUI();
      if (ui != null) {
        toolsUI.add(ui);
        toolMap.put(ui, tool);
      }
    }
    // Sort by priority
    Collections.sort(
        toolsUI,
        new Comparator() {

          public int compare(Object o1, Object o2) {
            Integer p1 = ((ToolUI) o1).getPosition();
            Integer p2 = ((ToolUI) o2).getPosition();
            return p1.compareTo(p2);
          }
        });

    // Create toolbar
    final Toolbar toolbar = new Toolbar();
    for (final ToolUI toolUI : toolsUI) {
      final Tool tool = toolMap.get(toolUI);
      JToggleButton btn;
      if (toolUI.getIcon() != null) {
        btn = new JToggleButton(toolUI.getIcon());
      } else {
        btn =
            new JToggleButton(
                new ImageIcon(getClass().getResource("/org/gephi/desktop/tools/tool.png")));
      }
      btn.setToolTipText(toolUI.getName() + " - " + toolUI.getDescription());
      btn.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent e) {
              // Let the user unselect a tool (by clicking on it again) without having to select
              // other tool:
              if (tool == currentTool) {
                toolbar.clearSelection();
                unselect();
              } else {
                select(tool);

                if (!unselectTool) propertiesBar.select(toolUI.getPropertiesBar(tool));
              }
            }
          });
      toolbar.add(btn);
    }

    // SelectionManager events
    VizController.getInstance()
        .getSelectionManager()
        .addChangeListener(
            new ChangeListener() {

              public void stateChanged(ChangeEvent e) {
                SelectionManager selectionManager =
                    VizController.getInstance().getSelectionManager();

                if (selectionManager.isRectangleSelection() && currentTool != null) {
                  toolbar.clearSelection();
                  unselect();
                } else if (selectionManager.isSelectionEnabled()
                    && currentTool != null
                    && currentTool.getSelectionType() == ToolSelectionType.NONE) {
                  toolbar.clearSelection();
                  unselect();
                } else if (selectionManager.isDraggingEnabled() && currentTool != null) {
                  toolbar.clearSelection();
                  unselect();
                }
              }
            });

    this.toolbar = toolbar;

    return toolbar;
  }
Esempio n. 13
0
 @Override
 public void defaultEdgeColor(Renderer renderer) {
   color = VizController.getInstance().getVizModel().getTextModel().edgeColor;
 }
Esempio n. 14
0
 public TextColorMode() {
   this.vizConfig = VizController.getInstance().getVizConfig();
 }
  public void initArchitecture() {
    model = VizController.getInstance().getVizModel().getTextModel();
    vizConfig = VizController.getInstance().getVizConfig();
    drawable = VizController.getInstance().getDrawable();
    initRenderer();

    // Init sizemodes
    for (SizeMode s : sizeModes) {
      s.init();
    }

    // Model listening
    model.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent e) {
            if (!nodeRenderer.getFont().equals(model.getNodeFont())) {
              nodeRenderer.setFont(model.getNodeFont());
            }
            if (!edgeRenderer.getFont().equals(model.getEdgeFont())) {
              edgeRenderer.setFont(model.getEdgeFont());
            }
            nodeRefresh = true;
            edgeRefresh = true;
          }
        });

    // Model change
    VizController.getInstance()
        .getVizModel()
        .addPropertyChangeListener(
            new PropertyChangeListener() {

              public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("init")) {
                  TextManager.this.model = VizController.getInstance().getVizModel().getTextModel();

                  // Initialize columns if needed
                  if (model.getNodeTextColumns() == null
                      || model.getNodeTextColumns().length == 0) {
                    AttributeController attributeController =
                        Lookup.getDefault().lookup(AttributeController.class);
                    if (attributeController != null && attributeController.getModel() != null) {
                      AttributeModel attributeModel = attributeController.getModel();
                      AttributeColumn[] nodeCols =
                          new AttributeColumn[] {
                            attributeModel
                                .getNodeTable()
                                .getColumn(PropertiesColumn.NODE_LABEL.getIndex())
                          };
                      AttributeColumn[] edgeCols =
                          new AttributeColumn[] {
                            attributeModel
                                .getEdgeTable()
                                .getColumn(PropertiesColumn.EDGE_LABEL.getIndex())
                          };
                      model.setTextColumns(nodeCols, edgeCols);
                    }
                  }

                  DynamicModel dynamicModel = dynamicController.getModel();
                  if (dynamicModel != null) {
                    currentTimeInterval = dynamicModel.getVisibleInterval();
                    builder.setDefaultEstimator(dynamicModel.getEstimator());
                    builder.setNumberEstimator(dynamicModel.getNumberEstimator());
                  } else {
                    currentTimeInterval = null;
                  }
                }
              }
            });

    // Settings
    antialised = vizConfig.isLabelAntialiased();
    mipmap = vizConfig.isLabelMipMap();
    fractionalMetrics = vizConfig.isLabelFractionalMetrics();
    renderer3d = false;

    // Dynamic change
    dynamicController = Lookup.getDefault().lookup(DynamicController.class);
    dynamicController.addModelListener(
        new DynamicModelListener() {

          public void dynamicModelChanged(DynamicModelEvent event) {
            if (event.getEventType().equals(DynamicModelEvent.EventType.VISIBLE_INTERVAL)) {
              currentTimeInterval = (TimeInterval) event.getData();
            }
          }
        });
  }
Esempio n. 16
0
 public void initArchitecture() {
   this.drawable = VizController.getInstance().getDrawable();
   this.limits = VizController.getInstance().getLimits();
   this.vizController = VizController.getInstance();
 }