/** 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");
        }
      }
    }
  }