示例#1
0
  public Container CreateContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // the log panel
    log = new JTextPane();
    log.setEditable(false);
    log.setBackground(Color.BLACK);
    logPane = new JScrollPane(log);
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    log.setEditorKit(kit);
    log.setDocument(doc);
    DefaultCaret c = (DefaultCaret) log.getCaret();
    c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ClearLog();

    // the preview panel
    previewPane = new DrawPanel();
    previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right);

    // status bar
    statusBar = new StatusBar();
    Font f = statusBar.getFont();
    statusBar.setFont(f.deriveFont(Font.BOLD, 15));
    Dimension d = statusBar.getMinimumSize();
    d.setSize(d.getWidth(), d.getHeight() + 30);
    statusBar.setMinimumSize(d);

    // layout
    Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT);
    split.add(previewPane);
    split.add(logPane);
    split.setDividerSize(8);

    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(split, BorderLayout.CENTER);

    // open the file
    if (recentFiles[0].length() > 0) {
      OpenFileOnDemand(recentFiles[0]);
    }

    // connect to the last port
    ListSerialPorts();
    if (Arrays.asList(portsDetected).contains(recentPort)) {
      OpenPort(recentPort);
    }

    return contentPane;
  }
    public WWPanel(Dimension size) {
      this.wwd = new WorldWindowGLCanvas();
      this.wwd.setSize(size);

      this.wwd.setModel((Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME));

      this.setLayout(new BorderLayout(5, 5));
      this.add(this.wwd, BorderLayout.CENTER);

      StatusBar statusBar = new StatusBar();
      statusBar.setEventSource(wwd);
      this.add(statusBar, BorderLayout.SOUTH);
    }
示例#3
0
  // User has asked that a file be opened.
  public void OpenFileOnDemand(String filename) {
    Log("<font color='green'>Opening file " + recentFiles[0] + "...</font>\n");

    String ext = filename.substring(filename.lastIndexOf('.'));
    if (!ext.equalsIgnoreCase(".ngc")) {
      LoadImage(filename);
    } else {
      LoadGCode(filename);
    }

    statusBar.Clear();
  }
示例#4
0
  // Take the next line from the file and send it to the robot, if permitted.
  public void SendFileCommand() {
    if (running == false
        || paused == true
        || fileOpened == false
        || portConfirmed == false
        || linesProcessed >= linesTotal) return;

    String line;
    do {
      // are there any more commands?
      line = gcode.get((int) linesProcessed++).trim();
      previewPane.setLinesProcessed(linesProcessed);
      statusBar.SetProgress(linesProcessed, linesTotal);
      // loop until we find a line that gets sent to the robot, at which point we'll
      // pause for the robot to respond.  Also stop at end of file.
    } while (ProcessLine(line) && linesProcessed < linesTotal);

    if (linesProcessed == linesTotal) {
      // end of file
      Halt();
    }
  }
示例#5
0
  @Override
  public void actionPerformed(ActionEvent event) {

    String cmd = event.getActionCommand();
    statusBar.setStatus("Befehl " + cmd + " wird ausgefuehrt...");
    System.out.println(cmd);
    if (cfg.useCmd_log()) {
      SendToServer.info("Action:" + cmd);
    }

    /*
     * Aufruf einer "Unterfunktion" in separatem thread:
     *
     * !!! Setzt aber voraus, daß der ActionListener in einem separaten
     * "NichtSwingThread" läuft!
     *
     * SwingUtilities.invokeLater(new Runnable() {
     *
     * public void run() { jIntKfzLb lb = new jIntKfzLb(); MyEventListener
     * el = new MyEventListener(); lb.addMyEventListener(el);
     * lb.setVisible(true); dp.add(lb); } }); }
     */

    /*
     * LOGIN mit Aufbau Vbdg.
     */
    if (cmd.equals("Anmeldung")) {
      this.cfg.initLDAP();
      this.gui.initMenu();
      this.cfg.setDst_list(null);
      System.out.println("Starte Anmelde-Prozess...");
      lD = LoginDialog.getInstance();
    }

    if (cmd.equals("USER")) {

      String user = LoginDialog.getInstance().getUserName();
      this.snd.play(Sound.SoundClip.KASSE);
      if (this.cfg.isDebug()) {
        System.out.println("USER: "******"LOGIN")) {

      if (this.cfg.isWaitPanel() && this.cfg.isUseSwingWorker()) {

        this.workerWait =
            new SwingWorker<String, Void>() {
              @Override
              protected String doInBackground() {
                wt = new Wait("WARTE", "Anmeldung am System...");
                return "OK";
              }

              @Override
              protected void done() {}
            };
        workerLogin =
            new SwingWorker<String, Void>() {
              @Override
              protected String doInBackground() {
                gui.login2();
                return "OK";
              }

              @Override
              protected void done() {
                wt.stop();
              }
            };
        // bei Anmeldung wird versucht, LOG-Eintrag zu erstellen, auch
        // wenn eventuell vorher die Vbdg. zum CMD-Server ohne Erfolg war
        cfg.setCmd_log(true);
        workerWait.execute();
        workerLogin.execute();

      } else {

        CursorTools.startWaitCursor(gui);
        gui.login2();
        CursorTools.stopWaitCursor(gui);
      }
    }

    if (cmd.equals("ABBRUCH")) {
      if (lD != null) {
        System.out.println("Abbruch LOGIN- Bearbeitung...");
        lD.close();
        lD = null;
        cfg.initLDAP();
        cfg.setLogin_usr("");
        cfg.setLogin_pwd("");
        cfg.setLogin_ok(false);
        Jan.logger.info("===> Abbruch der Anmeldung ");
        snd.play(Sound.SoundClip.LASER);
        gui.setTitle(cfg.getTitle() + " <NICHT ANGEMELDET>");
      }
    }

    // mit VM verbinden
    if (cmd.equals("CVM")) {

      if (cfg.isLogin_ok()) {

        act_dst = "";
        dl = LdapEntry_Parser.parse_protocol(cfg.getLdap_vm().trim());
        if (dl != null) {
          if (dl.getEntryNum() > 1) {
            SelectDestination sd = new SelectDestination();
            act_dst = sd.getDestination(dl);
          } else if (dl.getEntryNum() == 1) {
            act_dst = dl.getDstList().get(0).getDestinationTitle();
          } else {
            System.out.println("CVM: destination list is empty!!!");
          }
        } else {
          System.out.println("CVM: destination list is NULL!!!");
        }

        if (cfg.isDebug()) {
          System.out.print("selected destination: " + act_dst + "\n");
        }

        StartClientReturnCode rc = Destination_Hub.startThis(act_dst);

      } else {
        String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n";
        if (cfg.isInternalFrames()) {
          JOptionPane.showInternalMessageDialog(
              gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        } else {
          JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        }
      }
    }
    // Info/Version
    if (cmd.equals("VERSION")) {
      snd.play(Sound.SoundClip.TAB);
      String msg =
          "\n Titel: "
              + cfg.getTitle()
              + "\n Version: "
              + cfg.getVersion()
              + "\n\n Autor: "
              + cfg.getAutor()
              + "\n\n Info: "
              + cfg.getInfo()
              + "\n\n";
      if (cfg.isInternalFrames()) {
        JOptionPane.showInternalMessageDialog(
            gui.getContentPane(), msg, "Info", JOptionPane.INFORMATION_MESSAGE);
      } else {
        JOptionPane.showMessageDialog(gui, msg, "Info", JOptionPane.INFORMATION_MESSAGE);
      }
    }
    // Info/Umgebung
    if (cmd.equals("ENV")) {

      String param;
      snd.play(Sound.SoundClip.TAB);
      if (cfg.getLdap_vm().length() > 77) {
        param = cfg.getLdap_vm().substring(1, 77) + "...";
      } else {
        param = cfg.getLdap_vm();
      }
      String msg =
          "\n"
              + cfg.getTitle()
              + "\n"
              + cfg.getVersion()
              + "\n\n Host: "
              + cfg.getLocal_HostName()
              + "\n IP: "
              + cfg.getLocal_IP()
              + "\n MAC: "
              + cfg.getLocal_MAC()
              + "\n java version: "
              + cfg.getLocal_java_version()
              + "\n os name: "
              + cfg.getLocal_os_name()
              + "\n linux Rel.: "
              + cfg.getLinuxRelease()
              + "\n jvm version: "
              + cfg.getLocal_jvm_version()
              + "\n\n user: "******"\n context: "
              + cfg.getLogin_context()
              + "\n PARAM: "
              + param
              + "\n eMail: "
              + cfg.getLdap_mail()
              + "\n fullName: "
              + cfg.getLdap_fullName()
              + "\n last login time: "
              + Tools.t2s(cfg.getLdap_loginTime())
              + "\n login exp. time: "
              + Tools.t2s(cfg.getLdap_passwordExpirationTime())
              + "\n login disabled : "
              + cfg.getLdap_loginDisabled()
              + "\n login grace limit     : "
              + cfg.getLdap_loginGraceLimit()
              + "\n login grace remaining : "
              + cfg.getLdap_loginGraceRemaining()
              + "\n passwordMinimumLength : "
              + cfg.getLdap_passwordMinimumLength()
              + "\n passwordUniqueRequired: "
              + cfg.getLdap_passwordUniqueRequired()
              + "\n\n";
      if (cfg.isInternalFrames()) {
        JOptionPane.showInternalMessageDialog(
            gui.getContentPane(), msg, "Umgebung", JOptionPane.INFORMATION_MESSAGE);
      } else {
        JOptionPane.showMessageDialog(gui, msg, "Umgebung", JOptionPane.INFORMATION_MESSAGE);
      }
    }

    // Info/Uhr
    if (cmd.equals("UHR")) {
      JDialog f = new JDialog();
      f.setTitle("Uhr-Zeit");
      f.setIconImage(res.clockIcon);
      f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      f.setResizable(false);
      f.getContentPane().add(new Clock());
      f.pack();
      f.setLocationRelativeTo(null);
      f.setAlwaysOnTop(true);
      f.setResizable(false);
      f.setVisible(true);
    }

    // Hilfe001
    if (cmd.equals("HELP001")) {
      Calendar cal = Calendar.getInstance();
      int day = cal.get(Calendar.DAY_OF_MONTH);
      int month = cal.get(Calendar.MONTH);

      if (day == 7 && month == 9) { // 7. October
        Help00x.show();
      } else {
        Help000.show();
      }
    }

    // CountDown via ProgressMonitor
    if (cmd.equals("CNTDWN")) {
      final JDialog f = new JDialog();
      f.setTitle("FRAGE");
      f.setResizable(false);
      f.setIconImage(res.clockIcon);
      f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      f.setSize(290, 220);

      JLabel l1 = new JLabel("Start-Befehl wurde gesendet.");
      JLabel l2 = new JLabel(" Was soll ich jetzt tun?");
      final JButton ok = new JButton("VERBINDEN");
      ok.setMnemonic('v');
      ok.setIcon(res.computerImageIcon);
      ok.setToolTipText("Verbindung wird erneut versucht.");
      ok.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              gui.getInstance().startRHEV(true);
              f.dispose();
            }
          });

      final JButton cancel = new JButton("Abbruch");
      cancel.setMnemonic('a');
      cancel.setIcon(res.cancelImageIcon);
      cancel.setToolTipText("Funktion abbrechen.");
      cancel.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              f.dispose();
            }
          });

      JPanel p = new JPanel();
      p.setLayout(new BorderLayout());
      JPanel p_north = new JPanel();
      JPanel p_south = new JPanel();
      JPanel p_center = new JPanel();
      JPanel p_east = new JPanel();
      JPanel p_west = new JPanel();
      p_center.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

      p_north.add(l1);
      p_center.add(l2);
      p_south.add(ok);
      p_south.add(cancel);

      p.add(BorderLayout.NORTH, p_north);
      p.add(BorderLayout.SOUTH, p_south);
      p.add(BorderLayout.CENTER, p_center);
      p.add(BorderLayout.EAST, p_east);
      p.add(BorderLayout.WEST, p_west);

      CountDown cd = new CountDown(cfg.getRhevCntDwnVMstart());
      // p.add(cd);

      f.add(p);
      f.pack();
      f.setLocationRelativeTo(null);
      f.setVisible(true);

      cd.start();
    }

    // Senden
    if (cmd.equals("SENDEN")) {

      if (cfg.isLogin_ok()) {
        System.out.println("starte Sende-Dialog!");
        int result = ImportSelector.selectFiles();
        if (result > 0) {
          System.out.println("" + result + " Dateien übertragen");
        } else {
          System.out.println("Fehler " + result + " beim Senden der Dateien aufgetreten.");
        }

      } else {
        String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n";
        if (cfg.isInternalFrames()) {
          JOptionPane.showInternalMessageDialog(
              gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        } else {
          JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        }
      }
    }

    // Empfangen
    if (cmd.equals("EMPFANGEN")) {
      if (cfg.isLogin_ok()) {

        System.out.println("starte Empfang-Dialog!");
        int result = ExportSelector.selectFiles();
        if (result > 0) {
          System.out.println("" + result + " Dateien kopiert");
        } else {
          System.out.println("Fehler " + result + " beim Empfang der Dateien aufgetreten.");
        }

      } else {
        String msg = "\n Sie sind nicht erfolgreich angemeldet! \n\n";
        if (cfg.isInternalFrames()) {
          JOptionPane.showInternalMessageDialog(
              gui.getContentPane(), msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        } else {
          JOptionPane.showMessageDialog(gui, msg, "FEHLER", JOptionPane.ERROR_MESSAGE);
        }
      }
    }

    // Programm-Ende
    if (cmd.equals("ENDE")) {
      gui.sac();
    }

    // Computer ausschalten
    if (cmd.equals("SHUTDOWN")) {
      System.out.println("Starte Shutdown-Prozess...");
      gui.shutdownClient();
    }

    statusBar.setStatus("Befehl " + cmd + " beendet.");
  }
  public MainFrame() {
    super("Cacophony");
    setFocusTraversalKeysEnabled(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setExtendedState(JFrame.MAXIMIZED_BOTH);

    final Synthesizer syn = system.getSynthesizer();
    instruments = new DefaultMidiInstruments(syn);

    grates.register(GrateModes.KEYS, new DefaultKeyGrate());
    grates.register(GrateModes.COMMAND, new DefaultCommandGrate(instruments, status));

    final JPanel mainView = new JPanel();
    add(mainView, BorderLayout.CENTER);

    add(status.view(), BorderLayout.SOUTH);

    final SwitchableView[] switchableViews = ocelot.views();
    mainView.setLayout(new GridLayout(switchableViews.length + 1, 1));

    final List<Toridor> views =
        meerkat.views(
            reader.read(
                new StringReader(
                    "Vibraphone\n"
                        + "50,51,52_16|54_32|53_16|56_16|55_16|58_16|55_16|56_16|58_16|53_16|68_16|70_16|68_16|70_16|68_16|70_16|67_16\n"
                        + "String Ensemble 1\n"
                        + "70_64|70_16|61,62_16|64_32|53_16|56_16|55_16|58_16|55_16|56_16|58_16|53_16|68_16|70_16|68_16|70_16|68_16|70_16|67_16\n"
                        + "Flute\n"
                        + "70_64|61,62_16|64_32|53_16|56_16|55_64\n"
                        +
                        //                "Lead 8 (bass + lead)\n" +
                        //                "70_64|61,62_16\n" +
                        "Seashore\n"
                        + "70_64|61,62_16|64_32|53_16|56_16|55_16|58_16|70_16|68_16|70_16|67_16\n"
                        + "Gunshot\n"
                        + "70_64|61,62_16|64_32|53_16|56_16|55_16|58_16|55_16|56_16|58_16|53_16|68_16|70_16|68_16|70_16|68_16|70_16|67_16")),
            instruments);

    for (final SwitchableView switchableView : switchableViews) {
      mainView.add(switchableView.view());
    }

    for (int i = 0; i < views.size(); i++) {
      final Toridor toridor = views.get(i);
      if (i < switchableViews.length) switchableViews[i].show(toridor);
    }

    ocelot.setCandidates(views);

    manager = new DefaultToridorManager(views);

    mainView.add(infoPanel.view());

    infoPanel.refresh();
    addKeyListener(
        new KeyAdapter() {
          public void keyPressed(final KeyEvent e) {
            final Operation operation = grates.handle(e);
            status.clearMessage();
            operation.fold(
                new ChannelOp() {
                  public boolean op(final H<Ocelot, Control, Boolean> h) {
                    return h.h(ocelot, control);
                  }
                },
                new ControlOp() {
                  public boolean op(final G<Control, Boolean> g) {
                    g.g(control);
                    updateInfo();
                    return true;
                  }
                },
                new SystemOp() {
                  public boolean op(final H<SoundSystem, ToridorManager, Boolean> h) {
                    return h.h(system, manager);
                  }
                },
                new UiOp() {
                  public boolean op(final G<Grates, Boolean> g) {
                    g.g(grates);
                    updateInfo();
                    return true;
                  }
                },
                new NoOp() {
                  public boolean op() {
                    // FIX 17/03/12 This may be a bit verbose as it picks up when a meta key is
                    // pressed.
                    return true;
                  }
                });
          }
        });
  }
示例#7
0
  // The user has done something.  respond to it.
  public void actionPerformed(ActionEvent e) {
    Object subject = e.getSource();

    if (subject == buttonZoomIn) {
      previewPane.ZoomIn();
      return;
    }
    if (subject == buttonZoomOut) {
      previewPane.ZoomOut();
      return;
    }
    if (subject == buttonOpenFile) {
      OpenFileDialog();
      return;
    }

    if (subject == buttonStart) {
      if (fileOpened) {
        paused = false;
        running = true;
        UpdateMenuBar();
        linesProcessed = 0;
        previewPane.setRunning(running);
        previewPane.setLinesProcessed(linesProcessed);
        statusBar.Start();
        SendFileCommand();
      }
      return;
    }
    if (subject == buttonPause) {
      if (running) {
        if (paused == true) {
          buttonPause.setText("Pause");
          paused = false;
          // @TODO: if the robot is not ready to unpause, this might fail and the program would
          // appear to hang.
          SendFileCommand();
        } else {
          buttonPause.setText("Unpause");
          paused = true;
        }
      }
      return;
    }
    if (subject == buttonDrive) {
      Drive();
      return;
    }
    if (subject == buttonHalt) {
      Halt();
      return;
    }
    if (subject == buttonRescan) {
      ListSerialPorts();
      UpdateMenuBar();
      return;
    }
    if (subject == buttonConfig) {
      UpdateConfig();
      return;
    }
    if (subject == buttonJogMotors) {
      JogMotors();
      return;
    }
    if (subject == buttonAbout) {
      JOptionPane.showMessageDialog(
          null,
          "Created by Dan Royer ([email protected]).\n\n"
              + "Find out more at http://www.marginallyclever.com/\n"
              + "Get the latest version and read the documentation online @ http://github.com/i-make-robots/DrawBot/");
      return;
    }
    if (subject == buttonCheckForUpdate) {
      CheckForUpdate();
      return;
    }
    if (subject == buttonExit) {
      System.exit(0); // @TODO: be more graceful?
      return;
    }

    int i;
    for (i = 0; i < 10; ++i) {
      if (subject == buttonRecent[i]) {
        OpenFileOnDemand(recentFiles[i]);
        return;
      }
    }

    for (i = 0; i < portsDetected.length; ++i) {
      if (subject == buttonPorts[i]) {
        OpenPort(portsDetected[i]);
        return;
      }
    }
  }
示例#8
0
  void EstimateDrawTime() {
    int i, j;

    float drawScale = 1.0f;
    double px = 0, py = 0, pz = 0;
    float feed_rate = 1.0f;

    estimated_time = 0;
    float estimated_length = 0;
    int estimate_count = 0;

    for (i = 0; i < gcode.size(); ++i) {
      String line = gcode.get(i);
      String[] pieces = line.split(";");
      if (pieces.length == 0) continue;

      String[] tokens = pieces[0].split("\\s");
      if (tokens.length == 0) continue;

      for (j = 0; j < tokens.length; ++j) {
        if (tokens[j].equals("G20")) drawScale = 0.393700787f;
        if (tokens[j].equals("G21")) drawScale = 0.1f;
        if (tokens[j].startsWith("F")) {
          feed_rate = Float.valueOf(tokens[j].substring(1)) * drawScale;
          Log("<span style='color:green'>feed rate=" + feed_rate + "</span>\n");
          feed_rate *= 1;
        }
      }

      double x = px;
      double y = py;
      double z = pz;
      double ai = px;
      double aj = py;
      for (j = 1; j < tokens.length; ++j) {
        if (tokens[j].startsWith("X")) x = Float.valueOf(tokens[j].substring(1)) * drawScale;
        if (tokens[j].startsWith("Y")) y = Float.valueOf(tokens[j].substring(1)) * drawScale;
        if (tokens[j].startsWith("Z")) z = Float.valueOf(tokens[j].substring(1)) * drawScale;
        if (tokens[j].startsWith("I")) ai = px + Float.valueOf(tokens[j].substring(1)) * drawScale;
        if (tokens[j].startsWith("J")) aj = py + Float.valueOf(tokens[j].substring(1)) * drawScale;
      }

      if (tokens[0].equals("G00")
          || tokens[0].equals("G0")
          || tokens[0].equals("G01")
          || tokens[0].equals("G1")) {
        // draw a line
        double ddx = x - px;
        double ddy = y - py;
        double dd = Math.sqrt(ddx * ddx + ddy * ddy);
        estimated_time += dd / feed_rate;
        estimated_length += dd;
        ++estimate_count;
        px = x;
        py = y;
        pz = z;
      } else if (tokens[0].equals("G02")
          || tokens[0].equals("G2")
          || tokens[0].equals("G03")
          || tokens[0].equals("G3")) {
        // draw an arc
        int dir = (tokens[0].equals("G02") || tokens[0].equals("G2")) ? -1 : 1;
        double dx = px - ai;
        double dy = py - aj;
        double radius = Math.sqrt(dx * dx + dy * dy);

        // find angle of arc (sweep)
        double angle1 = atan3(dy, dx);
        double angle2 = atan3(y - aj, x - ai);
        double theta = angle2 - angle1;

        if (dir > 0 && theta < 0) angle2 += 2.0 * Math.PI;
        else if (dir < 0 && theta > 0) angle1 += 2.0 * Math.PI;

        theta = Math.abs(angle2 - angle1);

        // Draw the arc from a lot of little line segments.
        for (int k = 0; k <= theta * DrawPanel.STEPS_PER_DEGREE; ++k) {
          double angle3 =
              (angle2 - angle1) * ((double) k / (theta * DrawPanel.STEPS_PER_DEGREE)) + angle1;
          float nx = (float) (ai + Math.cos(angle3) * radius);
          float ny = (float) (aj + Math.sin(angle3) * radius);

          double ddx = nx - px;
          double ddy = ny - py;
          double dd = Math.sqrt(ddx * ddx + ddy * ddy);
          estimated_time += dd / feed_rate;
          estimated_length += dd;
          ++estimate_count;
          px = nx;
          py = ny;
        }
        double ddx = x - px;
        double ddy = y - py;
        double dd = Math.sqrt(ddx * ddx + ddy * ddy);
        estimated_time += dd / feed_rate;
        estimated_length += dd;
        ++estimate_count;
        px = x;
        py = y;
        pz = z;
      }
    } // for ( each instruction )
    estimated_time += estimate_count * 0.007617845117845f;

    Log(
        "<font color='green'>"
            + estimate_count
            + " line segments.\n"
            + estimated_length
            + "cm of line.\n"
            + "Estimated "
            + statusBar.formatTime((long) (estimated_time * 10000))
            + "s to draw.</font>\n");
  }
  /** Dynamic Init. Table Layout, Visual, Listener */
  private void dynInit() {

    ColumnInfo[] layout =
        new ColumnInfo[] {
          new ColumnInfo(Msg.translate(Env.getCtx(), "M_Product_ID"), ".", KeyNamePair.class), //  1
          new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), ".", String.class) //  2
        };

    xProductTable.prepareTable(layout, "", "", false, "");
    xAssociateTable.prepareTable(layout, "", "", true, "");

    xAssociateTable.setAutoResizeMode(3);
    xProductTable.setAutoResizeMode(3);

    //  Visual
    CompiereColor.setBackground(this);

    //  Listener
    xProductTable.getSelectionModel().addListSelectionListener(this);
    xAssociateTable.getModel().addTableModelListener(this);
    bDisassociate.addActionListener(this);
    bNewProduct.addActionListener(this);

    // pregunto si hay productos asociados para ver si cargo las tablas
    boolean ready = verify();

    if (ready == false) {

      tableInit_option = 0;
      tableInit();
      tableLoad(xProductTable);

    } else {
      tableInit_option = 1;
      tableInit();
      tableLoad(xAssociateTable);

      bNewProduct.setEnabled(false);
      bDisassociate.setEnabled(true);
    }

    xProductTable.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {

              int rowP = xProductTable.getSelectedRow();

              if (!(rowP == -1)) {
                cmd_associate();
              }
            }
          }
        });

    //  Init
    statusBar.setStatusLine("");
    statusBar.setStatusDB(0);

    MOrder order = new MOrder(Env.getCtx(), LineRefProv.getC_Order_ID(), null);

    boolean block = false;
    String oS = order.getXX_OrderStatus();
    String compS = order.getDocStatus();
    if (oS.equals("AN") || compS.equals("CO")) {
      block = true;
    }

    if (order.isXX_OrderReadyStatus() && order.getXX_OrderType().equalsIgnoreCase("Nacional"))
      block = true;

    if (order.getXX_OrderType().equalsIgnoreCase("Importada")
        && order.get_ValueAsInt("XX_ImportingCompany_ID") != 0) {

      if (order.get_ValueAsInt("XX_ImportingCompany_ID")
          != Env.getCtx().getContextAsInt("#XX_L_VSI_CLIENTCENTROBECO_ID")) {
        block = true;
      }
    }

    if (order.getXX_StoreDistribution().equals("Y") || block) {
      xProductTable.setEnabled(false);
      xAssociateTable.setEnabled(false);
      bNewProduct.setEnabled(false);
      bDisassociate.setEnabled(false);
    }
  } //  dynInit