Package org.gephi.visualization.apiimpl

Examples of org.gephi.visualization.apiimpl.ModelImpl


    }

    @Override
    public void display(GL gl, GLU glu) {
        for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_NODE); itr.hasNext();) {       //TODO Move this
            ModelImpl obj = itr.next();
            modelClasses[AbstractEngine.CLASS_NODE].getCurrentModeler().chooseModel(obj);
            setViewportPosition(obj);
        }

        markTime++;

        CompatibilityModelClass edgeClass = modelClasses[AbstractEngine.CLASS_EDGE];
        CompatibilityModelClass nodeClass = modelClasses[AbstractEngine.CLASS_NODE];
        CompatibilityModelClass arrowClass = modelClasses[AbstractEngine.CLASS_ARROW];
        CompatibilityModelClass potatoClass = modelClasses[AbstractEngine.CLASS_POTATO];

        VizModel vizModel = VizController.getInstance().getVizModel();

        //Potato
        if (potatoClass.isEnabled()) {
            potatoClass.beforeDisplay(gl, glu);
            for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_POTATO); itr.hasNext();) {
                ModelImpl obj = itr.next();

                if (obj.markTime != markTime) {
                    obj.display(gl, glu, vizModel);
                    obj.markTime = markTime;
                }

            }
            potatoClass.afterDisplay(gl, glu);
        }

        //Edges
        if (edgeClass.isEnabled()) {
            edgeClass.beforeDisplay(gl, glu);
            for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_EDGE); itr.hasNext();) {
                ModelImpl obj = itr.next();
                //Renderable renderable = obj.getObj();

                if (obj.markTime != markTime) {
                    obj.display(gl, glu, vizModel);
                    obj.markTime = markTime;
                }

            }
            edgeClass.afterDisplay(gl, glu);
        }

        //Arrows
        if (arrowClass.isEnabled()) {
            arrowClass.beforeDisplay(gl, glu);
            for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_ARROW); itr.hasNext();) {
                ModelImpl obj = itr.next();
                if (obj.markTime != markTime) {
                    obj.display(gl, glu, vizModel);
                    obj.markTime = markTime;
                }
            }
            arrowClass.afterDisplay(gl, glu);
        }

        //Nodes
        if (nodeClass.isEnabled()) {
            nodeClass.beforeDisplay(gl, glu);
            for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_NODE); itr.hasNext();) {
                ModelImpl obj = itr.next();
                if (obj.markTime != markTime) {
                    obj.display(gl, glu, vizModel);
                    obj.markTime = markTime;
                }
            }
            nodeClass.afterDisplay(gl, glu);
        }

        //Labels
        if (vizModel.getTextModel().isShowNodeLabels() || vizModel.getTextModel().isShowEdgeLabels()) {
            markTime++;
            if (nodeClass.isEnabled() && vizModel.getTextModel().isShowNodeLabels()) {
                textManager.getNodeRenderer().beginRendering();
                textManager.defaultNodeColor();
                if (textManager.isSelectedOnly()) {
                    for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_NODE); itr.hasNext();) {
                        ModelImpl obj = itr.next();
                        if (obj.markTime != markTime) {
                            if ((obj.isSelected() || obj.isHighlight()) && obj.getObj().getTextData().isVisible()) {
                                textManager.getNodeRenderer().drawTextNode(obj);
                            }
                            obj.markTime = markTime;
                        }
                    }
                } else {
                    for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_NODE); itr.hasNext();) {
                        ModelImpl obj = itr.next();
                        if (obj.markTime != markTime) {
                            if (obj.getObj().getTextData().isVisible()) {
                                textManager.getNodeRenderer().drawTextNode(obj);
                            }
                            obj.markTime = markTime;
                        }
                    }
                }
                textManager.getNodeRenderer().endRendering();
            }
            if (edgeClass.isEnabled() && vizModel.getTextModel().isShowEdgeLabels()) {
                textManager.getEdgeRenderer().beginRendering();
                textManager.defaultEdgeColor();
                if (textManager.isSelectedOnly()) {
                    for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_EDGE); itr.hasNext();) {
                        ModelImpl obj = itr.next();
                        if (obj.markTime != markTime) {
                            if ((obj.isSelected() || obj.isHighlight()) && obj.getObj().getTextData().isVisible()) {
                                textManager.getEdgeRenderer().drawTextEdge(obj);
                            }
                            obj.markTime = markTime;
                        }
                    }
                } else {
                    for (Iterator<ModelImpl> itr = octree.getObjectIterator(AbstractEngine.CLASS_EDGE); itr.hasNext();) {
                        ModelImpl obj = itr.next();
                        if (obj.markTime != markTime) {
                            if (obj.getObj().getTextData().isVisible()) {
                                textManager.getEdgeRenderer().drawTextEdge(obj);
                            }
                            obj.markTime = markTime;
                        }
                    }
View Full Code Here


            int i = 0;
            boolean someSelection = false;
            for (ModelClass objClass : selectableClasses) {
                markTime2++;
                for (Iterator<ModelImpl> itr = octree.getSelectedObjectIterator(objClass.getClassId()); itr.hasNext();) {
                    ModelImpl obj = itr.next();
                    if (isUnderMouse(obj) && currentSelectionArea.select(obj.getObj())) {
                        if (!obj.isSelected()) {
                            //New selected
                            obj.setSelected(true);
                            /*if (vizEventManager.hasSelectionListeners()) {
                            newSelectedObjects.add(obj);
                            }*/
                            selectedObjects[i].add(obj);
                        }
                        someSelection = true;
                        obj.selectionMark = markTime2;
                    }
                }
                if (!(rectangle.isCtrl() && someSelection)) {
                    for (Iterator<ModelImpl> itr = selectedObjects[i].iterator(); itr.hasNext();) {
                        ModelImpl o = itr.next();
                        if (o.selectionMark != markTime2) {
                            itr.remove();
                            o.setSelected(false);
                        }
                    }
                }

                i++;
View Full Code Here

        boolean someSelection = false;
        boolean forceUnselect = false;
        for (ModelClass objClass : selectableClasses) {
            forceUnselect = objClass.isAloneSelection() && someSelection;
            for (Iterator<ModelImpl> itr = octree.getSelectedObjectIterator(objClass.getClassId()); itr.hasNext();) {
                ModelImpl obj = itr.next();
                if (!forceUnselect && isUnderMouse(obj) && currentSelectionArea.select(obj.getObj())) {
                    if (!objClass.isAloneSelection()) {  //avoid potatoes to select
                        someSelection = true;
                    }
                    if (!obj.isSelected()) {
                        //New selected
                        obj.setSelected(true);
                        /*if (vizEventManager.hasSelectionListeners()) {
                        newSelectedObjects.add(obj);
                        }*/
                        selectedObjects[i].add(obj);
                    }
                    obj.selectionMark = markTime2;
                } else if (currentSelectionArea.unselect(obj.getObj())) {
                    if (forceUnselect) {
                        obj.setAutoSelect(false);
                    } /*else if (vizEventManager.hasSelectionListeners() && obj.isSelected()) {
                    unSelectedObjects.add(obj);
                    }*/
                }
            }

            for (Iterator<ModelImpl> itr = selectedObjects[i].iterator(); itr.hasNext();) {
                ModelImpl o = itr.next();
                if (o.selectionMark != markTime2) {
                    itr.remove();
                    o.setSelected(false);
                }
            }
            i++;
        }

View Full Code Here

    public void startDrag() {
        float x = graphIO.getMouseDrag3d()[0];
        float y = graphIO.getMouseDrag3d()[1];

        for (Iterator<ModelImpl> itr = selectedObjects[0].iterator(); itr.hasNext();) {
            ModelImpl o = itr.next();
            float[] tab = o.getDragDistanceFromMouse();
            tab[0] = o.getObj().x() - x;
            tab[1] = o.getObj().y() - y;
        }
    }
View Full Code Here

        return selectedObjects[modelClasses[modelClass].getSelectionId()].toArray(new ModelImpl[0]);
    }

    @Override
    public void selectObject(Model obj) {
        ModelImpl modl = (ModelImpl) obj;
        if (!customSelection) {
            vizConfig.setRectangleSelection(false);
            customSelection = true;
            configChanged = true;
            //Reset
            for (ModelClass objClass : selectableClasses) {
                for (Iterator<ModelImpl> itr = selectedObjects[objClass.getSelectionId()].iterator(); itr.hasNext();) {
                    ModelImpl o = itr.next();
                    itr.remove();
                    o.setSelected(false);
                }
            }
            anySelected = true;
            //Force highlight
            if (vizController.getVizModel().isLightenNonSelectedAuto()) {
View Full Code Here

            customSelection = true;
            configChanged = true;
            //Reset
            for (ModelClass objClass : selectableClasses) {
                for (Iterator<ModelImpl> itr = selectedObjects[objClass.getSelectionId()].iterator(); itr.hasNext();) {
                    ModelImpl o = itr.next();
                    itr.remove();
                    o.setSelected(false);
                }
            }
            anySelected = true;
            //Force highlight
            if (vizController.getVizModel().isLightenNonSelectedAuto()) {

                if (vizConfig.isLightenNonSelectedAnimation()) {
                    //Start animation
                    lightenAnimationDelta = 0.07f;
                    vizConfig.setLightenNonSelected(true);
                } else {
                    vizConfig.setLightenNonSelected(true);
                }
            }
        } else {
            //Reset
            for (ModelClass objClass : selectableClasses) {
                for (Iterator<ModelImpl> itr = selectedObjects[objClass.getSelectionId()].iterator(); itr.hasNext();) {
                    ModelImpl o = itr.next();
                    itr.remove();
                    o.setSelected(false);
                }
            }

            for (Iterator<ModelImpl> itr = octree.getSelectedObjectIterator(modelClasses[AbstractEngine.CLASS_EDGE].getClassId()); itr.hasNext();) {
                ModelImpl obj = itr.next();
                obj.setSelected(false);
            }
        }
        for (Model r : objs) {
            if (r != null) {
                ModelImpl mdl = (ModelImpl) r;
                mdl.setSelected(true);
                if (mdl.getObj() instanceof NodeData) {
                    selectedObjects[modelClasses[AbstractEngine.CLASS_NODE].getSelectionId()].add(mdl);
                } else if (mdl.getObj() instanceof EdgeData) {
                    selectedObjects[modelClasses[AbstractEngine.CLASS_EDGE].getSelectionId()].add(mdl);
                }
            }
        }
View Full Code Here

        //forceSelectRefresh(modelClasses[AbstractEngine.CLASS_EDGE].getClassId());
    }

    public void forceSelectRefresh(int selectedClass) {
        for (Iterator<ModelImpl> itr = octree.getSelectedObjectIterator(selectedClass); itr.hasNext();) {
            ModelImpl obj = itr.next();
            if (isUnderMouse(obj)) {
                if (!obj.isSelected()) {
                    //New selected
                    obj.setSelected(true);
                    /*if (vizEventManager.hasSelectionListeners()) {
                    newSelectedObjects.add(obj);
                    }*/
                    selectedObjects[selectedClass].add(obj);
                }
View Full Code Here

        }
        if (!selected && vizModel.isHideNonSelectedEdges()) {
            return;
        }
        if (selected && vizModel.isAutoSelectNeighbor()) {
            ModelImpl m1 = (ModelImpl) obj.getSource().getModel();
            ModelImpl m2 = (ModelImpl) obj.getTarget().getModel();
            m1.mark = true;
            m2.mark = true;
        }

        //Edge weight
        GraphLimits limits = vizModel.getLimits();
        float w;
        if (obj.getEdge() instanceof MetaEdge) {
            float weightRatio;
            if (limits.getMinMetaWeight() == limits.getMaxMetaWeight()) {
                weightRatio = WEIGHT_MINIMUM / limits.getMinMetaWeight();
            } else {
                weightRatio = Math.abs((WEIGHT_MAXIMUM - WEIGHT_MINIMUM) / (limits.getMaxMetaWeight() - limits.getMinMetaWeight()));
            }
            float edgeScale = vizModel.getEdgeScale() * vizModel.getMetaEdgeScale();
            w = weight;
            w = ((w - limits.getMinMetaWeight()) * weightRatio + WEIGHT_MINIMUM) * edgeScale;
        } else {
            float weightRatio;
            if (limits.getMinWeight() == limits.getMaxWeight()) {
                weightRatio = WEIGHT_MINIMUM / limits.getMinWeight();
            } else {
                weightRatio = Math.abs((WEIGHT_MAXIMUM - WEIGHT_MINIMUM) / (limits.getMaxWeight() - limits.getMinWeight()));
            }
            float edgeScale = vizModel.getEdgeScale();
            w = weight;
            w = ((w - limits.getMinWeight()) * weightRatio + WEIGHT_MINIMUM) * edgeScale;
        }
        //

        float x1 = obj.getSource().x();
        float x2 = obj.getTarget().x();
        float y1 = obj.getSource().y();
        float y2 = obj.getTarget().y();
        float z1 = obj.getSource().z();
        float z2 = obj.getTarget().z();
        float t1 = w;
        float t2 = w;

        //CameraVector, from camera location to any point on the line
        float cameraVectorX = x1 - cameraLocation[0];
        float cameraVectorY = y1 - cameraLocation[1];
        float cameraVectorZ = z1 - cameraLocation[2];

        //This code has been replaced by followinf more efficient
        //Vec3f edgeVector = new Vec3f(x2 - x1,y2 - y1,z2 - z1);
        //Vec3f cameraVector = new Vec3f(drawable.getCameraLocation()[0] - (x2 - x1)/2f,drawable.getCameraLocation()[1] - (y2 - y1)/2f,drawable.getCameraLocation()[2] - (z2 - z1)/2f);
        //Vec3f sideVector = edgeVector.cross(cameraVector);
        //sideVector.normalize();

        //Vector line
        float edgeVectorX = x2 - x1;
        float edgeVectorY = y2 - y1;
        float edgeVectorZ = z2 - z1;

        //Cross product
        float sideVectorX = edgeVectorY * cameraVectorZ - edgeVectorZ * cameraVectorY;
        float sideVectorY = edgeVectorZ * cameraVectorX - edgeVectorX * cameraVectorZ;
        float sideVectorZ = edgeVectorX * cameraVectorY - edgeVectorY * cameraVectorX;

        //Normalize
        float norm = (float) Math.sqrt(sideVectorX * sideVectorX + sideVectorY * sideVectorY + sideVectorZ * sideVectorZ);
        if (norm > 0f) // Avoid divizion by zero if cameraVector & sideVector colinear
        {
            sideVectorX /= norm;
            sideVectorY /= norm;
            sideVectorZ /= norm;
        } else {
            sideVectorX = 0f;
            sideVectorY = 0f;
            sideVectorZ = 0f;
        }

        float x1Thick = sideVectorX / 2f * t1;
        float x2Thick = sideVectorX / 2f * t2;
        float y1Thick = sideVectorY / 2f * t1;
        float y2Thick = sideVectorY / 2f * t2;
        float z1Thick = sideVectorZ / 2f * t1;
        float z2Thick = sideVectorZ / 2f * t2;

        if (!selected) {
            float r;
            float g;
            float b;
            float a;
            r = obj.r();
            if (r == -1f) {
                if (vizModel.isEdgeHasUniColor()) {
                    float[] uni = vizModel.getEdgeUniColor();
                    r = uni[0];
                    g = uni[1];
                    b = uni[2];
                    a = uni[3];
                } else {
                    NodeData source = obj.getSource();
                    r = 0.498f * source.r();
                    g = 0.498f * source.g();
                    b = 0.498f * source.b();
                    a = obj.alpha();
                }
            } else {
                g = 0.498f * obj.g();
                b = 0.498f * obj.b();
                r *= 0.498f;
                a = obj.alpha();
            }
            if (vizModel.getConfig().isLightenNonSelected()) {
                float lightColorFactor = vizModel.getConfig().getLightenNonSelectedFactor();
                a = a - (a - 0.01f) * lightColorFactor;
                gl.glColor4f(r, g, b, a);
            } else {
                gl.glColor4f(r, g, b, a);
            }
        } else {
            float r = 0f;
            float g = 0f;
            float b = 0f;
            if (vizModel.isEdgeSelectionColor()) {
                ModelImpl m1 = (ModelImpl) obj.getSource().getModel();
                ModelImpl m2 = (ModelImpl) obj.getTarget().getModel();
                if (m1.isSelected() && m2.isSelected()) {
                    float[] both = vizModel.getEdgeBothSelectionColor();
                    r = both[0];
                    g = both[1];
                    b = both[2];
                } else if (m1.isSelected()) {
                    float[] out = vizModel.getEdgeOutSelectionColor();
                    r = out[0];
                    g = out[1];
                    b = out[2];
                } else if (m2.isSelected()) {
                    float[] in = vizModel.getEdgeInSelectionColor();
                    r = in[0];
                    g = in[1];
                    b = in[2];
                }
View Full Code Here

        } else {
            float r = 0f;
            float g = 0f;
            float b = 0f;
            if (vizModel.isEdgeSelectionColor()) {
                ModelImpl m1 = (ModelImpl) edge.getSource().getModel();
                ModelImpl m2 = (ModelImpl) edge.getTarget().getModel();
                if (m1.isSelected() && m2.isSelected()) {
                    float[] both = vizModel.getEdgeBothSelectionColor();
                    r = both[0];
                    g = both[1];
                    b = both[2];
                } else if (m1.isSelected()) {
                    float[] out = vizModel.getEdgeOutSelectionColor();
                    r = out[0];
                    g = out[1];
                    b = out[2];
                } else if (m2.isSelected()) {
                    float[] in = vizModel.getEdgeInSelectionColor();
                    r = in[0];
                    g = in[1];
                    b = in[2];
                }
View Full Code Here

            }
            obj.setCacheMarker(cacheMarker);

            //Modeaction
            if (modeManager.getMode().equals(ModeManager.AVAILABLE_MODES.HIGHLIGHT)) {
                ModelImpl impl = (ModelImpl) obj;
//                if (!node.isVisible()) {
//                    ColorLayer.layerColor(impl, 0.8f, 0.8f, 0.8f);
//                }
            }
        }
View Full Code Here

TOP

Related Classes of org.gephi.visualization.apiimpl.ModelImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.