/** Returns DebugGraphicsInfo, or creates one if none exists. */
 static DebugGraphicsInfo info() {
   DebugGraphicsInfo debugGraphicsInfo =
       (DebugGraphicsInfo) SwingUtilities.appContextGet(debugGraphicsInfoKey);
   if (debugGraphicsInfo == null) {
     debugGraphicsInfo = new DebugGraphicsInfo();
     SwingUtilities.appContextPut(debugGraphicsInfoKey, debugGraphicsInfo);
   }
   return debugGraphicsInfo;
 }
Exemple #2
0
 /** ***************** Main to run the game ****************** */
 public static void main(String[] args) {
   // Use EDT, was running into exceptions before so I added this
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           new TicTac();
         }
       });
 }
  public void generarFondo(Component componente) {
    boolean dibujarFondo = false;
    Rectangle med = this.getBounds();
    Rectangle areaDibujo = this.getBounds();
    BufferedImage tmp;
    GraphicsConfiguration gc =
        GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getDefaultScreenDevice()
            .getDefaultConfiguration();

    if (Principal.fondoBlur) {
      dibujarFondo = true;
    }
    if (dibujarFondo) {
      JRootPane root = SwingUtilities.getRootPane(this);
      blurBuffer = GraphicsUtilities.createCompatibleImage(Principal.sysAncho, Principal.sysAlto);
      Graphics2D g2 = blurBuffer.createGraphics();
      g2.setClip(med);
      blurBuffer = blurBuffer.getSubimage(med.x, med.y, med.width, med.height);
      ((Escritorio) Principal.getEscritorio()).getFrameEscritorio().paint(g2);
      g2.dispose();
      backBuffer = blurBuffer;
      // blurBuffer = toGrayScale(blurBuffer);
      blurBuffer = GraphicsUtilities.createThumbnailFast(blurBuffer, getWidth() / 2);
      blurBuffer = new GaussianBlurFilter(4).filter(blurBuffer, null);
      g2 = (Graphics2D) blurBuffer.getGraphics();
      g2.setColor(new Color(0, 0, 0, 195));
      g2.fillRect(0, 0, Principal.sysAncho, Principal.sysAlto);
      listo = true;
    }
  }
Exemple #4
0
 /**
  * Gets the value of the <code>defaultButton</code> property, which if <code>true</code> means
  * that this button is the current default button for its <code>JRootPane</code>. Most look and
  * feels render the default button differently, and may potentially provide bindings to access the
  * default button.
  *
  * @return the value of the <code>defaultButton</code> property
  * @see JRootPane#setDefaultButton
  * @see #isDefaultCapable
  * @beaninfo description: Whether or not this button is the default button
  */
 public boolean isDefaultButton() {
   JRootPane root = SwingUtilities.getRootPane(this);
   if (root != null) {
     return root.getDefaultButton() == this;
   }
   return false;
 }
Exemple #5
0
 /**
  * Overrides <code>JComponent.removeNotify</code> to check if this button is currently set as the
  * default button on the <code>RootPane</code>, and if so, sets the <code>RootPane</code>'s
  * default button to <code>null</code> to ensure the <code>RootPane</code> doesn't hold onto an
  * invalid button reference.
  */
 public void removeNotify() {
   JRootPane root = SwingUtilities.getRootPane(this);
   if (root != null && root.getDefaultButton() == this) {
     root.setDefaultButton(null);
   }
   super.removeNotify();
 }
Exemple #6
0
  public static void main(String[] args) {
    try {
      // non-throwing message printer
      Kdu_sysout_message sysout = new Kdu_sysout_message(false);
      // exception-throwing message printer
      Kdu_sysout_message syserr = new Kdu_sysout_message(true);
      // non-throwing formatted printer
      Kdu_message_formatter formattedSysout = new Kdu_message_formatter(sysout);
      // throwing formatted printer
      Kdu_message_formatter formattedSyserr = new Kdu_message_formatter(syserr);

      Kdu_global.Kdu_customize_warnings(formattedSysout);
      Kdu_global.Kdu_customize_errors(formattedSyserr);
    } catch (KduException e) {
      System.err.printf("Exception during Kdu stream tie: %s\n", e.getMessage());
    }

    if (args.length != 1) {
      System.err.println("You must supply a filename (JP2, JPX or raw code-stream)");
      System.exit(0);
    }

    final String filename = args[0];

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            Haikdu app = new Haikdu(filename);
          }
        });
  }
Exemple #7
0
  public static void main(String[] args) {
    //      args = new String[]{"nothing=junk"};
    RSF par = new RSF(args);
    // RSFFrame sf = new RSFFrame();
    //
    //
    //
    //

    ArrayList<String> cubes = new ArrayList<String>();
    ArrayList<String> points = new ArrayList<String>();
    ArrayList<String> lines = new ArrayList<String>();
    for (String arg : args) {
      if (arg.contains("cube")) {
        String cube = par.getString(arg.split("=")[0], "");
        System.err.printf("Found cube: %s\n", cube);
        cubes.add(cube);
      } else if (arg.contains("point")) {
        String point = par.getString(arg.split("=")[0], "");
        System.err.printf("Found point: %s\n", point);
        points.add(point);
      } else if (arg.contains("line")) {
        String line = par.getString(arg.split("=")[0], "");
        System.err.printf("Found line: %s\n", line);
        lines.add(line);
      }
    }

    final String[] cubeNames = new String[cubes.size()];
    for (int i = 0; i < cubes.size(); ++i) {
      cubeNames[i] = cubes.get(i);
    }

    final String[] lineNames = new String[lines.size()];
    for (int i = 0; i < lines.size(); ++i) {
      lineNames[i] = lines.get(i);
    }
    final String[] pointNames = new String[points.size()];
    for (int i = 0; i < points.size(); ++i) {
      pointNames[i] = points.get(i);
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            RSFFrame frame = new RSFFrame();
            for (String name : cubeNames) {
              frame.addRSFCube(name);
            }
            for (String name : lineNames) {
              frame.addRSFLine(name);
            }
            for (String name : pointNames) {
              frame.addRSFPoint(name);
            }
          }
        });
  }
 /*
  *  Create a BufferedImage for AWT components.
  *
  *  @param	 component AWT component to create image from
  *  @param	 fileName name of file to be created or null
  *  @return	image the image for the given region
  *  @exception AWTException see Robot class constructors
  *  @exception IOException if an error occurs during writing
  */
 public static BufferedImage createImage(Component component, String fileName)
     throws AWTException, IOException {
   Point p = new Point(0, 0);
   SwingUtilities.convertPointToScreen(p, component);
   Rectangle region = component.getBounds();
   region.x = p.x;
   region.y = p.y;
   return ScreenCapture.createImage(region, fileName);
 }
 void rotationFinished() {
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           animationPanel = null;
           listener.animationFinished();
           listener = null;
         }
       });
 }
Exemple #10
0
 public void propertyChange(PropertyChangeEvent evt) {
   if (DisplayOptions.isUpdateUIEvent(evt)) {
     SwingUtilities.updateComponentTreeUI(this);
     gradientPanel.remove(drawable);
     JPanel newpanel = createGradientPanel();
     contentPane.remove(gradientPanel);
     gradientPanel = newpanel;
     gradientPanel.add(drawable, BorderLayout.CENTER);
     contentPane.add(gradientPanel, BorderLayout.CENTER);
   }
 }
  public void end() {
    final int[] selected = table.getSelectedRows();

    model.clear(rows.size());
    Iterator i = rows.iterator();
    while (i.hasNext()) {
      model.addEntry((Map) i.next());
    }
    rows.clear();

    if (SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              model.fireListeners();
              fixSelection(selected);
            }
          });
    } else {
      model.fireListeners();
      fixSelection(selected);
    }
  }
  public static void main(String[] args) {
    // read arguments and respond correctly
    File in;
    File out;
    String tileDirectory;
    if (args.length == 0 || args.length > 2) {
      in = null;
      out = null;
      tileDirectory = "";
      System.err.println("Incorrect number of arguments. Required: Filename (tileset path)");
      System.exit(0);
    } else if (args.length == 1) { // load old file
      in = new File(args[0]);
      out = in;
      Scanner s = null;
      try {
        s = new Scanner(in);
      } catch (FileNotFoundException e) {
        System.out.println("Could not find input file.");
        System.exit(0);
      }
      tileDirectory = s.nextLine();
    } else {
      in = null;
      out = new File(args[0]);
      tileDirectory = args[1];
      try {
        File f = new File(tileDirectory);
        if (!f.isDirectory()) {
          throw new IOException("Tileset does not exist");
        }
      } catch (IOException e) {
        System.err.println(e);
        System.out.println("This error is likely thanks to an invalid tileset path");
        System.exit(0);
      }
    }

    MapBuilder test = new MapBuilder("Map Editor", in, out, tileDirectory);

    // Build GUI
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            test.CreateAndDisplayGUI();
          }
        });
  }
Exemple #13
0
  /** simply dump status info to the textarea */
  private void sout(final String s) {
    Runnable soutRunner =
        new Runnable() {
          public void run() {
            if (ttaStatus.getText().equals("")) {
              ttaStatus.setText(s);
            } else {
              ttaStatus.setText(ttaStatus.getText() + "\n" + s);
            }
          }
        };

    if (ThreadUtils.isInEDT()) {
      soutRunner.run();
    } else {
      SwingUtilities.invokeLater(soutRunner);
    }
  }
  public void fadeIn() {
    final float acel = 0.1f;
    generarFondo(this);
    super.setVisible(true);

    try {
      while (BlurGlass.this.getAlpha() + acel <= 1.0f) {
        SwingUtilities.invokeAndWait(
            new Runnable() {
              public void run() {
                BlurGlass.this.setAlpha(BlurGlass.this.getAlpha() + acel);
              }
            });
        Thread.sleep(50);
      }
    } catch (Exception e) {
      Dialogos.error("Error en fadein", e);
    }
  }
  public void setActivo(boolean val) {
    glass.setVisible(val);
    setVisible(val);
    JLayeredPane.getLayeredPaneAbove(glass).moveToFront(glass);

    if (val) {
      synchronized (syncMonitor) {
        try {
          if (SwingUtilities.isEventDispatchThread()) {
            EventQueue theQueue = getToolkit().getSystemEventQueue();
            while (isVisible()) {
              AWTEvent event = theQueue.getNextEvent();
              Object source = event.getSource();

              if (event instanceof ActiveEvent) {
                ((ActiveEvent) event).dispatch();
              } else if (source instanceof Component) {
                ((Component) source).dispatchEvent(event);
              } else if (source instanceof MenuComponent) {
                ((MenuComponent) source).dispatchEvent(event);
              } else {
                System.out.println("No se puede despachar: " + event);
              }
            }
          } else {
            while (isVisible()) {
              syncMonitor.wait();
            }
          }
        } catch (InterruptedException ignored) {
          System.out.println("Excepción de interrupción: " + ignored.getMessage());
        }
      }
    } else {
      synchronized (syncMonitor) {
        setVisible(false);
        glass.setVisible(false);
        syncMonitor.notifyAll();

        eliminarDelContenedor();
      }
    }
  }
  public void fadeOut() {
    super.setVisible(true);

    try {
      final float desacel = 0.1f;
      while (BlurGlass.this.getAlpha() - desacel >= 0.0f) {
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                BlurGlass.this.setAlpha(BlurGlass.this.getAlpha() - desacel);
              }
            });
        Thread.sleep(50);
      }
      BlurGlass.this.setAlpha(0.0f);
    } catch (Exception e) {
      Dialogos.error("Error en fadeout", e);
    }
    // super.setVisible(false);
    // BlurGlass.this.setAlpha(0.2f);
    // setAlpha(0.2f);
    super.setVisible(false);
  }
  @Override
  protected void paintText(
      Graphics g,
      int tabPlacement,
      Font font,
      FontMetrics metrics,
      int tabIndex,
      String title,
      Rectangle textRect,
      boolean isSelected) {
    g.setFont(font);

    int titleWidth = SwingUtilities.computeStringWidth(metrics, title);

    int preferredWidth = 0;
    if (isOneActionButtonEnabled()) {
      preferredWidth = calculateTabWidth(tabPlacement, tabIndex, metrics) - WIDTHDELTA - 15;

      if (isCloseEnabled()) preferredWidth -= BUTTONSIZE;

      if (isMaxEnabled()) preferredWidth -= BUTTONSIZE;
    } else {
      preferredWidth = titleWidth;
    }

    while (titleWidth > preferredWidth) {
      if (title.endsWith("...")) title = title.substring(0, title.indexOf("...") - 1).concat("...");
      else title = title.substring(0, title.length() - 4).concat("...");

      titleWidth = SwingUtilities.computeStringWidth(metrics, title);
    }

    textRect.width = titleWidth;

    View v = getTextViewForTab(tabIndex);
    if (v != null) {
      // html
      v.paint(g, textRect);
    } else {
      // plain text
      int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);

      if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
        if (isSelected) g.setColor(TAB_SELECTED_FOREGROUND_COLOR);
        else {
          if (this.isTabHighlighted(tabIndex)) {
            g.setColor(TAB_HIGHLIGHT_FOREGROUND_COLOR);
          } else g.setColor(tabPane.getForegroundAt(tabIndex));
        }

        BasicGraphicsUtils.drawString(
            g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());
      } else { // tab disabled
        g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
        BasicGraphicsUtils.drawStringUnderlineCharAt(
            g, title, mnemIndex, textRect.x, textRect.y + metrics.getAscent());

        g.setColor(tabPane.getBackgroundAt(tabIndex).darker());
        BasicGraphicsUtils.drawStringUnderlineCharAt(
            g, title, mnemIndex, textRect.x - 1, textRect.y + metrics.getAscent() - 1);
      }
    }
  }
    public void actionPerformed(ActionEvent e) {
      int tempW = mapWidth;
      int tempH = mapHeight;
      int targetW;
      int targetH;
      try {
        targetW = Integer.parseInt(widthField.getText());
        targetH = Integer.parseInt(heightField.getText());

        if (targetH <= 0 || targetW <= 0) {
          JOptionPane.showMessageDialog(null, "Both x and y must be above 0.");
        } else {

          // shrink width if necessary
          while (targetW < mapWidth) {
            for (int i = mapHeight * mapWidth - 1; i >= 0; i -= mapWidth) {
              map.remove(i);
            }
            mapWidth--;
            mapScroll.revalidate();
            map.repaint();

            backEnd.removeColumn(backEnd.getWidth() - 1);
          }

          // shrink height if necessary
          while (targetH < mapHeight) {
            for (int i = 1; i <= mapWidth; i++) {
              map.remove(mapHeight * mapWidth - i);
            }
            mapHeight--;
            // map.setLayout(new GridLayout(mapHeight,mapWidth));
            map.repaint();
            backEnd.removeRow(backEnd.getHeight() - 1);
          }

          // Grow if necessary
          if (targetW > mapWidth || targetH > mapHeight) {
            // add new rows and columns, then rebuild and re-add display
            int[] mov = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
            while (targetW > mapWidth) {
              // add new column to backEnd
              List<Tile> tList = new ArrayList<Tile>();
              for (int i = 0; i < mapHeight; i++) {
                Tile t = new Tile(currTileImg, "Test", 0, 0, mov, "none", true, currTileLoc);
                t.setPreferredSize(
                    new Dimension(TILE_SIZE * DISPLAY_SCALE, TILE_SIZE * DISPLAY_SCALE));
                t.addMouseListener(new MapButtonListener());
                tList.add(t);
              }
              backEnd.addColumn(tList);
              mapWidth++;
            }
            while (targetH > mapHeight) {
              // add new row to backEnd
              List<Tile> tList = new ArrayList<Tile>();
              for (int i = 0; i < mapWidth; i++) {
                Tile t = new Tile(currTileImg, "Test", 0, 0, mov, "none", true, currTileLoc);
                t.setPreferredSize(
                    new Dimension(TILE_SIZE * DISPLAY_SCALE, TILE_SIZE * DISPLAY_SCALE));
                t.addMouseListener(new MapButtonListener());
                tList.add(t);
              }
              backEnd.addRow(tList);
              mapHeight++;
            }

            GridBagConstraints gbc = new GridBagConstraints();

            for (int i = 0; i < mapHeight; i++) {
              gbc.gridy = i;
              for (int j = 0; j < mapWidth; j++) {
                gbc.gridx = j;
                map.add(backEnd.getTile(j, i), gbc);
              }
            }
            map.revalidate();
            map.repaint();
            parentPanel.revalidate();
            parentPanel.repaint();
            ((MapBuilder) SwingUtilities.getWindowAncestor(parentPanel)).pack();
          }
        }
      } catch (NumberFormatException f) {
        JOptionPane.showMessageDialog(null, "Both x and y must be valid integers.");
      }
    }
Exemple #19
0
  // Thread's run method aimed at creating a bitmap asynchronously
  public void run() {
    Drawing drawing = new Drawing();
    PicText rawPicText = new PicText();
    String s = ((PicText) element).getText();
    rawPicText.setText(s);
    drawing.add(
        rawPicText); // bug fix: we must add a CLONE of the PicText, otherwise it loses it former
                     // parent... (then pb with the view )
    drawing.setNotparsedCommands(
        "\\newlength{\\jpicwidth}\\settowidth{\\jpicwidth}{"
            + s
            + "}"
            + CR_LF
            + "\\newlength{\\jpicheight}\\settoheight{\\jpicheight}{"
            + s
            + "}"
            + CR_LF
            + "\\newlength{\\jpicdepth}\\settodepth{\\jpicdepth}{"
            + s
            + "}"
            + CR_LF
            + "\\typeout{JPICEDT INFO: \\the\\jpicwidth, \\the\\jpicheight,  \\the\\jpicdepth }"
            + CR_LF);
    RunExternalCommand.Command commandToRun = RunExternalCommand.Command.BITMAP_CREATION;
    // RunExternalCommand command = new RunExternalCommand(drawing, contentType,commandToRun);
    boolean isWriteTmpTeXfile = true;
    String bitmapExt = "png"; // [pending] preferences
    String cmdLine =
        "{i}/unix/tetex/create_bitmap.sh {p} {f} "
            + bitmapExt
            + " "
            + fileDPI; // [pending] preferences
    ContentType contentType = getContainer().getContentType();
    RunExternalCommand.isGUI = false; // System.out, no dialog box // [pending] debug
    RunExternalCommand command =
        new RunExternalCommand(drawing, contentType, cmdLine, isWriteTmpTeXfile);
    command
        .run(); // synchronous in an async. thread => it's ok (anyway, we must way until the LaTeX
                // process has completed)

    if (wantToComputeLatexDimensions) {
      // load size of text:
      try {
        File logFile = new File(command.getTmpPath(), command.getTmpFilePrefix() + ".log");
        BufferedReader reader = null;
        try {
          reader = new BufferedReader(new FileReader(logFile));
        } catch (FileNotFoundException fnfe) {
          System.out.println("Cannot find log file! " + fnfe.getMessage());
          System.out.println(logFile);
        } catch (IOException ioex) {
          System.out.println("Log file IO exception");
          ioex.printStackTrace();
        } // utile ?
        System.out.println("Log file created! file=" + logFile);
        getDimensionsFromLogFile(reader, (PicText) element);
        syncStringLocation(); // update dimensions
        syncBounds();
        syncFrame();
        SwingUtilities.invokeLater(
            new Thread() {
              public void run() {
                repaint(null);
              }
            });
        // repaint(null); // now that dimensions are available, we force a repaint() [pending]
        // smart-repaint ?
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    if (wantToGetBitMap) {
      // load image:
      try {
        File bitmapFile =
            new File(command.getTmpPath(), command.getTmpFilePrefix() + "." + bitmapExt);
        this.image = ImageIO.read(bitmapFile);
        System.out.println(
            "Bitmap created! file="
                + bitmapFile
                + ", width="
                + image.getWidth()
                + "pixels, height="
                + image.getHeight()
                + "pixels");
        if (image == null) return;
        syncStringLocation(); // sets strx, stry, and dimensions of text
        syncBounds();
        // update the AffineTransform that will be applied to the bitmap before displaying on screen
        PicText te = (PicText) element;
        text2ModelTr.setToIdentity(); // reset
        PicPoint anchor = te.getCtrlPt(TextEditable.P_ANCHOR, ptBuf);
        text2ModelTr.rotate(getRotation(), anchor.x, anchor.y); // rotate along P_ANCHOR !
        text2ModelTr.translate(te.getLeftX(), te.getTopY());
        text2ModelTr.scale(
            te.getWidth() / image.getWidth(),
            -(te.getHeight() + te.getDepth()) / image.getHeight());
        // [pending]  should do something special to avoid dividing by 0 or setting a rescaling
        // factor to 0 [non invertible matrix] (java will throw an exception)
        syncFrame();
        SwingUtilities.invokeLater(
            new Thread() {
              public void run() {
                repaint(null);
              }
            });
        // repaint(null); // now that bitmap is available, we force a repaint() [pending]
        // smart-repaint ?
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
    protected void importImagery() {
      try {
        // Read the data and save it in a temp file.
        File sourceFile = ExampleUtil.saveResourceToTempFile(IMAGE_PATH, ".tif");

        // Create a raster reader to read this type of file. The reader is created from the
        // currently
        // configured factory. The factory class is specified in the Configuration, and a different
        // one can be
        // specified there.
        DataRasterReaderFactory readerFactory =
            (DataRasterReaderFactory)
                WorldWind.createConfigurationComponent(AVKey.DATA_RASTER_READER_FACTORY_CLASS_NAME);
        DataRasterReader reader = readerFactory.findReaderFor(sourceFile, null);

        // Before reading the raster, verify that the file contains imagery.
        AVList metadata = reader.readMetadata(sourceFile, null);
        if (metadata == null || !AVKey.IMAGE.equals(metadata.getStringValue(AVKey.PIXEL_FORMAT)))
          throw new Exception("Not an image file.");

        // Read the file into the raster. read() returns potentially several rasters if there are
        // multiple
        // files, but in this case there is only one so just use the first element of the returned
        // array.
        DataRaster[] rasters = reader.read(sourceFile, null);
        if (rasters == null || rasters.length == 0)
          throw new Exception("Can't read the image file.");

        DataRaster raster = rasters[0];

        // Determine the sector covered by the image. This information is in the GeoTIFF file or
        // auxiliary
        // files associated with the image file.
        final Sector sector = (Sector) raster.getValue(AVKey.SECTOR);
        if (sector == null) throw new Exception("No location specified with image.");

        // Request a sub-raster that contains the whole image. This step is necessary because only
        // sub-rasters
        // are reprojected (if necessary); primary rasters are not.
        int width = raster.getWidth();
        int height = raster.getHeight();

        // getSubRaster() returns a sub-raster of the size specified by width and height for the
        // area indicated
        // by a sector. The width, height and sector need not be the full width, height and sector
        // of the data,
        // but we use the full values of those here because we know the full size isn't huge. If it
        // were huge
        // it would be best to get only sub-regions as needed or install it as a tiled image layer
        // rather than
        // merely import it.
        DataRaster subRaster = raster.getSubRaster(width, height, sector, null);

        // Tne primary raster can be disposed now that we have a sub-raster. Disposal won't affect
        // the
        // sub-raster.
        raster.dispose();

        // Verify that the sub-raster can create a BufferedImage, then create one.
        if (!(subRaster instanceof BufferedImageRaster))
          throw new Exception("Cannot get BufferedImage.");
        BufferedImage image = ((BufferedImageRaster) subRaster).getBufferedImage();

        // The sub-raster can now be disposed. Disposal won't affect the BufferedImage.
        subRaster.dispose();

        // Create a SurfaceImage to display the image over the specified sector.
        final SurfaceImage si1 = new SurfaceImage(image, sector);

        // On the event-dispatch thread, add the imported data as an SurfaceImageLayer.
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                // Add the SurfaceImage to a layer.
                SurfaceImageLayer layer = new SurfaceImageLayer();
                layer.setName("Imported Surface Image");
                layer.setPickEnabled(false);
                layer.addRenderable(si1);

                // Add the layer to the model and update the application's layer panel.
                insertBeforeCompass(AppFrame.this.getWwd(), layer);
                AppFrame.this.getLayerPanel().update(AppFrame.this.getWwd());

                // Set the view to look at the imported image.
                ExampleUtil.goTo(getWwd(), sector);
              }
            });
      } catch (Exception e) {
        e.printStackTrace();
      }
    }