/** * Returns an array containing the output products generated by this graph's output * nodes, i.e. nodes that are not input to other nodes. * * @return an array containing the output products of this graph */ public Product[] getOutputProducts() { Product[] products = new Product[outputNodeContextList.size()]; for (int i = 0; i < products.length; i++) { products[i] = outputNodeContextList.get(i).getTargetProduct(); } return products; }
private Map<Dimension, List<NodeContext>> buildTileDimensionMap(NodeContext[] outputNodeContexts) { final int mapSize = outputNodeContexts.length; Map<Dimension, List<NodeContext>> tileSizeMap = new HashMap<Dimension, List<NodeContext>>(mapSize); for (NodeContext outputNodeContext : outputNodeContexts) { Product targetProduct = outputNodeContext.getTargetProduct(); Dimension tileSize = targetProduct.getPreferredTileSize(); final int numXTiles = MathUtils.ceilInt(targetProduct.getSceneRasterWidth() / (double) tileSize.width); final int numYTiles = MathUtils.ceilInt(targetProduct.getSceneRasterHeight() / (double) tileSize.height); Dimension tileDim = new Dimension(numXTiles, numYTiles); List<NodeContext> nodeContextList = tileSizeMap.get(tileDim); if (nodeContextList == null) { nodeContextList = new ArrayList<NodeContext>(mapSize); tileSizeMap.put(tileDim, nodeContextList); } nodeContextList.add(outputNodeContext); } return tileSizeMap; }
final int numXTiles = dimension.width; final int numYTiles = dimension.height; Dimension tileSize = nodeContextList.get(0).getTargetProduct().getPreferredTileSize(); for (int tileY = 0; tileY < numYTiles; tileY++) { for (int tileX = 0; tileX < numXTiles; tileX++) { fireTileStarted(graphContext, tileRectangle); for (NodeContext nodeContext : nodeContextList) { Product targetProduct = nodeContext.getTargetProduct(); if (nodeContext.canComputeTileStack()) {
private void initNodeContext(final NodeContext nodeContext, Operator graphOp) throws GraphException { if (nodeContext.isInitialized()) { return; } for (NodeSource source : nodeContext.getNode().getSources()) { NodeContext sourceNodeContext = getNodeContext(source.getSourceNode()); Product sourceProduct = null; if (sourceNodeContext != null) { initNodeContext(sourceNodeContext, graphOp); sourceProduct = sourceNodeContext.getTargetProduct(); } else { if (graphOp != null) { sourceProduct = graphOp.getSourceProduct(source.getSourceNodeId()); } } if (sourceProduct == null) { throw new GraphException(getMissingSourceMessage(nodeContext.getNode(), source)); } nodeContext.addSourceProduct(source.getName(), sourceProduct); } Node node = nodeContext.getNode(); DomElement configuration = node.getConfiguration(); OperatorConfiguration opConfiguration = this.createOperatorConfiguration(configuration, new HashMap<String, Object>()); nodeContext.setOperatorConfiguration(opConfiguration); nodeContext.initTargetProduct(); getInitNodeContextDeque().addFirst(nodeContext); }
public void testTargetProductIsSetByAnnotation() throws GraphException { Graph graph = new Graph("graph"); Node node = new Node("OutputNotSet", notInitTargetProductOpSPI.getOperatorAlias()); graph.addNode(node); GraphContext graphContext = new GraphContext(graph); NodeContext nodeContext = graphContext.getNodeContext(node); NotInitOutputOperator notInitOutputOperator = (NotInitOutputOperator) nodeContext.getOperator(); assertNotNull("Output of operator is null", notInitOutputOperator.output); assertSame(nodeContext.getTargetProduct(), notInitOutputOperator.output); }