Last change
on this file since 974 was 974, checked in by bln4, 9 years ago |
Publicified one of the formatter strings so we can use it for comparing dates.
Attract and Repel Text can now be turned on and off via a static field
|
File size:
1.5 KB
|
Rev | Line | |
---|
[934] | 1 | package org.expeditee.items.MagneticConstraint.Actions;
|
---|
| 2 |
|
---|
[963] | 3 | import java.awt.Point;
|
---|
| 4 |
|
---|
| 5 | import org.expeditee.gui.FrameUtils;
|
---|
[934] | 6 | import org.expeditee.items.Item;
|
---|
| 7 | import org.expeditee.items.MagneticConstraint.MagneticConstraintActionWithArguments;
|
---|
| 8 | import org.expeditee.items.MagneticConstraint.Utilities.Line;
|
---|
| 9 |
|
---|
| 10 | public class AttractTextAction extends
|
---|
| 11 | MagneticConstraintActionWithArguments<Float> {
|
---|
| 12 |
|
---|
[974] | 13 | public static boolean Enabled = true;
|
---|
| 14 |
|
---|
[934] | 15 | @Override
|
---|
| 16 | public boolean exec(Item item) {
|
---|
| 17 | return exec(item, 0f);
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | @Override
|
---|
| 21 | public boolean exec(Item item, Float... args) {
|
---|
[974] | 22 | if(!Enabled || item == null || item.getParent() == null || item.getText().startsWith("@") || !isSpIDERCodePage(item.getParent())) {
|
---|
[934] | 23 | return false;
|
---|
| 24 | }
|
---|
[963] | 25 | if(FrameUtils.getCurrentItem() == null) return false;
|
---|
| 26 | final Point selectedItemPosition = FrameUtils.getCurrentItem().getPosition();
|
---|
| 27 | if(!selectedItemPosition.equals(item.getPosition())) return false;
|
---|
| 28 |
|
---|
| 29 | if(item.getMagnetizedItemRight() == -1) return false;
|
---|
| 30 | else if(item.getParent().getItemWithID(item.getMagnetizedItemRight()) == null) {
|
---|
[934] | 31 | item.setMagnetizedItemRight(null);
|
---|
| 32 | return false;
|
---|
[963] | 33 | } else {
|
---|
[934] | 34 | final Item toMyRight = item.getParent().getItemWithID(item.getMagnetizedItemRight());
|
---|
[963] | 35 | final Line toAttract = Line.getLineFromToken(toMyRight);
|
---|
| 36 | toAttract.deltaX(-args[0].intValue());
|
---|
[934] | 37 | return true;
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | @Override
|
---|
| 42 | public boolean invert(Item item) {
|
---|
| 43 | System.err.println("Attract text action does not have a inverted implementation.");
|
---|
| 44 | return false;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.