Examples of SWITCH


Examples of hu.sztaki.ilab.longneck.process.block.Switch

        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
       
        Switch sw = new Switch();
        sw.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(sw);
       
        // Case 1
        Case c1 = new Case();
        c1.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 3, 3, 0));
        far.put(c1);
       
        // Case 1 check
        Check c1check = new Check();
        c1check.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 4, 4, 0));
        far.put(c1check);
       
        EqualsConstraint c1equals = new EqualsConstraint();
        c1equals.setApplyTo("a");
        c1equals.setValue("aaa");
        c1check.setConstraints(Arrays.asList(new Constraint[] { c1equals }));
       
        // Case 1 block
        Set c1set = new Set();
        c1set.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 5, 5, 0));
        far.put(c1set);
        c1set.setApplyTo("b");
        c1set.setValue("case1");       
       
        Set c1set2 = new Set();
        c1set2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 6, 6, 0));
        far.put(c1set2);
        c1set2.setApplyTo("c1");
        c1set2.setValue("case1");
       
        c1.setBlocks(Arrays.asList(new Block[] { c1check, c1set, c1set2 }));
       
       
        // Case 2
        Case c2 = new Case();
        c2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 7, 7, 0));
        far.put(c2);
       
        // Case 2 check
        Check c2check = new Check();
        c2check.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 8, 8, 0));
        far.put(c2check);
       
        EqualsConstraint c2equals = new EqualsConstraint();
        c2equals.setApplyTo("a");
        c2equals.setValue("bbb");
        c2check.setConstraints(Arrays.asList(new Constraint[] { c2equals }));
       
        // Case 2 block
        Set c2set = new Set();
        c2set.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 9, 9, 0));
        far.put(c2set);
        c2set.setApplyTo("b");
        c2set.setValue("case2");
       
        Set c2set2 = new Set();
        c2set2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 10, 10, 0));
        far.put(c2set2);
        c2set2.setApplyTo("c2");
        c2set2.setValue("case2");
       
        c2.setBlocks(Arrays.asList(new Block[] { c2check, c2set, c2set2 }));

       
        // Case 3
        Case c3 = new Case();
        c3.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 11, 11, 0));
        far.put(c1);
       
        // Case 3 check
        Check c3check = new Check();
        c3check.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 12, 12, 0));
        far.put(c3check);
       
        EqualsConstraint c3equals = new EqualsConstraint();
        c3equals.setApplyTo("a");
        c3equals.setValue("ccc");
        c3check.setConstraints(Arrays.asList(new Constraint[] { c3equals }));
       
        // Case 3 block
        Set c3set = new Set();
        c3set.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 13, 13, 0));
        far.put(c3set);
        c3set.setApplyTo("b");
        c3set.setValue("case3");       
       
        Set c3set2 = new Set();
        c3set2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 14, 14, 0));
        far.put(c3set2);
        c3set2.setApplyTo("c3");
        c3set2.setValue("case3");
       
        c3.setBlocks(Arrays.asList(new Block[] { c3check, c3set, c3set2 }));

        Set afterSet = new Set();
        afterSet.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 15, 15, 0));
        far.put(afterSet);
        afterSet.setApplyTo("after");
        afterSet.setValue("true");

        // Add cases to switch
        sw.setCases(Arrays.asList(new Case[] { c1, c2, c3 }));
        // Add blocks to top-level sequence       
        seq.setBlocks(Arrays.asList(new Block[] { sw, afterSet }));
       
        return seq;
    }
View Full Code Here

Examples of javax.media.j3d.Switch

    ca.setColor(1.0f,0.0f,1.0f);
    a.setColoringAttributes(ca);
    saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
    mainSwitch = new Switch(Switch.CHILD_MASK);
   
    mainSwitch.addChild(branchgroup);
    mainSwitch.addChild(axisGroup);
    mainSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    mainSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
View Full Code Here

Examples of javax.media.j3d.Switch

    ca.setColor(1.0f,0.0f,1.0f);
    a.setColoringAttributes(ca);
    saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
    mainSwitch = new Switch(Switch.CHILD_MASK);
   
    mainSwitch.addChild(branchgroup);
    mainSwitch.addChild(axisGroup);
    mainSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    mainSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
View Full Code Here

Examples of javax.media.j3d.Switch

    }

   
    private void readObject(java.io.ObjectInputStream in) throws java.lang.ClassNotFoundException, java.io.IOException {
      in.defaultReadObject();
      sw = new Switch(Switch.CHILD_MASK);
      sw.setUserData(this);
      sw.setPickable(true);
      sw.setCapability(Switch.ALLOW_SWITCH_WRITE);
      sw.setChildMask(status);
    }
View Full Code Here

Examples of javax.media.j3d.Switch

       
        public void apply() {
            super.apply();
            for (GraphObjectReference o : getReferences()) {
                if(o.getObject() instanceof Switch){
                    Switch s=((Switch)o.getObject());
                    switch(_kind){
                    case SELECTION:
                        if(s.getWhichChild()!=params[0]){
                            s.setWhichChild(params[0]);
                        }
                        break;
                    case MASK:
                        BitSet b=new BitSet();
                        intToBitSet(params[0],b);
                        if(!b.equals(s.getChildMask())){
                            ((Switch)o.getObject()).setChildMask(b);
                        }
                        break;
                    }
                }
View Full Code Here

Examples of javax.media.j3d.Switch

    static class AddSwitchAction extends AbstractNodeAction {
        // required for dynamic action creation
        public AddSwitchAction() {
        }
        public void actionPerformed(ActionEvent e) {
            ((GroupNode)getNode()).addChildUndoable(new Switch());
            getNode().refresh();
        }
View Full Code Here

Examples of javax.media.j3d.Switch

        b.getLower(fixl);
        double h2 = fixu.y-fixl.y;
        upper.y = h1;
        lower.y = h1-h2;

        Switch sw = new Switch(Switch.CHILD_MASK);
        sw.setCapability(Switch.ALLOW_SWITCH_WRITE);
        DistanceLOD lod = new DistanceLOD(new float[] { font.getFont().getSize()*10*(float)BoardModel.HEX_DIAMETER });
        lod.addSwitch(sw);
        lod.setSchedulingBounds(BoardModel.bounds);

        Appearance app = new Appearance();
        app.setColoringAttributes(new ColoringAttributes(fg, ColoringAttributes.SHADE_FLAT));
        sw.addChild(new Shape3D(geom, app));

        app = new Appearance();
        Color3f lodfg = new Color3f(fg);
        lodfg.scale(2/3f);
        lodfg.add(C.grey10);
        app.setColoringAttributes(new ColoringAttributes(lodfg, ColoringAttributes.SHADE_FLAT));
        sw.addChild(makeQuad(lower.x, lower.y+(upper.y-lower.y)/4, upper.x-lower.x, (upper.y-lower.y)/2, 0, app));

        addChild(sw);
        addChild(lod);

        setTransform(new Transform3D(C.nullRot, new Vector3d(0,0,0.1), 1.0));
View Full Code Here

Examples of javax.media.j3d.Switch

    tgmCyl.addChild(cylMoveR);
    tgmCyl.addChild(cylMoveL);


    //A Switch for the green and the red sphere.
    Switch colourSwitch = new Switch();
    colourSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    //An Appearance for the green sphere.
    Color3f ambientColourGSphere = new Color3f(0.0f,0.8f,0.0f);
    Color3f emissiveColourGSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourGSphere = new Color3f(0.0f,0.8f,0.0f);
    Color3f specularColourGSphere = new Color3f(0.0f,0.8f,0.0f);
    float shininessGSphere = 1.0f;

    Appearance greenSphereApp = new Appearance();
    greenSphereApp.setMaterial(new Material(ambientColourGSphere,
                                            emissiveColourGSphere,
                                            diffuseColourGSphere,
                                            specularColourGSphere,
                                            shininessGSphere));

    //Generate the green sphere.
    float radius = 0.1f;
    Sphere greenSphere = new Sphere(radius,greenSphereApp);



    //The same for the red sphere.
    Color3f ambientColourRSphere = new Color3f(0.6f,0.0f,0.0f);
    Color3f emissiveColourRSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourRSphere = new Color3f(0.6f,0.0f,0.0f);
    Color3f specularColourRSphere = new Color3f(0.8f,0.0f,0.0f);
    float shininessRSphere = 20.0f;

    Appearance redSphereApp = new Appearance();

    redSphereApp.setMaterial(new Material(ambientColourRSphere,emissiveColourRSphere,
                             diffuseColourRSphere,specularColourRSphere,shininessRSphere));

    Sphere redSphere = new Sphere(radius,redSphereApp);



    //Add the two spheres to the Switch.
    colourSwitch.addChild(greenSphere);
    colourSwitch.addChild(redSphere);

    //The CollisionBounds for the two spheres.
    colourSwitch.setCollisionBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),radius));

    //Enable the test for collision.
    colourSwitch.setCollidable(true);

    //The green sphere should be visible in the beginning.
    colourSwitch.setWhichChild(0);

    //A transformation group for the Switch (the spheres).
    Transform3D tfSphere = new Transform3D();
    tfSphere.setTranslation(new Vector3f(0.7f,0.0f,0.0f));
    TransformGroup tgSphere = new TransformGroup(tfSphere);
View Full Code Here

Examples of lombok.ast.Switch

  public Node createAssertStatement(Node assertion, Node message) {
    return posify(new Assert().rawAssertion(assertion).rawMessage(message));
  }
 
  public Node createSwitchStatement(Node condition, Node body) {
    return posify(new Switch().rawCondition(condition).rawBody(body));
  }
View Full Code Here

Examples of model.overview.Switch

   
    for(String dpid : switchDpids)
      futureStats.put(dpid, SwitchJSON.startSwitchRestCalls(dpid, false));
   
     for(String dpid : futureStats.keySet()){
       Switch sw = null;
       boolean updateSwitch = false;
      
       // Check to see if this switch already exists, if it does just update it
       if(!oldSwitches.isEmpty()){
         for(Switch oldSwitch : oldSwitches){
           if (oldSwitch.getDpid().equals(dpid)){
             sw = oldSwitch;
             updateSwitch = true;
           }
         }
       }
           // If it doesn't exist we make a new Switch object
       if(!updateSwitch)
         sw = new Switch(dpid);
      
              List<Port> ports = new ArrayList<Port>();
              Map<String, Future<Object>> stats;
            JSONObject descriptionObj = null, aggregateObj = null, portObj = null, featuresObj = null;
                try {
          stats = (Map<String, Future<Object>>) futureStats.get(dpid).get(5L, TimeUnit.SECONDS);
          // Don't bother if we are updating this switch, since description is static
          if(!updateSwitch)
            descriptionObj = (JSONObject)stats.get("description").get(5L, TimeUnit.SECONDS);
          aggregateObj = (JSONObject)stats.get("aggregate").get(5L, TimeUnit.SECONDS);
                  portObj = (JSONObject)stats.get("port").get(5L, TimeUnit.SECONDS);
                  featuresObj = (JSONObject)stats.get("features").get(5L, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (ExecutionException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (TimeoutException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

                // Description stats
                if(!updateSwitch && descriptionObj != null){
                  descriptionObj = descriptionObj.getJSONArray(dpid).getJSONObject(0);
                  sw.setManufacturerDescription(descriptionObj.getString("manufacturerDescription"));
                  sw.setHardwareDescription(descriptionObj.getString("hardwareDescription"));
                  sw.setSoftwareDescription(descriptionObj.getString("softwareDescription"));
                  sw.setSerialNumber(descriptionObj.getString("serialNumber"));
                  sw.setDatapathDescription(descriptionObj.getString("datapathDescription"));
              
               
                // Aggregate stats, ignore
                if(aggregateObj != null){
                    aggregateObj = aggregateObj.getJSONArray(dpid).getJSONObject(0);
                    sw.setPacketCount(String.valueOf(aggregateObj.getInt("packetCount")));
                    sw.setByteCount(String.valueOf(aggregateObj.getInt("byteCount")));
                    sw.setFlowCount(String.valueOf(aggregateObj.getInt("flowCount")));
                }
               
                // Flow Stats
                sw.setFlows(FlowJSON.getFlows(dpid));
               
                // Port and Features stats
                JSONArray json = portObj.getJSONArray(sw.getDpid());
                JSONObject objtwo = featuresObj.getJSONObject(sw.getDpid());
                JSONArray jsontwo = objtwo.getJSONArray("ports");
                for(int i = 0; i < json.length(); i++)
                {
                    obj = (JSONObject)json.get(i);
                    Port port = new Port(String.valueOf(obj.getInt("portNumber")));
                    port.setReceivePackets(FormatLong.formatPackets(obj.getLong("receivePackets"), false, false));
                    port.setTransmitPackets(FormatLong.formatPackets(obj.getLong("transmitPackets"), false, false));
                    port.setReceiveBytes(FormatLong.formatBytes(obj.getLong("receiveBytes"), true, false));
                    port.setTransmitBytes(FormatLong.formatBytes(obj.getLong("transmitBytes"), true, false));
                    port.setReceiveDropped(String.valueOf(obj.getLong("receiveDropped")));
                    port.setTransmitDropped(String.valueOf(obj.getLong("transmitDropped")));
                    port.setReceiveErrors(String.valueOf(obj.getLong("receiveErrors")));
                    port.setTransmitErrors(String.valueOf(obj.getLong("transmitErrors")));
                    port.setReceieveFrameErrors(String.valueOf(obj.getInt("receiveFrameErrors")));
                    port.setReceieveOverrunErrors(String.valueOf(obj.getInt("receiveOverrunErrors")));
                    port.setReceiveCRCErrors(String.valueOf(obj.getInt("receiveCRCErrors")));
                    port.setCollisions(String.valueOf(obj.getInt("collisions")));
                    if(!jsontwo.isNull(i))
                    {
                        obj = (JSONObject)jsontwo.get(i);
                        port.setAdvertisedFeatures(String.valueOf(obj.getInt("advertisedFeatures")));
                        port.setConfig(String.valueOf(obj.getInt("config")));
                        port.setCurrentFeatures(String.valueOf(obj.getInt("currentFeatures")));
                        port.setHardwareAddress(obj.getString("hardwareAddress"));
                        port.setName(obj.getString("name"));
                        port.setPeerFeatures(String.valueOf(obj.getInt("peerFeatures")));
                        port.setState(String.valueOf(obj.getInt("state")));
                        port.setSupportedFeatures(String.valueOf(obj.getInt("supportedFeatures")));
                    }
                    ports.add(port);
                }
    
                sw.setPorts(ports);
                switches.add(sw);
            }
            return switches;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.