1 | package org.expeditee.items.MagneticConstraint;
|
---|
2 |
|
---|
3 | import org.expeditee.items.Item;
|
---|
4 |
|
---|
5 | public class MagneticConstraints {
|
---|
6 | private static MagneticConstraints instance = null;
|
---|
7 |
|
---|
8 | private MagneticConstraintAction rightBorderHitAction = null;
|
---|
9 | private MagneticConstraintAction endOfLineHitAction = null;
|
---|
10 | private MagneticConstraintAction leftBorderHitAction = null;
|
---|
11 | private MagneticConstraintAction startOfLineHitAction = null;
|
---|
12 | private MagneticConstraintActionWithArguments<Float> textShrunkAction = null;
|
---|
13 | private MagneticConstraintActionWithArguments<Float> textGrownAction = null;
|
---|
14 |
|
---|
15 | public static MagneticConstraints getInstance() {
|
---|
16 | if (instance == null) {
|
---|
17 | instance = new MagneticConstraints();
|
---|
18 | return instance;
|
---|
19 | } else
|
---|
20 | return instance;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public boolean rightBorderHit(final Item item) {
|
---|
24 | if (rightBorderHitAction != null)
|
---|
25 | return rightBorderHitAction.exec(item);
|
---|
26 | else
|
---|
27 | return false;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public void setRightBorderHitAction(final MagneticConstraintAction action) {
|
---|
31 | rightBorderHitAction = action;
|
---|
32 | }
|
---|
33 |
|
---|
34 | public boolean endOfLineHit(final Item item) {
|
---|
35 | if (endOfLineHitAction != null)
|
---|
36 | return endOfLineHitAction.exec(item);
|
---|
37 | else
|
---|
38 | return false;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public void setEndOfLineHitAction(final MagneticConstraintAction action) {
|
---|
42 | endOfLineHitAction = action;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public boolean leftBorderHit(final Item item) {
|
---|
46 | if (leftBorderHitAction != null)
|
---|
47 | return leftBorderHitAction.exec(item);
|
---|
48 | else
|
---|
49 | return false;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public void setLeftBorderHitAction(final MagneticConstraintAction action) {
|
---|
53 | leftBorderHitAction = action;
|
---|
54 | }
|
---|
55 |
|
---|
56 | public boolean startOfLineHit(final Item item) {
|
---|
57 | if (startOfLineHitAction != null)
|
---|
58 | return startOfLineHitAction.exec(item);
|
---|
59 | else
|
---|
60 | return false;
|
---|
61 | }
|
---|
62 |
|
---|
63 | public void setStartOfLineHitAction(final MagneticConstraintAction action) {
|
---|
64 | startOfLineHitAction = action;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public boolean textShrunk(final Item item, final float delta) {
|
---|
68 | if(textShrunkAction != null)
|
---|
69 | return textShrunkAction.exec(item, delta);
|
---|
70 | else return false;
|
---|
71 | }
|
---|
72 |
|
---|
73 | public void setTextShrunkAction(final MagneticConstraintActionWithArguments<Float> action) {
|
---|
74 | textShrunkAction = action;
|
---|
75 | }
|
---|
76 |
|
---|
77 | public boolean textGrown(final Item item, final float delta) {
|
---|
78 | if(textGrownAction != null)
|
---|
79 | return textGrownAction.exec(item, delta);
|
---|
80 | else return false;
|
---|
81 | }
|
---|
82 |
|
---|
83 | public void setTextGrownAction(final MagneticConstraintActionWithArguments<Float> action) {
|
---|
84 | textGrownAction = action;
|
---|
85 | }
|
---|
86 | }
|
---|