Esempio n. 1
0
  /** LinesPanel constructor comment. */
  public Item getElementAt(int x, int y) {
    Item ret = boxes.getElementAt(x, y);
    if (ret != null) return ret;

    // Search connection lines
    return connections.getElementAt(x, y);
  }
Esempio n. 2
0
  /** LinesPanel constructor comment. */
  public void paintBuffer(java.awt.Graphics g) {
    //	Color c = g.getColor();
    //	g.setColor(Color.black);
    boxes.paint(g);
    //	g.setColor(Color.darkGray);
    connections.paint(g);
    //	g.setColor(c);
    Item.highlighted.paint(g);

    if (connecting) g.drawLine(x1, y1, x2, y2);
  }
Esempio n. 3
0
  /** LinesPanel constructor comment. */
  public void deleteElement(Item elem) {
    if (elem instanceof BoxItem) {
      Element element = ((BoxItem) elem).element;
      if (element instanceof Display) {
        // Remove also from runtime
        JChart chart = ((JDisplay) element).getChart();
        // System.out.println("c1 " + chart.getBounds());
        Main.app.runtimeFrame.removeChart(chart);
        // Main.app.runtimeFrame.show();
        Main.app.runtimeFrame.setVisible();
      }

      boxes.delete(elem);

      // Delete all connections to this element
      connections.deleteConnectedTo(elem);

      // Delete from runtime processor
      try {
        Main.app.processor.remove(element);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } else if (elem instanceof TieItem) {
      TieItem t = (TieItem) connections.delete(elem);
      if (t != null) {
        if (t.destPin.input) {
          Element e1 = t.src.element;
          Element e2 = t.dest.element;
          // Pipe p1 = e1.getOutputByName(t.srcPin.pipe.getName());
          // Pipe p2 = e2.getInputByName(t.destPin.pipe.getName());
          Pipe p1 = t.srcPin.pipe;
          Pipe p2 = t.destPin.pipe;
          // System.out.println("p1=" + p1);
          // System.out.println("p2=" + p2);
          if (p1 instanceof PipeDistributor) {
            boolean ret = ((PipeDistributor) p1).unregister(p2);
            // System.out.println("Unregistered tie " + ret);
            // System.out.println("All elements:\n" +
            // bioera.runtime.RuntimeManager.runtimeManager.printAllElements());
          } else {
            System.out.println("Error: Source is not a distributor");
          }
        } else {
          System.out.println("Error: Source is not an output");
        }
      }
    }
  }
Esempio n. 4
0
 /** LinesPanel constructor comment. */
 public void resetElements() throws Exception {
   boxes.reset();
   connections.reset();
 }
Esempio n. 5
0
 /** LinesPanel constructor comment. */
 public Item getElementById(int id) {
   return boxes.getElementById(id);
 }
Esempio n. 6
0
 /** LinesPanel constructor comment. */
 public void dispose() {
   connections.dispose();
   boxes.dispose();
 }