OperatorExecutor2 { public Object execute(Handler handler) throws Exception { int parallelism = Runtime.getRuntime().availableProcessors(); System.out.println("parallelism = " + parallelism); JAI.getDefaultInstance().getTileScheduler().setParallelism(parallelism); Dimension frameSize = getFrameSize(); int numXFrames = 1 + (product.getSceneRasterWidth() - 1) / frameSize.width; int numYFrames = 1 + (product.getSceneRasterHeight() - 1) / frameSize.height; Rectangle sceneRegion = new Rectangle(product.getSceneRasterWidth(), product.getSceneRasterHeight()); for (int frameY = 0; frameY < numYFrames; frameY++) { for (int frameX = 0; frameX < numXFrames; frameX++) { Rectangle frameRegion = new Rectangle(frameX * frameSize.width, frameY * frameSize.height, frameSize.width, frameSize.height).intersection(sceneRegion); int numBands = product.getNumBands(); Band[] bandArray = new Band[numBands]; ProductData[] dataArray = new ProductData[numBands]; for (int b = 0; b < numBands; b++) { Band band = product.getBandAt(b); PlanarImage planarImage = band.getSourceImage(); Point[] indices = planarImage.getTileIndices(null); System.out.println("indices = " + indices.length); TileRequest tileRequest = planarImage.queueTiles(indices); Raster raster = planarImage.getData(); System.out.println("raster = " + raster); ProductData data = band.createCompatibleRasterData(frameRegion.width, frameRegion.height); band.readRasterData(frameRegion.x, frameRegion.y, frameRegion.width, frameRegion.height, data); bandArray[b] = band; dataArray[b] = data; } MyFrame frame = new MyFrame(frameRegion, bandArray, dataArray); handler.frameComputed(frame); } } return new Object(); } OperatorExecutor2(Product product); Dimension getFrameSize(); void setFrameSize(int w, int h); Object execute(Handler handler);  }
@Test public void testData() throws Exception { SimpleOp op = new SimpleOp(); Product s = new Product("S", "S", 10, 10); s.setPreferredTileSize(10, 2); op.setSourceProduct(s); Product t = op.getTargetProduct(); OperatorExecutor2 ex = new OperatorExecutor2(t); TracingHandler2 handler = new TracingHandler2(); Object metrics = ex.execute(handler); assertEquals(5, handler.trace.size()); OperatorExecutor2.Frame frame0 = handler.trace.get(0); assertNotNull(frame0.getData(0)); assertEquals(0.1f, frame0.getData(0).getElemFloatAt(0), 0.0f); assertEquals(0.3f, frame0.getData(3).getElemFloatAt(0), 0.0f); assertEquals(0.1f - 0.3f, frame0.getData(6).getElemFloatAt(0), 0.0f); assertEquals(0.1f, frame0.getData(0).getElemFloatAt(7), 0.0f); assertEquals(0.3f, frame0.getData(3).getElemFloatAt(7), 0.0f); assertEquals(0.1f - 0.3f, frame0.getData(6).getElemFloatAt(7), 0.0f); OperatorExecutor2.Frame frame3 = handler.trace.get(3); assertEquals(0.1f, frame3.getData(0).getElemFloatAt(0), 0.0f); assertEquals(0.3f, frame3.getData(3).getElemFloatAt(0), 0.0f); assertEquals(0.1f - 0.3f, frame3.getData(6).getElemFloatAt(0), 0.0f); assertEquals(0.1f, frame3.getData(0).getElemFloatAt(7), 0.0f); assertEquals(0.3f, frame3.getData(3).getElemFloatAt(7), 0.0f); assertEquals(0.1f - 0.3f, frame3.getData(6).getElemFloatAt(7), 0.0f); assertNotNull(metrics); }