Project

General

Profile

« Previous | Next » 

Revision 37397

process graph image

View differences:

ProcessGraphGenerator.java
1 1
package eu.dnetlib.functionality.modular.ui.workflows.sarasvati.viewer;
2 2

  
3
import java.awt.Graphics2D;
4
import java.awt.Image;
5 3
import java.awt.image.BufferedImage;
6 4
import java.io.File;
7 5
import java.io.FileOutputStream;
......
20 18
import eu.dnetlib.msro.dispatcher.ProcessInfo;
21 19
import eu.dnetlib.msro.dispatcher.SarasvatiUtils;
22 20
import eu.dnetlib.msro.dispatcher.WorkflowRegistry;
21
import eu.dnetlib.rmi.object.manager.ProcessImageDesc;
23 22
import eu.dnetlib.rmi.soap.ManagerWorkerService;
24
import eu.dnetlib.rmi.soap.exceptions.ManagerServiceException;
25 23

  
26 24
public class ProcessGraphGenerator {
27 25

  
......
33 31

  
34 32
	private MemEngine engine = new MemEngine();
35 33

  
36
	public BufferedImage getProcessImage(final String procId) throws Exception {
34
	public ProcessImageDesc getProcessImageDesc(final String procId) throws Exception {
37 35
		final ProcessInfo proc = wfRegistry.findProcess(procId);
38 36
		final ManagerWorkerService mws = serviceLocator.getService(ManagerWorkerService.class, proc.getWorkerId());
39
		final Image image = mws.getProcessImage(procId);
40
		return toBufferedImage(image);
41

  
37
		return mws.getProcessImageDesc(procId);
42 38
	}
43 39

  
44
	public String getProcessImageMap(final String procId) throws Exception {
45
		final ProcessInfo proc = wfRegistry.findProcess(procId);
46
		final ManagerWorkerService mws = serviceLocator.getService(ManagerWorkerService.class, proc.getWorkerId());
47
		final String map = mws.getProcessImageMap(procId);
48
		return map;
49
	}
50

  
51 40
	public BufferedImage getWfDescImage(final String id, final String name, final String xml) throws Exception {
52 41
		final Graph graph = loadGraph(name, xml);
53 42
		final GraphImageMapCreator creator = new GraphImageMapCreator(graph, new GraphToImageMapHelper(id));
......
75 64
		}
76 65
	}
77 66

  
78
	private BufferedImage toBufferedImage(final Image img) throws ManagerServiceException {
79
		if (img == null) {
80
			throw new ManagerServiceException("Fetched image is null");
81
		} else if (img instanceof BufferedImage) {
82
			return (BufferedImage) img;
83
		} else {
84
			final BufferedImage bimg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
85
			final Graphics2D bGr = bimg.createGraphics();
86
			bGr.drawImage(img, 0, 0, null);
87
			bGr.dispose();
88
			return bimg;
89
		}
90
	}
91

  
92 67
	public MemEngine getEngine() {
93 68
		return engine;
94 69
	}

Also available in: Unified diff