Exemplo n.º 1
0
  private void jButton3ActionPerformed(
      final ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed

    try {
      BufferedImage image = (BufferedImage) guiMap2D.getCanvas().getSnapShot();
      Object output0 = new File("temp0.png");
      Object output1 = new File("temp1.png");

      final Iterator<ImageWriter> writers = ImageIO.getImageWritersByMIMEType("image/png");
      while (writers.hasNext()) {
        final ImageWriter writer = writers.next();
        final ImageWriterSpi spi = writer.getOriginatingProvider();
        if (spi.canEncodeImage(image)) {
          ImageOutputStream stream = null;
          if (!isValidType(spi.getOutputTypes(), output0)) {
            stream = ImageIO.createImageOutputStream(output0);
            output0 = stream;
            stream = ImageIO.createImageOutputStream(output1);
            output1 = stream;
          }

          ImageWriteParam iwp = writer.getDefaultWriteParam();
          iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
          iwp.setCompressionQuality(0);
          IIOImage iimage = new IIOImage(image, null, null);
          writer.setOutput(output0);
          writer.write(null, iimage, iwp);
          writer.dispose();

          iwp = writer.getDefaultWriteParam();
          iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
          iwp.setCompressionQuality(1);
          iimage = new IIOImage(image, null, null);
          writer.setOutput(output1);
          writer.write(null, iimage, iwp);
          writer.dispose();

          if (output0 != null) {
            ((ImageOutputStream) output0).close();
            ((ImageOutputStream) output1).close();
          }

          return;
        }
      }
    } catch (Exception rx) {
      rx.printStackTrace();
    }
  } // GEN-LAST:event_jButton3ActionPerformed
Exemplo n.º 2
0
  protected JMap2DFrame(final MapContext context, boolean statefull, Hints hints) {
    initComponents();

    guiContextTree = (JContextTree) jScrollPane1;
    guiContextTree.setContext(context);
    initTree(guiContextTree);

    guiMap2D = new JMap2D(statefull);
    guiMap2D.getContainer().setContext(context);
    guiMap2D
        .getCanvas()
        .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    guiMap2D.getCanvas().setRenderingHint(GO2Hints.KEY_GENERALIZE, GO2Hints.GENERALIZE_ON);
    guiMap2D
        .getCanvas()
        .setRenderingHint(GO2Hints.KEY_BEHAVIOR_MODE, GO2Hints.BEHAVIOR_PROGRESSIVE);

    guiChainEditor = new JChainEditor(true);
    panETL.add(BorderLayout.CENTER, guiChainEditor);

    if (hints != null) {
      guiMap2D.getCanvas().setRenderingHints(hints);
    }

    guiMap2D.getCanvas().setAutoRepaint(true);

    for (TreePopupItem item : guiContextTree.controls()) {
      item.setMapView(guiMap2D);
    }

    try {
      Envelope env = context.getAreaOfInterest();
      if (env != null) {
        guiMap2D.getCanvas().setObjectiveCRS(env.getCoordinateReferenceSystem());
      } else {
        env = context.getBounds();
        guiMap2D.getCanvas().setObjectiveCRS(context.getCoordinateReferenceSystem());
      }
      if (env != null) {
        guiMap2D.getCanvas().setVisibleArea(env);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    // 2D map
    guiMap2D.addDecoration(
        new JClassicNavigationDecoration(JClassicNavigationDecoration.THEME.CLASSIC));
    panMap2D.add(BorderLayout.CENTER, guiMap2D);
    guiNavBar.setMap(guiMap2D);
    guiInfoBar.setMap(guiMap2D);
    guiCoordBar.setMap(guiMap2D);
    guiConfigBar.setMap(guiMap2D);
    guiSelectionBar.setMap(guiMap2D);
    guiEditBar.setMap(guiMap2D);
    guiMap2D.getCanvas().setAutoRepaint(true);
    guiMap2D.setHandler(new PanHandler(guiMap2D, false));

    // 3D map
    guiMap3D = new JMap3D();
    ((ContextContainer3D) guiMap3D.getMap3D().getContainer()).setContext(context);
    panMap3D.add(BorderLayout.CENTER, guiMap3D);

    setSize(1024, 768);
    setLocationRelativeTo(null);
  }