Package javax.media.jai

Examples of javax.media.jai.JAI


        values.put(KEY_JAI_AVAILABLE, Boolean.toString(isNativeJAIAvailable()));
        values.put(KEY_JAI_IMAGEIO_AVAILABLE, Boolean.toString(PackageUtil.isCodecLibAvailable()));

        GeoServerInfo geoServerInfo = getGeoServer().getGlobal();
        JAIInfo jaiInfo = geoServerInfo.getJAI();
        JAI jai =  jaiInfo.getJAI();
        SunTileCache jaiCache = jaiInfo.getTileCache();

        values.put(KEY_JAI_MAX_MEM, formatMemory(jaiCache.getMemoryCapacity()));
        values.put(KEY_JAI_MEM_USAGE, formatMemory(jaiCache.getCacheMemoryUsed()));
        values.put(KEY_JAI_MEM_THRESHOLD, Float.toString(100.0f * jaiCache.getMemoryThreshold()));
        values.put(KEY_JAI_TILE_THREADS, Integer.toString(jai.getTileScheduler().getParallelism()));
        values.put(KEY_JAI_TILE_THREAD_PRIORITY, Integer.toString(jai.getTileScheduler()
                .getPriority()));

        values.put(KEY_UPDATE_SEQUENCE, Long.toString(geoServerInfo.getUpdateSequence()));
    }
View Full Code Here


        public static boolean debugTileCache = false;
        /**
         Initialize Java Advanced Imaging.
         */
        public static void initJAI() {
            JAI jaiInstance = JAI.getDefaultInstance();
            jaiInstance.setTileCache( new SunTileCache( 100*1024*1024 ) );
            jaiInstance.setDefaultTileSize( new Dimension( 256, 256 ) );
        /*
         Not sure how much this helps in practice - Photovault still seems to use
         all heap available in the long run.
         */
            jaiInstance.setRenderingHint( JAI.KEY_CACHED_TILE_RECYCLING_ENABLED, Boolean.TRUE );
            if ( debugTileCache ) {
                try {
                    Class tcDebugger = Class.forName( "tilecachetool.TCTool" );
                    tcDebugger.newInstance();
                } catch (InstantiationException ex) {
View Full Code Here

            System.setSecurityManager(new RMISecurityManager());
        }

  // Load all JAIServerConfigurationSpi implementations on the CLASSPATH
  Iterator spiIter = Service.providers(JAIServerConfigurationSpi.class);
  JAI jai = JAI.getDefaultInstance();

  while (spiIter.hasNext()) {

      JAIServerConfigurationSpi serverSpi =
    (JAIServerConfigurationSpi)spiIter.next();
      serverSpi.updateServer(jai);
  }

        // Set the host name and port number.
        String host = null;
  int rmiRegistryPort = 1099; // default port is 1099
  int serverport = 0;

  if (args.length != 0) {

      String value;

      for (int i=0; i<args.length; i++) {

    if (args[i].equalsIgnoreCase("-help")) {

        System.out.println("Usage: java -Djava.rmi.server.codebase=file:$JAI/lib/jai.jar \\");
        System.out.println("-Djava.rmi.server.useCodebaseOnly=false \\");
        System.out.println("-Djava.security.policy=file:`pwd`/policy \\");
        System.out.println("com.sun.media.jai.rmi.JAIRMIImageServer \\");
        System.out.println("\nwhere options are:");
        System.out.println("\t-host <string> The server name or server IP address");
        System.out.println("\t-port <integer> The port that rmiregistry is running on");
        System.out.println("\t-rmiRegistryPort <integer> Same as -port option");
        System.out.println("\t-serverPort <integer> The port that the server should listen on, for connections from clients");
        System.out.println("\t-cacheMemCapacity <long> The memory capacity in bytes.");
        System.out.println("\t-cacheMemThreshold <float> The memory threshold, which is the fractional amount of cache memory to retain during tile removal");
        System.out.println("\t-disableDefaultCache Disable use of default tile cache. Tiles are not stored.");
        System.out.println("\t-schedulerParallelism <integer> The degree of parallelism of the default TileScheduler");
        System.out.println("\t-schedulerPrefetchParallelism <integer> The degree of parallelism of the default TileScheduler for tile prefetching");
        System.out.println("\t-schedulerPriority <integer> The priority of tile scheduling for the default TileScheduler");
        System.out.println("\t-schedulerPrefetchPriority <integer> The priority of tile prefetch scheduling for the default TileScheduler");
        System.out.println("\t-defaultTileSize <integer>x<integer> The default tile dimensions in the form <xSize>x<ySize>");
        System.out.println("\t-defaultRenderingSize <integer>x<integer> The default size to render a RenderableImage to, in the form <xSize>x<ySize>");
        System.out.println("\t-serializeDeepCopy <boolean> Whether a deep copy of the image data should be used when serializing images");
        System.out.println("\t-tileCodecFormat <string> The default format to be used for tile serialization via TileCodecs");
        System.out.println("\t-retryInterval <integer> The retry interval value to be used for dealing with network errors during remote imaging");
        System.out.println("\t-numRetries <integer> The number of retries to be used for dealing with network errors during remote imaging");

    } else if (args[i].equalsIgnoreCase("-host")) {

        host = args[++i];

    } else if (args[i].equalsIgnoreCase("-port") ||
         args[i].equalsIgnoreCase("-rmiRegistryPort")) {

        rmiRegistryPort = Integer.parseInt(args[++i]);

    } else if (args[i].equalsIgnoreCase("-serverport")) {

        serverport = Integer.parseInt(args[++i]);

    } else if (args[i].equalsIgnoreCase("-cacheMemCapacity")) {

        jai.getTileCache().setMemoryCapacity(
              Long.parseLong(args[++i]));

    } else if (args[i].equalsIgnoreCase("-cacheMemThreshold")) {

        jai.getTileCache().setMemoryThreshold(
              Float.parseFloat(args[++i]));

    } else if (args[i].equalsIgnoreCase("-disableDefaultCache")) {

        jai.disableDefaultTileCache();

    } else if (args[i].equalsIgnoreCase("-schedulerParallelism")) {

        jai.getTileScheduler().setParallelism(
              Integer.parseInt(args[++i]));

    } else if (args[i].equalsIgnoreCase("-schedulerPrefetchParallelism")) {

        jai.getTileScheduler().setPrefetchParallelism(
              Integer.parseInt(args[++i]));

    } else if (args[i].equalsIgnoreCase("-schedulerPriority")) {

        jai.getTileScheduler().setPriority(
              Integer.parseInt(args[++i]));

    } else if (args[i].equalsIgnoreCase("-schedulerPrefetchPriority")) {

        jai.getTileScheduler().setPrefetchPriority(
              Integer.parseInt(args[++i]));

    } else if (args[i].equalsIgnoreCase("-defaultTileSize")) {

        value = args[++i].toLowerCase();
        int xpos = value.indexOf("x");
        int xSize = Integer.parseInt(value.substring(0, xpos));
        int ySize = Integer.parseInt(value.substring(xpos+1));

        jai.setDefaultTileSize(new Dimension(xSize, ySize));

    } else if (args[i].equalsIgnoreCase("-defaultRenderingSize")) {

        value = args[++i].toLowerCase();
        int xpos = value.indexOf("x");
        int xSize = Integer.parseInt(value.substring(0, xpos));
        int ySize = Integer.parseInt(value.substring(xpos+1));

        jai.setDefaultRenderingSize(new Dimension(xSize, ySize));

    } else if (args[i].equalsIgnoreCase("-serializeDeepCopy")) {

        jai.setRenderingHint(JAI.KEY_SERIALIZE_DEEP_COPY,
           Boolean.valueOf(args[++i]));

    } else if (args[i].equalsIgnoreCase("-tileCodecFormat")) {

        jai.setRenderingHint(JAI.KEY_TILE_CODEC_FORMAT, args[++i]);

    } else if (args[i].equalsIgnoreCase("-retryInterval")) {

        jai.setRenderingHint(JAI.KEY_RETRY_INTERVAL,
           Integer.valueOf(args[++i]));

    } else if (args[i].equalsIgnoreCase("-numRetries")) {

        jai.setRenderingHint(JAI.KEY_NUM_RETRIES,
           Integer.valueOf(args[++i]));
    }
      }
  }
View Full Code Here

/* 1412 */     if (System.getSecurityManager() == null) {
/* 1413 */       System.setSecurityManager(new RMISecurityManager());
/*      */     }
/*      */
/* 1417 */     Iterator spiIter = Service.providers(JAIServerConfigurationSpi.class);
/* 1418 */     JAI jai = JAI.getDefaultInstance();
/*      */
/* 1420 */     while (spiIter.hasNext())
/*      */     {
/* 1422 */       JAIServerConfigurationSpi serverSpi = (JAIServerConfigurationSpi)spiIter.next();
/*      */
/* 1424 */       serverSpi.updateServer(jai);
/*      */     }
/*      */
/* 1428 */     String host = null;
/* 1429 */     int rmiRegistryPort = 1099;
/* 1430 */     int serverport = 0;
/*      */
/* 1432 */     if (args.length != 0)
/*      */     {
/* 1436 */       for (int i = 0; i < args.length; i++)
/*      */       {
/* 1438 */         if (args[i].equalsIgnoreCase("-help"))
/*      */         {
/* 1440 */           System.out.println("Usage: java -Djava.rmi.server.codebase=file:$JAI/lib/jai.jar \\");
/* 1441 */           System.out.println("-Djava.rmi.server.useCodebaseOnly=false \\");
/* 1442 */           System.out.println("-Djava.security.policy=file:`pwd`/policy \\");
/* 1443 */           System.out.println("com.sun.media.jai.rmi.JAIRMIImageServer \\");
/* 1444 */           System.out.println("\nwhere options are:");
/* 1445 */           System.out.println("\t-host <string> The server name or server IP address");
/* 1446 */           System.out.println("\t-port <integer> The port that rmiregistry is running on");
/* 1447 */           System.out.println("\t-rmiRegistryPort <integer> Same as -port option");
/* 1448 */           System.out.println("\t-serverPort <integer> The port that the server should listen on, for connections from clients");
/* 1449 */           System.out.println("\t-cacheMemCapacity <long> The memory capacity in bytes.");
/* 1450 */           System.out.println("\t-cacheMemThreshold <float> The memory threshold, which is the fractional amount of cache memory to retain during tile removal");
/* 1451 */           System.out.println("\t-disableDefaultCache Disable use of default tile cache. Tiles are not stored.");
/* 1452 */           System.out.println("\t-schedulerParallelism <integer> The degree of parallelism of the default TileScheduler");
/* 1453 */           System.out.println("\t-schedulerPrefetchParallelism <integer> The degree of parallelism of the default TileScheduler for tile prefetching");
/* 1454 */           System.out.println("\t-schedulerPriority <integer> The priority of tile scheduling for the default TileScheduler");
/* 1455 */           System.out.println("\t-schedulerPrefetchPriority <integer> The priority of tile prefetch scheduling for the default TileScheduler");
/* 1456 */           System.out.println("\t-defaultTileSize <integer>x<integer> The default tile dimensions in the form <xSize>x<ySize>");
/* 1457 */           System.out.println("\t-defaultRenderingSize <integer>x<integer> The default size to render a RenderableImage to, in the form <xSize>x<ySize>");
/* 1458 */           System.out.println("\t-serializeDeepCopy <boolean> Whether a deep copy of the image data should be used when serializing images");
/* 1459 */           System.out.println("\t-tileCodecFormat <string> The default format to be used for tile serialization via TileCodecs");
/* 1460 */           System.out.println("\t-retryInterval <integer> The retry interval value to be used for dealing with network errors during remote imaging");
/* 1461 */           System.out.println("\t-numRetries <integer> The number of retries to be used for dealing with network errors during remote imaging");
/*      */         }
/* 1463 */         else if (args[i].equalsIgnoreCase("-host"))
/*      */         {
/* 1465 */           host = args[(++i)];
/*      */         }
/* 1467 */         else if ((args[i].equalsIgnoreCase("-port")) || (args[i].equalsIgnoreCase("-rmiRegistryPort")))
/*      */         {
/* 1470 */           rmiRegistryPort = Integer.parseInt(args[(++i)]);
/*      */         }
/* 1472 */         else if (args[i].equalsIgnoreCase("-serverport"))
/*      */         {
/* 1474 */           serverport = Integer.parseInt(args[(++i)]);
/*      */         }
/* 1476 */         else if (args[i].equalsIgnoreCase("-cacheMemCapacity"))
/*      */         {
/* 1478 */           jai.getTileCache().setMemoryCapacity(Long.parseLong(args[(++i)]));
/*      */         }
/* 1481 */         else if (args[i].equalsIgnoreCase("-cacheMemThreshold"))
/*      */         {
/* 1483 */           jai.getTileCache().setMemoryThreshold(Float.parseFloat(args[(++i)]));
/*      */         }
/* 1486 */         else if (args[i].equalsIgnoreCase("-disableDefaultCache"))
/*      */         {
/* 1488 */           JAI.disableDefaultTileCache();
/*      */         }
/* 1490 */         else if (args[i].equalsIgnoreCase("-schedulerParallelism"))
/*      */         {
/* 1492 */           jai.getTileScheduler().setParallelism(Integer.parseInt(args[(++i)]));
/*      */         }
/* 1495 */         else if (args[i].equalsIgnoreCase("-schedulerPrefetchParallelism"))
/*      */         {
/* 1497 */           jai.getTileScheduler().setPrefetchParallelism(Integer.parseInt(args[(++i)]));
/*      */         }
/* 1500 */         else if (args[i].equalsIgnoreCase("-schedulerPriority"))
/*      */         {
/* 1502 */           jai.getTileScheduler().setPriority(Integer.parseInt(args[(++i)]));
/*      */         }
/* 1505 */         else if (args[i].equalsIgnoreCase("-schedulerPrefetchPriority"))
/*      */         {
/* 1507 */           jai.getTileScheduler().setPrefetchPriority(Integer.parseInt(args[(++i)]));
/*      */         }
/* 1510 */         else if (args[i].equalsIgnoreCase("-defaultTileSize"))
/*      */         {
/* 1512 */           String value = args[(++i)].toLowerCase();
/* 1513 */           int xpos = value.indexOf("x");
/* 1514 */           int xSize = Integer.parseInt(value.substring(0, xpos));
/* 1515 */           int ySize = Integer.parseInt(value.substring(xpos + 1));
/*      */
/* 1517 */           JAI.setDefaultTileSize(new Dimension(xSize, ySize));
/*      */         }
/* 1519 */         else if (args[i].equalsIgnoreCase("-defaultRenderingSize"))
/*      */         {
/* 1521 */           String value = args[(++i)].toLowerCase();
/* 1522 */           int xpos = value.indexOf("x");
/* 1523 */           int xSize = Integer.parseInt(value.substring(0, xpos));
/* 1524 */           int ySize = Integer.parseInt(value.substring(xpos + 1));
/*      */
/* 1526 */           JAI.setDefaultRenderingSize(new Dimension(xSize, ySize));
/*      */         }
/* 1528 */         else if (args[i].equalsIgnoreCase("-serializeDeepCopy"))
/*      */         {
/* 1530 */           jai.setRenderingHint(JAI.KEY_SERIALIZE_DEEP_COPY, Boolean.valueOf(args[(++i)]));
/*      */         }
/* 1533 */         else if (args[i].equalsIgnoreCase("-tileCodecFormat"))
/*      */         {
/* 1535 */           jai.setRenderingHint(JAI.KEY_TILE_CODEC_FORMAT, args[(++i)]);
/*      */         }
/* 1537 */         else if (args[i].equalsIgnoreCase("-retryInterval"))
/*      */         {
/* 1539 */           jai.setRenderingHint(JAI.KEY_RETRY_INTERVAL, Integer.valueOf(args[(++i)]));
/*      */         }
/* 1542 */         else if (args[i].equalsIgnoreCase("-numRetries"))
/*      */         {
/* 1544 */           jai.setRenderingHint(JAI.KEY_NUM_RETRIES, Integer.valueOf(args[(++i)]));
/*      */         }
/*      */
/*      */       }
/*      */
/*      */     }
View Full Code Here

        int numTilesInCache = 16;
        long memCapacity = numTilesInCache * bytesPerPixel * tileWidth * tileHeight
                * tileSampleModel.getNumBands();
        this.tileCache = JAI.createTileCache(memCapacity);

        final JAI jai = JAI.getDefaultInstance();
        TileFactory tileFactory = (TileFactory) jai.getRenderingHint(JAI.KEY_TILE_FACTORY);
        if (tileFactory == null) {
            if (tileCache instanceof Observable) {
                super.tileFactory = new RecyclingTileFactory((Observable) tileCache);
            } else {
                // not a SunTileCache?
View Full Code Here

      {
        //I am pretty sure this should not happen. However I am not sure we should throw an error
        interpolation=null;
      }
    final int transferType = source.getSampleModel().getDataType();
    final JAI processor = OperationJAI.getJAI(hints);
    PlanarImage image;
    if (interpolation!=null&&!(interpolation instanceof InterpolationNearest)
        && (transferType == DataBuffer.TYPE_FLOAT || transferType == DataBuffer.TYPE_DOUBLE)) {

      synchronized (lock) {

        /**
         * Disables the native acceleration for the "Scale" operation.
         * In JAI 1.1.2, the "Scale" operation on TYPE_FLOAT datatype
         * with INTERP_BILINEAR interpolation cause an exception in the
         * native code of medialib, which halt the Java Virtual Machine.
         * Using the pure Java implementation instead resolve the
         * problem.
         *
         * @todo Remove this hack when Sun will fix the medialib bug.
         *       See
         *       http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4906854
         */

        Registry.setNativeAccelerationAllowed(getName(), false);
        image = processor.createNS(getName(),
            parameters, hints).getRendering();


        /**
         * see above
         */
        Registry.setNativeAccelerationAllowed(getName(), true);
      }

    } else
      image = processor.createNS(getName(), parameters, hints);

    return image;
  }
View Full Code Here

      /*
         * @see TestCase#setUp()
         */
        protected void setUp() throws Exception {
            super.setUp();
            final JAI jaiDef = JAI.getDefaultInstance();
   
            // using a big tile cache
            final TileCache cache = jaiDef.getTileCache();
            cache.setMemoryCapacity(64 * 1024 * 1024);
            cache.setMemoryThreshold(0.75f);
   
            factory = new GeoTiffDriver();
        }
View Full Code Here

    private static boolean jaiMessageRedirect = false;
    private static void checkJaiMessageRedirect() {
        if( jaiMessageRedirect ) {
            return; // checked already
        }
        JAI jai = null;
        try {
            jai = JAI.getDefaultInstance();
        }
        catch (Throwable t){
            // JAI is not ready yet
        }
        if( jai == null){
            return; // JAI not ready yet we cannot check
        }
        ImagingListener imagingListener = jai.getImagingListener();
        if( imagingListener == null || imagingListener.getClass().getName().contains("ImagingListenerImpl")){
            // Client code has not provided an ImagingListener so we can use our own
            // Custom GeoTools ImagingListener used to ignore common warnings
            jai.setImagingListener(new LoggingImagingListener());
            System.out.println("Logging JAI messages: redirected to javax.media.jai logger");
        }
        else {
            System.out.println("Logging JAI messages: ImagingListener already in use: "+imagingListener);
        }
View Full Code Here

    // //
    //
    // JAI cache fine tuning
    //
    // //
    final JAI jaiDef = JAI.getDefaultInstance();
    // setting the tile cache
    final TileCache cache = jaiDef.getTileCache();
    cache.setMemoryCapacity(tileCacheSize * 1024 * 1024);

    // //
    // Imageio caching behaviour in case it is ever needed.
    // //
View Full Code Here

    targetHints.put(JAI.KEY_IMAGE_LAYOUT, layout);

    //
    // prepare the processor to use for this operation
    //
    final JAI processor = OperationJAI.getJAI(targetHints);
    final boolean useProvidedProcessor = !processor.equals(JAI.getDefaultInstance());

    try {

            if (cropROI != null) {
                // replace the cropEnvelope with the envelope of the intersection
                // of the ROI and the cropEnvelope.
                // Remember that envelope(intersection(roi,cropEnvelope)) != intersection(cropEnvelope, envelope(roi))
                final Polygon modelSpaceROI = FeatureUtilities.getPolygon(cropEnvelope, GFACTORY);
                Geometry intersection =  IntersectUtils.intersection(cropROI, modelSpaceROI);
                Envelope2D e2d = JTS.getEnvelope2D(intersection.getEnvelopeInternal(), cropEnvelope.getCoordinateReferenceSystem());
                GeneralEnvelope ge = new GeneralEnvelope((org.opengis.geometry.Envelope)e2d);
                cropEnvelope.setEnvelope(ge);
            }

      // //
      //
      // Build the new range by keeping into
      // account translation of grid geometry constructor for respecting
      // OGC PIXEL-IS-CENTER ImageDatum assumption.
      //
      // //
      final AffineTransform sourceWorldToGridTransform = sourceGridToWorldTransform.createInverse();

      // //
      //
            // finalRasterArea will hold the smallest rectangular integer raster area that contains the floating point raster
      // area which we obtain when applying the world-to-grid transform to the cropEnvelope. Note that we need to intersect
      // such an area with the area covered by the source coverage in order to be sure we do not try to crop outside the
      // bounds of the source raster.
      //
      // //
            final Rectangle2D finalRasterAreaDouble = XAffineTransform.transform(sourceWorldToGridTransform, cropEnvelope.toRectangle2D(),null);
            final Rectangle finalRasterArea = finalRasterAreaDouble.getBounds();

            // intersection with the original range in order to not try to crop outside the image bounds
            Rectangle.intersect(finalRasterArea, sourceGridRange, finalRasterArea);
            if(finalRasterArea.isEmpty())
              throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));

            // //
            //
            // It is worth to point out that doing a crop the G2W transform
            // should not change while the envelope might change as
            // a consequence of the rounding of the underlying image datum
            // which uses integer factors or in case the G2W is very
            // complex. Note that we will always strive to
            // conserve the original grid-to-world transform.
            //
            // //

            // we do not have to crop in this case (should not really happen at
            // this time)
            if (finalRasterArea.equals(sourceGridRange) && isSimpleTransform && cropROI==null)
                    return sourceCoverage;

            // //
            //
            // if I get here I have something to crop
            // using the world-to-grid transform for going from envelope to the
            // new grid range.
            //
            // //
            final double minX = finalRasterArea.getMinX();
            final double minY = finalRasterArea.getMinY();
            final double width = finalRasterArea.getWidth();
            final double height =finalRasterArea.getHeight();

      // //
      //
      // Check if we need to use mosaic or crop
      //
      // //
      final PlanarImage croppedImage;
      final ParameterBlock pbj = new ParameterBlock();
      pbj.addSource(sourceImage);
      java.awt.Polygon rasterSpaceROI=null;
            String operatioName=null;
            if (!isSimpleTransform || cropROI!=null) {
                // /////////////////////////////////////////////////////////////////////
                //
                // We don't have a simple scale and translate transform, JAI
                // crop MAY NOT suffice. Let's decide whether or not we'll use
                // the Mosaic.
                //
                // /////////////////////////////////////////////////////////////////////
                Polygon modelSpaceROI = FeatureUtilities.getPolygon(cropEnvelope, GFACTORY);

        // //
        //
        // Now convert this polygon back into a shape for the source
        // raster space.
        //
        // //
        final List<Point2D> points = new ArrayList<Point2D>(5);
        rasterSpaceROI = FeatureUtilities.convertPolygonToPointArray(modelSpaceROI, ProjectiveTransform.create(sourceWorldToGridTransform), points);
        if(rasterSpaceROI==null||rasterSpaceROI.getBounds().isEmpty())
                if(finalRasterArea.isEmpty())
                  throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));
        final boolean doMosaic = forceMosaic ? true : decideJAIOperation(roiTolerance, rasterSpaceROI.getBounds2D(), points);
        if (doMosaic || cropROI != null) {
          // prepare the params for the mosaic
                    final ROI[] roiarr;
                    try {
                        if(cropROI != null) {
                            final Shape cropRoiLS2 = new LiteShape2(cropROI, ProjectiveTransform.create(sourceWorldToGridTransform), null, false);
                            final ROIShape cropRS = new ROIShape(cropRoiLS2);
                            roiarr = new ROI[]{cropRS};
                        } else {
                            final ROIShape roi = new ROIShape(rasterSpaceROI);
                            roiarr = new ROI[]{roi};
                        }
                    } catch (FactoryException ex) {
            throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP), ex);
                    }
          pbj.add(MosaicDescriptor.MOSAIC_TYPE_OVERLAY);
          pbj.add(null);
          pbj.add(roiarr);
          pbj.add(null);
           pbj.add(CoverageUtilities.getBackgroundValues(sourceCoverage));

           //prepare the final layout
          final Rectangle bounds = rasterSpaceROI.getBounds2D().getBounds();
          Rectangle.intersect(bounds, sourceGridRange, bounds);
          if(bounds.isEmpty())
            throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));

          // we do not have to crop in this case (should not really happen at
                    // this time)
                    if (!doMosaic && bounds.getBounds().equals(sourceGridRange) && isSimpleTransform)
                            return sourceCoverage;


                  // nice trick, we use the layout to do the actual crop
                    final Rectangle boundsInt=bounds.getBounds();
          layout.setMinX(boundsInt.x);
          layout.setWidth(boundsInt.width );
          layout.setMinY(boundsInt.y);
          layout.setHeight( boundsInt.height);
          operatioName = "Mosaic";
        }

      }
           
            //do we still have to set the operation name? If so that means we have to go for crop.
            if(operatioName==null) {
                // executing the crop
                pbj.add((float) minX);
                pbj.add((float) minY);
                pbj.add((float) width);
                pbj.add((float) height);
                operatioName = "GTCrop";
            }
            // //
            //
            // Apply operation
            //
            // //
            if (!useProvidedProcessor) {
                croppedImage = JAI.create(operatioName, pbj, targetHints);
            } else {
                croppedImage = processor.createNS(operatioName, pbj, targetHints);
            }

        //conserve the input grid to world transformation
            Map sourceProperties = sourceCoverage.getProperties();
            Map properties = null;
View Full Code Here

TOP

Related Classes of javax.media.jai.JAI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.