Skip to content
Snippets Groups Projects
Commit 6dacdff0 authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

also fixes corners

refs 2346
parent 0b9e76b5
No related branches found
No related tags found
No related merge requests found
...@@ -60,7 +60,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService; ...@@ -60,7 +60,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author aravantinos * @author aravantinos
* @author $Author$ * @author $Author$
* @version $Rev$ * @version $Rev$
* @ConQAT.Rating YELLOW Hash: 60245690315B7D65B464ADC89AC541B9 * @ConQAT.Rating YELLOW Hash: 70C42CF9316623FE28B2B7ABEAC08CB8
*/ */
public class DiagramKeyHandler extends KeyHandler { public class DiagramKeyHandler extends KeyHandler {
...@@ -167,18 +167,13 @@ public class DiagramKeyHandler extends KeyHandler { ...@@ -167,18 +167,13 @@ public class DiagramKeyHandler extends KeyHandler {
if((oo.getOrientation() == EOrientation.EAST || oo.getOrientation() == EOrientation.WEST) && if((oo.getOrientation() == EOrientation.EAST || oo.getOrientation() == EOrientation.WEST) &&
(event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP)) { (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP)) {
int newY = oo.getOffset() + scrollCoeff.y; int newY = oo.getOffset() + scrollCoeff.y;
if(newY >= 0 && newY < containerDim.getHeight() - DEFAULT_GRID_SIZE) { moveVertical(newY, containerDim, ep.getModel(), oo.getOrientation());
setStickyConnectorLayoutData(ep.getModel(),
oo.getOrientation(), newY);
}
} else if((oo.getOrientation() == EOrientation.NORTH || oo } else if((oo.getOrientation() == EOrientation.NORTH || oo
.getOrientation() == EOrientation.SOUTH) && .getOrientation() == EOrientation.SOUTH) &&
(event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT)) { (event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT)) {
int newX = oo.getOffset() + scrollCoeff.x; int newX = oo.getOffset() + scrollCoeff.x;
if(newX >= 0 && newX < containerDim.getWidth() - DEFAULT_GRID_SIZE) { moveHorizontal(newX, containerDim, ep.getModel(),
setStickyConnectorLayoutData(ep.getModel(), oo.getOrientation());
oo.getOrientation(), newX);
}
} }
} else { } else {
Angle angle = getConnectorAngle(ep.getModel()); Angle angle = getConnectorAngle(ep.getModel());
...@@ -195,6 +190,36 @@ public class DiagramKeyHandler extends KeyHandler { ...@@ -195,6 +190,36 @@ public class DiagramKeyHandler extends KeyHandler {
return true; return true;
} }
/** Moves the given layouted element vertically by the distance provided by offset. */
private void moveVertical(int offset, Dimension containerDim, ILayoutedModelElement layouted,
EOrientation orientation) {
int newOffset =
orientation == EOrientation.WEST ? 0 : containerDim.getWidth() - 2 *
DEFAULT_GRID_SIZE;
if(offset <= 0) {
setStickyConnectorLayoutData(layouted, EOrientation.NORTH, newOffset);
} else if(offset >= containerDim.getHeight() - 2 * DEFAULT_GRID_SIZE) {
setStickyConnectorLayoutData(layouted, EOrientation.SOUTH, newOffset);
} else {
setStickyConnectorLayoutData(layouted, orientation, offset);
}
}
/** Moves the given layouted element horizontally by the distance provided by offset. */
private void moveHorizontal(int offset, Dimension containerDim, ILayoutedModelElement layouted,
EOrientation orientation) {
int newOffset =
orientation == EOrientation.NORTH ? 0 : containerDim.getHeight() - 2 *
DEFAULT_GRID_SIZE;
if(offset <= 0) {
setStickyConnectorLayoutData(layouted, EOrientation.WEST, newOffset);
} else if(offset >= containerDim.getWidth() - 2 * DEFAULT_GRID_SIZE) {
setStickyConnectorLayoutData(layouted, EOrientation.EAST, newOffset);
} else {
setStickyConnectorLayoutData(layouted, orientation, offset);
}
}
/** Returns a coefficient of 1 if the SHIFT key is not pressed, 50 otherwise. */ /** Returns a coefficient of 1 if the SHIFT key is not pressed, 50 otherwise. */
private Point computeScrollCoeff(KeyEvent event) { private Point computeScrollCoeff(KeyEvent event) {
int coeff = (event.stateMask & SWT.SHIFT) == 0 ? 1 : 10; int coeff = (event.stateMask & SWT.SHIFT) == 0 ? 1 : 10;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment