예제 #1
2
  protected void runScript(String[] cmd, JTextArea txaMsg) {
    String strg = "";

    if (cmd == null) return;

    Process prcs = null;
    try {
      Messages.postDebug("Running script: " + cmd[2]);
      Runtime rt = Runtime.getRuntime();

      prcs = rt.exec(cmd);

      if (prcs == null) return;

      InputStream istrm = prcs.getInputStream();
      if (istrm == null) return;

      BufferedReader bfr = new BufferedReader(new InputStreamReader(istrm));

      while ((strg = bfr.readLine()) != null) {
        // System.out.println(strg);
        strg = strg.trim();
        // Messages.postDebug(strg);
        strg = strg.toLowerCase();
        if (txaMsg != null) {
          txaMsg.append(strg);
          txaMsg.append("\n");
        }
      }
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
      Messages.postDebug(e.toString());
    } finally {
      // It is my understanding that these streams are left
      // open sometimes depending on the garbage collector.
      // So, close them.
      try {
        if (prcs != null) {
          OutputStream os = prcs.getOutputStream();
          if (os != null) os.close();
          InputStream is = prcs.getInputStream();
          if (is != null) is.close();
          is = prcs.getErrorStream();
          if (is != null) is.close();
        }
      } catch (Exception ex) {
        Messages.writeStackTrace(ex);
      }
    }
  }
예제 #2
0
파일: GuiClient.java 프로젝트: x-mel/eva
 // we define the method for downloading when pressing on the download button
 public void downvidlink(String msg) {
   try {
     Runtime.getRuntime().exec("wget -c " + msg);
   } catch (Exception e) {
     System.out.println("Downloading with wget failed: " + e);
   }
 }
예제 #3
0
파일: GuiClient.java 프로젝트: x-mel/eva
 // we define the method for getting a streaming link when pressing on the stream button
 public void streamvidlink(String msg) {
   try {
     Runtime.getRuntime().exec("smplayer " + msg);
   } catch (Exception e) {
     System.out.println("Streaming with smplayer failed: " + e);
   }
 }
예제 #4
0
  public void view() {
    try {
      mk(
          new Dir().getdir()
              + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12");

      new FirstPageOfPaySlip().launch(emp, rav);

      new SecondPageOfPaySlip().launch(emp, rav);
    } catch (Exception ex) {
    }
    String cmd1 =
        "rundll32"
            + " "
            + "url.dll,FileProtocolHandler"
            + " "
            + new Dir().getdir()
            + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12/Salary_Slips.pdf";
    String cmd =
        "rundll32"
            + " "
            + "url.dll,FileProtocolHandler"
            + " "
            + new Dir().getdir()
            + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12/PLI1.pdf";
    try {
      Runtime.getRuntime().exec(cmd1);
    } catch (Exception ex) {
    }
  }
예제 #5
0
  public void merge() {
    try {
      mk(
          new Dir().getdir()
              + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12");
      new FirstPageOfPaySlip().launch(emp, rav);
      new SecondPageOfPaySlip().launch(emp, rav);
    } catch (Exception sd) {
    }
    try {
      new PDFMerger();
    } catch (Exception ex) {
    }

    String cmd1 =
        "rundll32"
            + " "
            + "url.dll,FileProtocolHandler"
            + " "
            + new Dir().getdir()
            + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12/Merged.pdf";
    try {
      Process pro = Runtime.getRuntime().exec(cmd1);
    } catch (Exception cdz) {
    }
  }
예제 #6
0
파일: WinSize.java 프로젝트: McNeight/GLsat
  void doExeCommand() {
    PSlider slider;
    Runtime program = Runtime.getRuntime();
    String currentCmd = new String();
    String X = new String();
    String Y = new String();

    // Kill the current executing program
    pid.destroy();

    // Setup the command parameters and run it
    slider = (PSlider) vSlider.elementAt(0);
    X = slider.getValue();
    slider = (PSlider) vSlider.elementAt(1);
    Y = slider.getValue();
    currentCmd = cmd + " " + X + " " + Y;

    try {
      pid = program.exec(currentCmd);
      if (isWindows == false) {
        Process pid2 = null;
        pid2 = program.exec("getpid WinSize");
      }
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      System.exit(-1);
    }

    // Update the new value in the source code of the program
    doSourceFileUpdate();
    scrollPane.getViewport().setViewPosition(new Point(0, 20));
  }
예제 #7
0
  @Override
  public void mousePressed(final MouseEvent e) {
    Performance.gc(3);
    repaint();

    final Runtime rt = Runtime.getRuntime();
    final long max = rt.maxMemory();
    final long total = rt.totalMemory();
    final long used = total - rt.freeMemory();

    final String inf =
        TOTAL_MEM_C
            + Performance.format(max, true)
            + NL
            + RESERVED_MEM_C
            + Performance.format(total, true)
            + NL
            + MEMUSED_C
            + Performance.format(used, true)
            + NL
            + NL
            + H_USED_MEM;

    BaseXDialog.info(gui, inf);
  }
예제 #8
0
파일: WinSize.java 프로젝트: McNeight/GLsat
 private void killUNIXProcess() {
   Runtime program = Runtime.getRuntime();
   try {
     pid = program.exec("trigger WinSize");
   } catch (IOException ie) {
     System.err.println("Error in killing process " + ie);
     System.exit(-1);
   }
 }
예제 #9
0
  void doExeCommand() {
    JViewport viewport = scrollPane.getViewport();
    String strContent = new String();
    PSlider slider;
    int i;
    File fp = new File(dataFile);

    RandomAccessFile access = null;
    Runtime program = Runtime.getRuntime();
    String cmdTrigger = "trigger";

    boolean delete = fp.delete();

    try {
      fp.createNewFile();
    } catch (IOException ie) {
      System.err.println("Couldn't create the new file " + ie);
      // System.exit(-1);;
    }

    try {
      access = new RandomAccessFile(fp, "rw");
    } catch (IOException ie) {
      System.err.println("Error in accessing the file " + ie);
      // System.exit(-1);;
    }

    for (i = 0; i < COMPONENTS; i++) {
      slider = (PSlider) vSlider.elementAt(i);
      /* Modified on March 20th to satisfy advisors' new request */
      if (slider.isString == true) strContent = strContent + slider.getRealStringValue() + " ";
      else strContent = strContent + slider.getValue() + " ";
    }

    // Get value of the radio button group
    if (firstBox.isSelected() == true) strContent = strContent + "1";
    else strContent = strContent + "0";

    try {
      access.writeBytes(strContent);
      access.close();
    } catch (IOException ie) {
      System.err.println("Error in writing to file " + ie);
      // System.exit(-1);;
    }
    // Trigger the OpenGL program to update with new values
    try {
      Process pid = program.exec(cmdTrigger);
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      // System.exit(-1);;
    }
    doSourceFileUpdate();
  }
예제 #10
0
파일: TMFrame.java 프로젝트: 52Jolynn/BSMS
 /** 帮助文档 */
 private void help() {
   Runtime rt = Runtime.getRuntime();
   try {
     logger.info("打开帮助文档. - " + TMFrame.class.getName());
     rt.exec("hh.exe help.chm");
     logger.info("打开帮助文档成功. - " + TMFrame.class.getName());
   } catch (IOException e) {
     logger.error("打开帮助文档失败! - " + TMFrame.class.getName());
     JOptionPane.showMessageDialog(this, "系统无法打开帮助文档,请联系开发人员。", "提示", JOptionPane.ERROR_MESSAGE);
   }
 }
예제 #11
0
  class RemindTask_send_update extends TimerTask {
    Runtime rxrunti = Runtime.getRuntime();

    public void
        run() { // ************************************************************************************

      krypton_update_token update = new krypton_update_token(tokenx_buffer);
      // krypton_net_client.send_unconfirmed_update(tokenx_buffer);
      krypton_database_load load = new krypton_database_load();
    } // runx***************************************************************************************************
  } // remindtask
예제 #12
0
 private void printCurrent() {
   if (tableModel instanceof TransportTableModel) {
     Transport o = (Transport) tableModel.getRowData(objectTable.getSelectedRow());
     String filename = TransportHelper.createHTMLFileFromTransport(o);
     try {
       Runtime runtime = Runtime.getRuntime();
       runtime.exec("explorer " + filename);
     } catch (IOException ioe) {
       System.out.println(ioe);
     }
   }
 }
예제 #13
0
파일: Installer.java 프로젝트: suever/CTP
 private boolean startLauncher(File dir) {
   try {
     Runtime rt = Runtime.getRuntime();
     ArrayList<String> command = new ArrayList<String>();
     command.add("java");
     command.add("-jar");
     command.add("Launcher.jar");
     String[] cmdarray = command.toArray(new String[command.size()]);
     Process proc = rt.exec(cmdarray, null, dir);
     return true;
   } catch (Exception ex) {
     System.err.println("Unable to start the Launcher program.\n" + ex.getMessage());
     return false;
   }
 }
예제 #14
0
 public static void openURL(final String url) {
   final Configuration.OperatingSystem os = Configuration.getCurrentOperatingSystem();
   try {
     if (os == Configuration.OperatingSystem.MAC) {
       final Class<?> fileMgr = Class.forName("com.apple.eio.FileManager");
       final Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] {String.class});
       openURL.invoke(null, url);
     } else if (os == Configuration.OperatingSystem.WINDOWS) {
       Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
     } else {
       final String[] browsers = {
         "firefox",
         "opera",
         "konqueror",
         "epiphany",
         "mozilla",
         "netscape",
         "google-chrome",
         "chromium-browser"
       };
       String browser = null;
       for (int count = 0; count < browsers.length && browser == null; count++) {
         if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0) {
           browser = browsers[count];
         }
       }
       if (browser == null) {
         throw new Exception("Could not find web browser");
       } else {
         Runtime.getRuntime().exec(new String[] {browser, url});
       }
     }
   } catch (final Exception e) {
     log.warning("Unable to open " + url);
   }
 }
예제 #15
0
  class RemindTask_restart extends TimerTask {
    Runtime rxrunti = Runtime.getRuntime();

    public void
        run() { // **************************************************************************************

      try {

        restartApplication();

      } catch (Exception e) {
        e.printStackTrace();
      }
    } // runx***************************************************************************************************
  } // remindtask
예제 #16
0
    protected BufferedImage makeImage() {
      BufferedImage image =
          new BufferedImage(IMAGE_SIZE, IMAGE_SIZE, BufferedImage.TYPE_4BYTE_ABGR);
      Graphics2D g = image.createGraphics();

      g.setPaint(Color.WHITE);
      g.fill3DRect(0, 0, IMAGE_SIZE, IMAGE_SIZE, false);

      g.setPaint(Color.RED);
      g.setFont(Font.decode("ARIAL-BOLD-50"));

      g.drawString(Long.toString(++this.counter) + " frames", 10, IMAGE_SIZE / 4);
      g.drawString(
          Long.toString((System.currentTimeMillis() - start) / 1000) + " sec", 10, IMAGE_SIZE / 2);
      g.drawString(
          "Heap:" + Long.toString(Runtime.getRuntime().totalMemory()), 10, 3 * IMAGE_SIZE / 4);

      g.dispose();

      return image;
    }
예제 #17
0
  @Override
  public void paintComponent(final Graphics g) {
    super.paintComponent(g);

    final Runtime rt = Runtime.getRuntime();
    final long max = rt.maxMemory();
    final long total = rt.totalMemory();
    final long used = total - rt.freeMemory();
    final int ww = getWidth();
    final int hh = getHeight();

    // draw memory box
    g.setColor(Color.white);
    g.fillRect(0, 0, ww - 3, hh - 3);
    g.setColor(GRAY);
    g.drawLine(0, 0, ww - 4, 0);
    g.drawLine(0, 0, 0, hh - 4);
    g.drawLine(ww - 3, 0, ww - 3, hh - 3);
    g.drawLine(0, hh - 3, ww - 3, hh - 3);

    // show total memory usage
    g.setColor(color1);
    g.fillRect(2, 2, Math.max(1, (int) (total * (ww - 6) / max)), hh - 6);

    // show current memory usage
    final boolean full = used * 6 / 5 > max;
    g.setColor(full ? colormark4 : color3);
    g.fillRect(2, 2, Math.max(1, (int) (used * (ww - 6) / max)), hh - 6);

    // print current memory usage
    final FontMetrics fm = g.getFontMetrics();
    final String mem = Performance.format(used, true);
    final int fw = (ww - fm.stringWidth(mem)) / 2;
    final int h = fm.getHeight() - 3;
    g.setColor(full ? colormark3 : DGRAY);
    g.drawString(mem, fw, h);
  }
예제 #18
0
  void rootdraw(GLState.Applier state, UI ui, BGL gl) {
    GLState.Buffer ibuf = new GLState.Buffer(state.cfg);
    gstate.prep(ibuf);
    ostate.prep(ibuf);
    GOut g = new GOut(gl, state.cgl, state.cfg, state, ibuf, new Coord(w, h));
    state.set(ibuf);

    g.state(ostate);
    g.apply();
    gl.glClearColor(0, 0, 0, 1);
    gl.glClear(GL.GL_COLOR_BUFFER_BIT);
    synchronized (ui) {
      ui.draw(g);
    }

    if (Config.dbtext) {
      int y = h - 150;
      FastText.aprintf(
          g,
          new Coord(10, y -= 15),
          0,
          1,
          "FPS: %d (%d%%, %d%% idle)",
          fps,
          (int) (uidle * 100.0),
          (int) (ridle * 100.0));
      Runtime rt = Runtime.getRuntime();
      long free = rt.freeMemory(), total = rt.totalMemory();
      FastText.aprintf(
          g,
          new Coord(10, y -= 15),
          0,
          1,
          "Mem: %,011d/%,011d/%,011d/%,011d",
          free,
          total - free,
          total,
          rt.maxMemory());
      FastText.aprintf(g, new Coord(10, y -= 15), 0, 1, "Tex-current: %d", TexGL.num());
      FastText.aprintf(g, new Coord(10, y -= 15), 0, 1, "GL progs: %d", g.st.numprogs());
      GameUI gi = ui.root.findchild(GameUI.class);
      if ((gi != null) && (gi.map != null)) {
        try {
          FastText.aprintf(
              g, new Coord(10, y -= 15), 0, 1, "MV pos: %s (%s)", gi.map.getcc(), gi.map.camera);
        } catch (Loading e) {
        }
        if (gi.map.rls != null)
          FastText.aprintf(
              g,
              new Coord(10, y -= 15),
              0,
              1,
              "Rendered: %,d+%,d(%,d)",
              gi.map.rls.drawn,
              gi.map.rls.instanced,
              gi.map.rls.instancified);
      }
      if (Resource.remote().qdepth() > 0)
        FastText.aprintf(
            g,
            new Coord(10, y -= 15),
            0,
            1,
            "RQ depth: %d (%d)",
            Resource.remote().qdepth(),
            Resource.remote().numloaded());
    }
    Object tooltip;
    try {
      synchronized (ui) {
        tooltip = ui.root.tooltip(mousepos, ui.root);
      }
    } catch (Loading e) {
      tooltip = "...";
    }
    Tex tt = null;
    if (tooltip != null) {
      if (tooltip instanceof Text) {
        tt = ((Text) tooltip).tex();
      } else if (tooltip instanceof Tex) {
        tt = (Tex) tooltip;
      } else if (tooltip instanceof Indir<?>) {
        Indir<?> t = (Indir<?>) tooltip;
        Object o = t.get();
        if (o instanceof Tex) tt = (Tex) o;
      } else if (tooltip instanceof String) {
        if (((String) tooltip).length() > 0) tt = (Text.render((String) tooltip)).tex();
      }
    }
    if (tt != null) {
      Coord sz = tt.sz();
      Coord pos = mousepos.add(sz.inv());
      if (pos.x < 0) pos.x = 0;
      if (pos.y < 0) pos.y = 0;
      g.chcolor(244, 247, 21, 192);
      g.rect(pos.add(-3, -3), sz.add(6, 6));
      g.chcolor(35, 35, 35, 192);
      g.frect(pos.add(-2, -2), sz.add(4, 4));
      g.chcolor();
      g.image(tt, pos);
    }
    ui.lasttip = tooltip;
    Resource curs = ui.root.getcurs(mousepos);
    if (curs != null) {
      if (cursmode == "awt") {
        if (curs != lastcursor) {
          try {
            setCursor(makeawtcurs(curs.layer(Resource.imgc).img, curs.layer(Resource.negc).cc));
            lastcursor = curs;
          } catch (Exception e) {
            cursmode = "tex";
          }
        }
      } else if (cursmode == "tex") {
        Coord dc = mousepos.add(curs.layer(Resource.negc).cc.inv());
        g.image(curs.layer(Resource.imgc), dc);
      }
    }
    state.clean();
    GLObject.disposeall(state.cgl, gl);
  }
예제 #19
0
  public JComponent buildCommon() {
    String colSpec = FormLayoutUtil.getColSpec(COMMON_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, COMMON_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    maxbuffer = new JTextField("" + configuration.getMaxMemoryBufferSize());
    maxbuffer.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(maxbuffer.getText());
              configuration.setMaxMemoryBufferSize(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse max memory buffer size from \"" + maxbuffer.getText() + "\"");
            }
          }
        });

    JComponent cmp =
        builder.addSeparator(
            Messages.getString("NetworkTab.5"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("NetworkTab.6")
            .replaceAll("MAX_BUFFER_SIZE", configuration.getMaxMemoryBufferSizeStr()),
        FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation));
    builder.add(maxbuffer, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    String nCpusLabel =
        String.format(
            Messages.getString("NetworkTab.7"), Runtime.getRuntime().availableProcessors());
    builder.addLabel(nCpusLabel, FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation));

    String[] guiCores = new String[MAX_CORES];
    for (int i = 0; i < MAX_CORES; i++) {
      guiCores[i] = Integer.toString(i + 1);
    }
    nbcores = new JComboBox(guiCores);
    nbcores.setEditable(false);
    int nbConfCores = configuration.getNumberOfCpuCores();
    if (nbConfCores > 0 && nbConfCores <= MAX_CORES) {
      nbcores.setSelectedItem(Integer.toString(nbConfCores));
    } else {
      nbcores.setSelectedIndex(0);
    }

    nbcores.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setNumberOfCpuCores(Integer.parseInt(e.getItem().toString()));
          }
        });
    builder.add(nbcores, FormLayoutUtil.flip(cc.xy(3, 5), colSpec, orientation));

    chapter_interval = new JTextField("" + configuration.getChapterInterval());
    chapter_interval.setEnabled(configuration.isChapterSupport());
    chapter_interval.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(chapter_interval.getText());
              configuration.setChapterInterval(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse chapter interval from \"" + chapter_interval.getText() + "\"");
            }
          }
        });

    chapter_support = new JCheckBox(Messages.getString("TrTab2.52"));
    chapter_support.setContentAreaFilled(false);
    chapter_support.setSelected(configuration.isChapterSupport());

    chapter_support.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setChapterSupport((e.getStateChange() == ItemEvent.SELECTED));
            chapter_interval.setEnabled(configuration.isChapterSupport());
          }
        });

    builder.add(chapter_support, FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation));

    builder.add(chapter_interval, FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.3"),
            FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    channels =
        new JComboBox(
            new Object[] {
              Messages.getString("TrTab2.55"),
              Messages.getString("TrTab2.56") /*, "8 channels 7.1" */
            }); // 7.1 not supported by Mplayer :\
    channels.setEditable(false);
    if (configuration.getAudioChannelCount() == 2) {
      channels.setSelectedIndex(0);
    } else {
      channels.setSelectedIndex(1);
    }
    channels.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setAudioChannelCount(
                Integer.parseInt(e.getItem().toString().substring(0, 1)));
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.50"), FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));
    builder.add(channels, FormLayoutUtil.flip(cc.xy(3, 13), colSpec, orientation));

    forcePCM = new JCheckBox(Messages.getString("TrTab2.27"));
    forcePCM.setContentAreaFilled(false);
    if (configuration.isMencoderUsePcm()) {
      forcePCM.setSelected(true);
    }
    forcePCM.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderUsePcm(e.getStateChange() == ItemEvent.SELECTED);
          }
        });

    builder.add(forcePCM, FormLayoutUtil.flip(cc.xyw(1, 15, 3), colSpec, orientation));

    ac3remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.32")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    ac3remux.setContentAreaFilled(false);
    if (configuration.isRemuxAC3()) {
      ac3remux.setSelected(true);
    }
    ac3remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setRemuxAC3((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(ac3remux, FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation));

    forceDTSinPCM =
        new JCheckBox(
            Messages.getString("TrTab2.28")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    forceDTSinPCM.setContentAreaFilled(false);
    if (configuration.isDTSEmbedInPCM()) {
      forceDTSinPCM.setSelected(true);
    }
    forceDTSinPCM.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            configuration.setDTSEmbedInPCM(forceDTSinPCM.isSelected());
            if (configuration.isDTSEmbedInPCM()) {
              JOptionPane.showMessageDialog(
                  (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                  Messages.getString("TrTab2.10"),
                  "Information",
                  JOptionPane.INFORMATION_MESSAGE);
            }
          }
        });

    builder.add(forceDTSinPCM, FormLayoutUtil.flip(cc.xyw(1, 19, 3), colSpec, orientation));

    abitrate = new JTextField("" + configuration.getAudioBitrate());
    abitrate.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(abitrate.getText());
              configuration.setAudioBitrate(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug("Could not parse audio bitrate from \"" + abitrate.getText() + "\"");
            }
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.29"), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation));
    builder.add(abitrate, FormLayoutUtil.flip(cc.xy(3, 21), colSpec, orientation));

    mpeg2remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.39")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    mpeg2remux.setContentAreaFilled(false);
    if (configuration.isMencoderRemuxMPEG2()) {
      mpeg2remux.setSelected(true);
    }
    mpeg2remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderRemuxMPEG2((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(mpeg2remux, FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.4"),
            FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("TrTab2.32"),
        FormLayoutUtil.flip(cc.xyw(1, 29, 3), colSpec, orientation));

    Object data[] =
        new Object[] {
          configuration.getMencoderMainSettings(), /* default */
          String.format(
              "keyint=5:vqscale=1:vqmin=2  /* %s */", Messages.getString("TrTab2.60")), /* great */
          String.format(
              "keyint=5:vqscale=1:vqmin=1  /* %s */",
              Messages.getString("TrTab2.61")), /* lossless */
          String.format(
              "keyint=5:vqscale=2:vqmin=3  /* %s */",
              Messages.getString("TrTab2.62")), /* good (wired) */
          String.format(
              "keyint=25:vqmax=5:vqmin=2  /* %s */",
              Messages.getString("TrTab2.63")), /* good (wireless) */
          String.format(
              "keyint=25:vqmax=7:vqmin=2  /* %s */",
              Messages.getString("TrTab2.64")), /* medium (wireless) */
          String.format(
              "keyint=25:vqmax=8:vqmin=3  /* %s */", Messages.getString("TrTab2.65")) /* low */
        };

    MyComboBoxModel cbm = new MyComboBoxModel(data);

    vq = new JComboBox(cbm);
    vq.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String s = (String) e.getItem();
              if (s.indexOf("/*") > -1) {
                s = s.substring(0, s.indexOf("/*")).trim();
              }
              configuration.setMencoderMainSettings(s);
            }
          }
        });
    vq.getEditor()
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              @Override
              public void keyPressed(KeyEvent e) {}

              @Override
              public void keyTyped(KeyEvent e) {}

              @Override
              public void keyReleased(KeyEvent e) {
                vq.getItemListeners()[0].itemStateChanged(
                    new ItemEvent(vq, 0, vq.getEditor().getItem(), ItemEvent.SELECTED));
              }
            });
    vq.setEditable(true);
    builder.add(vq, FormLayoutUtil.flip(cc.xyw(1, 31, 3), colSpec, orientation));

    String help1 = Messages.getString("TrTab2.39");
    help1 += Messages.getString("TrTab2.40");
    help1 += Messages.getString("TrTab2.41");
    help1 += Messages.getString("TrTab2.42");
    help1 += Messages.getString("TrTab2.43");
    help1 += Messages.getString("TrTab2.44");

    JTextArea decodeTips = new JTextArea(help1);
    decodeTips.setEditable(false);
    decodeTips.setBorder(BorderFactory.createEtchedBorder());
    decodeTips.setBackground(new Color(255, 255, 192));
    builder.add(decodeTips, FormLayoutUtil.flip(cc.xyw(1, 41, 3), colSpec, orientation));

    disableSubs = new JCheckBox(Messages.getString("TrTab2.51"));
    disableSubs.setContentAreaFilled(false);

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.7"),
            FormLayoutUtil.flip(cc.xyw(1, 33, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.add(disableSubs, FormLayoutUtil.flip(cc.xy(1, 35), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.8"), FormLayoutUtil.flip(cc.xy(1, 37), colSpec, orientation));

    notranscode = new JTextField(configuration.getNoTranscode());
    notranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setNoTranscode(notranscode.getText());
          }
        });
    builder.add(notranscode, FormLayoutUtil.flip(cc.xy(3, 37), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.9"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation));

    forcetranscode = new JTextField(configuration.getForceTranscode());
    forcetranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setForceTranscode(forcetranscode.getText());
          }
        });
    builder.add(forcetranscode, FormLayoutUtil.flip(cc.xy(3, 39), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
  }
예제 #20
0
  // create a new profile: read the script and possibly execute the queries,
  // save the stats (if 'import' == true, we assume the profile already exists
  // and don't run the queries)
  public void createWkld(String name, String scriptFile, boolean runQueries) {
    System.gc();
    Workload wkld = new Workload(name);

    if (showCmdsItem.getState()) {
      consoleFrame.echoCmd((!runQueries ? "importprof " : "newwkld ") + name + " " + scriptFile);
    }

    // construct the Workload object from the script;
    // first, check if the file exists
    try {
      FileReader reader = new FileReader(scriptFile);
      reader.close();
    } catch (FileNotFoundException e) {
      System.out.println("couldn't open " + scriptFile);
      return;
    } catch (IOException e) {
      System.out.println("couldn't close " + scriptFile);
    }

    // now, check if it contains only queries
    int scriptId = 0;
    try {
      scriptId = Libgist.openScript(scriptFile);
    } catch (LibgistException e) {
      System.out.println("couldn't open (C) " + scriptFile);
      return;
    }
    char[] arg1 = new char[64 * 1024];
    StringBuffer arg1Buf = new StringBuffer();
    char[] arg2 = new char[64 * 1024];
    StringBuffer arg2Buf = new StringBuffer();
    // for (;;) {
    // int cmd = Libgist.getCommand(scriptId, arg1, arg2);
    // if (cmd == Libgist.EOF) break;
    // if (cmd != Libgist.FETCH) {
    // there should only be queries
    // System.out.println("Script file contains non-SELECT command");
    // return;
    // }
    // }

    if (runQueries) {
      // turn profiling on and execute queries
      // Libgist.setProfilingEnabled(true);
      Libgist.disableBps(true); // we don't want to stop at breakpoints

      // rescan queries
      try {
        scriptId = Libgist.openScript(scriptFile);
      } catch (LibgistException e) {
        System.out.println("couldn't open (C) " + scriptFile);
        return;
      }
      int cnt = 1;
      // for (;;) {
      // int cmd = Libgist.getCommand(scriptId, arg1, arg2);
      // if (cmd == Libgist.EOF) break;
      // arg1Buf.setLength(0);
      // arg1Buf.append(arg1, 0, strlen(arg1));
      // arg2Buf.setLength(0);
      // arg2Buf.append(arg2, 0, strlen(arg2));
      // OpThread.execCmd(LibgistCommand.FETCH, arg1Buf.toString(),
      // arg2Buf.toString(), false);
      // System.out.print(cnt + " ");
      // System.out.println(cnt + ": execute " + arg2Buf.toString() + " "
      // + arg1Buf.toString());
      // cnt++;
      // }
      System.out.println();

      Libgist.disableBps(false);
      // compute optimal clustering and some more statistics
      // Libgist.computeMetrics(wkld.filename);
    }

    // save profile
    try {
      // we're saving Java and C++ data in separate files (filename and filename.prof)
      // the profile object only contains the filename, the queries will be
      // read in from the file when the profile is opened (faster that way)
      ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(wkld.filename));
      out.writeObject(wkld);
      out.close();
      System.out.println("copy query file");
      Runtime.getRuntime().exec("cp " + scriptFile + " " + wkld.filename + ".queries");
      System.out.println("saving tree and profile");
      Libgist.saveToFile(wkld.filename + ".idx");
      if (runQueries) {
        // Libgist.saveProfile(wkld.filename + ".prof");
      }
    } catch (Exception e) {
      System.out.println("Error saving profile: " + e);
      return;
    }

    if (runQueries) {
      // turn profiling off (after the metrics were computed and
      // the profile saved)
      // Libgist.setProfilingEnabled(false);
    }
  }
예제 #21
0
  // Run selected test cases.
  private void runTests() {

    for (int i = 0; i < tests.size(); i++) {
      // If box for test is checked, run it.
      if (tests.get(i).isSelected()) {

        // Get the URLs of all of the required files.
        String folderURL = tests.get(i).getText();
        String testURL = folderURL.concat(folderURL.substring(folderURL.lastIndexOf('/')));
        String efgFile = testURL + ".EFG";
        String guiFile = testURL + ".GUI";
        String tstFile = testURL + ".TST";
        String prgFile = testURL + ".PRG";

        // attempt to read in file with program's parameters
        try {
          FileInputStream fstream = new FileInputStream(prgFile);
          DataInputStream in = new DataInputStream(fstream);
          BufferedReader br = new BufferedReader(new InputStreamReader(in));
          HashMap<String, String> prgParams = new HashMap<String, String>();
          String strLine;
          while ((strLine = br.readLine()) != null) {
            // add found parameters into prgParams as <key, value>
            String[] matches = strLine.split("=");
            prgParams.put(matches[0], matches[1]);
          }

          if (prgParams.containsKey("path") && prgParams.containsKey("main")) {
            programPath = prgParams.get("path");
            mainClass = prgParams.get("main");
          }

          in.close();
        } catch (Exception e) {
          System.err.println(e.getMessage());
        }

        System.out.println("We hit Run");

        // Run the replayer using the three test files.
        System.out.println(
            "../../../dist/guitar/jfc-replayer.sh -cp "
                + programPath
                + " -c "
                + mainClass
                + " -g "
                + guiFile
                + " -e "
                + efgFile
                + " -t "
                + tstFile);
        try {
          Runtime rt = Runtime.getRuntime();
          Process proc =
              rt.exec(
                  "../../../dist/guitar/jfc-replayer.sh -cp "
                      + programPath
                      + " -c "
                      + mainClass
                      + " -g "
                      + guiFile
                      + " -e "
                      + efgFile
                      + " -t "
                      + tstFile);

          // InputStream ips = proc.getInputStream();
          BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
          String inputLine;
          while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
          in.close();

        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
예제 #22
0
  public OrderTrans2() {
    super(windowTitle);
    int i;
    int currentPanel; // Value to specify which is the current panel in the vector
    JPanel subPanel = new JPanel(); // value used when adding sliders to the frame
    Runtime program = Runtime.getRuntime();
    Container content = getContentPane();

    createSliderVector();
    createPanelVector();
    getCodeSwapString();
    /** Set code-swap strings' value. */

    /** Get current OS of the system. */
    if (System.getProperty("os.name").startsWith("Windows")) isWindows = true;
    else isWindows = false;

    /** Add the radio buttons to the group */
    radioGrp.add(firstBox);
    radioGrp.add(secondBox);
    /** Set interactive buttons for the user interface */
    JButton exeButton = new JButton("Execute");
    exeButton.setToolTipText("Re-execute the program");
    JButton resetButton = new JButton("Reset");
    resetButton.setToolTipText("Reset Value");
    JButton exitButton = new JButton("Exit");
    exitButton.setToolTipText("Exit the Program");

    // Create the main panel that contains everything.
    JPanel mainPanel = new JPanel();
    // Create the panel that contains the sliders
    JPanel subPanel1 = new JPanel();
    // Create the panel that contains the checkboxes
    JPanel subPanel2 = new JPanel();
    // Create the panel that contains the buttons
    JPanel subPanel3 = new JPanel();

    // JScrollPane scrollPane = new JScrollPane(); // main text pane with scroll bars
    content.add(mainPanel, BorderLayout.SOUTH);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    content.add(scrollPane, BorderLayout.CENTER);
    scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
    scrollPane.getViewport().add(textPane);

    mainPanel.add(subPanel1);
    mainPanel.add(subPanel2);
    mainPanel.add(subPanel3);
    subPanel1.setLayout(new GridLayout(0, 1));
    /** Add subPanel elements to the subPanel1, each would be a row of sliders */
    for (i = 0; i < ROWS; i++) subPanel1.add((JPanel) vSubPanel.elementAt(i));
    /** Set the first element in the Panel Vector as the current subPanel. */
    currentPanel = 0;
    subPanel = (JPanel) vSubPanel.elementAt(currentPanel);
    /** Allocate sliders to the sub-panels. */
    for (i = 0; i < COMPONENTS; i++) {
      PSlider slider = (PSlider) vSlider.elementAt(i);
      if (slider.getResideValue() == 'n') {
        currentPanel += 1;
        subPanel = (JPanel) vSubPanel.elementAt(currentPanel);
      }
      subPanel.add((PSlider) vSlider.elementAt(i));
    }

    /** Set and view the source code on the frame */
    textPane.setEditable(false);
    textPane.setContentType("text/html; charset=EUC-JP");

    subPanel2.setLayout(new GridLayout(0, 2));
    subPanel2.add(firstBox);
    subPanel2.add(secondBox);
    subPanel3.setLayout(new GridLayout(0, 3));
    subPanel3.add(exeButton);
    exeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doExeCommand();
          }
        });
    subPanel3.add(resetButton);
    resetButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doResetCommand();
          }
        });
    subPanel3.add(exitButton);
    exitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doExitCommand();
          }
        });

    /** Run the illustrated program */
    try {
      pid = program.exec(cmd);
      if (isWindows == false) {
        Process pid2 = null;
        pid2 = program.exec("getpid " + cmd.substring(4));
      }
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      // System.exit(-1);;
    }
    /** Set the initial status for the window */
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            File fp = new File(dataFile);
            doResetCommand();
            boolean delete = fp.delete();
            pid.destroy();
          }
        });

    doExeCommand();
    setSize(WIDTH, HEIGHT);
    setLocation(500, 0);
    setVisible(true);
  }
예제 #23
0
  Client(String[] args) {
    //
    // Initialize an Ice communicator.
    //
    try {
      com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData();
      initData.properties = com.zeroc.Ice.Util.createProperties();
      initData.properties.load("config.client");
      initData.dispatcher =
          (runnable, connection) -> {
            SwingUtilities.invokeLater(runnable);
          };
      _communicator = com.zeroc.Ice.Util.initialize(args, initData).communicator;
    } catch (Throwable ex) {
      handleException(ex);
    }

    Container cp = this;

    JLabel l1 = new JLabel("Hostname");
    _hostname = new JTextField();
    JLabel l2 = new JLabel("Mode");
    _mode = new JComboBox<String>();
    JLabel l3 = new JLabel("Timeout");
    _timeoutSlider = new JSlider(0, MAX_TIME);
    _timeoutLabel = new JLabel("0.0");
    JLabel l4 = new JLabel("Delay");
    _delaySlider = new JSlider(0, MAX_TIME);
    _delayLabel = new JLabel("0.0");
    JPanel buttonPanel = new JPanel();
    _hello = new JButton("Hello World!");
    _shutdown = new JButton("Shutdown");
    _flush = new JButton("Flush");
    _flush.setEnabled(false);
    JSeparator statusPanelSeparator = new JSeparator();
    _status = new JLabel();
    _status.setText("Ready");

    //
    // Default to localhost.
    //
    _hostname.setText("127.0.0.1");
    _hostname
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void changedUpdate(DocumentEvent e) {
                updateProxy();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                if (e.getDocument().getLength() > 0) {
                  _hello.setEnabled(true);
                  _shutdown.setEnabled(true);
                }
                updateProxy();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                if (e.getDocument().getLength() == 0) {
                  _hello.setEnabled(false);
                  _shutdown.setEnabled(false);
                  _flush.setEnabled(false);
                }
                updateProxy();
              }
            });

    _mode.setModel(new DefaultComboBoxModel<String>(DELIVERY_MODE_DESC));

    _hello.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            sayHello();
          }
        });
    _shutdown.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            shutdown();
          }
        });
    _flush.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            flush();
          }
        });
    _mode.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            changeDeliveryMode(_mode.getSelectedIndex());
          }
        });
    changeDeliveryMode(_mode.getSelectedIndex());

    _timeoutSlider.addChangeListener(new SliderListener(_timeoutSlider, _timeoutLabel));
    _timeoutSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent ce) {
            updateProxy();
          }
        });
    _timeoutSlider.setValue(0);
    _delaySlider.addChangeListener(new SliderListener(_delaySlider, _delayLabel));
    _delaySlider.setValue(0);

    GridBagConstraints gridBagConstraints;

    cp.setMaximumSize(null);
    cp.setPreferredSize(null);
    cp.setLayout(new GridBagLayout());

    l1.setText("Hostname");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(5, 5, 5, 5);
    cp.add(l1, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(5, 0, 5, 5);
    cp.add(_hostname, gridBagConstraints);

    l2.setText("Mode");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l2, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 0, 5, 5);
    cp.add(_mode, gridBagConstraints);

    l3.setText("Timeout");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l3, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    cp.add(_timeoutSlider, gridBagConstraints);

    _timeoutLabel.setMinimumSize(new Dimension(20, 17));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_timeoutLabel, gridBagConstraints);

    l4.setText("Delay");
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 0);
    cp.add(l4, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    cp.add(_delaySlider, gridBagConstraints);

    _delayLabel.setMinimumSize(new Dimension(20, 17));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_delayLabel, gridBagConstraints);

    _hello.setText("Hello World!");
    buttonPanel.add(_hello);

    _shutdown.setText("Shutdown");
    buttonPanel.add(_shutdown);

    _flush.setText("Flush");
    buttonPanel.add(_flush);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.ipady = 5;
    cp.add(buttonPanel, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(statusPanelSeparator, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new Insets(0, 5, 5, 5);
    cp.add(_status, gridBagConstraints);

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    _shutdownHook =
        new Thread("Shutdown hook") {
          @Override
          public void run() {
            destroyCommunicator();
          }
        };

    try {
      Runtime.getRuntime().addShutdownHook(_shutdownHook);
    } catch (IllegalStateException e) {
      //
      // Shutdown in progress, ignored
      //
    }

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            destroyCommunicator();
            Runtime.getRuntime().removeShutdownHook(_shutdownHook);
            dispose();
            Runtime.getRuntime().exit(0);
          }
        });

    setTitle("Ice - Hello World!");
    pack();
    locateOnScreen(this);
    setVisible(true);
  }
예제 #24
0
  class RemindTask_server extends TimerTask {
    Runtime rxrunti = Runtime.getRuntime();

    public void
        run() { // ************************************************************************************

      String jsonText2 = new String("");

      JSONObject obj_out = new JSONObject();

      ServerSocket welcomeSocket;

      while (true) {

        try { // *********************************************************

          welcomeSocket = new ServerSocket(network.api_port, 0, InetAddress.getByName("localhost"));
          Socket connectionSocket = welcomeSocket.accept();
          BufferedReader inFromClient =
              new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
          DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());
          clientSentence = inFromClient.readLine();

          JSONParser parser = new JSONParser();

          try { // *********************************************************

            statex = "0";
            responsex = "e00";
            jsonText = "";

            if (!clientSentence.contains("")) {
              throw new EmptyStackException();
            }
            Object obj = parser.parse(clientSentence);

            jsonObject = (JSONObject) obj;

            String request = (String) jsonObject.get("request");

            String item_id = new String("");
            String item_array = new String("");
            String old_key = new String("");
            String node = new String("");
            try {
              item_id = (String) jsonObject.get("item_id").toString();
            } catch (Exception e) {
              System.out.println("extra info no item_id...");
            }
            try {
              item_array = (String) jsonObject.get("item_array").toString();
            } catch (Exception e) {
              System.out.println("extra info no item_array...");
            }
            try {
              old_key = (String) jsonObject.get("key").toString();
            } catch (Exception e) {
              System.out.println("extra info no key...");
            }
            try {
              node = (String) jsonObject.get("node").toString();
            } catch (Exception e) {
              System.out.println("extra info no node...");
            }

            while (network.database_in_use == 1 && !request.equals("status")) {

              System.out.println("Database in use...");
              try {
                Thread.sleep(1000);
              } catch (InterruptedException e) {
              }
            } // **************************************************************

            if (request.equals("status")) {
              statex = "1";
              responsex = get_status();
            } // ***************************
            else if (request.equals("get_version")) {
              statex = "1";
              responsex = network.versionx;
            } //
            else if (request.equals("get_tor_active")) {
              statex = "1";
              responsex = Integer.toString(network.tor_active);
            } //
            else if (request.equals("get_last_block")) {
              statex = "1";
              responsex = network.last_block_id;
            } //
            else if (request.equals("get_last_block_timestamp")) {
              statex = "1";
              responsex = network.last_block_timestamp;
            } //
            else if (request.equals("get_last_block_hash")) {
              statex = "1";
              responsex = network.last_block_idx;
            } //
            else if (request.equals("get_difficulty")) {
              statex = "1";
              responsex = Long.toString(network.difficultyx);
            } //
            else if (request.equals("get_last_mining_id")) {
              statex = "1";
              responsex = network.last_block_mining_idx;
            } //
            else if (request.equals("get_prev_mining_id")) {
              statex = "1";
              responsex = network.prev_block_mining_idx;
            } //
            else if (request.equals("get_last_unconfirmed_id")) {
              statex = "1";
              responsex = get_item_ids();
            } //
            else if (request.equals("get_my_token_total")) {
              statex = "1";
              responsex = Integer.toString(network.database_listings_owner);
            } //
            else if (request.equals("get_my_id_list")) {
              statex = "1";
              responsex = get_item_ids();
            } //
            else if (request.equals("get_my_ids_limit")) {
              statex = "1";
              responsex = get_item_ids();
            } //
            else if (request.equals("get_token")) {
              statex = "1";
              responsex = get_item_array(item_id);
            } //
            else if (request.equals("get_settings")) {
              statex = "1";
              responsex = get_settings_array();
            } //
            else if (request.equals("get_mining_info")) {
              statex = "1";
              responsex = get_item_array(item_id);
            } //
            else if (request.equals("get_new_keys")) {
              statex = "1";
              responsex = build_keysx();
            } //
            else if (request.equals("delete_node")) {
              statex = "1";
              responsex = delete_node(node);
            } //
            else if (request.equals("delete_all_nodes")) {
              statex = "1";
              responsex = delete_all_nodes();
            } //
            else if (request.equals("set_new_node")) {
              statex = "1";
              responsex = set_new_node(node);
            } //
            else if (request.equals("set_old_key")) {
              statex = "1";
              responsex = set_old_key(old_key);
            } //
            else if (request.equals("set_new_block")) {
              statex = "1";
              responsex = set_new_block(item_array);
            } //
            else if (request.equals("set_edit_block")) {
              statex = "1";
              update_state = "set_edit_block";
              responsex = update_token(item_array);
            } //
            else if (request.equals("set_transfer_block")) {
              statex = "1";
              update_state = "set_transfer_block";
              responsex = update_token(item_array);
            } //
            else if (request.equals("system_restart")) {
              statex = "1";
              responsex = "restarting";
              toolkit = Toolkit.getDefaultToolkit();
              xtimerx = new Timer();
              xtimerx.schedule(new RemindTask_restart(), 0);
            } //
            else if (request.equals("system_exit")) {
              statex = "1";
              System.exit(0);
            } //
            else {
              statex = "0";
              responsex = "e01 UnknownRequestException";
            }

          } // try
          catch (ParseException e) {
            e.printStackTrace();
            statex = "0";
            responsex = "e02 ParseException";
          } catch (Exception e) {
            e.printStackTrace();
            statex = "0";
            responsex = "e03 Exception";
          }

          JSONObject obj = new JSONObject();
          obj.put("response", statex);
          try {
            obj.put("message", responsex);
          } catch (Exception e) {
            e.printStackTrace();
          }

          StringWriter outs = new StringWriter();
          obj.writeJSONString(outs);
          jsonText = outs.toString();
          System.out.println("SEND RESPONSE " + responsex);

          outToClient.writeBytes(jsonText + '\n');
          welcomeSocket.close();

        } catch (Exception e) {
          e.printStackTrace();
          System.out.println("Server ERROR x3");
        }
      } // **********while
    } // runx***************************************************************************************************
  } // remindtask
 private void doLaunch() throws IOException {
   // kicks off the launch after confirm and check if not null, two possibilities. Select Folder
   // sets flag and does folder. All others just makes a list.
   int reply =
       JOptionPane.showConfirmDialog(
           null, "Are you sure you want to launch?", "Launch?", JOptionPane.YES_NO_OPTION);
   if (reply == JOptionPane.YES_OPTION) {
     int numRow = table.getRowCount();
     if (numRow < 1) {
       JOptionPane.showMessageDialog(frame, "You need to select tests to launch.");
       return;
     }
     if (selFoFl == 0) {
       try (BufferedWriter bw =
           new BufferedWriter(
               new FileWriter(
                   "C:\\Projects\\testSeleniumFramework\\framework\\runSelectedTests.bat"))) {
         if (numRow < 2) {
           pullS = table.getValueAt(0, 0).toString();
         }
         if (numRow > 1) {
           for (int i = 0; i < numRow; i++) {
             Object o = table.getValueAt(i, 0);
             pullS += ",";
             pullS += o.toString();
           }
         }
         if (pullS.contains("null,")) {
           pullS = pullS.substring(5);
         }
         if (pullS.startsWith(",")) {
           pullS = pullS.substring(1);
         }
         // String lineC ="";
         if (flagF == 1) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + pullS
                   + "\"";
         }
         if (flagF == 2) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + pullS
                   + " Y\"";
         }
         if (flagF == 3) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + pullS
                   + " ONLYFAIL\"";
         }
         bw.write(
             "Echo \"Launching tests..."
                 + "\r\ncd C:\\Projects\\testSeleniumFramework\r\n"
                 + lineC
                 + "\r\n");
       }
       pullS = "";
       Process p =
           Runtime.getRuntime()
               .exec(
                   "cmd /c start C:\\Projects\\testSeleniumFramework\\framework\\runSelectedTests.bat");
     }
     if (selFoFl == 1) {
       try (BufferedWriter bw =
           new BufferedWriter(
               new FileWriter(
                   "C:\\Projects\\testSeleniumFramework\\framework\\runSelectedTests.bat"))) {
         // String lineC = "";
         if (flagF == 1) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + dtm.getValueAt(0, 1).toString()
                   + "\\\"";
         }
         if (flagF == 2) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + dtm.getValueAt(0, 1).toString()
                   + "\\ Y\"";
         }
         if (flagF == 3) {
           lineC =
               "mvn clean test exec:java -Dconcordion.output.dir=\""
                   + placeS
                   + "\" -Dexec.args=\""
                   + dtm.getValueAt(0, 1).toString()
                   + "\\ ONLYFAIL\"";
         }
         bw.write(
             "Echo \"Launching tests..."
                 + "\r\ncd C:\\Projects\\testSeleniumFramework\r\n"
                 + lineC
                 + "\r\n");
       }
       pullS = "";
       Process p =
           Runtime.getRuntime()
               .exec(
                   "cmd /c start C:\\Projects\\testSeleniumFramework\\framework\\runSelectedTests.bat");
     }
   } else {
   }
 }
    public void init(GLAutoDrawable glAutoDrawable) {
      StringBuilder sb = new StringBuilder();

      sb.append(gov.nasa.worldwind.Version.getVersion() + "\n");

      sb.append("\nSystem Properties\n");
      sb.append("Processors: " + Runtime.getRuntime().availableProcessors() + "\n");
      sb.append("Free memory: " + Runtime.getRuntime().freeMemory() + " bytes\n");
      sb.append("Max memory: " + Runtime.getRuntime().maxMemory() + " bytes\n");
      sb.append("Total memory: " + Runtime.getRuntime().totalMemory() + " bytes\n");

      for (Map.Entry prop : System.getProperties().entrySet()) {
        sb.append(prop.getKey() + " = " + prop.getValue() + "\n");
      }

      GL gl = glAutoDrawable.getGL();

      sb.append("\nOpenGL Values\n");

      String oglVersion = gl.glGetString(GL.GL_VERSION);
      sb.append("OpenGL version: " + oglVersion + "\n");

      String oglVendor = gl.glGetString(GL.GL_VENDOR);
      sb.append("OpenGL vendor: " + oglVendor + "\n");

      String oglRenderer = gl.glGetString(GL.GL_RENDERER);
      sb.append("OpenGL renderer: " + oglRenderer + "\n");

      int[] intVals = new int[2];
      for (Attr attr : attrs) {
        sb.append(attr.name).append(": ");

        if (attr.attr instanceof Integer) {
          gl.glGetIntegerv((Integer) attr.attr, intVals, 0);
          sb.append(intVals[0]).append(intVals[1] > 0 ? ", " + intVals[1] : "");
        }

        sb.append("\n");
      }

      String extensionString = gl.glGetString(GL.GL_EXTENSIONS);
      String[] extensions = extensionString.split(" ");
      sb.append("Extensions\n");
      for (String ext : extensions) {
        sb.append("    " + ext + "\n");
      }

      sb.append("\nJOGL Values\n");
      String pkgName = "javax.media.opengl";
      try {
        getClass().getClassLoader().loadClass(pkgName + ".GL");

        Package p = Package.getPackage(pkgName);
        if (p == null) {
          sb.append("WARNING: Package.getPackage(" + pkgName + ") is null\n");
        } else {
          sb.append(p + "\n");
          sb.append("Specification Title = " + p.getSpecificationTitle() + "\n");
          sb.append("Specification Vendor = " + p.getSpecificationVendor() + "\n");
          sb.append("Specification Version = " + p.getSpecificationVersion() + "\n");
          sb.append("Implementation Vendor = " + p.getImplementationVendor() + "\n");
          sb.append("Implementation Version = " + p.getImplementationVersion() + "\n");
        }
      } catch (ClassNotFoundException e) {
        sb.append("Unable to load " + pkgName + "\n");
      }

      this.outputArea.setText(sb.toString());
    }
예제 #27
0
  public void RedoPortraits(int screen) {
    // PortraitObjects = new LinkedList();
    if (screen == -1) {
      ScreenNum = 0;
      screen = 0;
      TotalPortrait = CalculateValidPortraits();
    }

    int CurrentNum = 0;
    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    PortraitsWindow.removeAll();
    PortraitsWindow.repaint();
    String filenames[] = (new File(directory)).list(new ImageFilter());
    String sexstr = "";
    int sex = ((Integer) menucreate.MainCharData[0].get(new Integer(0))).intValue();
    int race = Integer.parseInt(menucreate.MainCharDataAux[1][0]);
    int numbif = 0;

    for (int p = 0; p < portraitmap.length; p++) {
      String basepicfilename = portraitmap[p][1];
      if (basepicfilename != null && portraitmap[p][2] != null && portraitmap[p][3] != null) {
        basepicfilename = basepicfilename.toLowerCase();
        if (!basepicfilename.startsWith("plc")
            && !basepicfilename.equalsIgnoreCase("door01_")
            && (Integer.parseInt(portraitmap[p][2]) == sex && sexlock || !sexlock)
            && (Integer.parseInt(portraitmap[p][3]) == race && racelock || !racelock)
            && CheckPortrait(directory, "po_" + basepicfilename)) {
          String picFilename = "po_" + basepicfilename + "m.tga";
          CurrentNum++;
          if ((CurrentNum <= (50 * (screen + 1))) && (CurrentNum > (50 * screen))) {
            try {
              File tempImage = RESFAC.TempImageFile(picFilename);
              if (tempImage != null) {
                Portrait port =
                    new Portrait(
                        tempImage.getParent() + FileDelim,
                        tempImage.getName(),
                        true,
                        basepicfilename);
                port.getComponent(0).setSize(64, 100);
                PortraitsWindow.add(port, -1);
                numbif++;
              }
            } catch (IOException err) {
              JOptionPane.showMessageDialog(
                  null,
                  "Error reading " + picFilename + ". Out of Memory. Error: " + err,
                  "Error",
                  0);
              System.exit(0);
            }
          }
        }
      }
    }

    for (int i = 0; i < filenames.length; ++i) {
      ++CurrentNum;
      if ((CurrentNum <= (50 * (screen + 1))) && (CurrentNum > (50 * screen))) {
        Portrait port = new Portrait(directory, filenames[i], false, "");
        port.getComponent(0).setSize(64, 100);
        PortraitsWindow.add(port, -1);
      }
    }

    FirstButton.setEnabled(screen != 0);
    BackButton.setEnabled(screen != 0);
    LastButton.setEnabled(screen < (ScreenCount - 1));
    ForwardButton.setEnabled(screen < (ScreenCount - 1));

    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    menucreate.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    Runtime r = Runtime.getRuntime();
    r.gc();
  }
예제 #28
0
  public BoxOnTable() {
    super(windowTitle);
    int i;

    Runtime program = Runtime.getRuntime();
    Container content = getContentPane();

    /** Get current OS of the system. */
    if (System.getProperty("os.name").startsWith("Windows")) isWindows = true;
    else isWindows = false;
    /** Set interactive buttons for the user interface */
    JButton exitButton = new JButton("Exit");
    exitButton.setToolTipText("Exit the Program");

    JPanel mainPanel = new JPanel();

    content.add(mainPanel, BorderLayout.SOUTH);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    content.add(scrollPane, BorderLayout.CENTER);
    scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
    scrollPane.getViewport().add(textPane);

    mainPanel.add(exitButton, BorderLayout.CENTER);

    /** Set and view the source code on the frame */
    textPane.setEditable(false);
    textPane.setContentType("text/html; charset=EUC-JP");
    try {
      URL url = new URL("file:" + exampleSource);
      textPane.setPage(url);
    } catch (IOException ie) {
      System.err.println("Error in opening html source file " + ie);
      System.exit(-1);
    }

    exitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doExitCommand();
          }
        });

    /** Run the illustrated program */
    try {
      pid = program.exec(cmd);
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      System.exit(-1);
    }
    /** Set the initial status for the window */
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            pid.destroy();
          }
        });
    setSize(WIDTH, HEIGHT);
    setLocation(500, 0);
    setVisible(true);
  }
예제 #29
0
  public class Surface extends JPanel implements Runnable {

    public Thread thread;
    public long sleepAmount = 1000;
    private int w, h;
    private BufferedImage bimg;
    private Graphics2D big;
    private Font font = new Font("Times New Roman", Font.PLAIN, 11);
    private Runtime r = Runtime.getRuntime();
    private int columnInc;
    private int pts[];
    private int ptNum;
    private int ascent, descent;
    private float freeMemory, totalMemory;
    private Rectangle graphOutlineRect = new Rectangle();
    private Rectangle2D mfRect = new Rectangle2D.Float();
    private Rectangle2D muRect = new Rectangle2D.Float();
    private Line2D graphLine = new Line2D.Float();
    private Color graphColor = new Color(46, 139, 87);
    private Color mfColor = new Color(0, 100, 0);
    private String usedStr;

    public Surface() {
      setBackground(BLACK);
      addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              if (thread == null) start();
              else stop();
            }
          });
    }

    public Dimension getMinimumSize() {
      return getPreferredSize();
    }

    public Dimension getMaximumSize() {
      return getPreferredSize();
    }

    public Dimension getPreferredSize() {
      return new Dimension(135, 80);
    }

    public void paint(Graphics g) {

      if (big == null) {
        return;
      }

      big.setBackground(getBackground());
      big.clearRect(0, 0, w, h);

      float freeMemory = (float) r.freeMemory();
      float totalMemory = (float) r.totalMemory();

      // .. Draw allocated and used strings ..
      big.setColor(GREEN);
      big.drawString(
          String.valueOf((int) totalMemory / 1024) + "K allocated", 4.0f, (float) ascent + 0.5f);
      usedStr = String.valueOf(((int) (totalMemory - freeMemory)) / 1024) + "K used";
      big.drawString(usedStr, 4, h - descent);

      // Calculate remaining size
      float ssH = ascent + descent;
      float remainingHeight = (float) (h - (ssH * 2) - 0.5f);
      float blockHeight = remainingHeight / 10;
      float blockWidth = 20.0f;
      float remainingWidth = (float) (w - blockWidth - 10);

      // .. Memory Free ..
      big.setColor(mfColor);
      int MemUsage = (int) ((freeMemory / totalMemory) * 10);
      int i = 0;
      for (; i < MemUsage; i++) {
        mfRect.setRect(5, (float) ssH + i * blockHeight, blockWidth, (float) blockHeight - 1);
        big.fill(mfRect);
      }

      // .. Memory Used ..
      big.setColor(GREEN);
      for (; i < 10; i++) {
        muRect.setRect(5, (float) ssH + i * blockHeight, blockWidth, (float) blockHeight - 1);
        big.fill(muRect);
      }

      // .. Draw History Graph ..
      big.setColor(graphColor);
      int graphX = 30;
      int graphY = (int) ssH;
      int graphW = w - graphX - 5;
      int graphH = (int) remainingHeight;
      graphOutlineRect.setRect(graphX, graphY, graphW, graphH);
      big.draw(graphOutlineRect);

      int graphRow = graphH / 10;

      // .. Draw row ..
      for (int j = graphY; j <= graphH + graphY; j += graphRow) {
        graphLine.setLine(graphX, j, graphX + graphW, j);
        big.draw(graphLine);
      }

      // .. Draw animated column movement ..
      int graphColumn = graphW / 15;

      if (columnInc == 0) {
        columnInc = graphColumn;
      }

      for (int j = graphX + columnInc; j < graphW + graphX; j += graphColumn) {
        graphLine.setLine(j, graphY, j, graphY + graphH);
        big.draw(graphLine);
      }

      --columnInc;

      if (pts == null) {
        pts = new int[graphW];
        ptNum = 0;
      } else if (pts.length != graphW) {
        int tmp[] = null;
        if (ptNum < graphW) {
          tmp = new int[ptNum];
          System.arraycopy(pts, 0, tmp, 0, tmp.length);
        } else {
          tmp = new int[graphW];
          System.arraycopy(pts, pts.length - tmp.length, tmp, 0, tmp.length);
          ptNum = tmp.length - 2;
        }
        pts = new int[graphW];
        System.arraycopy(tmp, 0, pts, 0, tmp.length);
      } else {
        big.setColor(YELLOW);
        pts[ptNum] = (int) (graphY + graphH * (freeMemory / totalMemory));
        for (int j = graphX + graphW - ptNum, k = 0; k < ptNum; k++, j++) {
          if (k != 0) {
            if (pts[k] != pts[k - 1]) {
              big.drawLine(j - 1, pts[k - 1], j, pts[k]);
            } else {
              big.fillRect(j, pts[k], 1, 1);
            }
          }
        }
        if (ptNum + 2 == pts.length) {
          // throw out oldest point
          for (int j = 1; j < ptNum; j++) {
            pts[j - 1] = pts[j];
          }
          --ptNum;
        } else {
          ptNum++;
        }
      }
      g.drawImage(bimg, 0, 0, this);
    }

    public void start() {
      thread = new Thread(this);
      thread.setPriority(Thread.MIN_PRIORITY);
      thread.setName("MemoryMonitor");
      thread.start();
    }

    public synchronized void stop() {
      thread = null;
      notify();
    }

    public void run() {

      Thread me = Thread.currentThread();

      while (thread == me && !isShowing() || getSize().width == 0) {
        try {
          thread.sleep(500);
        } catch (InterruptedException e) {
          return;
        }
      }

      while (thread == me && isShowing()) {
        Dimension d = getSize();
        if (d.width != w || d.height != h) {
          w = d.width;
          h = d.height;
          bimg = (BufferedImage) createImage(w, h);
          big = bimg.createGraphics();
          big.setFont(font);
          FontMetrics fm = big.getFontMetrics(font);
          ascent = (int) fm.getAscent();
          descent = (int) fm.getDescent();
        }
        repaint();
        try {
          thread.sleep(sleepAmount);
        } catch (InterruptedException e) {
          break;
        }
        if (MemoryMonitor.dateStampCB.isSelected()) {
          System.out.println(new Date().toString() + " " + usedStr);
        }
      }
      thread = null;
    }
  }