View | Details | Raw Unified | Return to bug 186249
Collapse All | Expand All

(-)src/org/eclipse/draw2d/graph/Rank.java (-1 / +3 lines)
Lines 75-81 Link Here
75
	for (int i = 0; i < size(); i++) {
75
	for (int i = 0; i < size(); i++) {
76
		Node n = getNode(i);
76
		Node n = getNode(i);
77
		n.y = location;
77
		n.y = location;
78
		n.height = rowHeight;
78
		if (!n.isConstantSize()) {
79
			n.height = rowHeight;
80
		}
79
	}
81
	}
80
}
82
}
81
83
(-)src/org/eclipse/draw2d/graph/Node.java (+26 lines)
Lines 83-88 Link Here
83
 */
83
 */
84
public int incomingOffset = -1;
84
public int incomingOffset = -1;
85
85
86
/**
87
 * Specifies whether nodes should keep their size untouched by the layout algorithm
88
 */
89
boolean constantSize;
90
86
// A non-decreasing number given to consecutive nodes in a Rank.
91
// A non-decreasing number given to consecutive nodes in a Rank.
87
int index;
92
int index;
88
93
Lines 315-318 Link Here
315
	return right;
320
	return right;
316
}
321
}
317
322
323
/**
324
 * Checks if node preserves its size.
325
 * 
326
 * @return <code>true</code> if node has constant size
327
 * @since 3.5
328
 */
329
public boolean isConstantSize() {
330
	return constantSize;
331
}
332
333
/**
334
 * Sets the flag on the node for the layout algorithm that specifies whether
335
 * the layout algorithm is allowed to modify the size of the node or not,
336
 * 
337
 * @param constantSize
338
 * @since 3.5
339
 */
340
public void setConstantSize(boolean constantSize) {
341
	this.constantSize = constantSize;
342
}
343
318
}
344
}
(-)src/org/eclipse/draw2d/GridLayout.java (-1 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 197-202 Link Here
197
			size.width = wHint;
197
			size.width = wHint;
198
		if (hHint != SWT.DEFAULT)
198
		if (hHint != SWT.DEFAULT)
199
			size.height = hHint;
199
			size.height = hHint;
200
		
201
		/*
202
		 * Adjust for the size of the border
203
		 */
204
		size.expand(container.getInsets().getWidth(),
205
				container.getInsets().getHeight());
206
		size.union(getBorderPreferredSize(container));		
200
207
201
		return size;
208
		return size;
202
	}
209
	}
(-)src/org/eclipse/draw2d/examples/graph/GraphTests.java (+88 lines)
Lines 779-782 Link Here
779
779
780
}
780
}
781
781
782
public static DirectedGraph constantSizeNodes1() {
783
	Node a,b,c,d,e,f,g;
784
	NodeList nodes = new NodeList();
785
	EdgeList edges = new EdgeList();
786
787
	nodes.add(a = new Node("node a"));
788
	nodes.add(b = new Node("node b"));
789
	nodes.add(c = new Node("node c"));
790
	nodes.add(d = new Node("node d"));
791
	nodes.add(e = new Node("node e"));
792
	nodes.add(f = new Node("node f"));
793
	nodes.add(g = new Node("node g"));
794
	a.setConstantSize(true);
795
	b.setConstantSize(true);
796
	c.setConstantSize(true);
797
	d.setConstantSize(true);
798
	e.setConstantSize(true);
799
	f.setConstantSize(true);
800
	g.setConstantSize(true);
801
	a.width = 30; a.height = 60;
802
	b.width = 40; b.height = 20;
803
	c.width = c.height = 80;
804
	d.width = d.height = 40;
805
	e.width = 70; e.height = 20;
806
	f.width = f.height = 40;
807
	g.width = 70; g.height = 60;
808
809
	edges.add(new Edge(a, d));
810
	edges.add(new Edge(b, d));
811
	edges.add(new Edge(c, d));
812
	edges.add(new Edge(d, e));
813
	edges.add(new Edge(d, f));
814
	edges.add(new Edge(d, g));
815
	edges.add(new Edge(c, g));	
816
	
817
	DirectedGraph graph = new DirectedGraph();
818
	graph.nodes = nodes;
819
	graph.edges = edges;
820
	
821
	new DirectedGraphLayout()
822
		.visit(graph);
823
	return graph;
824
}
825
826
public static DirectedGraph constantSizeNodes_Problems() {
827
	Node a,b,c,d,e,f,g;
828
	NodeList nodes = new NodeList();
829
	EdgeList edges = new EdgeList();
830
831
	nodes.add(a = new Node("node a"));
832
	nodes.add(b = new Node("node b"));
833
	nodes.add(c = new Node("node c"));
834
	nodes.add(d = new Node("node d"));
835
	nodes.add(e = new Node("node e"));
836
	nodes.add(f = new Node("node f"));
837
	nodes.add(g = new Node("node g"));
838
	a.setConstantSize(true);
839
	b.setConstantSize(true);
840
	c.setConstantSize(true);
841
	d.setConstantSize(true);
842
	e.setConstantSize(true);
843
	f.setConstantSize(true);
844
	g.setConstantSize(true);
845
	a.width = 40; a.height = 40;
846
	b.width = b.height = 150;
847
	c.width = c.height = 40;
848
	d.width = d.height = 40;
849
	e.width = 40; e.height = 20;
850
	f.width = f.height = 40;
851
	g.width = 100; g.height = 60;
852
853
	edges.add(new Edge(a, d));
854
	edges.add(new Edge(b, d));
855
	edges.add(new Edge(c, d));
856
	edges.add(new Edge(d, e));
857
	edges.add(new Edge(d, f));
858
	edges.add(new Edge(d, g));
859
	edges.add(new Edge(c, g));	
860
	
861
	DirectedGraph graph = new DirectedGraph();
862
	graph.nodes = nodes;
863
	graph.edges = edges;
864
	
865
	new DirectedGraphLayout()
866
		.visit(graph);
867
	return graph;
868
}
869
782
}
870
}

Return to bug 186249