blob: 97a2a35be4e17824f7a4069e4e2527468bcb01a8 (
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
|
/*******************************************************************************
* Copyright (c) 2012 THALES GLOBAL SERVICES.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.diagram.business.internal.bracket.locators;
import org.eclipse.draw2d.BendpointLocator;
import org.eclipse.draw2d.Connection;
import org.eclipse.sirius.diagram.business.internal.bracket.BracketConnectionQuery;
/**
* A BendpointHandle that is used to rotate an existing bendpoint.
*
* @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
*/
public class BendpointRotateLocator extends BendpointLocator {
/**
* Default constructor.
*
* @param connection
* the dimension {@link Connection} on which do a rotate.
* @param index
* the index of the bendpoint.
*/
public BendpointRotateLocator(Connection connection, int index) {
super(connection, index);
}
/**
* Overridden to change the index in case we have only 2 point in the
* {@link Connection#getPoints()}. {@inheritDoc}
*/
@Override
protected int getIndex() {
int index = super.getIndex();
final Connection connection = getConnection();
if (connection.getPoints().size() == 2) {
if (index == BracketConnectionQuery.ORIGIN_POINT_INDEX) {
index = 0;
} else if (index == BracketConnectionQuery.TARGET_POINT_INDEX) {
index = 1;
}
}
return index;
}
}
|