Exemplo n.º 1
0
 /** Returns the contents of the next textarea. */
 public String getNextText() {
   String text;
   if (textAreaIndex == 0 && textArea1 != null) {
     // textArea1.selectAll();
     text = textArea1.getText();
     textAreaIndex++;
     if (macro) text = Macro.getValue(macroOptions, "text1", text);
     if (recorderOn) {
       String text2 = text;
       String cmd = Recorder.getCommand();
       if (cmd != null && cmd.equals("Convolve...")) {
         text2 = text.replaceAll("\n", "\\\\n");
         if (!text.endsWith("\n")) text2 = text2 + "\\n";
       } else text2 = text.replace('\n', ' ');
       Recorder.recordOption("text1", text2);
     }
   } else if (textAreaIndex == 1 && textArea2 != null) {
     textArea2.selectAll();
     text = textArea2.getText();
     textAreaIndex++;
     if (macro) text = Macro.getValue(macroOptions, "text2", text);
     if (recorderOn) Recorder.recordOption("text2", text.replace('\n', ' '));
   } else text = null;
   return text;
 }
  /** Method declaration Adjust this method for large strings...ie multi megabtypes. */
  void execute() {

    String sCmd = null;

    if (4096 <= ifHuge.length()) {
      sCmd = ifHuge;
    } else {
      sCmd = txtCommand.getText();
    }

    if (sCmd.startsWith("-->>>TEST<<<--")) {
      testPerformance();

      return;
    }

    String g[] = new String[1];

    lTime = System.currentTimeMillis();

    try {
      sStatement.execute(sCmd);

      lTime = System.currentTimeMillis() - lTime;

      int r = sStatement.getUpdateCount();

      if (r == -1) {
        formatResultSet(sStatement.getResultSet());
      } else {
        g[0] = "update count";

        gResult.setHead(g);

        g[0] = String.valueOf(r);

        gResult.addRow(g);
      }

      addToRecent(txtCommand.getText());
    } catch (SQLException e) {
      lTime = System.currentTimeMillis() - lTime;
      g[0] = "SQL Error";

      gResult.setHead(g);

      String s = e.getMessage();

      s += " / Error Code: " + e.getErrorCode();
      s += " / State: " + e.getSQLState();
      g[0] = s;

      gResult.addRow(g);
    }

    updateResult();
    System.gc();
  }
 /*
  * Test method for 'java.awt.TextArea.TextArea(String)'
  */
 public void testTextAreaString() {
   String text = "text";
   area = new TextArea(text);
   assertEquals(text, area.getText());
   assertEquals(0, area.getColumns());
   assertEquals(0, area.getRows());
   assertEquals(TextArea.SCROLLBARS_BOTH, area.getScrollbarVisibility());
   area = new TextArea(text = null);
   assertEquals("", area.getText());
 }
 /*
  * Test method for 'java.awt.TextArea.TextArea()'
  */
 public void testTextArea() {
   assertNotNull(area);
   assertEquals("", area.getText());
   assertEquals(0, area.getColumns());
   assertEquals(0, area.getRows());
   assertEquals(TextArea.SCROLLBARS_BOTH, area.getScrollbarVisibility());
 }
Exemplo n.º 5
0
        public void actionPerformed(ActionEvent e) {

          if ((e.getSource() instanceof JMenuItem)) {
            JMenuItem item = (JMenuItem) e.getSource();
            int lineNumber = Math.round(item.getAlignmentX() * 1000000);
            TextArea ta = OJ.editor.getTextArea();
            String txt = ta.getText();
            int lines = 0;
            int selBegin = 0;
            int selEnd = 0;
            for (int charPos = 0; charPos < txt.length(); charPos++) {
              if (txt.charAt(charPos) == '\n') {
                lines++;
                if (lines == (lineNumber + 1)) {
                  selEnd = charPos;
                  break;
                }
                selBegin = charPos;
              }
            }
            ij.IJ.showStatus("" + lineNumber);
            ta.select(selBegin + 1, selEnd + 1);
            IJ.wait(500);
            ta.setCaretPosition(selBegin + 1);
            ta.setVisible(true);
            ta.requestFocus();
            OJ.editor.setIsMacroWindow(true);
          }
        }
Exemplo n.º 6
0
  public boolean action(Event event, Object object) {
    if (event.target instanceof Button) {
      if ("Apply".equals(object)) {
        if (setValues_()) hide();
        return true;
      } else if ("Cancel".equals(object)) {
        hide();
        return true;
      }
    } else if (event.target == data_) {
      dataHash_.put(currentData_, dataText_.getText());

      String old_data = currentData_;
      currentData_ = data_.getSelectedItem();
      if (!currentData_.equals("<NEW>")) {
        String value = (String) dataHash_.get(currentData_);
        if (value == null) value = new String("");
        dataText_.setText(value);
      } else {
        new InputDialog(
            frame_,
            "Enter name for new data item " + "(must be a letter followed by letters and numbers).",
            this,
            9999);
        if (data_.getSelectedItem().equals("<NEW>")) data_.select(old_data);
      }
    }

    return false;
  }
 /*
  * Test method for 'java.awt.TextArea.TextArea(int, int)'
  */
 public void testTextAreaIntInt() {
   int cols = 12;
   int rows = 15;
   area = new TextArea(rows, cols);
   assertEquals("", area.getText());
   assertEquals(cols, area.getColumns());
   assertEquals(rows, area.getRows());
 }
 /*
  * Test method for 'java.awt.TextArea.appendText(String)'
  */
 @SuppressWarnings("deprecation")
 public void testAppendText() {
   String text = "text";
   area.setText(text);
   String str = "\nappended text";
   area.appendText(str);
   assertEquals(text + str, area.getText());
   assertEquals(0, area.getColumns());
 }
 /*
  * Test method for 'java.awt.TextArea.insert(String, int)'
  */
 public void testInsert() {
   String text = "text";
   area.setText(text);
   String str = "inserted text\n";
   area.insert(str, 0);
   assertEquals(str + text, area.getText());
   assertEquals(0, area.getRows());
   assertEquals(0, area.getCaretPosition());
 }
Exemplo n.º 10
0
  private JPanel getContainer() {
    layout = new FlowLayout(); // Instanciation du layout
    layout.setAlignment(FlowLayout.CENTER); // On centre les composants

    container = new JPanel(); // On cr�e notre objet
    container.setLayout(layout); // On applique le layout

    textCycle.setEditable(false);
    textCycle.setPreferredSize(new Dimension(600, 200));
    for (int k = 0; k < cycles.size(); k++) {
      textCycle.setText(
          textCycle.getText()
              + "Cycle no"
              + k
              + " :"
              + cycles.get(k).toString()
              + "\n"
              + "\n"); // On lui donne un texte
      container.add(textCycle); // On l'ajoute au container
    }

    btnPath = new JButton(); // Cr�ation du bouton
    btnPath.setPreferredSize(new Dimension(200, 25)); // On lui donne une taille
    btnPath.setText("Show path"); // On lui donne un texte
    btnPath.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnPath); // On l'ajoute � la fen�tre

    oneState =
        new JComboBox(listOneState); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    oneState.setPreferredSize(new Dimension(140, 25)); // On lui donne une taille
    container.add(oneState); // on l'ajoute � la fen�tre

    twoStates =
        new JComboBox(listTwoStates); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    twoStates.setPreferredSize(new Dimension(140, 25)); // On lui donne une taille
    container.add(twoStates); // on l'ajoute � la fen�tre

    btnCycle = new JButton(); // Cr�ation du bouton
    btnCycle.setPreferredSize(new Dimension(300, 25)); // On lui donne une taille
    btnCycle.setText("Show cycle"); // On lui donne un texte
    btnCycle.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnCycle); // On l'ajoute � la fen�tre

    cyclesBox =
        new JComboBox(listCycles); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    cyclesBox.setPreferredSize(new Dimension(120, 25)); // On lui donne une taille
    container.add(cyclesBox); // on l'ajoute � la fen�tre

    btnReset = new JButton(); // Cr�ation du bouton
    btnReset.setPreferredSize(new Dimension(400, 25)); // On lui donne une taille
    btnReset.setText("Clear"); // On lui donne un texte
    btnReset.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnReset); // On l'ajoute � la fen�tre

    return container;
  }
Exemplo n.º 11
0
 /*
  * Test method for 'java.awt.TextArea.replaceText(String, int, int)'
  */
 @SuppressWarnings("deprecation")
 public void testReplaceText() {
   String text = "This is old text";
   area.setText(text);
   String str = "new\n";
   area.replaceText(str, 8, 12);
   assertEquals("This is new\ntext", area.getText());
   assertEquals(0, area.getColumns());
   assertEquals(0, area.getCaretPosition());
 }
Exemplo n.º 12
0
 /*
  * Test method for 'java.awt.TextArea.insertText(String, int)'
  */
 @SuppressWarnings("deprecation")
 public void testInsertText() {
   String text = "text";
   area.setText(text);
   String str = "inserted text\n";
   area.insertText(str, 0);
   assertEquals(str + text, area.getText());
   assertEquals(0, area.getColumns());
   assertEquals(0, area.getCaretPosition());
 }
Exemplo n.º 13
0
  /*
   * Test method for 'java.awt.TextArea.append(String)'
   */
  public void testAppend() {
    String text = "text";
    area.setText(text);
    String str = "\nappended text";

    area.append(str);
    assertEquals(text + str, area.getText());
    assertEquals(0, area.getRows());
    assertEquals(0, area.getCaretPosition());
  }
Exemplo n.º 14
0
 /*
  * Test method for 'java.awt.TextArea.replaceRange(String, int, int)'
  */
 public void testReplaceRange() {
   int start = 8;
   int end = 11;
   String text = "This is old text";
   area.setText(text);
   String str = "brand new";
   area.replaceRange(str, start, end);
   assertEquals("This is brand new text", area.getText());
   assertEquals("", area.getSelectedText());
   assertEquals(0, area.getRows());
   assertEquals(0, area.getCaretPosition());
 }
  public void actionPerformed(ActionEvent e) {
    JButton b = (JButton) e.getSource();
    if (b == bu) {
      j14 = new JLabel("NEW IMAGE");
      j14.setBounds(840, 200, 300, 300);
      q.add(j14);

      JFileChooser filechooser = new JFileChooser();
      int result = filechooser.showOpenDialog(this);
      f = filechooser.getSelectedFile();
      try {
        String dir1 = f.getAbsolutePath();
        // setText(dir);
        str = dir1;
        // ResizeImage.resize(dir);
        f = new File(dir1);
      } catch (Exception e1) {
      }
      repaint();
      // b=(JButton)e.getSource();

    }
    if (b == ba) {
      try {
        read();
        patient.add(tadd.getText(), tsym.getText(), f, str);
        JOptionPane.showMessageDialog(null, "Patient ID: " + patient.pid + " Record Added");
      } catch (Exception e4) {
        System.out.println("" + e4);
      }
    }
    if (b == bm) {
      try {
        setVisible(false);
      } catch (Exception e4) {
        System.out.println("" + e4);
      }
    }
  }
Exemplo n.º 16
0
 /*
  * Test method for 'java.awt.TextArea.TextArea(String, int, int, int)'
  */
 public void testTextAreaStringIntIntInt() {
   String text = "text";
   int cols = 12;
   int rows = 5;
   int scrollbars = TextArea.SCROLLBARS_NONE;
   area = new TextArea(text, rows, cols, scrollbars);
   assertEquals(text, area.getText());
   assertEquals(cols, area.getColumns());
   assertEquals(rows, area.getRows());
   assertEquals(scrollbars, area.getScrollbarVisibility());
   scrollbars = -1;
   area = new TextArea(text, rows, cols, scrollbars);
   assertEquals(TextArea.SCROLLBARS_BOTH, area.getScrollbarVisibility());
 }
Exemplo n.º 17
0
 public ExParValue getExParValue() {
   ExParValue v = null;
   try {
     // ExDesignTreeParser parser = new ExDesignTreeParser(new
     // StringReader(text.getText()), Base.getEncoding());
     ExDesignTreeParser parser = new ExDesignTreeParser(new StringReader(text.getText()));
     v = parser.assignableParameterValue();
   } catch (ParseException pex) {
     new de.pxlab.pxl.NonFatalError(pex.getMessage());
   } catch (TokenMgrError tex) {
     new de.pxlab.pxl.NonFatalError(tex.getMessage());
   }
   return v;
 }
 String[] getContactList() {
   java.util.List cl = new java.util.LinkedList();
   StringTokenizer st = new StringTokenizer(contactList.getText());
   StringBuffer sb = new StringBuffer();
   StringBuffer dbg = new StringBuffer("test applet contactlist: ");
   while (st.hasMoreTokens()) {
     String loginId = st.nextToken().trim();
     if (loginId.length() == 0) continue;
     dbg.append("'" + loginId + "' ");
     cl.add(loginId);
     sb.append(loginId).append('\n');
   }
   CAT.info(dbg.toString());
   contactList.setText(sb.toString());
   return (String[]) cl.toArray(new String[cl.size()]);
 }
Exemplo n.º 19
0
  public void actionPerformed(ActionEvent event) {
    if (event.getSource() == Cancel) {
      setVisible(false);
      dispose();
      return;
    }

    if (event.getSource() == Okay) {
      try {
        setVisible(false);
        f1.put(text.getText());
        dispose();
      } catch (xBaseJException e1) {
        System.out.println(e1);
      }
    }
  }
Exemplo n.º 20
0
  public void refreshPopupItems() {
    if (!showPopUp) {
      return;
    }
    macrosPopup.removeAll();
    TextArea ta = OJ.editor.getTextArea();
    String macros_text = ta.getText();
    int caretPos = ta.getCaretPosition();
    String menuStrings = UtilsOJ.extractFunctions(macros_text, caretPos);
    String[] lines = menuStrings.split("\n");
    Font theFont = new java.awt.Font("MS Sans Serif", 0, 12); // NOI18N

    for (int jj = 0; jj < lines.length; jj++) {
      String line = lines[jj];
      if (line.length() > 5) {
        int lineNo = Integer.parseInt(line.substring(0, 5).trim());
        char kind = line.charAt(6);
        char caret = line.charAt(7);
        String title = line.substring(8, line.length());
        Color color = new Color(0, 0, 255);

        if (kind == 'f') {
          color = new Color(0, 100, 0);
          title = "    " + title;
        }
        if (kind == 'b') {
          color = new Color(200, 0, 80);
          title = "    " + title;
        }

        JMenuItem thisItem = new javax.swing.JMenuItem(title);
        thisItem.setAlignmentX((float) lineNo / 1000000);
        thisItem.setForeground(color);
        if (caret == '*') {
          thisItem.setBackground(new Color(255, 255, 188));
        }
        thisItem.setFont(theFont);
        macrosPopup.add(thisItem);
        thisItem.addActionListener(itemAction);
      }
    }
  }
Exemplo n.º 21
0
 // --------------------------------------------------
 void button6_Clicked(Event event) {
   textArea2.setText(textArea2.getText() + "Hai premuto bottone 6\n");
 }
Exemplo n.º 22
0
 // --------------------------------------------------
 public void send() {
   os.println(commandArea.getText());
 }
  /** Method declaration */
  void testPerformance() {

    String all = txtCommand.getText();
    StringBuffer b = new StringBuffer();
    long total = 0;

    for (int i = 0; i < all.length(); i++) {
      char c = all.charAt(i);

      if (c != '\n') {
        b.append(c);
      }
    }

    all = b.toString();

    String g[] = new String[4];

    g[0] = "ms";
    g[1] = "count";
    g[2] = "sql";
    g[3] = "error";

    gResult.setHead(g);

    int max = 1;

    lTime = System.currentTimeMillis() - lTime;

    while (!all.equals("")) {
      int i = all.indexOf(';');
      String sql;

      if (i != -1) {
        sql = all.substring(0, i);
        all = all.substring(i + 1);
      } else {
        sql = all;
        all = "";
      }

      if (sql.startsWith("--#")) {
        max = Integer.parseInt(sql.substring(3));

        continue;
      } else if (sql.startsWith("--")) {
        continue;
      }

      g[2] = sql;

      long l = 0;

      try {
        l = DatabaseManagerCommon.testStatement(sStatement, sql, max);
        total += l;
        g[0] = String.valueOf(l);
        g[1] = String.valueOf(max);
        g[3] = "";
      } catch (SQLException e) {
        g[0] = g[1] = "n/a";
        g[3] = e.toString();
      }

      gResult.addRow(g);
      System.out.println(l + " ms : " + sql);
    }

    g[0] = "" + total;
    g[1] = "total";
    g[2] = "";

    gResult.addRow(g);

    lTime = System.currentTimeMillis() - lTime;

    updateResult();
  }
  /**
   * Method declaration
   *
   * @param ev
   */
  public void actionPerformed(ActionEvent ev) {

    String s = ev.getActionCommand();

    if (s == null) {
      if (ev.getSource() instanceof MenuItem) {
        MenuItem i;

        s = ((MenuItem) ev.getSource()).getLabel();
      }
    }

    if (s.equals("Execute")) {
      execute();
    } else if (s.equals("Exit")) {
      windowClosing(null);
    } else if (s.equals("Transfer")) {
      Transfer.work(null);
    } else if (s.equals("Dump")) {
      Transfer.work(new String[] {"-d"});

      /* NB - 26052002 Restore is not implemented yet in the transfer tool */
      /*
              } else if (s.equals("Restore")) {
                  Transfer.work(new String[]{"-r"});
      */
    } else if (s.equals("Logging on")) {
      jdbcSystem.setLogToSystem(true);
    } else if (s.equals("Logging off")) {
      jdbcSystem.setLogToSystem(false);
    } else if (s.equals("Refresh Tree")) {
      refreshTree();
    } else if (s.startsWith("#")) {
      int i = Integer.parseInt(s.substring(1));

      txtCommand.setText(sRecent[i]);
    } else if (s.equals("Connect...")) {
      connect(ConnectionDialog.createConnection(fMain, "Connect"));
      refreshTree();
    } else if (s.equals("Results in Grid")) {
      iResult = 0;

      pResult.removeAll();
      pResult.add("Center", gResult);
      pResult.doLayout();
    } else if (s.equals("Open Script...")) {
      FileDialog f = new FileDialog(fMain, "Open Script", FileDialog.LOAD);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        txtCommand.setText(DatabaseManagerCommon.readFile(f.getDirectory() + file));
      }
    } else if (s.equals("Save Script...")) {
      FileDialog f = new FileDialog(fMain, "Save Script", FileDialog.SAVE);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtCommand.getText());
      }
    } else if (s.equals("Save Result...")) {
      FileDialog f = new FileDialog(fMain, "Save Result", FileDialog.SAVE);

      // (ulrivo): set default directory if set from command line
      if (defDirectory != null) {
        f.setDirectory(defDirectory);
      }

      f.show();

      String file = f.getFile();

      if (file != null) {
        showResultInText();
        DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtResult.getText());
      }
    } else if (s.equals("Results in Text")) {
      iResult = 1;

      pResult.removeAll();
      pResult.add("Center", txtResult);
      pResult.doLayout();
      showResultInText();
    } else if (s.equals("AutoCommit on")) {
      try {
        cConn.setAutoCommit(true);
      } catch (SQLException e) {
      }
    } else if (s.equals("AutoCommit off")) {
      try {
        cConn.setAutoCommit(false);
      } catch (SQLException e) {
      }
    } else if (s.equals("Enlarge Tree")) {
      Dimension d = tTree.getMinimumSize();

      d.width += 20;

      tTree.setMinimumSize(d);
      fMain.pack();
    } else if (s.equals("Shrink Tree")) {
      Dimension d = tTree.getMinimumSize();

      d.width -= 20;

      if (d.width >= 0) {
        tTree.setMinimumSize(d);
      }

      fMain.pack();
    } else if (s.equals("Enlarge Command")) {
      txtCommand.setRows(txtCommand.getRows() + 1);
      fMain.pack();
    } else if (s.equals("Shrink Command")) {
      int i = txtCommand.getRows() - 1;

      txtCommand.setRows(i < 1 ? 1 : i);
      fMain.pack();
    } else if (s.equals("Commit")) {
      try {
        cConn.commit();
      } catch (SQLException e) {
      }
    } else if (s.equals("Insert test data")) {
      insertTestData();
    } else if (s.equals("Rollback")) {
      try {
        cConn.rollback();
      } catch (SQLException e) {
      }
    } else if (s.equals("Disable MaxRows")) {
      try {
        sStatement.setMaxRows(0);
      } catch (SQLException e) {
      }
    } else if (s.equals("Set MaxRows to 100")) {
      try {
        sStatement.setMaxRows(100);
      } catch (SQLException e) {
      }
    } else if (s.equals("SELECT")) {
      showHelp(DatabaseManagerCommon.selectHelp);
    } else if (s.equals("INSERT")) {
      showHelp(DatabaseManagerCommon.insertHelp);
    } else if (s.equals("UPDATE")) {
      showHelp(DatabaseManagerCommon.updateHelp);
    } else if (s.equals("DELETE")) {
      showHelp(DatabaseManagerCommon.deleteHelp);
    } else if (s.equals("CREATE TABLE")) {
      showHelp(DatabaseManagerCommon.createTableHelp);
    } else if (s.equals("DROP TABLE")) {
      showHelp(DatabaseManagerCommon.dropTableHelp);
    } else if (s.equals("CREATE INDEX")) {
      showHelp(DatabaseManagerCommon.createIndexHelp);
    } else if (s.equals("DROP INDEX")) {
      showHelp(DatabaseManagerCommon.dropIndexHelp);
    } else if (s.equals("CHECKPOINT")) {
      showHelp(DatabaseManagerCommon.checkpointHelp);
    } else if (s.equals("SCRIPT")) {
      showHelp(DatabaseManagerCommon.scriptHelp);
    } else if (s.equals("SHUTDOWN")) {
      showHelp(DatabaseManagerCommon.shutdownHelp);
    } else if (s.equals("SET")) {
      showHelp(DatabaseManagerCommon.setHelp);
    } else if (s.equals("Test Script")) {
      showHelp(DatabaseManagerCommon.testHelp);
    }
  }
Exemplo n.º 25
0
  @Override
  public void actionPerformed(ActionEvent actionEvent) {
    Object obj = actionEvent.getSource();

    if (obj == btFindPat) {

      testpanel.removeAll();
      validate();
      repaint();
      if (taDictionary.getText().isEmpty()) {
        JOptionPane.showMessageDialog(
            frame, "Please load words so they appear in Text Area before Finding Path. ");

      } else if ((tfSourc.getText().isEmpty()) || (tfSourc_6.getText().isEmpty())) {
        JOptionPane.showMessageDialog(
            frame, "Please enter Source and Destination words before Finding Path. ");
      } else if (testpanel.getComponents().length != 0) {
        JOptionPane.showMessageDialog(frame, "Please clear results before continuing.");
      } else {
        wordLadder.findPath(
            tfSourc.getText(), tfSourc_6.getText(), Integer.parseInt(tfWordSize.getText()));
        lblFindPat.setText(
            "Time to find Path: " + String.valueOf(wordLadder.getTimeForPath()) + " milliseconds");
        lblCos.setText("Cost of Path: " + String.valueOf(wordLadder.g.getCost()));
        results = wordLadder.getResults();
        Collections.reverse(results);
        int x = 10;
        int y = 20;

        for (String s : results) {
          x += 20;
          y += 20;
          JLabel _lbl = new JLabel(s);
          _lbl.setLocation(x, y);
          _lbl.setSize(100, 26);

          if (results.indexOf(s) == 0) {
            _lbl.setForeground(new Color(-14646771));
          } else if (results.indexOf(s) == (results.size() - 1)) {
            _lbl.setForeground(new Color(-8254711));
          } else {
            _lbl.setForeground(new Color(-16777216));
          }
          testpanel.add(_lbl);
          testpanel.repaint();
        }
        if (wordLadder.g.getCost() == 0) {
          // if (wordLadder.g.getGraphError() != null){
          JLabel _lbl = new JLabel(wordLadder.g.getGraphError());
          _lbl.setLocation(x, y);
          _lbl.setSize(100, 26);
          testpanel.add(_lbl);
          testpanel.repaint();
          // }

        }
      }
      /*if (taDictionary.getText().isEmpty()){
      wordLadder = new WordLadder(tfFilePat.getText(), tfSourc.getText(), tfSourc_6.getText());
       }else if (!taDictionary.getText().isEmpty()){
          ArrayList<String> taList = new ArrayList<String>();
          StringTokenizer stringTokenizer = new StringTokenizer(taDump, "\t\n\r\f,\"");
          while (stringTokenizer.hasMoreTokens()) {
              String token = stringTokenizer.nextToken();
              taList.add(token);
          }
        */
      // }
    }

    if (obj == btLoadFil) {
      clearData();
      // wordLadder.setWords_size(Integer.parseInt(tfWordSize.getText()));
      // String size = tfWordSize.getText();
      // int intSize = Integer.parseInt(size);
      // WordLadderGUI.showMessage("Loading words of" + tfWordSize.getText() + " characters from
      // file: " + tfFilePat.getText(), Color.GREEN, Color.GREEN);
      lblIndexing1.setText("Indexing...");
      System.out.println(
          "Loading words of "
              + tfWordSize.getText()
              + " characters from file: "
              + tfFilePat.getText());
      wordLadder = new WordLadder(tfFilePat.getText(), Integer.parseInt(tfWordSize.getText()));
      // wordLadder.
      guiDictionary = new WordCollection(wordLadder.getWordList());
      WordLadderGUI.showMessage(
          "Displaying "
              + wordLadder.getWordList().size()
              + " words from file with length of "
              + tfWordSize.getText(),
          Color.GREEN,
          Color.GREEN);
      System.out.println(
          "Displaying "
              + wordLadder.getWordList().size()
              + " words from file with length of "
              + tfWordSize.getText());
      taDictionary.setText(guiDictionary.toString());
      lblIndexing1.setText("Indexing... done.");
      lblDictCoun.setText("Words in Dictionary = " + wordLadder.getWordList().size() + " words");
      wordLadder.buildGraph();
      System.out.println("Graph Built");
      lblProgres.setText("Time to Build Graph: " + wordLadder.getTimeForGraph() + " milliseconds");
    }

    if (obj == btLoadTextFiel) {
      wordLadder.setWords_size(Integer.parseInt(tfWordSize.getText()));
      String taDump = taDictionary.getText();
      System.out.println("Loading Words from Text Area");
      lblIndexing1.setText("Indexing...");
      ArrayList<String> taList = new ArrayList<String>();
      StringTokenizer stringTokenizer = new StringTokenizer(taDump, "\t\n\r\f,\"");
      while (stringTokenizer.hasMoreTokens()) {
        String token = stringTokenizer.nextToken();
        taList.add(token);
      }
      guiDictionary = new WordCollection();
      guiDictionary.setWords(taList);
      wordLadder = new WordLadder(taList);
      WordLadderGUI.showMessage(
          "Loading " + wordLadder.getWordList().size() + " words from Text Field",
          Color.GREEN,
          Color.GREEN);
      lblIndexing1.setText("Indexing... done.");
      lblDictCoun.setText("Words in Dictionary = " + wordLadder.getWordList().size() + " words");
      wordLadder.buildGraph();
      System.out.println("Graph Built");
      lblProgres.setText("Time to Build Graph: " + wordLadder.getTimeForGraph() + " milliseconds");
    }
    if (obj == btClear) {
      testpanel.removeAll();
      testpanel.validate();
      testpanel.repaint();
      wordLadder = null;
      lblCos.setText("Cost of Path: 0.0");
      lblCos.repaint();
      lblDictCoun.setText("Words in Dictionary = 0 words");
      lblFindPat.setText("Time to find Path: 0 milliseconds");
      tfSourc.setText("");
      tfSourc_6.setText("");
      taDictionary.setText("");
      results = null;
      lblProgres.setText("Time to Build Graph: 0 milliseconds");
    }
  }
Exemplo n.º 26
0
  private boolean setValues_() {
    //   if(edge_ != Edge.defaults)
    //   {
    String points_string = pointsText_.getText();

    // Scan the points string.
    StringTokenizer tokenizer = new StringTokenizer(points_string, " \t\n\r,", false);
    int num_tokens = tokenizer.countTokens();
    a:
    if ((num_tokens % 3) != 0)
      new MessageDialog(frame_, "Error", "Expecting " + "sets of three numbers for points", true);
    else {
      int count = num_tokens / 3;
      DPoint3[] points = new DPoint3[count];

      for (int i = 0; i < count; i++) points[i] = new DPoint3();

      String token;
      int index = 0;
      double val;
      while (tokenizer.hasMoreTokens()) {
        for (int element = 0; element < 3; element++) {
          token = tokenizer.nextToken();
          try {
            val = new Double(token).doubleValue();
          } catch (Exception e) {
            char el = 'X';
            if (element == 1) el = 'Y';
            if (element == 2) el = 'Z';
            new MessageDialog(
                frame_,
                "Error",
                "Element " + el + " of point " + index + " is not" + " a number.",
                true);
            break a;
          }

          if (element == 0) points[index].x = val;
          else if (element == 1) points[index].y = val;
          else points[index].z = val;
        }
        index++;
      }

      dataHash_.put(currentData_, dataText_.getText());

      for (Enumeration keys = dataHash_.keys(); keys.hasMoreElements(); ) {
        String key = (String) keys.nextElement();
        String value = (String) dataHash_.get(key);
        if (value != null && value.length() != 0) edge_.data_.put(key, value);
      }

      // Replace the old edge.
      Edge edge = new Edge(edge_.tail(), edge_.head(), points, false);
      graph_.insertEdge(edge);
      edge.setLabel(labelText_.getText());
      edge.setLineStyle(style_.getSelectedIndex());
      edge.data_ = edge_.data_;

      return true;
    }
    //   }

    return false;
  }
  public patientAdd(String s) {
    super(s);
    image =
        new JLabel() {
          public void paint(Graphics g) {
            ImageIcon ic = new ImageIcon(str);
            Image img = ic.getImage();
            g.drawImage(img, 0, 0, 150, 150, this);
          }
        };

    image.setBounds(670, 270, 300, 300);
    bu = new JButton("UPLOAD");
    bu.setBounds(700, 230, 100, 20);
    bu.addActionListener(this);
    //	q.add(bu);

    ldt = new JLabel("Date");
    lpid = new JLabel("Patient ID");
    lpnm = new JLabel("Patient Name");
    lgen = new JLabel("Gender");
    lbg = new JLabel("Blood Group");
    lage = new JLabel("Age");
    lwt = new JLabel("Weight                                          Kg");
    ladd = new JLabel("Address");
    lcno = new JLabel("Cont. no.");
    ldnm = new JLabel("Doctor Name            Dr.");
    lsym = new JLabel("Symptoms");
    ldig = new JLabel("Diagnosis");
    lfee = new JLabel("Fee                            Rs.");
    cbg = new CheckboxGroup();
    cm = new Checkbox("Male", cbg, false);
    cm.addItemListener(this);
    cf = new Checkbox("Female", cbg, false);
    cf.setState(true);
    cf.addItemListener(this);
    tdt = new JTextField(15);
    tpid = new JTextField(6);
    tpid.addFocusListener(this);
    tpfnm = new JTextField("first");
    tpmnm = new JTextField("middle");
    tplnm = new JTextField("last");
    tage = new JTextField(4);
    tage.addFocusListener(this);
    tbg = new JTextField(6);
    twt = new JTextField(5);
    tadd = new TextArea(patient.addr);
    tcno = new JTextField(20);
    tdnm = new JTextField(20);
    tsym = new TextArea();

    tdig = new JTextField(20);
    tfee = new JTextField(6);
    tfee.addFocusListener(this);
    ba = new JButton("ADD");
    ba.addActionListener(this);
    bm = new JButton("CANCEL");
    bm.addActionListener(this);
    bd = new JButton("DELETE");
    bd.addActionListener(this);
    bl = new JButton("DISPLAY");
    bl.addActionListener(this);
    bs = new JButton("SEARCH");
    bs.addActionListener(this);
    JPanel p = new JPanel();
    p.add(ba);
    p.add(bm);
    //	p.add(bd);
    //	p.add(bl);
    //	p.add(bs);
    add(p, BorderLayout.SOUTH);
    q = new JPanel();
    q.setLayout(null);
    ldt.setBounds(1015, 20, 60, 20);
    q.add(ldt);
    tdt.setBounds(1060, 20, 170, 20);
    q.add(tdt);
    lpid.setBounds(70, 60, 80, 20);
    q.add(lpid);
    tpid.setBounds(200, 60, 60, 20);
    q.add(tpid);
    lpnm.setBounds(70, 100, 80, 20);
    q.add(lpnm);
    tpfnm.setBounds(200, 100, 100, 20);
    q.add(tpfnm);
    tpmnm.setBounds(320, 100, 100, 20);
    q.add(tpmnm);
    tplnm.setBounds(440, 100, 100, 20);
    q.add(tplnm);
    lgen.setBounds(70, 140, 60, 20);
    q.add(lgen);
    lbg.setBounds(370, 140, 80, 20);
    q.add(lbg);
    tbg.setBounds(470, 140, 60, 20);
    q.add(tbg);
    cm.setBounds(200, 140, 60, 20);
    cf.setBounds(280, 140, 60, 20);
    lage.setBounds(70, 180, 40, 20);
    q.add(lage);
    tage.setBounds(200, 180, 50, 20);
    q.add(tage);
    lwt.setBounds(370, 180, 200, 20);
    q.add(lwt);
    twt.setBounds(470, 180, 60, 20);
    q.add(twt);
    ladd.setBounds(70, 220, 60, 20);
    q.add(ladd);
    tadd.setBounds(200, 220, 350, 50);
    q.add(tadd);
    lcno.setBounds(70, 310, 60, 20);
    q.add(lcno);
    tcno.setBounds(200, 310, 120, 20);
    q.add(tcno);
    ldnm.setBounds(70, 350, 200, 20);
    q.add(ldnm);
    tdnm.setBounds(200, 350, 150, 20);
    q.add(tdnm);
    lsym.setBounds(70, 390, 100, 20);
    q.add(lsym);
    tsym.setBounds(200, 390, 300, 70);
    q.add(tsym);
    ldig.setBounds(70, 480, 60, 20);
    q.add(ldig);
    tdig.setBounds(200, 480, 100, 20);
    q.add(tdig);
    lfee.setBounds(70, 520, 200, 20);
    q.add(lfee);
    tfee.setBounds(200, 520, 40, 20);
    q.add(tfee);
    q.add(cm);
    q.add(cf);
    q.add(image);
    q.add(bu);
    add(q, BorderLayout.CENTER);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            try {
              patient.con.close();
              System.exit(0);
            } catch (Exception e8) {
            }
          }
        });
    System.out.println(tadd.getText());
    setSize(1330, 740);
    setVisible(true);
  }
Exemplo n.º 28
0
 public void windowDeactivated(WindowEvent evt) {
   if (selection != null && !selection.equals(textArea.getText())) {
     selection = textArea.getText();
     viewer.setCutText(selection);
   }
 }
Exemplo n.º 29
0
  public void actionPerformed(ActionEvent com) {
    String e = com.getActionCommand();
    if (e.equals("1")) {
      msg.append("1");
    }
    if (e.equals("2")) {
      msg.append("2");
    }
    if (e.equals("3")) {
      msg.append("3");
    }
    if (e.equals("4")) {
      msg.append("4");
    }
    if (e.equals("5")) {
      msg.append("5");
    }
    if (e.equals("6")) {
      msg.append("6");
    }
    if (e.equals("7")) {
      msg.append("7");
    }
    if (e.equals("8")) {
      msg.append("8");
    }
    if (e.equals("9")) {
      msg.append("9");
    }
    if (e.equals("0")) {
      msg.append("0");
    }
    // *********************OPERANDS**********************

    if (e.equals("*")) {
      pushsign = 2;
      String peeked = new String(OperandStack.peek());
      if (peeked == "*") {
        frac2 = Fraction(FracStack.pop());
        frac1 = FracStack.pop();
        frac3 = frac1.multiply(frac2);
        FracStack.push(frac3);
        FracStack.push(new Fraction(msg.getText()));
        OperandStack.push(peeked);
      }
      if (peeked == "/") {
        frac2 = new Fraction(FracStack.pop());
        frac1 = new Fraction(FracStack.pop());
        frac3 = frac1.multiply(frac2);
        FracStack.push(frac3);
        FracStack.push(new Fraction(msg.getText()));
        OperandStack.push(peeked);
      }
    }
    if (e.equals("/")) {}

    if (e.equals("+")) {}

    if (e.equals("-")) {}

    if (e.equals("=")) {}

    if (e.equals("Frac")) {
      msg.append("/");
    }
  }
  public void read() {
    try {
      // patient.dt=""+tdt.getText();
      patient.pid = Integer.parseInt(tpid.getText());
      patient.pfnm = tpfnm.getText();
      patient.pmnm = tpmnm.getText();
      patient.plnm = tplnm.getText();
      patient.gen = cbg.getSelectedCheckbox().getLabel();

      try {
        patient.age = Integer.parseInt(tage.getText());
        tage.setText("" + patient.age);

      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid age inputed.");
        patient.age = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid age:"));
        tage.setText("" + patient.age);
      }

      try {
        int wet = Integer.parseInt(twt.getText());
        twt.setText("" + wet);
      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid weight inputed.");
        int wet = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid weight:"));
        twt.setText("" + wet);
      }
      patient.wt = twt.getText();
      patient.addr = tadd.getText();
      this.ad = tadd.getText();
      System.out.println(tadd.getText());

      while (true) {
        patient.cno = tcno.getText();
        if (patient.cno.length() == 10) break;
        else {
          JOptionPane.showMessageDialog(null, "Invalid Phone No.");
          patient.cno = JOptionPane.showInputDialog("Please enter valid 10-digit Phone No.:");
          tcno.setText(patient.cno);
        }
      }
      patient.dnm = tdnm.getText();
      patient.sym = tsym.getText();
      System.out.println(tsym.getText());

      patient.dig = tdig.getText();
      try {
        patient.fee = Integer.parseInt(tfee.getText());
        tfee.setText("" + patient.fee);

      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Invalid Fee inputed.");
        patient.fee = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid Fee:"));
        tfee.setText("" + patient.fee);
      }

      patient.bg = tbg.getText();
      patient.path = str;
    } catch (Exception e) {
    }
  }