@Override public void executeGraph(Graph graph, GraphProcessingObserver observer) throws GraphException { GraphProcessor processor = new GraphProcessor(); if (observer != null) { processor.addObserver(observer); } processor.executeGraph(graph, ProgressMonitor.NULL); }
/** * Executes the graph using a new default {@link GraphContext}. * * @param graph the {@link Graph} * @param pm a progress monitor. Can be used to signal progress. * * @throws GraphException if any error occurs during execution * @see GraphProcessor#executeGraph(GraphContext, com.bc.ceres.core.ProgressMonitor) */ public void executeGraph(Graph graph, ProgressMonitor pm) throws GraphException { GraphContext graphContext; try { pm.beginTask("Executing processing graph", 100); graphContext = new GraphContext(graph); executeGraph(graphContext, SubProgressMonitor.create(pm, 90)); graphContext.dispose(); } finally { pm.done(); } }
public void testAddingOberserverToChain() throws GraphException { GraphProcessor processor = new GraphProcessor(); GraphProcessingObserver[] observers = processor.getObservers(); assertNotNull(observers); assertEquals(0, observers.length); GraphProcessingObserverMock observerMock = new GraphProcessingObserverMock(); processor.addObserver(observerMock); observers = processor.getObservers(); assertNotNull(observers); assertEquals(1, observers.length); assertSame(observerMock, observers[0]); Graph graph = new Graph("test-graph"); graph.addNode(new Node("a", OpMock.Spi.class.getName())); processor.executeGraph(graph, ProgressMonitor.NULL); assertEquals(6, observerMock.entries.size()); assertEquals("graph [test-graph] started", observerMock.entries.get(0)); assertEquals("tile java.awt.Rectangle[x=0,y=0,width=10,height=5] started", observerMock.entries.get(1)); assertEquals("tile java.awt.Rectangle[x=0,y=0,width=10,height=5] stopped", observerMock.entries.get(2)); assertEquals("tile java.awt.Rectangle[x=0,y=5,width=10,height=5] started", observerMock.entries.get(3)); assertEquals("tile java.awt.Rectangle[x=0,y=5,width=10,height=5] stopped", observerMock.entries.get(4)); assertEquals("graph [test-graph] stopped", observerMock.entries.get(5)); }
Product[] targetProducts = processor.executeGraph(graphContext, ProgressMonitor.NULL);
@SuppressWarnings("null") public void testTwoOpsExecutionOrder() throws Exception { GraphProcessor processor = new GraphProcessor(); Graph graph = new Graph("chain1"); Node node1 = new Node("node1", "Op1"); Node node2 = new Node("node2", "Op2"); node2.addSource(new NodeSource("input", "node1")); graph.addNode(node1); graph.addNode(node2); GraphContext graphContext = new GraphContext(graph); Product chainOut = processor.executeGraph(graphContext, ProgressMonitor.NULL)[0]; assertNotNull(chainOut); assertEquals("Op2Name", chainOut.getName()); assertEquals("Op1;Op2;", TestOps.getCalls()); TestOps.clearCalls(); }
processor.executeGraph(graph, ProgressMonitor.NULL);
Product[] targetProducts = processor.executeGraph(graphContext, ProgressMonitor.NULL);
processor.executeGraph(graph, ProgressMonitor.NULL);
public void testThreeOpsExecutionOrder() throws Exception { VerbousTileCache.setVerbous(false); Graph graph = new Graph("graph"); Node node1 = new Node("node1", "Op1"); Node node2 = new Node("node2", "Op2"); Node node3 = new Node("node3", "Op3"); node2.addSource(new NodeSource("input", "node1")); node3.addSource(new NodeSource("input1", "node1")); node3.addSource(new NodeSource("input2", "node2")); graph.addNode(node1); graph.addNode(node2); graph.addNode(node3); GraphProcessor processor = new GraphProcessor(); GraphContext graphContext = new GraphContext(graph); Product chainOut = graphContext.getOutputProducts()[0]; assertNotNull(chainOut); assertEquals("Op3Name", chainOut.getName()); processor.executeGraph(graphContext, ProgressMonitor.NULL); // - Op3 requires the two bands of Op2 // - Op2 computes all bands // --> Op2 should only be called once assertEquals("Op1;Op2;Op3;", TestOps.getCalls()); TestOps.clearCalls(); VerbousTileCache.setVerbous(false); }
Product[] outputProducts = processor.executeGraph(graphContext, ProgressMonitor.NULL);
Product[] outputProducts = processor.executeGraph(graphContext, ProgressMonitor.NULL);