Search in sources :

Example 1 with NodeModel

use of org.gephi.visualization.model.node.NodeModel in project gephi by gephi.

the class CompatibilityEngine method mouseDrag.

@Override
public void mouseDrag() {
    if (vizConfig.isMouseSelectionUpdateWhileDragging()) {
        mouseMove();
    } else {
        float[] drag = graphIO.getMouseDrag3d();
        if (dragSelected != null) {
            for (NodeModel obj : dragSelected) {
                float[] mouseDistance = obj.getDragDistanceFromMouse();
                obj.getNode().setX(drag[0] + mouseDistance[0]);
                obj.getNode().setY(drag[1] + mouseDistance[1]);
            }
        }
    }
}
Also used : NodeModel(org.gephi.visualization.model.node.NodeModel)

Example 2 with NodeModel

use of org.gephi.visualization.model.node.NodeModel in project gephi by gephi.

the class CompatibilityEngine method updateLOD.

@Override
public void updateLOD() {
    Iterator<NodeModel> iterator = octree.getNodeIterator();
    for (; iterator.hasNext(); ) {
        NodeModel obj = iterator.next();
        nodeModeler.chooseModel(obj);
    }
}
Also used : NodeModel(org.gephi.visualization.model.node.NodeModel)

Example 3 with NodeModel

use of org.gephi.visualization.model.node.NodeModel in project gephi by gephi.

the class CompatibilityEngine method display.

@Override
public void display(GL2 gl, GLU glu) {
    markTime++;
    VizModel vizModel = VizController.getInstance().getVizModel();
    //Edges
    if (edgeModeler.isEnabled()) {
        edgeModeler.beforeDisplay(gl, glu);
        for (Iterator<EdgeModel> itr = octree.getEdgeIterator(); itr.hasNext(); ) {
            EdgeModel obj = itr.next();
            if (obj.markTime != markTime) {
                obj.display(gl, glu, vizModel);
                obj.markTime = markTime;
            }
        }
        edgeModeler.afterDisplay(gl, glu);
    }
    markTime++;
    //Arrows
    if (edgeModeler.isEnabled() && vizConfig.isShowArrows() && dataBridge.isDirected()) {
        gl.glBegin(GL2.GL_TRIANGLES);
        for (Iterator<EdgeModel> itr = octree.getEdgeIterator(); itr.hasNext(); ) {
            EdgeModel obj = itr.next();
            if (obj.getEdge().isDirected() && obj.markTime != markTime) {
                obj.displayArrow(gl, glu, vizModel);
                obj.markTime = markTime;
            }
        }
        gl.glEnd();
    }
    //Nodes
    if (nodeModeler.isEnabled()) {
        nodeModeler.beforeDisplay(gl, glu);
        for (Iterator<NodeModel> itr = octree.getNodeIterator(); itr.hasNext(); ) {
            NodeModel obj = itr.next();
            if (obj.markTime != markTime) {
                obj.display(gl, glu, vizModel);
                obj.markTime = markTime;
            }
        }
        nodeModeler.afterDisplay(gl, glu);
    }
    //Labels
    if (vizModel.getTextModel().isShowNodeLabels() || vizModel.getTextModel().isShowEdgeLabels()) {
        markTime++;
        if (nodeModeler.isEnabled() && vizModel.getTextModel().isShowNodeLabels()) {
            textManager.getNodeRenderer().beginRendering();
            textManager.defaultNodeColor();
            if (textManager.isSelectedOnly()) {
                for (Iterator<NodeModel> itr = octree.getNodeIterator(); itr.hasNext(); ) {
                    NodeModel obj = itr.next();
                    if (obj.markTime != markTime) {
                        if (obj.isSelected() && obj.isTextVisible()) {
                            textManager.getNodeRenderer().drawTextNode(obj);
                        }
                        obj.markTime = markTime;
                    }
                }
            } else {
                for (Iterator<NodeModel> itr = octree.getNodeIterator(); itr.hasNext(); ) {
                    NodeModel obj = itr.next();
                    if (obj.markTime != markTime) {
                        if (obj.isTextVisible()) {
                            textManager.getNodeRenderer().drawTextNode(obj);
                        }
                        obj.markTime = markTime;
                    }
                }
            }
            textManager.getNodeRenderer().endRendering();
        }
        //            }
        if (edgeModeler.isEnabled() && vizModel.getTextModel().isShowEdgeLabels()) {
            markTime++;
            textManager.getEdgeRenderer().beginRendering();
            textManager.defaultEdgeColor();
            if (textManager.isSelectedOnly()) {
                for (Iterator<EdgeModel> itr = octree.getEdgeIterator(); itr.hasNext(); ) {
                    EdgeModel obj = itr.next();
                    if (obj.markTime != markTime) {
                        if ((obj.isSelected() || obj.isAutoSelected()) && obj.isTextVisible()) {
                            textManager.getEdgeRenderer().drawTextEdge(obj);
                        }
                        obj.markTime = markTime;
                    }
                }
            } else {
                for (Iterator<EdgeModel> itr = octree.getEdgeIterator(); itr.hasNext(); ) {
                    EdgeModel obj = itr.next();
                    if (obj.markTime != markTime) {
                        if (obj.isTextVisible()) {
                            textManager.getEdgeRenderer().drawTextEdge(obj);
                        }
                        obj.markTime = markTime;
                    }
                }
            }
            textManager.getEdgeRenderer().endRendering();
        }
    }
//        octree.displayOctree(gl, glu);
}
Also used : VizModel(org.gephi.visualization.VizModel) NodeModel(org.gephi.visualization.model.node.NodeModel) EdgeModel(org.gephi.visualization.model.edge.EdgeModel)

Example 4 with NodeModel

use of org.gephi.visualization.model.node.NodeModel in project gephi by gephi.

the class CompatibilityEngine method mouseMove.

@Override
public void mouseMove() {
    //Selection
    if (vizConfig.isSelectionEnable() && rectangleSelection) {
        Rectangle rectangle = (Rectangle) currentSelectionArea;
        rectangle.setMousePosition(graphIO.getMousePosition(), graphIO.getMousePosition3d());
        if (rectangle.isStop()) {
            return;
        }
    }
    if (customSelection || currentSelectionArea.blockSelection()) {
        return;
    }
    if (!rectangleSelection && graphIO.isDragging()) {
        return;
    }
    boolean someSelection = false;
    for (Iterator<NodeModel> itr = octree.getSelectableNodeIterator(); itr.hasNext(); ) {
        NodeModel obj = itr.next();
        if (isUnderMouse(obj)) {
            if (!obj.isSelected()) {
                //New selected
                obj.setSelected(true);
            }
            someSelection = true;
        } else if (obj.isSelected()) {
            obj.setSelected(false);
        }
    }
    if (vizController.getVizModel().isLightenNonSelectedAuto()) {
        if (vizConfig.isLightenNonSelectedAnimation()) {
            if (!anySelected && someSelection) {
                //Start animation
                lightenAnimationDelta = 0.07f;
            } else if (anySelected && !someSelection) {
                //Stop animation
                lightenAnimationDelta = -0.07f;
            }
            vizConfig.setLightenNonSelected(someSelection || lightenAnimationDelta != 0);
        } else {
            vizConfig.setLightenNonSelected(someSelection);
        }
    }
    anySelected = someSelection;
}
Also used : NodeModel(org.gephi.visualization.model.node.NodeModel) Rectangle(org.gephi.visualization.selection.Rectangle)

Example 5 with NodeModel

use of org.gephi.visualization.model.node.NodeModel in project gephi by gephi.

the class CompatibilityEngine method startDrag.

@Override
public void startDrag() {
    float x = graphIO.getMouseDrag3d()[0];
    float y = graphIO.getMouseDrag3d()[1];
    dragSelected = getSelectedNodes();
    for (NodeModel selected : dragSelected) {
        float[] tab = selected.getDragDistanceFromMouse();
        tab[0] = selected.getNode().x() - x;
        tab[1] = selected.getNode().y() - y;
    }
}
Also used : NodeModel(org.gephi.visualization.model.node.NodeModel)

Aggregations

NodeModel (org.gephi.visualization.model.node.NodeModel)10 Node (org.gephi.graph.api.Node)2 EdgeModel (org.gephi.visualization.model.edge.EdgeModel)2 Rectangle (org.gephi.visualization.selection.Rectangle)2 ArrayList (java.util.ArrayList)1 JPopupMenu (javax.swing.JPopupMenu)1 Edge (org.gephi.graph.api.Edge)1 Graph (org.gephi.graph.api.Graph)1 VizModel (org.gephi.visualization.VizModel)1 EdgeModeler (org.gephi.visualization.model.edge.EdgeModeler)1 NodeModeler (org.gephi.visualization.model.node.NodeModeler)1 Octree (org.gephi.visualization.octree.Octree)1 GraphContextMenuItem (org.gephi.visualization.spi.GraphContextMenuItem)1