source: trunk/src/org/expeditee/items/MagneticConstraint/Actions/VerticalTabAction.java@ 1102

Last change on this file since 1102 was 1102, checked in by davidb, 6 years ago

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

File size: 1.3 KB
Line 
1package org.expeditee.items.MagneticConstraint.Actions;
2
3import org.expeditee.gio.EcosystemManager;
4import org.expeditee.gui.DisplayController;
5import org.expeditee.items.Item;
6import org.expeditee.items.MagneticConstraint.MagneticConstraintAction;
7import org.expeditee.items.MagneticConstraint.Utilities.Line;
8
9public class VerticalTabAction extends MagneticConstraintAction {
10
11 @Override
12 public boolean exec(final Item item) {
13 if(item.getParent() == null || !this.isSpIDERCodePage(item.getParent())) return false;
14 final int tabWidth = EcosystemManager.getTextLayoutManager().getStringWidth(null, " ");
15 tab(item, tabWidth);
16 return true;
17 }
18
19 @Override
20 public boolean invert(Item item) {
21 if(item.getParent() == null || !this.isSpIDERCodePage(item.getParent())) return false;
22 final int tabWidth = -(EcosystemManager.getTextLayoutManager().getStringWidth(null, " "));
23 tab(item, tabWidth);
24 return true;
25 }
26
27 private void tab(final Item item, final int tabWidth) {
28 if(item == null) {
29 DisplayController.setCursorPosition(DisplayController.getMouseX() + tabWidth, DisplayController.getMouseY());
30 } else {
31 final Line postTabLine = Line.getLineFromToken(item);
32 postTabLine.deltaX(tabWidth);
33 if(postTabLine.size() > 0)
34 DisplayController.setCursorPosition(postTabLine.get(0).getPosition());
35 }
36 }
37}
Note: See TracBrowser for help on using the repository browser.