Package simtools.diagram.gate

Examples of simtools.diagram.gate.Gate


        if (_elementContainer.getSelection().getShapeCount()==1 &&  _elementContainer.getSelection().getSelectedShape(0) instanceof ConnectionPathSelection){
            ConnectionPathSelection cs = (ConnectionPathSelection)_elementContainer.getSelection().getSelectedShape(0);
            Connection connection = cs.getConnection();

            if( cs.isFirstEndSelected() && connection.getFirstEndGate()!=null ){
                Gate firstGate = connection.getFirstEndGate()
                connection.disconnect(firstGate);
                ce.addEdit(new GateDisconnectEdit(connection, firstGate,true));  

            } else if( cs.isLastEndSelected() && connection.getLastEndGate()!=null  ){
                Gate lastGate = connection.getLastEndGate()
                connection.disconnect(lastGate);
                ce.addEdit(new GateDisconnectEdit(connection, lastGate,false));  
            }
        }
View Full Code Here


        for(int i=0;i<_currentTrackedGates.size(); i++){
            TrackedGate tg = (TrackedGate)_currentTrackedGates.get(i);
           
            // Check whether or not a connection is allowed with the current gate
            boolean allowConnection = true;
            Gate otherGate;
           
            if (tg.connection != null){
                if (tg.isFirstEnd){
                    otherGate = tg.connection.getLastEndGate();
                }else {
View Full Code Here

            for(int i=0;i<_currentTrackedGates.size();i++){

                TrackedGate tg = (TrackedGate)_currentTrackedGates.get(i);

                Gate otherGate = tg.isFirstEnd? tg.connection.getFirstEndGate() : tg.connection.getLastEndGate();


                if (tg.gate.allowConnection(otherGate)){
                    // Perform the connection
                    tg.connection.connect(tg.gate, tg.isFirstEnd);
View Full Code Here

                        _dragPoint.translate(dx,dy);

                    }else if (currentElementCreator != null && !_elementHasBeenCreated){
                        _elementHasBeenCreated = true;

                        Gate selectedGate = null;
                        if(!_currentTrackedGates.isEmpty() ){
                            selectedGate =  ((TrackedGate)_currentTrackedGates.get(0)).gate;
                        }

                       // Create a new element
View Full Code Here

             if (ds instanceof ConnectionPathSelection){

                 ConnectionPathSelection cs = (ConnectionPathSelection)ds;
                 Connection connection = cs.getConnection();

                 Gate firstGate = connection.getFirstEndGate()
                 if (firstGate!=null && !_elementContainer.getSelection().isSelected((Shape)firstGate.getOwner())) {
                     res = false;
                 }

                 Gate lastGate = connection.getLastEndGate();
                 if (lastGate!=null && !_elementContainer.getSelection().isSelected((Shape)lastGate.getOwner())) {
                     res = false;
                 }
             }
         }
         return res;
View Full Code Here

    public TestGatedRectangle(int x, int y, int w, int h) {
        super(x, y, w, h);
        gateHolder = new GatesHolder(this);

        addGate(northGate = new Gate(this, Gate.NORTH));
        addGate(southGate = new Gate(this, Gate.SOUTH));
        addGate(eastGate = new Gate(this, Gate.EAST));
        addGate(westGate = new Gate(this, Gate.WEST));
    }
View Full Code Here

        // Now Copy the connectors
        for (int i = 0; i < selectedConnectors.size(); i++) {
            Connection connection = (Connection) selectedConnectors.get(i);

            if (connection instanceof AbstractShape){
                Gate fisrtGate = (Gate) connection.getFirstEndGate();
                Gate lastGate = (Gate) connection.getLastEndGate();
               
                Gate newFg = null;
                Gate newLg = null;

                if ((fisrtGate!=null) && selectedGatedComponent.contains(fisrtGate.getOwner())){
                    newFg = (Gate) clonedGates.get(fisrtGate);
                }
                if ((lastGate!=null) && selectedGatedComponent.contains(lastGate.getOwner())){
View Full Code Here

            // Now Copy the connectors
            for (int i = 0; i < selectedConnectors.size(); i++) {
                Connection connection = (Connection) selectedConnectors.get(i);

                if (connection instanceof TestConnection){
                    Gate fisrtGate = (Gate) connection.getFirstEndGate();
                    Gate lastGate = (Gate) connection.getLastEndGate();

                    Gate newFg = null;
                    Gate newLg = null;

                    if ((fisrtGate!=null) && selectedGatedComponent.contains(fisrtGate.getOwner())){
                        newFg = (Gate) clonedGates.get(fisrtGate);
                    }
                    if ((lastGate!=null) && selectedGatedComponent.contains(lastGate.getOwner())){
View Full Code Here

            Point p = new Point(_moveX, _moveY);
            GatedComponent gc = getGateComponentAt(p);
            if (gc != null){
                _currentTrackedComponent.add(gc);
            }
            Gate gate  =  getGateAt(p);
            if (gate != null){
                _currentTrackedGates.add(new TrackedGate(null, true, gate));
            }
           
        } else if (_elementContainer.getSelection().getShapeCount()== 1){
            //  track gates and components for selected gated components or connections
            ElementSelection ss =  _elementContainer.getSelection().getSelection(0);


            // look up for gate at selected end
            if (_translatingPoint &&  ss instanceof ConnectionPathSelection && ((ConnectionPathSelection)ss).isOneEndSelected()){

                ConnectionPathSelection cps = ((ConnectionPathSelection)ss);
                Connection connection = cps.getConnection();

                boolean isFirstEndSelected = ((ConnectionPathSelection)ss).isFirstEndSelected();

                Point p = isFirstEndSelected? connection.getPath().getNode(0) : connection.getPath().getNode(connection.getPath().getNodeNumber()-1);

                // Component
                GatedComponent gc = getGateComponentAt(p);
                if (gc != null){
                    _currentTrackedComponent.add(gc);
                }
               
                // Gate
                Gate gate  =  getGateAt(p);
                if (gate != null){
                    _currentTrackedGates.add(new TrackedGate(connection, isFirstEndSelected, gate));
                }

            }  else if (_translatingShapes){
                Shape s = ss.element;

                // For each  connection ends, look up for a gate
                if (ss instanceof ConnectionPathSelection){
                    Connection connection = ((ConnectionPathSelection)ss).getConnection();
                    Path connectionPath = connection.getPath();

                    Point firstEnd = connectionPath.getNode(0); // first end
                   
                    GatedComponent gc = getGateComponentAt(firstEnd);
                    if (gc != null){
                        _currentTrackedComponent.add(gc);
                    }
                   
                    Gate gate  =  getGateAt(firstEnd);
                    if (gate != null){
                        _currentTrackedGates.add(new TrackedGate(connection, true, gate));
                    }

                    Point lastEnd = connectionPath.getNode(connectionPath.getNodeNumber()-1); // first end
                   
                    gc = getGateComponentAt(lastEnd);
                    if (gc != null){
                        _currentTrackedComponent.add(gc);
                    }
                   
                    gate  =  getGateAt(lastEnd);
                    if (gate != null){
                        _currentTrackedGates.add(new TrackedGate(connection, false, gate));
                    }


                    // For each gates, look up for a connection ends
                } else if (s instanceof GatedComponent){   
                    GatedComponent gc = ((GatedComponent)s);
                    List gates = gc.getGates();

                    for(int i =0;i<gates.size();i++){
                        Gate gate = (Gate)gates.get(i);
                        Point gateAnchor = gate.getAnchor();

                        Connection connection = _elementContainer.getSelection().getConnectionAt(gateAnchor.x, gateAnchor.y);
                        if (connection != null && !connection.isConnected(gate)){

                            // first connection bound is free
                            if ( gate.canBeHanged(connection.getPath().getNode(0)) && connection.getFirstEndGate()==null){
                                _currentTrackedGates.add(new TrackedGate(connection, true, gate));

                                // last connection bound is free
                            } else if gate.canBeHanged(connection.getPath().getNode(connection.getPath().getNodeNumber()-1))
                                    && connection.getLastEndGate()==null){
                                _currentTrackedGates.add(new TrackedGate(connection, false, gate));
                            }
                        }
                    }
View Full Code Here

     * Return the gate found on current diagram at given position
     * @param p
     * @return the gate found on current diagram at given position, or null if not gate found.
     */
    private Gate getGateAt(Point p){
        Gate res = null;
        GatedComponent gc = getGateComponentAt(p);
        if (gc != null){
            res = gc.getGateAt(p.x, p.y);
        }
        return res;
View Full Code Here

TOP

Related Classes of simtools.diagram.gate.Gate

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.