private void initGUI() {

    JPanel pCommand = new JPanel();

    pResult = new JPanel();
    nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult);

    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());

    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new JTextArea(5, 40);

    txtCommand.setMargin(new Insets(5, 5, 5, 5));
    txtCommand.addKeyListener(this);

    txtCommandScroll = new JScrollPane(txtCommand);
    txtResult = new JTextArea(20, 40);

    txtResult.setMargin(new Insets(5, 5, 5, 5));

    txtResultScroll = new JScrollPane(txtResult);

    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
    /*
    // button replaced by toolbar
            butExecute = new JButton("Execute");

            butExecute.addActionListener(this);
            pCommand.add(butExecute, BorderLayout.EAST);
    */
    pCommand.add(txtCommandScroll, BorderLayout.CENTER);

    gResult = new GridSwing();
    gResultTable = new JTable(gResult);
    gScrollPane = new JScrollPane(gResultTable);

    // getContentPane().setLayout(new BorderLayout());
    pResult.add(gScrollPane, BorderLayout.CENTER);

    // Set up the tree
    rootNode = new DefaultMutableTreeNode("Connection");
    treeModel = new DefaultTreeModel(rootNode);
    tTree = new JTree(treeModel);
    tScrollPane = new JScrollPane(tTree);

    tScrollPane.setPreferredSize(new Dimension(120, 400));
    tScrollPane.setMinimumSize(new Dimension(70, 100));
    txtCommandScroll.setPreferredSize(new Dimension(360, 100));
    txtCommandScroll.setMinimumSize(new Dimension(180, 100));
    gScrollPane.setPreferredSize(new Dimension(460, 300));

    ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane);

    fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);
    doLayout();
    fMain.pack();
  }
  public DistributedTextEditor() {
    area1.setFont(new Font("Monospaced", Font.PLAIN, 12));

    area2.setFont(new Font("Monospaced", Font.PLAIN, 12));
    ((AbstractDocument) area1.getDocument()).setDocumentFilter(dec);
    area2.setEditable(false);

    Container content = getContentPane();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

    JScrollPane scroll1 =
        new JScrollPane(
            area1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    content.add(scroll1, BorderLayout.CENTER);

    JScrollPane scroll2 =
        new JScrollPane(
            area2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    content.add(scroll2, BorderLayout.CENTER);

    content.add(ipaddress, BorderLayout.CENTER);
    content.add(portNumber, BorderLayout.CENTER);

    JMenuBar JMB = new JMenuBar();
    setJMenuBar(JMB);
    JMenu file = new JMenu("File");
    JMenu edit = new JMenu("Edit");
    JMB.add(file);
    JMB.add(edit);

    file.add(Listen);
    file.add(Connect);
    file.add(Disconnect);
    file.addSeparator();
    file.add(Save);
    file.add(SaveAs);
    file.add(Quit);

    edit.add(Copy);
    edit.add(Paste);
    edit.getItem(0).setText("Copy");
    edit.getItem(1).setText("Paste");

    Save.setEnabled(false);
    SaveAs.setEnabled(false);
    Disconnect.setEnabled(false);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    area1.addKeyListener(k1);
    area1.addMouseListener(m1);
    setTitle("Disconnected");
    setVisible(true);
    area1.insert("Welcome to Hjortehandlerne's distributed text editor. \n", 0);

    this.addWindowListener(w1);
  }
Example #3
0
    public void mousePressed(MouseEvent e) {
      if (e.getButton() == e.BUTTON3) {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2);
        int index = list.locationToIndex(e.getPoint());
        GetImageFile gif = new GetImageFile(files[index]);

        JTextArea area =
            new JTextArea(
                "File: "
                    + gif.getImageString()
                    + "\n"
                    + "Score: "
                    + nf.format(scores[index])
                    + "\n"
                    + "Pairs: "
                    + nrpairs[index]);
        area.setEditable(false);
        area.setBorder(BorderFactory.createLineBorder(Color.black));
        area.setFont(new Font("times", Font.PLAIN, 12));
        PopupFactory factory = PopupFactory.getSharedInstance();
        popup =
            factory.getPopup(
                null,
                area,
                (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25,
                (int) e.getComponent().getLocationOnScreen().getY() + e.getY());
        popup.show();
      }
    }
Example #4
0
 public ConsolePanel() {
   super(new BorderLayout());
   text.setFont(StyleContext.getDefaultStyleContext().getFont("SansSerif", Font.PLAIN, 10));
   JScrollPane scroller = new JScrollPane(text);
   scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
   add(BorderLayout.CENTER, scroller);
 }
Example #5
0
 public void setSelectedFont(Font font) {
   selectedFont = font;
   family = font.getFamily();
   style = font.getStyle();
   size = font.getSize();
   preview.setFont(font);
 }
Example #6
0
  public static JTextArea getTextArea() {
    JTextArea component = new JTextArea();
    component.setBackground(BACKGROUND_COLOR_TXTA);
    component.setForeground(TEXT_COLOR_TXTA);
    component.setFont(FONT_TYPE_TXTA);

    return component;
  }
Example #7
0
  private JPanel createTopPanel(YWorkItem item) {
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.setBackground(YAdminGUI._apiColour);

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JTextArea explanatoryText = new JTextArea();
    explanatoryText.setText(
        "The data you submitted for this work item was \n"
            + "validated against a schema (see below).  For some reason the\n"
            + "this data did not succeed in passing the constrainst set\n"
            + "inside the schema.\n"
            + "Usage Note: If this is causing problems try using the Web server\n"
            + "version of YAWL, which supports automatic forms generation.\n"
            + "Otherwise you could copy the schema from this page and use it\n "
            + "to create a valid output document using an XML development tool.");
    explanatoryText.setEditable(false);
    explanatoryText.setFont(new Font("Arial", Font.BOLD, 12));
    explanatoryText.setForeground(Color.DARK_GRAY);
    explanatoryText.setBackground(YAdminGUI._apiColour);
    leftPanel.add(explanatoryText);
    topPanel.add(leftPanel, BorderLayout.WEST);

    JPanel rightPanel = new JPanel(new GridLayout(4, 2));

    rightPanel.setBackground(YAdminGUI._apiColour);
    rightPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
                BorderFactory.createEtchedBorder(), "Work Item Details"),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    YTask task =
        YEngine.getInstance().getTaskDefinition(item.getSpecificationID(), item.getTaskID());
    String taskName = task.getName();

    String[] text = {
      item.getSpecificationID().toString(), taskName, item.getIDString(), item.getStartTimeStr()
    };
    String[] labels = {"Specification ID", "Task Name", "WorkItem ID", "Task Started"};
    for (int i = 0; i < text.length; i++) {
      String s = text[i];
      rightPanel.add(new JLabel(labels[i]));
      JTextField t = new JTextField(s);
      t.setEditable(false);
      rightPanel.add(t);
    }
    topPanel.add(rightPanel, BorderLayout.CENTER);
    return topPanel;
  }
Example #8
0
  /*
   **构造函数
   */
  public AboutDialog() {
    setTitle("蜘蛛牌");
    setSize(300, 200);
    setResizable(false);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    Container c = this.getContentPane();

    jt1.setSize(260, 200);
    jt2.setSize(260, 200);

    jt1.setEditable(false);
    jt2.setEditable(false);

    jt1.setLineWrap(true);
    jt2.setLineWrap(true);

    jt1.setFont(new Font("楷体_GB2312", java.awt.Font.BOLD, 13));
    jt1.setForeground(Color.blue);

    jt2.setFont(new Font("楷体_GB2312", java.awt.Font.BOLD, 13));
    jt2.setForeground(Color.black);

    jPanel1.add(jt1);
    jPanel2.add(jt2);

    jTabbedPane.setSize(300, 200);
    jTabbedPane.addTab("游戏规则", null, jPanel1, null);
    jTabbedPane.addTab("声明", null, jPanel2, null);

    jMainPane.add(jTabbedPane);
    c.add(jMainPane);

    pack();
    this.setVisible(true);
  }
Example #9
0
  // Конструктор класса
  public Log() {
    text = new JTextArea(); // Добавляем текст на панель
    text.setAlignmentX(LEFT_ALIGNMENT); // Позиционируем её налево
    text.setAlignmentY(TOP_ALIGNMENT); // и прижимаем к верху
    text.setBackground(Color.BLACK); // Задний фон - чёрный
    text.setForeground(Color.WHITE); // Цвет текста - белый
    text.setFont(References.LOG_FONT); // Стиль шрифта из файла References
    text.setLineWrap(true); // Устанавливаем перенос строк
    text.setWrapStyleWord(true); // И слов

    JScrollPane scrollPane = new JScrollPane(text); // Создаём ScrollBar
    scrollPane.setPreferredSize(new Dimension(500, 200)); // Ограничиваем размеры области вывода
    this.add(scrollPane); // Добавляем к нашей импровизированной консоли
    this.setVisible(true); // Отрисовываем
  }
Example #10
0
  public Exercise01() {
    jTextField.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            int value = Integer.parseInt(jTextField.getText(), 16);
            int maxValue = 65536;
            StringBuilder stringBuilder = new StringBuilder();
            for (int i = 0; i < 20; i++) {
              stringBuilder.append(Integer.toHexString(value) + '\t');
              for (int j = 0; j < 16; j++) {
                if (value >= maxValue) {
                  break;
                }
                stringBuilder.append((char) (value) + "\t");
                value++;
              }
              stringBuilder.append("\n");
              if (value >= maxValue) {
                break;
              }
            }
            jTextArea.setText(stringBuilder.toString());
            jTextField.setText("");
            jTextField.requestFocus();
          }
        });
    JPanel mainPanel = new JPanel(new BorderLayout(5, 5));
    mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

    JPanel jPanel1 = new JPanel(new FlowLayout());
    jPanel1.setBorder(new TitledBorder("Specify Unicode"));
    jPanel1.add(jTextField);
    mainPanel.add(jPanel1, BorderLayout.NORTH);

    jTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14));
    jTextArea.setEditable(false);
    JScrollPane jScrollPane = new JScrollPane(jTextArea);
    mainPanel.add(jScrollPane, BorderLayout.CENTER);

    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
  }
Example #11
0
  public GeneralGUI(Whois whois) {

    super("Internic Whois");
    this.server = whois;
    Container pane = this.getContentPane();

    // whois.internic.net assumes a monospaced font, 72 columns across
    Font f = new Font("Monospaced", Font.PLAIN, 12);
    names.setFont(f);
    names.setEditable(false);

    JPanel CenterPanel = new JPanel();
    CenterPanel.setLayout(new GridLayout(1, 1, 10, 10));
    JScrollPane jsp = new JScrollPane(names);
    CenterPanel.add(jsp);
    pane.add("Center", CenterPanel);

    // You don't want the buttons in the south and north
    // to fill the entire sections so add Panels there
    // and use FlowLayouts in the Panel
    JPanel NorthPanel = new JPanel();
    JPanel NorthPanelTop = new JPanel();
    NorthPanelTop.setLayout(new FlowLayout(FlowLayout.LEFT));
    NorthPanelTop.add(new JLabel("Whois: "));
    NorthPanelTop.add("North", searchString);
    NorthPanelTop.add(exactMatch);
    NorthPanelTop.add(findButton);
    NorthPanel.setLayout(new BorderLayout(2, 1));
    NorthPanel.add("North", NorthPanelTop);
    JPanel NorthPanelBottom = new JPanel();
    NorthPanelBottom.setLayout(new GridLayout(1, 3, 5, 5));
    NorthPanelBottom.add(initRecordType());
    NorthPanelBottom.add(initSearchFields());
    NorthPanelBottom.add(initServerChoice());
    NorthPanel.add("Center", NorthPanelBottom);
    JPanel SouthPanel = new JPanel();

    pane.add("North", NorthPanel);

    ActionListener al = new LookupNames();
    findButton.addActionListener(al);
    searchString.addActionListener(al);
  }
Example #12
0
  public TestHTML() {
    int d = (Frame.getFrames().length == 0) ? JFrame.EXIT_ON_CLOSE : JFrame.DISPOSE_ON_CLOSE;

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COL);
    pan.setFont(font);
    lab = new JLabel(MSG); // , SwingConstants.CENTER);
    lab.setName("title");
    lab.setFont(new Font("Serif", 3, 16));
    // lab.setForeground(Color.black);
    pan.add(lab, "North");

    text = new JTextArea("JTextArea\n");
    text.setName("area");
    text.setLineWrap(true);
    text.setFont(font);
    JScrollPane scr1 = new JScrollPane(text);
    scr1.setPreferredSize(new Dimension(300, 500));
    pan.add(scr1, "Center");

    html = new JEditorPane();
    html.setContentType("text/html");
    html.setEditable(false);
    html.addMouseListener(this);
    html.addMouseMotionListener(this);
    JScrollPane scr2 = new JScrollPane(html);
    scr2.setPreferredSize(new Dimension(350, 500));
    pan.add(scr2, "East");

    but = new JButton("Copy text from JTextArea to JEditorPane");
    but.addActionListener(this);
    pan.add(but, "South");

    frm = new JFrame(MSG);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(d);
    frm.setLocation(100, 150);
    frm.pack();
    frm.setVisible(true);
  }
Example #13
0
  private void popupHelp(final JButton helpB) {
    try {
      helpB.setEnabled(false);

      InputStream inR =
          this.getClass()
              .getClassLoader()
              .getResourceAsStream("weka/gui/knowledgeflow/README_KnowledgeFlow");

      StringBuilder helpHolder = new StringBuilder();
      LineNumberReader lnr = new LineNumberReader(new InputStreamReader(inR));

      String line;

      while ((line = lnr.readLine()) != null) {
        helpHolder.append(line + "\n");
      }

      lnr.close();
      final javax.swing.JFrame jf = new javax.swing.JFrame();
      jf.getContentPane().setLayout(new java.awt.BorderLayout());
      final JTextArea ta = new JTextArea(helpHolder.toString());
      ta.setFont(new Font("Monospaced", Font.PLAIN, 12));
      ta.setEditable(false);
      final JScrollPane sp = new JScrollPane(ta);
      jf.getContentPane().add(sp, java.awt.BorderLayout.CENTER);
      jf.addWindowListener(
          new java.awt.event.WindowAdapter() {
            @Override
            public void windowClosing(java.awt.event.WindowEvent e) {
              helpB.setEnabled(true);
              jf.dispose();
            }
          });
      jf.setSize(600, 600);
      jf.setVisible(true);

    } catch (Exception ex) {
      ex.printStackTrace();
      helpB.setEnabled(true);
    }
  }
Example #14
0
  /** 创建对话框面板 */
  private void createPanel() {

    textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setFont(new Font("aFont", Font.PLAIN, 12));

    receiveTxt();

    JPanel panel = new JPanel();
    JButton button = new JButton("确定");
    panel.add(button);

    add(textArea, BorderLayout.CENTER);
    add(panel, BorderLayout.SOUTH);

    button.addActionListener(
        (ActionEvent e) -> {
          setVisible(false);
        });
  }
Example #15
0
  private void initUI() {
    // Create tabbed pane with commands in it
    tabbedPane = new JTabbedPane();
    getContentPane().add(tabbedPane, BorderLayout.NORTH);

    tabbedPane.addTab("Book", null, createBookPane(), "View book information");
    tabbedPane.addTab("Author", null, createAuthorPane(), "View author information");
    tabbedPane.addTab("Customer", null, createCustomerPane(), "View customer information");
    tabbedPane.addTab("Borrow Book", null, createBorrowPane(), "Borrow books for a customer");
    tabbedPane.addTab("Return Book", null, createReturnPane(), "Return books for a customer");

    // Create output area with scrollpane
    outputArea = new JTextArea();
    // outputArea.setFont(new Font("Monospaced",Font.PLAIN,12));
    outputArea.setFont(new Font("Monospaced", Font.ROMAN_BASELINE, 12));
    outputArea.setEditable(false);
    outputArea.setFocusable(false);
    outputArea.setTabSize(2);
    JScrollPane sp = new JScrollPane(outputArea);
    sp.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS);

    getContentPane().add(sp, BorderLayout.CENTER);

    // Create menus
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');

    JMenuItem clearTextMenuItem = new JMenuItem(clearTextAction);
    JMenuItem exitMenuItem = new JMenuItem(exitAction);

    fileMenu.add(clearTextMenuItem);
    fileMenu.addSeparator();
    fileMenu.add(exitMenuItem);

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    setJMenuBar(menuBar);

    // Pack it all
    pack();
  }
Example #16
0
  public GUI() {
    String[] keys = {"no Quotation found"};
    if (tryDir(".") || tryDir("BLM305") || tryDir("CSE470")) keys = Q.keySet().toArray(keys);
    menu = new JComboBox<String>(keys);
    if (Q.size() > 0) setMessage(0);

    JPanel pan = new JPanel();
    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    pan.add(topPanel(), "North");

    txt.setFont(LARGE);
    txt.setEditable(false);
    txt.setRows(5);
    txt.setColumns(30);
    txt.setWrapStyleWord(true);
    txt.setLineWrap(true);
    txt.setDragEnabled(true);
    pan.add(new JScrollPane(txt), "Center");

    ref.setFont(SMALL);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "South");

    pan.setToolTipText("A project realized collectively by the class");
    menu.setToolTipText("Quotation classes");
    who.setToolTipText("author()+year()");
    txt.setToolTipText("text()");
    ref.setToolTipText("reference()");

    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack();
    frm.setVisible(true);
  }
  public OutputPopup(JFrame parent, AlignViewport av, Controller c, String title) {
    super(parent, av, c, title);

    sp = new JScrollPane();
    ta = new JTextArea(10, 60);
    f = new JComboBox();

    ta.setFont(new Font("Courier", Font.PLAIN, 10));
    format = new JLabel("Alignment format");

    for (int i = 0; i < FormatProperties.getFormats().size(); i++) {
      f.addItem((String) FormatProperties.getFormats().elementAt(i));
    }

    sp.add(ta);

    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1.0;

    add(sp, gb, gbc, 0, 0, 2, 2);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(format, gb, gbc, 0, 2, 1, 1);
    add(f, gb, gbc, 1, 2, 1, 1);

    add(status, gb, gbc, 0, 3, 2, 2);

    setApplyAction(new AreaOutputAction("area output", av, c));

    pack();

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    setLocation(
        (screenSize.width - getSize().width) / 2, (screenSize.height - getSize().height) / 2);

    show();
  }
  /* Build up the GUI using Swing magic. Nothing very exciting here - the
  BagPanel class makes the code a bit cleaner/easier to read. */
  private void guiInit() throws Exception {
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setMinimumSize(new Dimension(500, 250));
    mainPanel.setPreferredSize(new Dimension(500, 300));

    /* The message area */
    JScrollPane mssgPanel = new JScrollPane();
    mssgPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    mssgPanel.setAutoscrolls(true);
    mssgArea = new JTextArea();
    mssgArea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 20));
    mainPanel.add(mssgPanel, BorderLayout.CENTER);
    mssgPanel.getViewport().add(mssgArea, null);

    /* The button area */
    BagPanel buttonPanel = new BagPanel();
    GridBagConstraints c = buttonPanel.c;

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;

    buttonPanel.makeLabel("Detection", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    detDarkCb = buttonPanel.makeCheckBox("Dark", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    detAccelCb = buttonPanel.makeCheckBox("Movement", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Theft Reports", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repLedCb = buttonPanel.makeCheckBox("LED", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repSirenCb = buttonPanel.makeCheckBox("Siren", false);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repServerCb = buttonPanel.makeCheckBox("Server", false);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repNeighboursCb = buttonPanel.makeCheckBox("Neighbours", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Interval", JLabel.CENTER);
    fieldInterval = buttonPanel.makeTextField(10, null);
    fieldInterval.setText(Integer.toString(Constants.DEFAULT_CHECK_INTERVAL));

    ActionListener settingsAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateSettings();
          }
        };
    buttonPanel.makeButton("Update", settingsAction);

    mainPanel.add(buttonPanel, BorderLayout.EAST);

    /* The frame part */
    frame = new JFrame("AntiTheft");
    frame.setSize(mainPanel.getPreferredSize());
    frame.getContentPane().add(mainPanel);
    frame.setVisible(true);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
Example #19
0
  private void createUI() {

    setTitle(strings.getString("window.title"));

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    mailBodyArea = new JTextArea(20, 70);
    mailBodyArea.setLineWrap(true);
    mailBodyArea.setWrapStyleWord(true);
    mailBodyArea.setFont(new Font("monospaced", Font.PLAIN, 12));

    scrollPane = new JScrollPane(mailBodyArea);

    mailSubjectField = new JTextField(20);
    mailToField = new JTextField(20);
    mailFromField = new JTextField(20);

    mailSubjectLabel = new JLabel(strings.getString("subject.label"));
    mailToLabel = new JLabel(strings.getString("to.label"));
    setToFieldEditable(false);

    toLabelListener =
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            mouseClicked_searchSource();
          }

          public void mouseEntered(MouseEvent e) {
            setCursor(new Cursor(Cursor.HAND_CURSOR));
          }

          public void mouseExited(MouseEvent e) {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
          }
        };

    mailFromLabel = new JLabel(strings.getString("from.label"));

    sendMailButton = new JButton(strings.getString("sendmail.text"));
    sendMailButton.setIcon(
        new ImageIcon(getClass().getResource(strings.getString("sendmail.icon"))));
    sendMailButton.setToolTipText(strings.getString("sendmail.tooltip"));
    cancelButton = new JButton(strings.getString("cancel.text"));
    cancelButton.setIcon(new ImageIcon(getClass().getResource(strings.getString("cancel.icon"))));
    cancelButton.setToolTipText(strings.getString("cancel.tooltip"));

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPerformed_cancel();
          }
        });

    sendMailButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPerformed_sendMail();
          }
        });

    Container pane = this.getContentPane();

    container.setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 0, 5);
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    pane.add(mailFromLabel, c);
    c.gridx = 1;
    pane.add(mailFromField, c);

    c.gridx = 0;
    c.gridy = 1;
    pane.add(mailToLabel, c);
    c.gridx = 1;
    pane.add(mailToField, c);

    c.gridx = 0;
    c.gridy = 2;
    pane.add(mailSubjectLabel, c);
    c.gridx = 1;
    pane.add(mailSubjectField, c);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    pane.add(scrollPane, c);

    JPanel bPane = new JPanel();
    bPane.add(sendMailButton);
    bPane.add(cancelButton);

    c.gridx = 0;
    c.gridy = 4;
    pane.add(bPane, c);

    mailToField.requestFocus();
  }
  /** Constructs the <tt>LoginWindow</tt>. */
  private void init() {
    String title;

    if (windowTitle != null) title = windowTitle;
    else
      title =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_WINDOW_TITLE", new String[] {server});

    String text;
    if (windowText != null) text = windowText;
    else
      text =
          DesktopUtilActivator.getResources()
              .getI18NString("service.gui.AUTHENTICATION_REQUESTED_SERVER", new String[] {server});

    String uinText;
    if (usernameLabelText != null) uinText = usernameLabelText;
    else uinText = DesktopUtilActivator.getResources().getI18NString("service.gui.IDENTIFIER");

    String passText;
    if (passwordLabelText != null) passText = passwordLabelText;
    else passText = DesktopUtilActivator.getResources().getI18NString("service.gui.PASSWORD");

    setTitle(title);

    infoTextArea.setEditable(false);
    infoTextArea.setOpaque(false);
    infoTextArea.setLineWrap(true);
    infoTextArea.setWrapStyleWord(true);
    infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD));
    infoTextArea.setText(text);
    infoTextArea.setAlignmentX(0.5f);

    JLabel uinLabel = new JLabel(uinText);
    uinLabel.setFont(uinLabel.getFont().deriveFont(Font.BOLD));

    JLabel passwdLabel = new JLabel(passText);
    passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD));

    TransparentPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

    labelsPanel.add(uinLabel);
    labelsPanel.add(passwdLabel);

    TransparentPanel textFieldsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8));

    textFieldsPanel.add(uinValue);
    textFieldsPanel.add(passwdField);

    JPanel southFieldsPanel = new TransparentPanel(new GridLayout(1, 2));

    this.rememberPassCheckBox.setOpaque(false);
    this.rememberPassCheckBox.setBorder(null);

    southFieldsPanel.add(rememberPassCheckBox);
    if (signupLink != null && signupLink.length() > 0)
      southFieldsPanel.add(
          createWebSignupLabel(
              DesktopUtilActivator.getResources().getI18NString("plugin.simpleaccregwizz.SIGNUP"),
              signupLink));
    else southFieldsPanel.add(new JLabel());

    boolean allowRememberPassword = true;

    String allowRemPassStr =
        DesktopUtilActivator.getResources().getSettingsString(PNAME_ALLOW_SAVE_PASSWORD);
    if (allowRemPassStr != null) {
      allowRememberPassword = Boolean.parseBoolean(allowRemPassStr);
    }
    allowRememberPassword =
        DesktopUtilActivator.getConfigurationService()
            .getBoolean(PNAME_ALLOW_SAVE_PASSWORD, allowRememberPassword);

    setAllowSavePassword(allowRememberPassword);

    JPanel buttonPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));

    buttonPanel.add(loginButton);
    buttonPanel.add(cancelButton);

    JPanel southEastPanel = new TransparentPanel(new BorderLayout());
    southEastPanel.add(buttonPanel, BorderLayout.EAST);

    TransparentPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));

    mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 20, 20));

    JPanel mainFieldsPanel = new TransparentPanel(new BorderLayout(0, 10));
    mainFieldsPanel.add(labelsPanel, BorderLayout.WEST);
    mainFieldsPanel.add(textFieldsPanel, BorderLayout.CENTER);
    mainFieldsPanel.add(southFieldsPanel, BorderLayout.SOUTH);

    mainPanel.add(infoTextArea, BorderLayout.NORTH);
    mainPanel.add(mainFieldsPanel, BorderLayout.CENTER);
    mainPanel.add(southEastPanel, BorderLayout.SOUTH);

    this.getContentPane().add(mainPanel, BorderLayout.EAST);

    this.loginButton.setName("ok");
    this.cancelButton.setName("cancel");
    if (loginButton.getPreferredSize().width > cancelButton.getPreferredSize().width)
      cancelButton.setPreferredSize(loginButton.getPreferredSize());
    else loginButton.setPreferredSize(cancelButton.getPreferredSize());

    this.loginButton.setMnemonic(
        DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.OK"));
    this.cancelButton.setMnemonic(
        DesktopUtilActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    this.loginButton.addActionListener(this);
    this.cancelButton.addActionListener(this);

    this.getRootPane().setDefaultButton(loginButton);
  }
  public void setup() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    title = new JLabel(SHTML + TITLE + elem.title + EHTML);
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridy = 4;
    gbc.gridx = 0;
    gbc.gridwidth = 2;
    gbc.gridheight = 1;
    gbc.weighty = 1.0;
    add(title, gbc);
    donor = new JLabel(SHTML + DONOR + elem.donor + EHTML);
    gbc.gridy = 5;
    add(donor, gbc);
    subDate = new JLabel(SHTML + SUB_DATE + elem.subDate.toString() + EHTML);
    gbc.gridy = 6;
    add(subDate, gbc);
    objDate = new JLabel(SHTML + OBJ_DATE + elem.objDate.toString() + EHTML);
    gbc.gridy = 7;
    add(objDate, gbc);
    medium = new JLabel(SHTML + MEDIUM + elem.medium + EHTML);
    gbc.gridy = 8;
    add(medium, gbc);
    accNum = new JLabel(SHTML + ACC_NUM + elem.accNum + EHTML);
    gbc.gridy = 9;
    add(accNum, gbc);
    desc = new JLabel(SHTML + DESC + EHTML);
    // gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.insets = new Insets(0, 50, 0, 0);
    gbc.gridy = 4;
    gbc.gridx = 2;
    add(desc, gbc);
    descView = new JTextArea();
    descView.setLineWrap(true);
    descView.setWrapStyleWord(true);
    descView.setEditable(false);
    descView.setText(elem.desc);
    descView.setFont(new Font("Times New Roman", Font.PLAIN, 13));
    JScrollPane scrollPane = new JScrollPane(descView);
    scrollPane.setPreferredSize(new Dimension(225, 100));
    // scrollPane.setBorder(null);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    descView.setCaretPosition(0);
    gbc.gridy = 5;
    gbc.gridheight = 4;
    gbc.gridx = 2;
    add(scrollPane, gbc);

    gbc.insets = null;
    gbc.gridy = 0;
    gbc.gridx = 0;
    gbc.gridwidth = 4;
    gbc.gridheight = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 10, 0);
    vpan = new V3DPanel(elem, provider);
    vpan.setPreferredSize(new Dimension(500, 300));
    setBackground(BACKGROUND);
    add(vpan, gbc);
    validate();
  }
  @Override
  public boolean onStart() {
    window = new JFrame("Interface Explorer");
    treeModel = new InterfaceTreeModel();
    treeModel.update("");
    tree = new JTree(treeModel);
    tree.setRootVisible(false);
    tree.setEditable(false);
    renderer = new HighlightTreeCellRenderer(tree.getCellRenderer());
    tree.setCellRenderer(renderer);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          private void addInfo(final String key, final String value, final boolean highlight) {
            final JPanel row = new JPanel();
            row.setAlignmentX(Component.LEFT_ALIGNMENT);
            row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
            for (final String data : new String[] {key, value}) {
              final JLabel label = new JLabel(data);
              label.setAlignmentY(Component.TOP_ALIGNMENT);
              if (highlight) {
                label.setForeground(Color.magenta);
              }
              row.add(label);
            }
            infoArea.add(row);
          }

          public void valueChanged(final TreeSelectionEvent e) {
            final Object node = tree.getLastSelectedPathComponent();
            if (node == null || node instanceof RSInterfaceWrap) {
              return;
            }
            infoArea.removeAll();
            RSComponent iface = null;
            if (node instanceof RSComponentWrap) {
              iface = ((RSComponentWrap) node).wrapped;
            }
            if (iface == null) {
              return;
            }
            List<Integer> changes = new ArrayList<Integer>();
            for (int i = 0; i < HighLightWraps.size(); i++) {
              if (iface.getParent() == null) {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              } else {
                if (HighLightWraps.get(i).getChild().getIndex() == iface.getParent().getIndex()
                    && HighLightWraps.get(i).getParent().getIndex()
                        == iface.getParent().getInterface().getIndex()) {
                  changes.add(HighLightWraps.get(i).getChange());
                }
              }
            }
            addInfo("Type: ", "" + iface.getType(), changes.contains(1));
            addInfo("SpecialType: ", "" + iface.getSpecialType(), changes.contains(2));
            addInfo("Bounds Index: ", "" + iface.getBoundsArrayIndex(), changes.contains(3));
            if (iface.getArea() != null) {
              Rectangle size = iface.getArea();
              addInfo("Size: ", size.width + "," + size.height, changes.contains(15));
            }
            addInfo("Model ID: ", "" + iface.getModelID(), changes.contains(4));
            addInfo("Texture ID: ", "" + iface.getBackgroundColor(), changes.contains(5));
            addInfo("Parent ID: ", "" + iface.getParentID(), changes.contains(6));
            addInfo("Text: ", "" + iface.getText(), changes.contains(7));
            addInfo("Tooltip: ", "" + iface.getTooltip(), changes.contains(8));
            addInfo("SelActionName: ", "" + iface.getSelectedActionName(), changes.contains(9));
            if (iface.getActions() != null) {
              String actions = "";
              for (final String action : iface.getActions()) {
                if (!actions.equals("")) {
                  actions += "\n";
                }
                actions += action;
              }
              addInfo("Actions: ", actions, changes.contains(10));
            }
            addInfo("Component ID: ", "" + iface.getComponentID(), changes.contains(11));
            addInfo(
                "Component Stack Size: ", "" + iface.getComponentStackSize(), changes.contains(12));
            addInfo(
                "Relative Location: ",
                "(" + iface.getRelativeX() + "," + iface.getRelativeY() + ")",
                changes.contains(13));
            addInfo(
                "Absolute Location: ",
                "(" + iface.getAbsoluteX() + "," + iface.getAbsoluteY() + ")",
                changes.contains(14));
            addInfo(
                "Rotation: ",
                "x: "
                    + iface.getXRotation()
                    + "  y: "
                    + iface.getYRotation()
                    + "  z: "
                    + iface.getZRotation(),
                changes.contains(16));
            setHighlightArea(iface.getArea());
            infoArea.validate();
            infoArea.repaint();
          }
        });
    final JDialog Help = new JDialog();
    JScrollPane jScrollPane1;
    JTextArea jTextArea1;
    jScrollPane1 = new JScrollPane();
    jTextArea1 = new JTextArea();
    Help.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Help.setTitle("Help");
    Help.setResizable(false);
    jTextArea1.setColumns(20);
    jTextArea1.setEditable(false);
    jTextArea1.setFont(new java.awt.Font("MS UI Gothic", 0, 12));
    jTextArea1.setLineWrap(true);
    jTextArea1.setRows(5);
    jTextArea1.setText(
        "Once toggled the listener feature of the interface explorer will detect any changes made to Runescapes interfaces in realtime. If a change is found that interface and data will then be highlighted within the explorers tree model. To use the listener feature you would :\n\n1) Toggle the listener button as active\n2) Wait or commit changes in Runescape\n3) Repaint tree using repaint button or reclick interface folders in GUI\n\n\nTips : While listening for changes the tree model in the GUI will not update itself, changing colors. To refresh the GUI either use the repaint button or close and open Interface folder already within the tree model.");
    jTextArea1.setWrapStyleWord(true);
    jScrollPane1.setViewportView(jTextArea1);
    final GroupLayout layout = new GroupLayout(Help.getContentPane());
    Help.getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jScrollPane1, GroupLayout.PREFERRED_SIZE, 220, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    Help.pack();
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.WEST);
    infoArea = new JPanel();
    infoArea.setLayout(new BoxLayout(infoArea, BoxLayout.Y_AXIS));
    scrollPane = new JScrollPane(infoArea);
    scrollPane.setPreferredSize(new Dimension(250, 500));
    window.add(scrollPane, BorderLayout.CENTER);
    final ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            treeModel.update(searchBox.getText());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener toggleListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            if (listenerButton.isSelected()) {
              log("Cleared");
              HighLightWraps.clear();
            }
            check();
          }
        };
    final ActionListener repaintListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            log("Refreshed Tree");
            treeModel.fireTreeStructureChanged(treeModel.getRoot());
            infoArea.removeAll();
            infoArea.validate();
            infoArea.repaint();
          }
        };
    final ActionListener helpListener =
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            Help.setVisible(true);
          }
        };
    final JPanel toolArea = new JPanel();
    toolArea.setLayout(new FlowLayout(FlowLayout.LEFT));
    toolArea.add(new JLabel("Filter:"));
    searchBox = new JTextField(20);
    searchBox.addActionListener(actionListener);
    toolArea.add(searchBox);
    final JButton updateButton = new JButton("Update");
    final JButton repaintButton = new JButton("Repaint");
    final JButton helpButton = new JButton("Help");
    helpButton.addActionListener(helpListener);
    listenerButton.addActionListener(toggleListener);
    updateButton.addActionListener(actionListener);
    repaintButton.addActionListener(repaintListener);
    toolArea.add(updateButton);
    toolArea.add(listenerButton);
    toolArea.add(repaintButton);
    toolArea.add(helpButton);
    window.add(toolArea, BorderLayout.NORTH);
    window.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    window.pack();
    window.setVisible(true);
    return true;
  }
  public static void makescalaSciCodeFromParams(int odeSolveMethod) {
    switch (odeSolveMethod) {
      case ODEWizardScalaSci.ODErke:
        scriptText =
            " import scala._ \n import scalaSci._ \n import scalaSci.Vec._ \n"
                + " import scalaSci.Mat._ \n import java.util.Vector \n"
                + " import numal._ \n import  scalaSci.math.plot.plot._  \n";

        scriptText +=
            " \n var  n= "
                + systemOrder
                + ";  // the number of equations of the system\n"
                + "var  x = new Array[Double](1)     // entry:   x(0) is the initial value of the independent variable  \n"
                + "var  xe = new Array[Double](1)    //  entry:  xe(0) is the final value of the independent variable    \n"
                + "var y = new Array[Double](n+1)   // entry: the dependent variable, the initial values at x = x0 \n"
                + "var data = new Array[Double](7)   // in array data one should give: \n"
                + "                                        //     data(1):   the relative tolerance \n"
                + "                                        //     data(2):  the absolute tolerance  \n"
                + "                                        //  after each step data(3:6) contains:  \n"
                + "                                        //      data(3):  the steplength used for the last step \n"
                + "                                       //      data(4):  the number of integration steps performed \n"
                + "                                       //      data(5):  the number of integration steps rejected  \n "
                + "                                       //      data(6):  the number of integration steps skipped \n"
                + "                                 // if upon completion of rke data(6) > 0, then results should be considered most criticallly \n"
                + " fi = true;                        // if fi is true then the integration starts at x0 with a trial step xe-x0;  \n"
                + "                                        // if fi is false then the integration is continued with a step length data(3)* sign(xe-x0) \n"
                + "data(1) = 1.0e-6;  data(2) = 1.0e-6; \n\n"
                + "var xOut:Vector[Array[Double]] = new Vector();  \n"
                + "var yOut:Vector[Array[Double]] = new Vector();  \n"
                + "// a Java class that implements the AP_rke_methods interface should be specified \n"
                + "// The AP_rke_methods interface requires the implementation of two procedures: \n"
                + "//    void der(int n, double t, double v[]) \n"
                + "//              this procedure performs an evaluation of the right-hand side of the system with dependent variable v[1:n] and \n"
                + "//              and independent variable t; upon completion of der the right-hand side should be overwritten on v[1:n] \n"
                + "//    void out(int n, double x[], double xe[], double y[], double data[]) \n"
                + "//              after each integration step performed, out can be used to obtain information from the solution process, \n"
                + "//              e.g., the values of x, y[1:n], and data[3:6]; out can also be used to update data, but x and xe remain unchanged \n\n";

        scriptText +=
            "\n var xStart = "
                + xStart
                + ";"
                + "\n var xEnd =  "
                + xEnd
                + ";   // start and end values of integration \n \n";
        for (int k = 1; k <= systemOrder; k++)
          scriptText += "y(" + k + ") = " + Math.random() + "; \n";

        scriptText += " x(0) = xStart; \n  xe(0) = xEnd; \n";
        scriptText +=
            "var javaClassName  = "
                + "\""
                + editingClassName
                + "\""
                + ";   // name of the Java class that implements the ODE \n";

        scriptText +=
            "\n var invocationObject = Class.forName(javaClassName, false, GlobalValues.globalInterpreter.classLoader).newInstance(); \n"
                + "\n var lorenz2RKEObject = invocationObject.asInstanceOf[AP_rke_methods] \n";

        scriptText += "tic() \n";
        scriptText += "var fi = true \n";
        scriptText +=
            "\nAnalytic_problems.rke(x, xe, n, y, lorenz2RKEObject,  data, fi,  xOut, yOut); \n"
                + "\n var timeCompute = toc() \n";

        scriptText +=
            "var plotTitle = \"Lorenz attractor in ScalaSci, time =  \"+timeCompute+ \" Runge-Kutta (rke()),  integrating from \"+xStart+\", to tEnd= \"+xEnd  \n";
        scriptText += "var color = Color.RED \n";

        scriptText += "  figure3d(1); plotV(yOut, color, plotTitle) \n";

        break;

      case ODEWizardScalaSci.ODEmultistep:
        scriptText =
            " import scala._ \n import scalaSci._  \n import scalaSci.Vec._ \n import scalaSci.Mat._ \n "
                + "import java.util.Vector \n import numal._ \n import  scalaSci.math.plot.plot._\n";

        scriptText +=
            "\n var n= "
                + systemOrder
                + "; // the number of equations of the system \n"
                + "var first = new  Array[Boolean](1);   // if first is true then the procedure starts the integration with a first order Adams method \n"
                + "// and a steplength equal to hmin,  upon completion of a call, first is set to false \n"
                + "first(0)=true; \n"
                + "var btmp = new Array[Boolean](2) \n"
                + "var itmp = new Array[Int](3) \n"
                + "var xtmp = new Array[Double](7) \n"
                + "var x = new Array[Double](1) \n"
                + "var y = new Array[Double](6*n+1) \n"
                + "var ymax = new Array[Double](4) \n"
                + "var save = new Array[Double](6*n+39)  //    in this array the procedure stores information which can be used in a continuing call \n"
                + "          // with first = false; also the following messages are delivered: \n"
                + "          //      save[38] == 0;  an Adams method has been used  \n"
                + "          //      save[38] == 1;  the procedure switched to Gear's method \n"
                + "          //      save[37] == 0;  no error message  \n"
                + "          //      save[37] == 1; with the hmin specified the procedure cannot handle the nonlinearity (decrease hmin!) \n"
                + "          //      save[36] ;  number of times that the requested local error bound was exceeded   \n"
                + "         //      save[35] ;  if save[36] is nonzero then save[35] gives an estimate of the maximal local error bound, otherwise save[35]=0 \n\n"
                + "\n  var   jac = Array.ofDim[Double](n+1)  \n"
                + "var k=0;     while (k<=n) {        jac(k) = new Array[Double](n+1);    k += 1; } \n"
                + "var xOut:Vector[Array[Double]] = new Vector() \n"
                + "var yOut:Vector[Array[Double]] = new Vector() \n"
                + "var hmin=1.0e-10;    var eps=1.0e-9 \n"
                + "\n y(1)=0.12; y(2)=0.3; y(3)=0.12; \n"
                + "ymax(1) = 0.00001;   ymax(2) = 0.00001;    ymax(3) = 0.00001;    var tstart = 0.0;    x(0) = tstart \n"
                + "var xendDefault =\"100.0\"  // end point of integration, default value \n"
                + "var prompt = \"Specify the end integration value\" \n"
                + "var inVal  = JOptionPane.showInputDialog(prompt, xendDefault) \n"
                + "var tend = inVal.toDouble \n";

        scriptText +=
            "var javaClassName  = "
                + "\""
                + editingClassName
                + "\""
                + ";   // name of the Java class that implements the ODE \n";

        scriptText +=
            "\n var invocationObject = Class.forName(javaClassName, false, GlobalValues.globalInterpreter.classLoader).newInstance(); \n";

        scriptText +=
            "\n var multistepObject = invocationObject.asInstanceOf[AP_multistep_methods] \n";

        scriptText +=
            "\ntic() \n"
                + "\nAnalytic_problems.multistep(x, tend,y,hmin,5,ymax,eps,first, save, multistepObject, jac, true,n,btmp,itmp,xtmp, xOut, yOut) \n"
                + "var  runTime =  toc() \n"
                + "var plotTitle = \"Lorenz system, method Multistep,  ntegratin from \"+tstart+\", to tEnd= \"+tend+\", runTime = \"+runTime \n";

        scriptText += "var color = Color.RED \n  figure3d(1); plotV(yOut, color, plotTitle) ";

        break;

      case ODEWizardScalaSci.ODEdiffsys:
        scriptText =
            " import scala._ \n import scalaSci._ \n import scalaSci.Vec._  \n "
                + "import scalaSci.Mat._ \n import java.util.Vector  \n import  numal._  \n import scalaSci.math.plot.plot._  \n";

        scriptText +=
            "var tol = 0.0000000000004 \n var aeta = tol; var reta = tol\n "
                + "var n = 3; // the number of equations of the system \n"
                + "var x = new Array[Double](1)  // entry: x(0) is the initial value of the independent variable \n"
                + "var y = new Array[Double](n+1)   // entry: the dependent variable, the initial values at x = x0 \n"
                + "aeta = tol  // aeta: required absolute precision in the integration process \n"
                + "reta = tol // reta: required relative precision in the integration process \n"
                + "var s = new Array[Double](n+1) \n"
                + "var h0=0.000001  // h0: the initial step to be taken \n"
                + "var xOut:Vector[Array[Double]] = new Vector() \n"
                + "var yOut:Vector[Array[Double]] = new Vector() \n"
                + "y(1)=0.4; y(2)= -0.3; y(3)=0.9; \n"
                + "\n x(0)=0;  var xe = 720; \n"
                + "\nvar javaClassName  = "
                + "\""
                + editingClassName
                + "\""
                + ";   // name of the Java class that implements the ODE \n";

        scriptText +=
            "\n var invocationObject = Class.forName(javaClassName, false, GlobalValues.globalInterpreter.classLoader).newInstance(); \n"
                + "var diffSysObject = invocationObject.asInstanceOf[AP_diffsys_methods] \n"
                + "\n tic() \n"
                + "Analytic_problems.diffsys(x, xe, n, y, diffSysObject, aeta, reta , s, h0, xOut, yOut) \n"
                + "var timeCompute = toc() \n"
                + "var plotTitle = \"Double Scroll attractor with ScalaSci, time \"+timeCompute+ \" end point = \"+xe \n"
                + "var color = Color.RED \n"
                + " figure3d(1); plotV(yOut, color, plotTitle); \n";

        break;

      default:
        scriptText = "";
    }

    scriptTextArea.setFont(new Font("Arial", Font.PLAIN, 12));
    scriptTextArea.setRows(30);
    scriptTextArea.setText(scriptText);

    scriptPanel = new JPanel();
    scriptScrollPane = new JScrollPane(scriptTextArea);
    scriptPanel.add(scriptScrollPane);

    JButton scriptSaveButton = new JButton("Save Script Code");
    scriptSaveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String currentWorkingDirectory = GlobalValues.ScalaSciClassPath;
            JFileChooser chooser = new JFileChooser(currentWorkingDirectory);
            chooser.setSelectedFile(new File(editingClassName + ".gsci"));
            int ret = chooser.showSaveDialog(ODEWizardScalaSci.scriptFrame);

            if (ret != JFileChooser.APPROVE_OPTION) {
              return;
            }
            File f = chooser.getSelectedFile();
            try {
              PrintWriter out = new PrintWriter(f);
              String scriptCodeText = scriptTextArea.getText();
              out.write(scriptCodeText);
              out.close();
            } catch (java.io.FileNotFoundException enf) {
              System.out.println("File " + f.getName() + " not found");
              enf.printStackTrace();
            }
          }
        });

    JButton scriptRunButton = new JButton("Run Script Code");
    scriptRunButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            GlobalValues.scalalabMainFrame.scalalabConsole.interpretLine(scriptText + "\n");
          }
        });
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.add(scriptSaveButton);
    buttonsPanel.add(scriptRunButton);

    ODEWizardScalaSciScala.scriptFrame = new JFrame("Your script code");
    ODEWizardScalaSciScala.scriptFrame.setLayout(new BorderLayout());
    ODEWizardScalaSciScala.scriptFrame.add(scriptPanel, BorderLayout.CENTER);
    ODEWizardScalaSciScala.scriptFrame.add(buttonsPanel, BorderLayout.SOUTH);
    ODEWizardScalaSciScala.scriptFrame.setSize(
        GlobalValues.figFrameSizeX, GlobalValues.figFrameSizeY);
    ODEWizardScalaSciScala.scriptFrame.setVisible(true);
  }
Example #24
0
  /**
   * Component initialization.
   *
   * @throws java.lang.Exception
   */
  private void jbInit() throws Exception {

    contentPane = (JPanel) getContentPane();
    contentPane.setLayout(null);

    this.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    setSize(new Dimension(400, 621));
    setTitle("实时通讯模块测试程序");
    jButton1.setBounds(new Rectangle(11, 412, 82, 26));
    jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton1.setText("召测接口");
    jButton1.addActionListener(new RealTimeTestFrame_jButton1_actionAdapter(this));
    jButton2.setBounds(new Rectangle(10, 366, 83, 26));
    jButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton2.setText("创建对象");
    jButton2.addActionListener(new RealTimeTestFrame_jButton2_actionAdapter(this));
    jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel1.setText("接入IP:");
    jLabel1.setBounds(new Rectangle(23, 22, 63, 16));
    jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel2.setText("接入端口:");
    jLabel2.setBounds(new Rectangle(23, 67, 63, 16));
    jTextField1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jTextField1.setText("172.19.74.13");
    txt_port.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_port.setText("3000");
    txt_port.setBounds(new Rectangle(84, 64, 88, 22));
    jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel3.setText("AppID:");
    jLabel3.setBounds(new Rectangle(23, 113, 63, 16));
    contentPane.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel4.setText("ZDLJDZ:");
    jLabel4.setBounds(new Rectangle(23, 158, 63, 16));
    jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel5.setText("规约号:");
    jLabel5.setBounds(new Rectangle(23, 186, 63, 16));
    jLabel6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel6.setText("发送内容:");
    jLabel6.setBounds(new Rectangle(23, 333, 63, 16));
    jLabel7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel7.setText("通讯方式:");
    jLabel7.setBounds(new Rectangle(21, 219, 63, 16));
    txt_AppID.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_AppID.setText("25");
    txt_AppID.setBounds(new Rectangle(84, 110, 83, 22));
    txt_zdljdz.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_zdljdz.setText("91010022");
    txt_zdljdz.setBounds(new Rectangle(84, 155, 88, 22));
    txt_gyh.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_gyh.setText("100");
    txt_gyh.setBounds(new Rectangle(84, 183, 63, 22));
    txt_txfs.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_txfs.setText("40");
    txt_txfs.setBounds(new Rectangle(84, 218, 63, 22));
    jTextField7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_ip.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    InetAddress localhost = java.net.InetAddress.getLocalHost();
    String hostIP = localhost.getHostAddress();
    txt_ip.setText(hostIP);
    txt_ip.setBounds(new Rectangle(84, 19, 159, 22));
    txt_content.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_content.setText("6000000100111107");
    txt_content.setBounds(new Rectangle(84, 330, 298, 22));
    txt_content.addActionListener(new RealTimeTestFrame_txt_content_actionAdapter(this));
    jButton3.setBounds(new Rectangle(200, 412, 89, 26));
    jButton3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton3.setText("发送短信");
    jButton3.addActionListener(new RealTimeTestFrame_jButton3_actionAdapter(this));
    jButton4.setBounds(new Rectangle(295, 366, 96, 26));
    jButton4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton4.setText("自定义命令");
    jButton4.addActionListener(new RealTimeTestFrame_jButton4_actionAdapter(this));
    lab_yxj.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    lab_yxj.setText("优先级:");
    lab_yxj.setBounds(new Rectangle(23, 287, 61, 16));
    txt_gnm.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_gnm.setText("0D");
    txt_gnm.setBounds(new Rectangle(84, 251, 63, 22));
    jLabel9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel9.setText("手机号码:");
    jLabel9.setBounds(new Rectangle(190, 67, 67, 16));
    txt_sjhm.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_sjhm.setText("13800571505");
    txt_sjhm.setBounds(new Rectangle(250, 64, 111, 22));
    jLabel10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel10.setText("命令序号:");
    jLabel10.setBounds(new Rectangle(190, 112, 73, 16));
    txt_mlxh.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_mlxh.setText("1");
    txt_mlxh.setBounds(new Rectangle(250, 109, 110, 22));
    jButton5.setBounds(new Rectangle(105, 366, 83, 26));
    jButton5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton5.setText("连接");
    jButton5.addActionListener(new RealTimeTestFrame_jButton5_actionAdapter(this));
    jButton6.setBounds(new Rectangle(200, 366, 83, 26));
    jButton6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton6.setText("断开连接");
    jButton6.addActionListener(new RealTimeTestFrame_jButton6_actionAdapter(this));
    jLabel11.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel11.setText("终端逻辑地址:");
    jLabel11.setBounds(new Rectangle(164, 199, 87, 16));
    txt_listterminal.setText("12041234");
    txt_listterminal.setBounds(new Rectangle(252, 196, 130, 22));
    jButton8.setBounds(new Rectangle(170, 248, 90, 26));
    jButton8.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton8.setText("加入队列");
    jButton8.addActionListener(new RealTimeTestFrame_jButton8_actionAdapter(this));
    jButton9.setBounds(new Rectangle(283, 248, 85, 26));
    jButton9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton9.setText("在线状态");
    jButton9.addActionListener(new RealTimeTestFrame_jButton9_actionAdapter(this));
    memo1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    memo1.setToolTipText("");
    memo1.setEditable(false);
    memo1.setLineWrap(true);
    memo1.setWrapStyleWord(true);
    memo1.setBounds(new Rectangle(17, 451, 361, 154));
    jButton7.setBounds(new Rectangle(226, 289, 92, 26));
    jButton7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton7.setText("设置掉线");
    jButton7.addActionListener(new RealTimeTestFrame_jButton7_actionAdapter(this));
    jButton10.setBounds(new Rectangle(192, 155, 90, 23));
    jButton10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton10.setText("手工建档");
    jButton10.addActionListener(new RealTimeTestFrame_jButton10_actionAdapter(this));
    jLabel12.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jLabel12.setText("功能码:");
    jLabel12.setBounds(new Rectangle(23, 254, 61, 16));
    txt_yxj.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    txt_yxj.setText("08");
    txt_yxj.setBounds(new Rectangle(84, 283, 63, 22));
    jButton11.setBounds(new Rectangle(105, 412, 82, 26));
    jButton11.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton11.setActionCommand("");
    jButton11.setText("获取结果");
    jButton11.addActionListener(new RealTimeTestFrame_jButton11_actionAdapter(this));
    jButton12.setBounds(new Rectangle(301, 412, 87, 26));
    jButton12.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
    jButton12.setText("批量测试");
    jButton12.addActionListener(new RealTimeTestFrame_jButton12_actionAdapter(this));
    contentPane.add(jLabel1);
    contentPane.add(jLabel2);
    contentPane.add(txt_port);
    contentPane.add(jLabel3);
    contentPane.add(jLabel4);
    contentPane.add(jTextField1);
    contentPane.add(txt_AppID);
    contentPane.add(txt_zdljdz);
    contentPane.add(jTextField7);
    contentPane.add(txt_ip);
    contentPane.add(txt_content);
    contentPane.add(jLabel6);
    contentPane.add(jLabel9);
    contentPane.add(txt_sjhm);
    contentPane.add(jLabel10);
    contentPane.add(txt_mlxh);
    contentPane.add(txt_listterminal);
    contentPane.add(jLabel11);
    contentPane.add(jButton8);
    contentPane.add(jButton9);
    contentPane.add(memo1);
    contentPane.add(jButton7);
    contentPane.add(jButton10);
    contentPane.add(txt_gnm);
    contentPane.add(txt_txfs);
    contentPane.add(txt_gyh);
    contentPane.add(jLabel5);
    contentPane.add(jLabel7);
    contentPane.add(jLabel12);
    contentPane.add(lab_yxj);
    contentPane.add(txt_yxj);
    contentPane.add(jButton2);
    contentPane.add(jButton5);
    contentPane.add(jButton6);
    contentPane.add(jButton4);
    contentPane.add(jButton1);
    contentPane.add(jButton11);
    contentPane.add(jButton3);
    contentPane.add(jButton12);
  }
Example #25
0
 public static JTextArea getTextArea(String s) {
   JTextArea ret = new JTextArea(s);
   ret.setFont(new Font("Courier", Font.PLAIN, 12));
   ret.setTabSize(4);
   return ret;
 }
  public ODEWizardScalaSci() {
    editingClassName = "Lorenz";
    systemOrder = 3; // the order of ODE system

    copyTemplateButton =
        new JButton("1. Copy and Edit Template", new ImageIcon("/scalaLab.jar/yellow-ball.gif"));
    generateEditingButton = new JButton("2. Generate Java Class", new ImageIcon("./blue-ball.gif"));
    saveJavaClassButton =
        new JButton("3. Save Java Class", new ImageIcon("scalaLab.jar/red-ball.gif"));
    compileJavaClassButton =
        new JButton("4.a. Java Compile - External Compiler", new ImageIcon("blue-ball.gif"));
    compileJavaInternalCompilerButton =
        new JButton("4.b. Java Compile - Internal Compiler", new ImageIcon("blue-ball.gif"));
    generateScriptCodeButton =
        new JButton("Generate scalaSci Script", new ImageIcon("red-ball.gif"));

    ODEWizardFrame = new JFrame("ODE Wizard for scalaSci with Java implementation of. ODEs");

    editPanel = new JPanel();
    editPanel.setLayout(new GridLayout(1, 2));

    paramPanel = new JPanel(new GridLayout(1, 4));
    availODEMethods.add("ODErke");
    availODEMethods.add("ODEmultistep");
    availODEMethods.add("ODEdiffsys");
    ODEselectMethodLabel = new JLabel("ODE method: ");
    ODEselectMethodComboBox = new JComboBox(availODEMethods);
    ODEselectMethodComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ODESolveMethod = ODEselectMethodComboBox.getSelectedIndex();
            updateTemplateText();
            templateTextArea.setText(templateText);
            currentlySelectedLabel.setText(
                "Selected Method: " + (String) availODEMethods.get(ODESolveMethod));
          }
        });

    JLabel javaFileTextLabel = new JLabel("Java File Name: ");
    javaFileTextBox = new JTextField(editingClassName);
    javaFileTextBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            editingClassName = javaFileTextBox.getText();
            String updatedStatusText = prepareStatusText();
            statusAreaTop.setText(updatedStatusText);
          }
        });

    JLabel systemOrderLabel = new JLabel("System order: ");
    systemOrderText = new JTextField(String.valueOf(systemOrder));
    systemOrderText.addActionListener(new editSystemOrder());
    JPanel javaFilePanel = new JPanel();
    javaFilePanel.add(javaFileTextLabel);
    javaFilePanel.add(javaFileTextBox);
    JPanel systemOrderPanel = new JPanel();
    systemOrderPanel.add(systemOrderLabel);
    systemOrderPanel.add(systemOrderText);

    paramMethodPanel = new JPanel();
    paramMethodPanel.add(ODEselectMethodLabel);
    paramMethodPanel.add(ODEselectMethodComboBox);
    paramPanel.add(paramMethodPanel);
    paramPanel.add(javaFilePanel);
    paramPanel.add(systemOrderPanel);
    currentlySelectedLabel =
        new JLabel("Selected Method: " + (String) availODEMethods.get(ODESolveMethod));
    paramPanel.add(currentlySelectedLabel);

    statusPanel = new JPanel(new GridLayout(2, 1));
    statusAreaTop = new JTextArea();
    statusAreaTop.setFont(new Font("Arial", Font.BOLD, 16));
    String statusText = prepareStatusText();

    statusAreaTop.setText(statusText);
    statusAreaBottom = new JTextArea();
    statusAreaBottom.setText(
        "Step1:  Copy and edit the template ODE  (implements the famous Lorenz chaotic system),\n"
            + "Then set the name of your Java Class (instead of \"Lorenz\"),  without the extension .java\n"
            + "Also set the proper order (i.e. number of equations and variables) of your system. ");
    statusPanel.add(statusAreaTop);
    statusPanel.add(statusAreaBottom);

    templateTextArea = new JTextArea();
    updateTemplateText();

    templateTextArea.setFont(new Font("Arial", Font.ITALIC, 12));
    templateTextArea.setText(templateText);
    templateScrollPane = new JScrollPane();
    templateViewPort = templateScrollPane.getViewport();
    templateViewPort.add(templateTextArea);

    ODEWizardTextArea = new JTextArea();
    ODEWizardText = "";
    ODEWizardTextArea.setText(ODEWizardText);
    ODEWizardTextArea.setFont(new Font("Arial", Font.BOLD, 12));

    ODEWizardScrollPane = new JScrollPane();
    wizardViewPort = ODEWizardScrollPane.getViewport();
    wizardViewPort.add(ODEWizardTextArea);

    editPanel.add(ODEWizardScrollPane);
    editPanel.add(templateScrollPane);

    // Step 1: copy template of ODE implementation from the
    // templateTextArea to ODEWizardTextArea
    copyTemplateButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ODEWizardTextArea.setText(templateTextArea.getText());
            generateEditingButton.setEnabled(true);
            statusAreaBottom.setText(
                "Step2:  If you have implemented correctly your ODE, the wizard completes the ready to compile Java class");
          }
        });

    // Step 2: generate Java Class from template
    JPanel buttonPanel = new JPanel();
    generateEditingButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String editingODE = ODEWizardTextArea.getText();
            String classImplementationString = // "package javaPluggins; \n"+
                "import  numal.*; \n\n"
                    + "public class "
                    + editingClassName
                    + " extends Object \n             implements "
                    + implementingInterfaces[ODESolveMethod]
                    + " \n \n "
                    + "{ \n";

            classImplementationString += (editingODE + "}\n");

            ODEWizardTextArea.setText(classImplementationString);
            saveJavaClassButton.setEnabled(true);
            statusAreaBottom.setText(
                "Step3:  The generated Java source is ready, you can check it, and then proceed to save.");
          }
        });

    // Step 3: save generated Java Class on disk
    saveJavaClassButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String currentWorkingDirectory = Directory.Current().get().path();
            JFileChooser chooser = new JFileChooser(currentWorkingDirectory);
            chooser.setSelectedFile(new File(editingClassName + ".java"));
            int ret = chooser.showSaveDialog(ODEWizardFrame);

            if (ret != JFileChooser.APPROVE_OPTION) {
              return;
            }
            File f = chooser.getSelectedFile();
            try {
              PrintWriter out = new PrintWriter(f);
              String javaCodeText = ODEWizardTextArea.getText();
              out.write(javaCodeText);
              out.close();
              // update the notion  of the working directory
              String fullPathOfSavedFile = f.getAbsolutePath();
              GlobalValues.workingDir =
                  fullPathOfSavedFile.substring(
                      0, fullPathOfSavedFile.lastIndexOf(File.separatorChar) + 1);

              compileJavaClassButton.setEnabled(true);
              compileJavaInternalCompilerButton.setEnabled(true);
              statusAreaBottom.setText(
                  "Step4:  The Java source file was saved to disk,  \n "
                      + "you can proceed to compile and load the corresponding class file");
            } catch (java.io.FileNotFoundException enf) {
              System.out.println("File " + f.getName() + " not found");
              enf.printStackTrace();
            } catch (Exception eOther) {
              System.out.println("Exception trying to create PrintWriter");
              eOther.printStackTrace();
            }
          }
        });

    // Step 4: Compile the generated Java class
    compileJavaClassButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String currentWorkingDirectory = GlobalValues.workingDir;
            JFileChooser chooser = new JFileChooser(currentWorkingDirectory);
            int ret = chooser.showOpenDialog(ODEWizardFrame);

            if (ret != JFileChooser.APPROVE_OPTION) {
              return;
            }
            File f = chooser.getSelectedFile();
            String javaFile = null;
            try {
              javaFile = f.getCanonicalPath();
            } catch (IOException ex) {
              System.out.println("I/O Exception in getCanonicalPath");
              ex.printStackTrace();
            }

            //   extract the path specification of the generated Java class that implements the ODE
            // solution method,
            //    in order to update the ScalaSci class path
            String SelectedFileWithPath = f.getAbsolutePath();
            String SelectedFilePathOnly =
                SelectedFileWithPath.substring(
                    0, SelectedFileWithPath.lastIndexOf(File.separatorChar));

            if (GlobalValues.ScalaSciClassPath.length() == 0) GlobalValues.ScalaSciClassPath = ".";
            if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly) == -1) {
              GlobalValues.ScalaSciClassPathComponents.add(0, SelectedFilePathOnly);
              GlobalValues.ScalaSciClassPath =
                  GlobalValues.ScalaSciClassPath + File.pathSeparator + SelectedFilePathOnly;
            }
            // update also the ScalaSciClassPath property
            StringBuilder fileStr = new StringBuilder();
            Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements();
            while (enumDirs.hasMoreElements()) {
              Object ce = enumDirs.nextElement();
              fileStr.append(File.pathSeparator + (String) ce);
            }
            GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString());

            ClassLoader parentClassLoader = getClass().getClassLoader();
            GlobalValues.extensionClassLoader =
                new ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader);

            // update GUI components to account for the updated ScalaSci classpath
            scalaExec.scalaLab.scalaLab.updateTree();

            boolean compilationSucccess = true;

            String tempFileName = "";
            tempFileName =
                javaFile + ".java"; // public classes and Java files should have the same name

            String[] command = new String[6];
            command[0] = "javac";
            command[1] = "-cp";
            command[2] = GlobalValues.jarFilePath + File.pathSeparator + GlobalValues.homeDir;
            command[3] = "-d"; // where to place output class files
            command[4] = SelectedFilePathOnly; //  the path to save the compiled class files
            command[5] = javaFile; // full filename to compile

            String compileCommandString =
                command[0]
                    + "  "
                    + command[1]
                    + "  "
                    + command[2]
                    + " "
                    + command[3]
                    + " "
                    + command[4]
                    + " "
                    + command[5];

            System.out.println("compileCommand Java= " + compileCommandString);

            try {
              Runtime rt = Runtime.getRuntime();
              Process javaProcess = rt.exec(command);
              // an error message?
              StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

              // any output?
              StreamGobbler outputGobbler =
                  new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

              // kick them off
              errorGobbler.start();
              outputGobbler.start();

              // any error???
              javaProcess.waitFor();
              int rv = javaProcess.exitValue();
              String commandString = command[0] + "  " + command[1] + "  " + command[2];
              if (rv == 0) {
                System.out.println("Process:  " + commandString + "  exited successfully ");
                generateScriptCodeButton.setEnabled(true);
                statusAreaBottom.setText(
                    "Step5:  You can proceed now to create a draft script that utilizes your Java-based  ODE integrator");
              } else
                System.out.println(
                    "Process:  " + commandString + "  exited with error, error value = " + rv);

            } catch (IOException exio) {
              System.out.println("IOException trying to executing " + command);
              exio.printStackTrace();

            } catch (InterruptedException ie) {
              System.out.println("Interrupted Exception  trying to executing " + command);
              ie.printStackTrace();
            }
          }
        });

    // Compile with the internal compiler
    compileJavaInternalCompilerButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            String currentWorkingDirectory = GlobalValues.workingDir;
            JFileChooser chooser = new JFileChooser(currentWorkingDirectory);
            int ret = chooser.showOpenDialog(ODEWizardFrame);

            if (ret != JFileChooser.APPROVE_OPTION) {
              return;
            }
            File f = chooser.getSelectedFile();
            String javaFile = null;
            try {
              javaFile = f.getCanonicalPath();
            } catch (IOException ex) {
              System.out.println("I/O Exception in getCanonicalPath");
              ex.printStackTrace();
            }

            //   extract the path specification of the generated Java class that implements the ODE
            // solution method,
            //    in order to update the ScalaSci class path
            String SelectedFileWithPath = f.getAbsolutePath();
            String SelectedFilePathOnly =
                SelectedFileWithPath.substring(
                    0, SelectedFileWithPath.lastIndexOf(File.separatorChar));

            if (GlobalValues.ScalaSciClassPath.length() == 0) GlobalValues.ScalaSciClassPath = ".";
            if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly) == -1) {
              GlobalValues.ScalaSciClassPathComponents.add(0, SelectedFilePathOnly);
              GlobalValues.ScalaSciClassPath =
                  GlobalValues.ScalaSciClassPath + File.pathSeparator + SelectedFilePathOnly;
            }
            // update also the ScalaSciClassPath property
            StringBuilder fileStr = new StringBuilder();
            Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements();
            while (enumDirs.hasMoreElements()) {
              Object ce = enumDirs.nextElement();
              fileStr.append(File.pathSeparator + (String) ce);
            }
            GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString());

            ClassLoader parentClassLoader = getClass().getClassLoader();
            GlobalValues.extensionClassLoader =
                new ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader);

            // update GUI components to account for the updated ScalaSci classpath
            scalaExec.scalaLab.scalaLab.updateTree();

            String[] command = new String[11];
            String toolboxes = "";
            for (int k = 0; k < GlobalValues.ScalaSciClassPathComponents.size(); k++)
              toolboxes =
                  toolboxes
                      + File.pathSeparator
                      + GlobalValues.ScalaSciClassPathComponents.elementAt(k);

            // compile the temporary file
            command[0] = "java";
            command[1] = "-classpath";
            command[2] =
                "."
                    + File.pathSeparator
                    + GlobalValues.jarFilePath
                    + File.pathSeparator
                    + toolboxes
                    + File.pathSeparator
                    + SelectedFilePathOnly;
            command[3] = "com.sun.tools.javac.Main"; // the name of the Java  compiler class
            command[4] = "-classpath";
            command[5] = command[2];
            command[6] = "-sourcepath";
            command[7] = command[2];
            command[8] = "-d"; // where to place output class files
            command[9] = SelectedFilePathOnly;
            command[10] = SelectedFileWithPath;
            String compileCommandString =
                command[0]
                    + "  "
                    + command[1]
                    + "  "
                    + command[2]
                    + " "
                    + command[3]
                    + " "
                    + command[4]
                    + " "
                    + command[5]
                    + " "
                    + command[6]
                    + " "
                    + command[7]
                    + " "
                    + command[8]
                    + " "
                    + command[9]
                    + " "
                    + command[10];

            System.out.println("compileCommand Java= " + compileCommandString);

            try {
              Runtime rt = Runtime.getRuntime();
              Process javaProcess = rt.exec(command);
              // an error message?
              StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

              // any output?
              StreamGobbler outputGobbler =
                  new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

              // kick them off
              errorGobbler.start();
              outputGobbler.start();

              // any error???
              javaProcess.waitFor();
              int rv = javaProcess.exitValue();
              if (rv == 0) {
                System.out.println("Process:  exited successfully ");

                JavaCompile javaCompileObj = null;
                try {
                  javaCompileObj = new JavaCompile();
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(
                      null,
                      "Unable to compile. Please check if your system's PATH variable includes the path to your javac compiler",
                      "Cannot compile - Check PATH",
                      JOptionPane.INFORMATION_MESSAGE);
                  ex.printStackTrace();
                }
                generateScriptCodeButton.setEnabled(true);
                statusAreaBottom.setText(
                    "Step5:  You can proceed now to create a draft ScalaSci-Script that utilizes your Java-based  ODE integrator");

              } else System.out.println("Process:  exited with error, error value = " + rv);

            } catch (IOException exio) {
              System.out.println("IOException trying to executing " + command);
              exio.printStackTrace();

            } catch (InterruptedException ie) {
              System.out.println("Interrupted Exception  trying to executing " + command);
              ie.printStackTrace();
            }
          }
        });

    // Step 5: Generate Script Code
    generateScriptCodeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new scriptCodeGenerationFrame("ODE Script code", editingClassName, systemOrder);
          }
        });

    buttonPanel.add(copyTemplateButton); // Step 1
    buttonPanel.setEnabled(true);
    buttonPanel.add(generateEditingButton); // Step 2
    generateEditingButton.setEnabled(false);
    buttonPanel.add(saveJavaClassButton); // Step 3
    saveJavaClassButton.setEnabled(false);
    buttonPanel.add(compileJavaClassButton); // Step 4
    buttonPanel.add(compileJavaInternalCompilerButton);
    compileJavaClassButton.setEnabled(false);
    compileJavaInternalCompilerButton.setEnabled(false);
    buttonPanel.add(generateScriptCodeButton); // Step 5
    generateScriptCodeButton.setEnabled(false);

    ODEWizardFrame.add(buttonPanel, BorderLayout.NORTH);
    ODEWizardFrame.add(editPanel, BorderLayout.CENTER);
    JPanel bottomPanel = new JPanel(new GridLayout(2, 1));

    bottomPanel.add(paramPanel);
    bottomPanel.add(statusPanel);
    ODEWizardFrame.add(bottomPanel, BorderLayout.SOUTH);
    ODEWizardFrame.setLocation(100, 100);
    ODEWizardFrame.setSize(1400, 800);
    ODEWizardFrame.setVisible(true);
  }
Example #27
0
  void jbInit() throws Exception {
    titledBorder1 =
        new TitledBorder(
            BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages");
    this.getContentPane().setLayout(borderLayout1);

    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);

    this.setTitle("EDIT");

    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(470);
    sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12));
    controlPanel.setLayout(gridBagLayout1);
    controlPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    positionPanel.setLayout(gridBagLayout2);
    fileLabel.setText("Source file:");
    fileText.setEditable(false);
    browseButton.setSelected(false);
    browseButton.setText("Browse ...");
    assembleButton.setEnabled(false);
    assembleButton.setText("Assemble file");
    saveButton.setEnabled(false);
    saveButton.setText("Save file");
    lineLabel.setText("Line:");
    lineText.setMinimumSize(new Dimension(50, 20));
    lineText.setPreferredSize(new Dimension(50, 20));
    lineText.setEditable(false);
    columnLabel.setText("Column:");
    columnText.setMinimumSize(new Dimension(41, 20));
    columnText.setPreferredSize(new Dimension(41, 20));
    columnText.setEditable(false);
    columnText.setText("");
    messageScrollPane.setBorder(titledBorder1);
    messageScrollPane.setMinimumSize(new Dimension(33, 61));
    messageScrollPane.setPreferredSize(new Dimension(60, 90));
    optionsButton.setEnabled(false);
    optionsButton.setText("Assembler options ...");
    messageScrollPane.getViewport().add(messageList, null);
    messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.add(textScrollPane, JSplitPane.TOP);
    splitPane.add(controlPanel, JSplitPane.BOTTOM);
    textScrollPane.getViewport().add(sourceArea, null);

    controlPanel.add(
        fileLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        fileText,
        new GridBagConstraints(
            1,
            0,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        browseButton,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        optionsButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        assembleButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        saveButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        positionPanel,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        lineLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    positionPanel.add(
        lineText,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        columnLabel,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    positionPanel.add(
        columnText,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        messageScrollPane,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
  public void go() {
    // build gui

    frame = new JFrame("Quiz Card Buider");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);
    question = new JTextArea(6, 20);
    question.setLineWrap(true);
    question.setWrapStyleWord(true);
    question.setFont(bigFont);

    JScrollPane qScroller = new JScrollPane(question);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    answer = new JTextArea(6, 20);
    answer.setLineWrap(true);
    answer.setWrapStyleWord(true);
    answer.setFont(bigFont);

    JScrollPane aScroller = new JScrollPane(question);
    aScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    aScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    JButton nextButton = new JButton("Next Card");

    cardList = new ArrayList<QuizCard>();

    JLabel qLabel = new JLabel("Question");
    JLabel aLabel = new JLabel("Answer");

    mainPanel.add(qLabel);
    mainPanel.add(qScroller);
    mainPanel.add(aLabel);
    mainPanel.add(aScroller);
    mainPanel.add(nextButton);

    nextButton.addActionListener(new NextCardListener());

    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");

    JMenuItem newMenuItem = new JMenuItem("New");
    JMenuItem saveMenuItem = new JMenuItem("Save");
    newMenuItem.addActionListener(new NewMenuListener());
    saveMenuItem.addActionListener(new SaveMenuListener());

    fileMenu.add(newMenuItem);
    fileMenu.add(saveMenuItem);
    menuBar.add(fileMenu);
    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(500, 600);
    frame.setVisible(true);
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  }
  public void go() {
    frame = new JFrame("Quiz Card Player");
    JPanel mainPanel = new JPanel();
    Font bigFont = new Font("sanserif", Font.BOLD, 24);

    display = new JTextArea(10, 20);
    display.setFont(bigFont);
    display.setLineWrap(true);
    display.setEditable(false);

    JScrollPane qScroller = new JScrollPane(display);
    qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

    nextButton = new JButton("Show Questions");
    nextButton.addActionListener(new NextCardListener());

    mainPanel.add(qScroller);
    mainPanel.add(nextButton);

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem loadMenuItem = new JMenuItem("Load Card Set");
    loadMenuItem.addActionListener(new OpenMenuListener());
    fileMenu.add(loadMenuItem);
    menuBar.add(fileMenu);

    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
    frame.setSize(640, 500);
    frame.setVisible(true);
  }
  public BaseGoogleLoginUI(@NotNull String signinText) {
    setLayout(new GridBagLayout());
    setPreferredSize(new Dimension(MIN_WIDTH, PREFERRED_HEIGHT));
    setOpaque(false);

    JLabel googleIcon = new JBLabel();

    setBorder(BorderFactory.createEmptyBorder(10, 15, 15, 15));
    googleIcon.setHorizontalAlignment(SwingConstants.CENTER);
    googleIcon.setVerticalAlignment(SwingConstants.CENTER);
    googleIcon.setOpaque(false);
    googleIcon.setIcon(GoogleLoginIcons.GOOGLE_LOGO);
    googleIcon.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weighty = 0;
    add(googleIcon, c);

    JTextArea signinTextArea = new JTextArea();
    signinTextArea.setFont(UIUtil.getLabelFont());
    signinTextArea.setLineWrap(true);
    signinTextArea.setWrapStyleWord(true);
    signinTextArea.setOpaque(false);
    signinTextArea.setText(signinText);
    c.gridx = 0;
    c.gridy = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    add(signinTextArea, c);
  }