|
1 | | -package ch.bailu.aat_lib.service.editor; |
| 1 | +package ch.bailu.aat_lib.service.editor |
2 | 2 |
|
3 | | -import ch.bailu.aat_lib.gpx.GpxList; |
4 | | -import ch.bailu.aat_lib.gpx.GpxPointNode; |
5 | | -import ch.bailu.aat_lib.gpx.interfaces.GpxPointInterface; |
6 | | -import ch.bailu.aat_lib.gpx.interfaces.GpxType; |
| 3 | +import ch.bailu.aat_lib.gpx.GpxList |
| 4 | +import ch.bailu.aat_lib.gpx.GpxPointNode |
| 5 | +import ch.bailu.aat_lib.gpx.interfaces.GpxPointInterface |
| 6 | +import ch.bailu.aat_lib.gpx.interfaces.GpxType |
7 | 7 |
|
8 | | -public final class GpxEditor { |
9 | | - |
10 | | - private final EditorRing ring; |
11 | | - |
12 | | - public GpxEditor(GpxList list) { |
13 | | - if (list.getPointList().size() > 0) { |
14 | | - ring = new EditorRing((new NodeEditor((GpxPointNode) list.getPointList().getFirst(), |
15 | | - list))); |
16 | | - } else { |
17 | | - ring = new EditorRing(new NodeEditor()); |
18 | | - } |
| 8 | +class GpxEditor(list: GpxList) { |
| 9 | + private val ring: EditorRing = if (list.pointList.size() > 0) { |
| 10 | + EditorRing( |
| 11 | + (NodeEditor( |
| 12 | + (list.pointList.first as GpxPointNode?)!!, |
| 13 | + list |
| 14 | + )) |
| 15 | + ) |
| 16 | + } else { |
| 17 | + EditorRing(NodeEditor()) |
19 | 18 | } |
20 | 19 |
|
21 | | - public void select(GpxPointNode point, GpxList list) { |
22 | | - ring.set(new NodeEditor(point, list)); |
| 20 | + fun select(point: GpxPointNode, list: GpxList) { |
| 21 | + ring.set(NodeEditor(point, list)) |
23 | 22 | } |
24 | 23 |
|
25 | | - public void clear() { |
26 | | - ring.add(new NodeEditor()); |
| 24 | + fun clear() { |
| 25 | + ring.add(NodeEditor()) |
27 | 26 | } |
28 | 27 |
|
29 | | - public void unlinkSelectedNode() { |
30 | | - ring.add(ring.get().unlink()); |
| 28 | + fun unlinkSelectedNode() { |
| 29 | + ring.add(ring.get().unlink()) |
31 | 30 | } |
32 | 31 |
|
33 | | - public void insertNode(GpxPointInterface point) { |
34 | | - ring.add(ring.get().insert(point)); |
| 32 | + fun insertNode(point: GpxPointInterface) { |
| 33 | + ring.add(ring.get().insert(point)) |
35 | 34 | } |
36 | 35 |
|
37 | | - public void moveSelectedUp() { |
38 | | - GpxPointInterface point = ring.get().getPoint(); |
| 36 | + fun moveSelectedUp() { |
| 37 | + val point: GpxPointInterface = ring.get().point |
39 | 38 |
|
40 | | - ring.add(ring.get().unlink()); |
41 | | - ring.set(ring.get().previous()); |
42 | | - ring.set(ring.get().insert(point)); |
| 39 | + ring.add(ring.get().unlink()) |
| 40 | + ring.set(ring.get().previous()) |
| 41 | + ring.set(ring.get().insert(point)) |
43 | 42 | } |
44 | 43 |
|
45 | | - public void moveSelectedDown() { |
46 | | - GpxPointInterface point = ring.get().getPoint(); |
47 | | - |
48 | | - ring.add(ring.get().unlink()); |
49 | | - ring.set(ring.get().next()); |
50 | | - ring.set(ring.get().insert(point)); |
| 44 | + fun moveSelectedDown() { |
| 45 | + val point: GpxPointInterface = ring.get().point |
51 | 46 |
|
| 47 | + ring.add(ring.get().unlink()) |
| 48 | + ring.set(ring.get().next()) |
| 49 | + ring.set(ring.get().insert(point)) |
52 | 50 | } |
53 | 51 |
|
54 | | - public GpxList getList() { |
55 | | - return ring.get().getList(); |
56 | | - } |
| 52 | + val list: GpxList |
| 53 | + get() = ring.get().list |
57 | 54 |
|
58 | | - public GpxPointNode getSelectedPoint() { |
59 | | - return ring.get().getPoint(); |
60 | | - } |
| 55 | + val selectedPoint: GpxPointNode |
| 56 | + get() = ring.get().point |
61 | 57 |
|
62 | | - public void setType(GpxType type) { |
63 | | - ring.get().getList().setType(type); |
| 58 | + fun setType(type: GpxType) { |
| 59 | + ring.get().list.setType(type) |
64 | 60 | } |
65 | 61 |
|
66 | | - public boolean undo() { |
67 | | - return ring.undo(); |
| 62 | + fun undo(): Boolean { |
| 63 | + return ring.undo() |
68 | 64 | } |
69 | 65 |
|
70 | | - public boolean redo() { |
71 | | - return ring.redo(); |
| 66 | + fun redo(): Boolean { |
| 67 | + return ring.redo() |
72 | 68 | } |
73 | 69 |
|
74 | | - public void simplify() { |
75 | | - ring.add(ring.get().simplify()); |
| 70 | + fun simplify() { |
| 71 | + ring.add(ring.get().simplify()) |
76 | 72 | } |
77 | 73 |
|
78 | | - public void fix() { |
79 | | - ring.add(ring.get().fix()); |
| 74 | + fun fix() { |
| 75 | + ring.add(ring.get().fix()) |
80 | 76 | } |
81 | 77 |
|
82 | | - public void inverse() { |
83 | | - ring.add(ring.get().inverse()); |
| 78 | + fun inverse() { |
| 79 | + ring.add(ring.get().inverse()) |
84 | 80 | } |
85 | 81 |
|
86 | | - public void attach(GpxList toAttach) { |
87 | | - ring.add(ring.get().attach(toAttach)); |
| 82 | + fun attach(toAttach: GpxList) { |
| 83 | + ring.add(ring.get().attach(toAttach)) |
88 | 84 | } |
89 | 85 |
|
90 | | - public void cutPreceding() { |
91 | | - ring.add(ring.get().cutPreciding()); |
| 86 | + fun cutPreceding() { |
| 87 | + ring.add(ring.get().cutPreceding()) |
92 | 88 | } |
93 | 89 |
|
94 | | - public void cutRemaining() { |
95 | | - ring.add(ring.get().cutRemaining()); |
| 90 | + fun cutRemaining() { |
| 91 | + ring.add(ring.get().cutRemaining()) |
96 | 92 | } |
97 | 93 | } |
0 commit comments