Ejemplo n.º 1
0
 /**
  * Obtiene la barra deslizadora con el radio del filtro de paso alto
  *
  * @return CheckSliderTextContainer
  */
 public CheckSliderTextContainer getRadio() {
   if (radio == null)
     radio =
         new CheckSliderTextContainer(
             0, 255, 127, false, RasterToolsUtil.getText(this, "radio"), true, false, false);
   return radio;
 }
Ejemplo n.º 2
0
 /**
  * Obtiene el desplegable con la lista de capas
  *
  * @return JComboBox
  */
 protected NewLayerPanel getNewLayerPanel() {
   if (newLayerPanel == null) {
     newLayerPanel = new NewLayerPanel(lyr);
     newLayerPanel.setOnlyReprojectables(true);
     newLayerPanel
         .getJPanel()
         .setBorder(BorderFactory.createTitledBorder(RasterToolsUtil.getText(this, "capa")));
     newLayerPanel.getRadioOpenMemory().setEnabled(!isInTOC.booleanValue());
     if (isInTOC.booleanValue()) newLayerPanel.getRadioFileGenerate().setSelected(true);
   }
   return newLayerPanel;
 }
Ejemplo n.º 3
0
  /**
   * Obtiene la lista de parámetros de los filtros añadidos
   *
   * @param lyr Capa raster
   * @return ArrayList
   */
  public ArrayList getParamStruct(
      FLyrRasterSE lyr, StretchPreviewRender prevRender, StretchData data) {
    RasterFilterList filterList = new RasterFilterList();
    filterList.setInitDataType(lyr.getDataType()[0]);
    RasterFilterListManager filterManager = new RasterFilterListManager(filterList);

    try {
      prevRender.addPosterization(filterManager, lyr);
    } catch (FilterTypeException e1) {
      RasterToolsUtil.messageBoxError(RasterToolsUtil.getText(null, "noposterization"), null, e1);
    }

    return getParams(filterList);
  }
Ejemplo n.º 4
0
  /**
   * Obtiene el panel de destino de fichero y nombre de capa
   *
   * @return JPanel
   */
  private JPanel getFilePanel() {
    if (filePanel == null) {
      filePanel = new JPanel();
      filePanel.setBorder(
          BorderFactory.createTitledBorder(RasterToolsUtil.getText(this, "dest_file")));
      filePanel.setLayout(new GridBagLayout());

      GridBagConstraints gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.weightx = 1D;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.anchor = GridBagConstraints.WEST;
      gbc.insets = new Insets(0, 0, 0, 5);
      filePanel.add(getNameFilePanel(), gbc);
    }
    return filePanel;
  }
Ejemplo n.º 5
0
  /**
   * Obtiene el bot�n que lanza el panel de selecci�n de proyecciones.
   *
   * @return
   */
  private CRSSelectPanel getProjectionDstSelector() {
    if (projectionDstSelector == null) {
      projectionDstSelector = CRSSelectPanel.getPanel(projDst);
      // projectionDstSelector.setTransPanelActive(true);
      projectionDstSelector.setPreferredSize(null);
      projectionDstSelector.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (projectionDstSelector.isOkPressed()) {
                projDst = projectionDstSelector.getCurProj();
              }
            }
          });
      projectionDstSelector.setBorder(
          BorderFactory.createTitledBorder(RasterToolsUtil.getText(this, "dest_proj")));

      if (!isInTOC.booleanValue()) StatusComponent.setDisabled(projectionDstSelector);
    }
    return projectionDstSelector;
  }
Ejemplo n.º 6
0
  /** Inicialización de los componentes gráficos */
  protected void init() {
    setLayout(new GridBagLayout());
    setBorder(
        BorderFactory.createTitledBorder(
            null,
            RasterToolsUtil.getText(this, "highpassfilter"),
            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
            javax.swing.border.TitledBorder.DEFAULT_POSITION,
            null,
            null));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.insets = new Insets(0, 0, 0, 0);

    add(getActive(), gbc);

    gbc.gridy = 1;
    add(getRadio(), gbc);

    getActive().addActionListener(this);
    setComponentEnabled(false);
  }
Ejemplo n.º 7
0
  /**
   * Obtiene el bot�n que lanza el panel de selecci�n de proyecciones.
   *
   * @return
   */
  private CRSSelectPanel getProjectionSrcSelector() {
    if (projectionSrcSelector == null) {

      IProjection projectionAux = null;
      IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
      if (activeWindow instanceof BaseView) {
        BaseView activeView = (BaseView) activeWindow;
        projectionAux = activeView.getProjection();
        activeView.setProjection(projSrc);
      }

      projectionSrcSelector = CRSSelectPanel.getPanel(projSrc);

      if (activeWindow instanceof BaseView) {
        BaseView activeView = (BaseView) activeWindow;
        activeView.setProjection(projectionAux);
      }

      // projectionSrcSelector.setTransPanelActive(true);
      projectionSrcSelector.setPreferredSize(null);
      projectionSrcSelector.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (projectionSrcSelector.isOkPressed()) {
                projSrc = projectionSrcSelector.getCurProj();
              }
            }
          });
      projectionSrcSelector.setBorder(
          BorderFactory.createTitledBorder(RasterToolsUtil.getText(this, "src_proj")));

      if (isInTOC.booleanValue() && this.lyr.readProjection() != null)
        StatusComponent.setDisabled(projectionSrcSelector);
    }
    return projectionSrcSelector;
  }
Ejemplo n.º 8
0
 /*
  * (non-Javadoc)
  *
  * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle()
  */
 public String getTitle() {
   return RasterToolsUtil.getText(this, "incremento_recorte");
 }
Ejemplo n.º 9
0
  /** Tarea de recorte */
  public void process() throws InterruptedException {
    IRasterDataSource dsetCopy = null;
    if (rasterSE != null) rasterSE.setReadingData(Thread.currentThread().toString());

    try {
      long t2;
      long t1 = new java.util.Date().getTime();

      insertLineLog(RasterToolsUtil.getText(this, "leyendo_raster"));

      dsetCopy = rasterSE.getDataSource().newDataset();
      BufferFactory bufferFactory = new BufferFactory(dsetCopy);
      bufferFactory.setDrawableBands(drawableBands);

      if (interpolationMethod != BufferInterpolation.INTERPOLATION_Undefined) {
        try {
          if (pValues != null) {
            if (RasterBuffer.isBufferTooBig(
                new double[] {pValues[0], pValues[3], pValues[2], pValues[1]},
                drawableBands.length)) bufferFactory.setReadOnly(true);
            bufferFactory.setAreaOfInterest(
                pValues[0], pValues[3], pValues[2] - pValues[0], pValues[1] - pValues[3]);
          } else if (wcValues != null) {
            // if (RasterBuffer.isBufferTooBig(new double[] {
            // wcValues[0], wcValues[3], wcValues[2], wcValues[1] },
            // rasterSE.getCellSize(), drawableBands.length))
            if (!rasterSE.isActionEnabled(IRasterLayerActions.REMOTE_ACTIONS))
              bufferFactory.setReadOnly(true);
            bufferFactory.setAreaOfInterest(
                wcValues[0],
                wcValues[1],
                Math.abs(wcValues[0] - wcValues[2]),
                Math.abs(wcValues[1] - wcValues[3]));
          }
        } catch (InvalidSetViewException e) {
          RasterToolsUtil.messageBoxError(
              "No se ha podido asignar la vista al inicial el proceso de recorte.", this, e);
        }
        buffer = bufferFactory.getRasterBuf();

        insertLineLog(RasterToolsUtil.getText(this, "interpolando"));

        if (buffer != null)
          buffer =
              ((RasterBuffer) buffer)
                  .getAdjustedWindow(resolutionWidth, resolutionHeight, interpolationMethod);
        else {
          RasterToolsUtil.messageBoxError(
              "El proceso de recorte ha fallado porque el buffer no contenía datos.",
              this,
              new NullPointerException());
          return;
        }
      } else {
        try {
          if (RasterBuffer.isBufferTooBig(
              new double[] {0, 0, resolutionWidth, resolutionHeight}, drawableBands.length))
            bufferFactory.setReadOnly(true);
          if (pValues != null)
            bufferFactory.setAreaOfInterest(
                pValues[0],
                pValues[3],
                Math.abs(pValues[2] - pValues[0]) + 1,
                Math.abs(pValues[1] - pValues[3]) + 1,
                resolutionWidth,
                resolutionHeight);
          else if (wcValues != null)
            bufferFactory.setAreaOfInterest(
                wcValues[0],
                wcValues[1],
                wcValues[2],
                wcValues[3],
                resolutionWidth,
                resolutionHeight);
          buffer = bufferFactory.getRasterBuf();
          if (buffer == null) {
            RasterToolsUtil.messageBoxError(
                "El proceso de recorte ha fallado porque el buffer no contenía datos.",
                this,
                new NullPointerException());
            return;
          }
        } catch (InvalidSetViewException e) {
          RasterToolsUtil.messageBoxError(
              "No se ha podido asignar la vista al inicial el proceso de recorte.", this, e);
        }
      }
      // TODO: FUNCIONALIDAD: Poner los getWriter con la proyección del
      // fichero fuente

      if ((selectedRois != null) && (!bufferFactory.isReadOnly())) {
        if (selectedRois.size() > 0) {
          int despX = 0;
          int despY = 0;
          if (pValues != null) {
            despX = pValues[0];
            despY = pValues[1];
          } else if (wcValues != null) {
            despX =
                (int) dsetCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getX();
            despY =
                (int) dsetCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getY();
          }
          drawOnlyROIs(buffer, selectedRois, despX, despY);
        }
      }

      insertLineLog(RasterToolsUtil.getText(this, "salvando_imagen"));

      String finalFileName = "";
      if (oneLayerPerBand) {
        long[] milis = new long[drawableBands.length];
        String[] fileNames = new String[drawableBands.length];
        for (int i = 0; i < drawableBands.length; i++) {
          fileNames[i] = fileName + "_B" + drawableBands[i] + ".tif";
          writerBufferServer.setBuffer(buffer, i);
          Params p = null;
          if (params == null) p = GeoRasterWriter.getWriter(fileNames[i]).getParams();
          else p = params;
          grw =
              GeoRasterWriter.getWriter(
                  writerBufferServer,
                  fileNames[i],
                  1,
                  affineTransform,
                  buffer.getWidth(),
                  buffer.getHeight(),
                  buffer.getDataType(),
                  p,
                  null);
          grw.setColorBandsInterpretation(new String[] {DatasetColorInterpretation.GRAY_BAND});
          grw.setWkt(dsetCopy.getWktProjection());
          grw.setCancellableRasterDriver(cancellableObj);
          grw.dataWrite();
          grw.writeClose();
          saveToRmf(fileNames[i]);
          t2 = new java.util.Date().getTime();
          milis[i] = (t2 - t1);
          t1 = new java.util.Date().getTime();
        }
        if (incrementableTask != null) {
          incrementableTask.processFinalize();
          incrementableTask = null;
        }
        if (viewName != null) {
          if (RasterToolsUtil.messageBoxYesOrNot("cargar_toc", this)) {
            try {
              for (int i = 0; i < drawableBands.length; i++) {
                FLayer lyr = RasterToolsUtil.loadLayer(viewName, fileNames[i], null);
                if (lyr != null && lyr instanceof FLyrRasterSE)
                  ((FLyrRasterSE) lyr).setRois(rasterSE.getRois());
              }
            } catch (RasterNotLoadException e) {
              RasterToolsUtil.messageBoxError("error_load_layer", this, e);
            }
          }
        }
        for (int i = 0; i < drawableBands.length; i++) {
          if (externalActions != null)
            externalActions.end(
                new Object[] {fileName + "_B" + drawableBands[i] + ".tif", new Long(milis[i])});
        }
      } else {
        if (isUsingFile(fileName)) {
          incrementableTask.hideWindow();
          RasterToolsUtil.messageBoxError("error_opened_file", this);
          return;
        }
        File f = new File(fileName);
        if (f.exists()) {
          f.delete();
        }
        f = null;
        writerBufferServer.setBuffer(buffer, -1);
        if (params == null) {
          finalFileName = fileName + ".tif";
          params = GeoRasterWriter.getWriter(finalFileName).getParams();
        } else finalFileName = fileName;
        grw =
            GeoRasterWriter.getWriter(
                writerBufferServer,
                finalFileName,
                buffer.getBandCount(),
                affineTransform,
                buffer.getWidth(),
                buffer.getHeight(),
                buffer.getDataType(),
                params,
                null);
        if (colorInterp != null) grw.setColorBandsInterpretation(colorInterp.getValues());
        grw.setWkt(dsetCopy.getWktProjection());
        grw.setCancellableRasterDriver(cancellableObj);
        grw.dataWrite();
        grw.writeClose();
        saveToRmf(finalFileName);
        t2 = new java.util.Date().getTime();
        if (incrementableTask != null) {
          incrementableTask.processFinalize();
          incrementableTask = null;
        }
        // Damos tiempo a parar el Thread del incrementable para que no
        // se cuelgue la ventana
        // El tiempo es como mínimo el de un bucle del run de la tarea
        // incrementable
        Thread.sleep(600);
        cutFinalize(finalFileName, (t2 - t1));
      }

    } catch (NotSupportedExtensionException e) {
      RasterToolsUtil.messageBoxError("error_not_suported_extension", this, e);
    } catch (RasterDriverException e) {
      RasterToolsUtil.messageBoxError("error_writer", this, e);
    } catch (IOException e) {
      RasterToolsUtil.messageBoxError("error_georasterwriter", this, e);
    } finally {
      if (rasterSE != null) rasterSE.setReadingData(null);
      if (dsetCopy != null) dsetCopy.close();
      buffer = null;
    }
  }
Ejemplo n.º 10
0
  /** Inicializaci�n de los componentes gr�ficos. */
  private void init() {
    GridBagConstraints gridBagConstraints;

    setLayout(new GridBagLayout());

    int posy = 0;

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = posy;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(5, 0, 2, 0);
    JPanel panelFile = new JPanel();
    panelFile.setLayout(new BorderLayout());
    panelFile.setBorder(BorderFactory.createTitledBorder(RasterToolsUtil.getText(this, "origen")));
    JLabel label = new JLabel("<html><b>" + lyr.getName() + "</b></html>");
    panelFile.add(label, BorderLayout.CENTER);
    add(panelFile, gridBagConstraints);

    posy++;
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = posy;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(2, 0, 2, 0);
    add(getProjectionSrcSelector(), gridBagConstraints);

    posy++;
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = posy;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new Insets(2, 0, 2, 0);
    add(getProjectionDstSelector(), gridBagConstraints);

    posy++;
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = posy;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.insets = new Insets(2, 0, 2, 0);
    add(getNewLayerPanel().getJPanel(), gridBagConstraints);

    posy++;
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = posy;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.insets = new Insets(2, 0, 0, 0);
    add(getFilePanel(), gridBagConstraints);

    // Insertamos un panel vacio
    posy++;
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = posy;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new Insets(0, 0, 0, 0);
    JPanel emptyPanel = new JPanel();
    add(emptyPanel, gridBagConstraints);
  }