Package simtools.diagram.gate

Examples of simtools.diagram.gate.Connection

  • 2 ends that can be connected to {@link Gate}.
  • A {@link Path} that provides the path from the first end to the last end @author zxpletran007

  •     protected void disconnectConnectionEnd(){
            CompoundEdit ce = new CompoundEdit();

            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));  
                }
            }

            ce.end();
    View Full Code Here


                               
                           
                                // If the element created is a connection and if a gate has been tracked,
                                // then perform the connection of the first connection end.
                                if (selectedGate!=null && createdElement instanceof Connection){
                                    Connection createdConnection = (Connection)createdElement;
                                    createdConnection.connect(selectedGate, true);
                                    createdConnection.gatePositionHasChanged(selectedGate);
                                    _compoundEdit.addEdit(new GateConnectEdit(createdConnection, selectedGate, true));
                                }
                               
                                // clear tracked gates and components
                                _currentTrackedGates.clear();
    View Full Code Here

             for (int i=0;i< selectionSize && res; i++){
                 ElementSelection ds = _elementContainer.getSelection().getSelectedShape(i);
                 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;
                     }
                 }
             }
    View Full Code Here

                // 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

            }
            }

            // 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())){
    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())){
    View Full Code Here

         * @param ox
         * @param oy
         * @return the first connection found at given position
         */
        public Connection getConnectionAt(int ox, int oy){
            Connection res = null;

            if(getElementContainer() != null){
                for(int i=0; i<getElementContainer().size() && res==null;i++){
                    Shape s = (Shape)getElementContainer().get(i);
                    if((s instanceof Connection) && s.contains(ox,oy)){
    View Full Code Here

                if (i<oldGates.size()){ // update gate reference and connections
                    CircuitGate oldGAte = (CircuitGate)oldGates.get(i);

                    List connections = new ArrayList(oldGAte.getConnections());
                    for(int j=0; j< connections.size(); j++){
                        Connection connection = (Connection)connections.get(j);

                        boolean isFirstGate = connection.getFirstEndGate() == oldGAte;
                        connection.disconnect(oldGAte);
                        connection.connect(newGate, isFirstGate);
                        connection.gatePositionHasChanged(newGate);
                    }
                }
            }
        }
    View Full Code Here

                }
            }

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

                if (ns!=null){
                    ns.translate(-p.x, -p.y);

                    v.addElement(ns);

                    Gate fisrtGate = (Gate) connection.getFirstEndGate();
                    Gate lastGate = (Gate) connection.getLastEndGate();

                    Gate newFg = null;
                    Gate newLg = null;

                    if ((fisrtGate!=null) && selectedGatedComponent.contains(fisrtGate.getOwner())){
    View Full Code Here

                    for(int k=0; k< gates.size(); k++){
                        Gate gate =  ((Gate)gates.get(k));
                        List connections = gate.getConnections();

                        for(int j=0; j< connections.size(); j++){
                            Connection connection = (Connection)connections.get(j);   
                            if (connection.isConnected(gate)){
                                ce.addEdit(new GateDisconnectEdit(connection, gate, connection.getFirstEndGate()!=null && connection.getFirstEndGate().equals(gate)));
                                connection.disconnect(gate);
                            }
                        }
                    }
                }


                if (ss.element instanceof Connection){
                    Connection gc = (Connection)ss.element;
                    if (gc.getFirstEndGate() != null){
                        ce.addEdit(new GateDisconnectEdit(gc, gc.getFirstEndGate(), true));
                        gc.disconnect(gc.getFirstEndGate());
                    }
                    if (gc.getLastEndGate() != null){
                        ce.addEdit(new GateDisconnectEdit(gc, gc.getLastEndGate(), false));
                        gc.disconnect(gc.getLastEndGate());
                    }
                }
                deleteShape(ss.element);
            }
    View Full Code Here

    TOP

    Related Classes of simtools.diagram.gate.Connection

    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.