Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ea9c675cc4138a4a6c347303cae3cdef824feb3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*****************************************************************************
 * Copyright (c) 2009 Atos Origin.
 *
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Allanic Alexia (Atos Origin) alexia.allanic@atosorigin.com - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.layout.algorithms.horizontalsymmetryalgorithm;

/**
 * The Class HorizontalSymmetryLayoutAlgorithm.
 */
public class HorizontalSymmetryLayoutAlgorithm extends AbstractLayoutAlgorithm {

	/**
	 * Instantiates a new horizontal symmetry layout algorithm.
	 *
	 * @param styles
	 *            the styles
	 */
	public HorizontalSymmetryLayoutAlgorithm(int styles) {
		super(styles);
	}

	/**
	 * Instantiates a new horizontal symmetry layout algorithm.
	 */
	public HorizontalSymmetryLayoutAlgorithm() {
		this(LayoutStyles.NONE);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#applyLayoutInternal(org.eclipse
	 * .zest.layouts.dataStructures.InternalNode[],
	 * org.eclipse.zest.layouts.dataStructures.InternalRelationship[], double, double, double,
	 * double)
	 */
	@Override
	protected void applyLayoutInternal(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider,
			double boundsX, double boundsY, double boundsWidth, double boundsHeight) {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#getCurrentLayoutStep()
	 */
	@Override
	protected int getCurrentLayoutStep() {
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#getTotalNumberOfLayoutSteps()
	 */
	@Override
	protected int getTotalNumberOfLayoutSteps() {
		return 0;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#isValidConfiguration(boolean,
	 * boolean)
	 */
	@Override
	protected boolean isValidConfiguration(boolean asynchronous, boolean continuous) {
		if (asynchronous && continuous) {
			return false;
		} else if (asynchronous && !continuous) {
			return true;
		} else if (!asynchronous && continuous) {
			return false;
		} else if (!asynchronous && !continuous) {
			return true;
		}

		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#postLayoutAlgorithm(org.eclipse
	 * .zest.layouts.dataStructures.InternalNode[],
	 * org.eclipse.zest.layouts.dataStructures.InternalRelationship[])
	 */
	@Override
	protected void postLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider) {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#preLayoutAlgorithm(org.eclipse
	 * .zest.layouts.dataStructures.InternalNode[],
	 * org.eclipse.zest.layouts.dataStructures.InternalRelationship[], double, double, double,
	 * double)
	 */
	@Override
	protected void preLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider,
			double x, double y, double width, double height) {
		double middle = calculateMiddleArea(y, height);
		for (InternalNode node : entitiesToLayout) {
			// node.setLocationInLayout(node.getXInLayout(),middle+(middle - node.getYInLayout()));
			node.setLocation(node.getInternalX(), (middle + (middle - node.getInternalY())) - node.getHeightInLayout());
			// node.setInternalLocation(node.getXInLayout(), middle+(middle - node.getYInLayout()));
		}
	}

	/**
	 * Calculate middle area.
	 *
	 * @param y
	 *            the y
	 * @param height
	 *            the height
	 *
	 * @return the double
	 */
	private double calculateMiddleArea(double y, double height) {
		return y + ((height - y) / 2);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm#setLayoutArea(double,
	 * double, double, double)
	 */
	@Override
	public void setLayoutArea(double x, double y, double width, double height) {

	}

}

Back to the top