示例#1
0
    public BGnodeFrame(
        String name,
        java.util.List<SingleProducer> producers,
        java.util.List<SingleConsumer> consumers,
        NodeID nid,
        ScatterGather sg) {
      super(name);

      BGnodePanel b = new BGnodePanel(nid, producers, consumers, sg);
      getContentPane().add(b);
      getContentPane().setLayout(new FlowLayout());

      for (int i = 0; i < consumers.size(); i++)
        b.addConsumer(consumers.get(i), null); // null means autolabel
      for (int i = 0; i < producers.size(); i++)
        b.addProducer(producers.get(i), null); // null means autolabel

      this.setLocation(hPos, vPos);
      vPos += 200;
    }
示例#2
0
  void createSampleNode(int index) {
    NodeID id;
    SingleProducer producer11;
    SingleProducer producer12;
    SingleProducer producer13;
    SingleConsumer consumer11;
    SingleConsumer consumer12;
    SingleConsumer consumer13;

    id = new NodeID(new byte[] {0, 0, 0, 0, 0, (byte) index});

    // create and connect the nodes
    producer11 = new SingleProducer(id, sg.getConnection(), new EventID(id, 1, 1));
    sg.register(producer11);

    producer12 = new SingleProducer(id, sg.getConnection(), new EventID(id, 1, 2));
    sg.register(producer12);

    producer13 = new SingleProducer(id, sg.getConnection(), new EventID(id, 1, 3));
    sg.register(producer13);

    consumer11 = new SingleConsumer(id, sg.getConnection(), new EventID(id, 0, 1));
    sg.register(consumer11);

    consumer12 = new SingleConsumer(id, sg.getConnection(), new EventID(id, 0, 2));
    sg.register(consumer12);

    consumer13 = new SingleConsumer(id, sg.getConnection(), new EventID(id, 0, 3));
    sg.register(consumer13);

    // composite GUI
    java.util.List<SingleProducer> producers = new ArrayList<SingleProducer>();
    producers.add(producer11);
    producers.add(producer12);
    producers.add(producer13);

    java.util.List<SingleConsumer> consumers = new ArrayList<SingleConsumer>();
    consumers.add(consumer11);
    consumers.add(consumer12);
    consumers.add(consumer13);
    JFrame f = new BGnodeFrame("BG simulated node " + index, producers, consumers, id, sg);
    f.pack();
    f.setVisible(true);
  }
示例#3
0
 /** Add a consumer to node. Note this should be a working consumer, already registered, etc */
 public void addConsumer(SingleConsumer n, String name) {
   consumers.add(n);
   ConsumerPane cp = new ConsumerPane(name, n);
   buttons.add(cp);
 }
示例#4
0
 /** Add a producer to node. Note this should be a working producer, already registered, etc */
 public void addProducer(SingleProducer n, String name) {
   producers.add(n);
   buttons.add(new ProducerPane(name, n));
 }
示例#5
0
    public BGnodePanel(
        NodeID nid,
        java.util.List<SingleProducer> producers,
        java.util.List<SingleConsumer> consumers,
        ScatterGather sg) {
      this.nid = nid;

      this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
      buttons = new JPanel();
      buttons.setLayout(new GridLayout(2, Math.max(consumers.size(), producers.size())));
      this.add(buttons);
      this.add(new JSeparator());

      JPanel p1 = new JPanel();
      p1.setLayout(new FlowLayout());
      this.add(p1);

      blueButton = new JButton("Blue");
      p1.add(blueButton);
      blueLabel = new JLabel("   ");
      setBlueOn(false);
      p1.add(blueLabel);

      goldButton = new JButton("Gold");
      p1.add(goldButton);
      goldLabel = new JLabel("   ");
      setGoldOn(false);
      p1.add(goldLabel);

      engine =
          new BlueGoldExtendedEngine(nid, sg, producers, consumers) {
            public void setBlueLightOn(boolean f) {
              setBlueOn(f);
            }

            public boolean getBlueLightOn() {
              return blueOn;
            }

            public void setBlueLightBlink(int dwell) {
              setBlueBlink(dwell);
            }

            public void setGoldLightOn(boolean f) {
              setGoldOn(f);
            }

            public boolean getGoldLightOn() {
              return goldOn;
            }

            public void setGoldLightBlink(int dwell) {
              setGoldBlink(dwell);
            }
          };

      sg.register(engine);

      blueButton.addMouseListener(
          new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent e) {
              blueTime = System.currentTimeMillis();
            }

            public void mouseReleased(java.awt.event.MouseEvent e) {
              if (System.currentTimeMillis() - blueTime < 2000) engine.blueClick();
              else longBluePress();
            }
          });

      goldButton.addMouseListener(
          new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent e) {
              goldTime = System.currentTimeMillis();
            }

            public void mouseReleased(java.awt.event.MouseEvent e) {
              if (System.currentTimeMillis() - goldTime < 2000) engine.goldClick();
              else longGoldPress();
            }
          });
    }