View Javadoc
1   package io.github.magwas.inez.ui.mindmap;
2   
3   import org.eclipse.gef.geometry.planar.Rectangle;
4   import org.eclipse.swt.SWT;
5   import org.eclipse.swt.widgets.Display;
6   
7   public class SimpleMindMapExampleFactory {
8   
9   	private static final double WIDTH = 150;
10  
11  	public SimpleMindMap createComplexExample() {
12  		SimpleMindMap mindMap = new SimpleMindMap();
13  
14  		MindMapNode center = new MindMapNode();
15  		center.setTitle("The Core Idea");
16  		center.setDescription("This is my Core idea");
17  		Display display = Display.getCurrent();
18  		center.setColor(display.getSystemColor(SWT.COLOR_GREEN));
19  		center.setBounds(new Rectangle(250, 50, WIDTH, 100));
20  
21  		mindMap.addChildElement(center);
22  
23  		MindMapNode child = null;
24  		for (int i = 0; i < 5; i++) {
25  			child = new MindMapNode();
26  			child.setTitle("Association #" + i);
27  			child
28  					.setDescription("I just realized, this is related to the core idea!");
29  			child.setColor(display.getSystemColor(SWT.COLOR_BLUE));
30  
31  			child.setBounds(new Rectangle(50 + (i * 200), 250, WIDTH, 100));
32  			mindMap.addChildElement(child);
33  
34  			MindMapConnection conn = new MindMapConnection();
35  			conn.connect(center, child);
36  			mindMap.addChildElement(conn);
37  		}
38  
39  		MindMapNode child2 = new MindMapNode();
40  		child2.setTitle("Association #4-2");
41  		child2.setDescription("I just realized, this is related to the last idea!");
42  		child2.setColor(display.getSystemColor(SWT.COLOR_GRAY));
43  		child2.setBounds(new Rectangle(250, 550, WIDTH, 100));
44  		mindMap.addChildElement(child2);
45  
46  		MindMapConnection conn = new MindMapConnection();
47  		conn.connect(child, child2);
48  		mindMap.addChildElement(conn);
49  
50  		return mindMap;
51  	}
52  
53  	public SimpleMindMap createSingleNodeExample() {
54  		SimpleMindMap mindMap = new SimpleMindMap();
55  
56  		MindMapNode center = new MindMapNode();
57  		center.setTitle("The Core Idea");
58  		center.setDescription(
59  				"This is my Core idea. I need a larger Explanation to it, so I can test the warpping.");
60  		center.setColor(Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW));
61  		center.setBounds(new Rectangle(20, 50, WIDTH, 100));
62  
63  		mindMap.addChildElement(center);
64  
65  		return mindMap;
66  	}
67  }