Project

General

Profile

Download (3.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright 2005, CHISEL Group, University of Victoria, Victoria, BC, Canada.
3
 * All rights reserved. This program and the accompanying materials are made
4
 * available under the terms of the Eclipse Public License v1.0 which
5
 * accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: The Chisel Group, University of Victoria
9
 *******************************************************************************/
10
package org.eclipse.zest.layouts.dataStructures;
11

    
12
import java.util.LinkedList;
13
import java.util.List;
14

    
15
import org.eclipse.zest.layouts.LayoutBendPoint;
16
import org.eclipse.zest.layouts.LayoutEntity;
17
import org.eclipse.zest.layouts.LayoutRelationship;
18
import org.eclipse.zest.layouts.constraints.BasicEdgeConstraints;
19
import org.eclipse.zest.layouts.constraints.LayoutConstraint;
20

    
21
/**
22
 * @author Ian Bull
23
 */
24
public class InternalRelationship implements LayoutRelationship {
25

    
26
	private LayoutRelationship externalRelationship;
27
	private InternalNode source;
28
	private InternalNode destination;
29
	private Object layoutInfo;
30
	private List bendPoints = new LinkedList();
31
	BasicEdgeConstraints basicEdgeConstraints = new BasicEdgeConstraints();
32

    
33
	public InternalRelationship(LayoutRelationship externalRelationship, InternalNode source, InternalNode destination) {
34
		this.externalRelationship = externalRelationship;
35
		this.externalRelationship.setLayoutInformation(this);
36
		this.source = source;
37
		this.destination = destination;
38
		this.externalRelationship.populateLayoutConstraint(basicEdgeConstraints);
39
	}
40

    
41
	public LayoutRelationship getLayoutRelationship() {
42
		return externalRelationship;
43
	}
44

    
45
	public InternalNode getSource() {
46
		if (this.source == null) {
47
			throw new RuntimeException("Source is null");
48
		}
49
		return this.source;
50
	}
51

    
52
	public InternalNode getDestination() {
53
		if (this.destination == null) {
54
			throw new RuntimeException("Dest is null");
55
		}
56
		return this.destination;
57
	}
58

    
59
	public double getWeight() {
60
		return this.basicEdgeConstraints.weight;
61
	}
62

    
63
	public boolean isBidirectional() {
64
		return this.basicEdgeConstraints.isBiDirectional;
65
	}
66

    
67
	/**
68
	 * Ensure this is called in order of source to target node position.
69
	 * @param x
70
	 * @param y
71
	 */
72
	public void addBendPoint(double x, double y) {
73
		bendPoints.add(new BendPoint(x, y));
74
	}
75

    
76
	/**
77
	 * Ensure this is called in order of source to target node position.
78
	 * Specifies if the bendpoint is a curve control point
79
	 * @param x
80
	 * @param y
81
	 * @param isControlPoint
82
	 */
83
	public void addBendPoint(double x, double y, boolean isControlPoint) {
84
		bendPoints.add(new BendPoint(x, y, isControlPoint));
85
	}
86

    
87
	public List getBendPoints() {
88
		return this.bendPoints;
89
	}
90

    
91
	public void clearBendPoints() {
92
		// TODO Auto-generated method stub
93

    
94
	}
95

    
96
	public LayoutEntity getDestinationInLayout() {
97
		// TODO Auto-generated method stub
98
		return destination;
99
	}
100

    
101
	public Object getLayoutInformation() {
102
		// TODO Auto-generated method stub
103
		return layoutInfo;
104
	}
105

    
106
	public LayoutEntity getSourceInLayout() {
107
		// TODO Auto-generated method stub
108
		return source;
109
	}
110

    
111
	public void populateLayoutConstraint(LayoutConstraint constraint) {
112
		// TODO Auto-generated method stub
113

    
114
	}
115

    
116
	public void setBendPoints(LayoutBendPoint[] bendPoints) {
117
		// TODO Auto-generated method stub
118

    
119
	}
120

    
121
	public void setLayoutInformation(Object layoutInformation) {
122
		this.layoutInfo = layoutInformation;
123

    
124
	}
125

    
126
	public Object getGraphData() {
127
		return null;
128
	}
129

    
130
	public void setGraphData(Object o) {
131

    
132
	}
133

    
134
}
(6-6/6)