public static void main(java.lang.String[] args) {
   String className = null;
   try {
     System.err.println("logging is done using log4j.");
     final ICQMessagingTest_Applet applet = new ICQMessagingTest_Applet();
     className = cfg.REQPARAM_MESSAGING_NETWORK_IMPL_CLASS_NAME.trim();
     CAT.info("Instantiating class \"" + className + "\"...");
     try {
       applet.plugin = (MessagingNetwork) Class.forName(className).newInstance();
       applet.plugin.init();
     } catch (Throwable tr) {
       CAT.error("ex in main", tr);
       System.exit(1);
     }
     java.awt.Frame frame = new java.awt.Frame("MessagingTest");
     frame.addWindowListener(
         new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
             applet.quit();
           }
         });
     frame.add("Center", applet);
     frame.setSize(800, 650);
     frame.setLocation(150, 100);
     applet.init();
     frame.show();
     frame.invalidate();
     frame.validate();
     applet.start();
   } catch (Throwable tr) {
     CAT.error("exception", tr);
     System.exit(1);
   }
 }
Esempio n. 2
0
  /** Save the double array as a sound file (using .wav or .au format). */
  public static void save(String filename, double[] input) {
    // assumes 44,100 samples per second
    // use 16-bit audio, mono, signed PCM, little Endian
    AudioFormat format = new AudioFormat(SAMPLE_RATE, 16, 1, true, false);
    byte[] data = new byte[2 * input.length];
    for (int i = 0; i < input.length; i++) {
      int temp = (short) (input[i] * MAX_16_BIT);
      data[2 * i + 0] = (byte) temp;
      data[2 * i + 1] = (byte) (temp >> 8);
    }

    // now save the file
    try {
      ByteArrayInputStream bais = new ByteArrayInputStream(data);
      AudioInputStream ais = new AudioInputStream(bais, format, input.length);
      if (filename.endsWith(".wav") || filename.endsWith(".WAV")) {
        AudioSystem.write(ais, AudioFileFormat.Type.WAVE, new File(filename));
      } else if (filename.endsWith(".au") || filename.endsWith(".AU")) {
        AudioSystem.write(ais, AudioFileFormat.Type.AU, new File(filename));
      } else {
        throw new RuntimeException("File format not supported: " + filename);
      }
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
    }
  }
Esempio n. 3
0
  // open up an audio stream
  private static void init() {
    try {
      // 44,100 samples per second, 16-bit audio, mono, signed PCM, little
      // Endian
      AudioFormat format = new AudioFormat((float) SAMPLE_RATE, BITS_PER_SAMPLE, 1, true, false);
      DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);

      line = (SourceDataLine) AudioSystem.getLine(info);
      line.open(format, SAMPLE_BUFFER_SIZE * BYTES_PER_SAMPLE);

      // the internal buffer is a fraction of the actual buffer size, this
      // choice is arbitrary
      // it gets divided because we can't expect the buffered data to line
      // up exactly with when
      // the sound card decides to push out its samples.
      buffer = new byte[SAMPLE_BUFFER_SIZE * BYTES_PER_SAMPLE / 3];
      listeners = new HashSet<AudioEventListener>();
    } catch (Exception e) {
      System.err.println("Error initializing StdAudio audio system:");
      e.printStackTrace();
      System.exit(1);
    }

    // no sound gets made before this call
    line.start();
  }
  public void init() {
    try {
      // data init
      loginId.setText("" + cfg.REQPARAM_SRC_LOGIN_ID);
      password.setText("" + cfg.REQPARAM_SRC_PASSWORD);

      // ui init
      setLayout(new GridLayout(2, 1));
      Panel inputArea = new Panel(new BorderLayout(2, 2));
      inputArea.add(contactList, "Center");
      Panel bottomR = new Panel(new FlowLayout(FlowLayout.RIGHT));
      bottomR.add(loginBtn);
      bottomR.add(logoutBtn);
      bottomR.add(closeBtn);
      Panel bottomL = new Panel(new FlowLayout());
      bottomL.add(new Label("status:"));
      bottomL.add(clientStatus);
      bottomL.add(new Label("  contact:"));
      bottomL.add(contactListEntry);
      bottomL.add(addToContactList);
      bottomL.add(removeFromContactList);
      bottomL.add(getUserDetailsButton());
      bottomL.add(getSendContactsButton());
      Panel bottom = new Panel(new BorderLayout());
      bottom.add("Center", bottomR);
      bottom.add("West", bottomL);
      inputArea.add(bottom, "South");
      Panel leftTop = new Panel(new GridLayout(10, 1));
      leftTop.add(new Label("login id:")); // 1
      leftTop.add(loginId); // 2
      leftTop.add(new Label("password:"******""));
      leftTop.add(new Label("")); // 6

      leftTop.add(new Label("send msg"));
      leftTop.add(sendMsg); // 8
      leftTop.add(new Label("to"));
      leftTop.add(dstLoginId); // 10

      Panel left = new Panel(new FlowLayout());
      left.add(leftTop);
      inputArea.add(left, "West");
      Panel eventLogPanel = new Panel(new BorderLayout());
      eventLogPanel.add("Center", eventLog);
      Panel eventLogPanelButtons = new Panel(new FlowLayout(FlowLayout.RIGHT));
      eventLogPanelButtons.add(clearEventLogBtn);
      eventLogPanel.add("South", eventLogPanelButtons);
      add(inputArea);
      add(eventLogPanel);
      setBackground(SystemColor.control);
      doLayout();
      sendMsg.requestFocus();
    } catch (Throwable tr) {
      CAT.error("exception", tr);
      System.exit(1);
    }
  }
Esempio n. 5
0
    public void run() {
      CdhrString cret;

      System.out.println("JopSpiderCmd start");

      while (true) {
        cret = qcom.getString(qcom_qix, qcom_nid);
        //      System.out.println("awake : " + cret.getSts());
        if (cret.oddSts()) {
          int idx;
          System.out.println("Command received :" + cret.str);

          Cli cli = new Cli(cliTable);
          String command = cli.parse(cret.str);
          if (cli.oddSts()) {

            if (command.equals("OPEN")) {

              if (cli.qualifierFound("cli_arg1")) {

                String jgraph = "JGRAPH";
                String cli_arg1 = cli.getQualValue("cli_arg1").toUpperCase();
                if (jgraph.length() >= cli_arg1.length()
                    && jgraph.substring(0, cli_arg1.length()).equals(cli_arg1)) {
                  // Command is "OPEN JGRAPH"

                  boolean newFrame = cli.qualifierFound("/NEW");
                  boolean scrollbar = cli.qualifierFound("/SCROLLBAR");

                  if (!cli.qualifierFound("cli_arg2")) {
                    System.out.println("Syntax error");
                    return;
                  }
                  String frameName = cli.getQualValue("cli_arg2");

                  System.out.println("Loading frame \"" + frameName + "\"");
                  try {
                    loadFrame(session, frameName, null, scrollbar);
                  } catch (ClassNotFoundException e) {
                  }
                }
              }
            } else if (command.equals("EXIT")) {
              System.out.println("Jop exiting");
              System.exit(0);
            }
          }
        }
        try {
          sleep(1000);
        } catch (InterruptedException e) {
        }
      }
    }
  public void run() {
    while (Thread.currentThread() == animator) {
      line.setX1(line.getX1() + line.getX1Run() * line.getX1Dir());
      line.setY1(line.getY1() + line.getY1Rise() * line.getY1Dir());
      line.setX2(line.getX2() + line.getX2Run() * line.getX2Dir());
      line.setY2(line.getY2() + line.getY2Rise() * line.getY2Dir());

      if (line.getX1() < 0) {
        line.setX1(0);
        line.switchX1Dir();
      } // end if
      else if (line.getX1() > this.getWidth()) {
        line.setX1(this.getWidth());
        line.switchX1Dir();
      } // end else if

      if (line.getY1() < 0) {
        line.setY1(0);
        line.switchY1Dir();
      } // end if
      else if (line.getY1() > this.getHeight()) {
        line.setY1(this.getHeight());
        line.switchY1Dir();
      } // end else if

      if (line.getX2() < 0) {
        line.setX2(0);
        line.switchX2Dir();
      } // end if
      else if (line.getX2() > this.getWidth()) {
        line.setX2(this.getWidth());
        line.switchX2Dir();
      } // end else if

      if (line.getY2() < 0) {
        line.setY2(0);
        line.switchY2Dir();
      } // end if
      else if (line.getY2() > this.getHeight()) {
        line.setY2(this.getHeight());
        line.switchY2Dir();
      } // end else if
    }

    repaint();

    try {
      Thread.sleep(delay); // have the thread sleep for "delay" milliseconds
    } // end try
    catch (InterruptedException e) {
      System.exit(-1);
    } // end catch
  } // end run method
  /**
   * Method declaration
   *
   * @param ev
   */
  public void windowClosing(WindowEvent ev) {

    try {
      cConn.close();
    } catch (Exception e) {
    }

    fMain.dispose();

    if (bMustExit) {
      System.exit(0);
    }
  }
Esempio n. 8
0
  /** Test client - play an A major scale to standard audio. */
  public static void main(String[] args) {
    // 440 Hz for 1 sec
    double freq = 440.0;
    for (int i = 0; i <= StdAudio.SAMPLE_RATE; i++) {
      StdAudio.play(0.5 * Math.sin(2 * Math.PI * freq * i / StdAudio.SAMPLE_RATE));
    }

    // scale increments
    int[] steps = {0, 2, 4, 5, 7, 9, 11, 12};
    for (int i = 0; i < steps.length; i++) {
      double hz = 440.0 * Math.pow(2, steps[i] / 12.0);
      StdAudio.play(note(hz, 1.0, 0.5));
    }

    // need to call this in non-interactive stuff so the program doesn't
    // terminate
    // until all the sound leaves the speaker.
    StdAudio.close();

    // need to terminate a Java program with sound
    System.exit(0);
  }
 public void quit() {
   System.exit(0);
 }
Esempio n. 10
0
 /** Exit the Application */
 private void exitForm(java.awt.event.WindowEvent evt) { // GEN-FIRST:event_exitForm
   System.exit(0);
 } // GEN-LAST:event_exitForm
Esempio n. 11
0
 public void windowClosing(WindowEvent e) {
   System.exit(0);
 }