Example #1
1
 static {
   if (Configuration.isMacOS()) {
     System.setProperty("apple.laf.useScreenMenuBar", "true");
     System.setProperty("com.apple.mrj.application.apple.menu.about.name", APP_NAME);
     System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
   }
 }
 /** Cancel all active downloads. */
 public void cancelActiveDownloads() {
   for (Component c : this.monitorPanel.getComponents()) {
     if (c instanceof DownloadMonitorPanel) {
       if (((DownloadMonitorPanel) c).thread.isAlive()) {
         DownloadMonitorPanel panel = (DownloadMonitorPanel) c;
         panel.cancelButtonActionPerformed(null);
         try {
           // Wait for thread to die before moving on
           long t0 = System.currentTimeMillis();
           while (panel.thread.isAlive() && System.currentTimeMillis() - t0 < 500) {
             Thread.sleep(10);
           }
         } catch (Exception ignore) {
         }
       }
     }
   }
 }
Example #3
0
  protected static class AppFrame extends ApplicationTemplate.AppFrame {
    public AppFrame() {
      super(true, true, true);

      RenderableLayer layer = new RenderableLayer();
      layer.setName("Video on terrain");
      insertBeforePlacenames(this.getWwd(), layer);
      this.layerPanel.update(
          this.getWwd()); // makes the ApplicationTemplate layer list show the new layer

      // Set up a SelectListener to drag the SurfaceImage.
      this.getWwd().addSelectListener(new SurfaceImageDragger(this.getWwd()));

      final SurfaceImage surfaceImage = new SurfaceImage(makeImage(), CORNERS);
      surfaceImage.setOpacity(IMAGE_OPACITY);
      layer.addRenderable(surfaceImage);

      javax.swing.Timer timer =
          new javax.swing.Timer(
              50,
              new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                  Iterable<LatLon> corners = surfaceImage.getCorners();
                  surfaceImage.setImageSource(makeImage(), corners);
                  getWwd().redraw();
                }
              });
      timer.start();
    }

    protected long counter;
    protected long start = System.currentTimeMillis();

    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;
    }
  }
Example #4
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;
    }