Example #1
0
 private Rectangle getScaledRectangle(Rectangle rectangle) {
   final AffineTransform i2mTransform =
       ImageManager.getImageToModelTransform(product.getGeoCoding());
   final double scaleX = i2mTransform.getScaleX();
   final double scaleY = i2mTransform.getScaleY();
   double scaleFactorY = Math.abs(scaleY / scaleX);
   final AffineTransform scaleTransform = AffineTransform.getScaleInstance(1.0, scaleFactorY);
   return scaleTransform.createTransformedShape(rectangle).getBounds();
 }
Example #2
0
    @Override
    protected RenderedImage createImage(int level) {
      RasterDataNode rdn = getRasterDataNode();
      NetcdfFile lock = ctx.getNetcdfFile();
      final Object object = ctx.getProperty(Constants.Y_FLIPPED_PROPERTY_NAME);
      boolean isYFlipped = object instanceof Boolean && (Boolean) object;
      int dataBufferType = ImageManager.getDataBufferType(rdn.getDataType());
      int sourceWidth = (int) (rdn.getSceneRasterWidth() / scaleFactor);
      int sourceHeight = (int) (rdn.getSceneRasterHeight() / scaleFactor);
      ResolutionLevel resolutionLevel = ResolutionLevel.create(getModel(), level);
      Dimension tileSize = getPreferredTileSize(rdn);

      RenderedImage netcdfImg;
      if (variable.getDataType() == DataType.LONG) {
        if (rdn.getName().endsWith("_lsb")) {
          netcdfImg =
              NetcdfOpImage.createLsbImage(
                  variable,
                  imageOrigin,
                  isYFlipped,
                  lock,
                  dataBufferType,
                  sourceWidth,
                  sourceHeight,
                  tileSize,
                  resolutionLevel);
        } else {
          netcdfImg =
              NetcdfOpImage.createMsbImage(
                  variable,
                  imageOrigin,
                  isYFlipped,
                  lock,
                  dataBufferType,
                  sourceWidth,
                  sourceHeight,
                  tileSize,
                  resolutionLevel);
        }
      } else {
        netcdfImg =
            new NetcdfOpImage(
                variable,
                imageOrigin,
                isYFlipped,
                lock,
                dataBufferType,
                sourceWidth,
                sourceHeight,
                tileSize,
                resolutionLevel);
      }

      return ScaleDescriptor.create(
          netcdfImg,
          scaleFactor,
          scaleFactor,
          0.5f,
          0.5f,
          Interpolation.getInstance(Interpolation.INTERP_NEAREST),
          null);
    }