17
17
package org .team2363 .helixnavigator .document ;
18
18
19
19
import java .io .File ;
20
- import java .util .List ;
20
+ import java .util .HashMap ;
21
+ import java .util .Map ;
21
22
import java .util .logging .Logger ;
22
23
24
+ import org .team2363 .helixnavigator .document .field .image .HFieldImage ;
25
+ import org .team2363 .helixnavigator .document .field .image .HReferenceFieldImage ;
26
+ import org .team2363 .helixnavigator .global .Standards ;
27
+
23
28
import com .jlbabilino .json .DeserializedJSONConstructor ;
24
29
import com .jlbabilino .json .DeserializedJSONObjectValue ;
25
30
import com .jlbabilino .json .DeserializedJSONTarget ;
26
31
import com .jlbabilino .json .JSONDeserializable ;
32
+ import com .jlbabilino .json .JSONEntry .JSONType ;
27
33
import com .jlbabilino .json .JSONSerializable ;
28
34
import com .jlbabilino .json .SerializedJSONObjectValue ;
29
- import com .jlbabilino .json .JSONEntry .JSONType ;
30
-
31
- import org .team2363 .helixnavigator .document .field .image .HFieldImage ;
32
- import org .team2363 .helixnavigator .document .field .image .HReferenceFieldImage ;
33
- import org .team2363 .helixnavigator .global .Standards ;
34
35
35
36
import javafx .beans .property .BooleanProperty ;
36
37
import javafx .beans .property .DoubleProperty ;
@@ -129,10 +130,22 @@ public HDocument() {
129
130
selectedPathIndex .addListener ((currentIndex , oldIndex , newIndex ) -> updateSelectedPath ());
130
131
}
131
132
133
+ // @DeserializedJSONConstructor
134
+ // public HDocument(@DeserializedJSONObjectValue(key = "paths") List<? extends HPath> initialPaths) {
135
+ // this();
136
+ // paths.setAll(initialPaths);
137
+ // }
138
+
132
139
@ DeserializedJSONConstructor
133
- public HDocument (@ DeserializedJSONObjectValue (key = "paths" ) List <? extends HPath > initialPaths ) {
140
+ public HDocument (@ DeserializedJSONObjectValue (key = "paths" ) Map < String , HPath > initialPathsMap ) {
134
141
this ();
135
- paths .setAll (initialPaths );
142
+
143
+ initialPathsMap .entrySet ().stream ().sorted ((a , b ) -> a .getKey ().compareTo (b .getKey ())).forEach (entry -> {
144
+ String pathName = entry .getKey ();
145
+ HPath path = entry .getValue ();
146
+ path .setName (pathName );
147
+ paths .add (path );
148
+ });
136
149
}
137
150
138
151
/**
@@ -222,12 +235,12 @@ public final DoubleProperty zoomScaleProperty() {
222
235
return zoomScale ;
223
236
}
224
237
225
- @ DeserializedJSONTarget
238
+ // @DeserializedJSONTarget
226
239
public final void setZoomScale (@ DeserializedJSONObjectValue (key = "zoom_scale" ) double value ) {
227
240
zoomScale .set (value );
228
241
}
229
242
230
- @ SerializedJSONObjectValue (key = "zoom_scale" )
243
+ // @SerializedJSONObjectValue(key = "zoom_scale")
231
244
public final double getZoomScale () {
232
245
return zoomScale .get ();
233
246
}
@@ -236,12 +249,12 @@ public final DoubleProperty zoomTranslateXProperty() {
236
249
return zoomTranslateX ;
237
250
}
238
251
239
- @ DeserializedJSONTarget
252
+ // @DeserializedJSONTarget
240
253
public final void setZoomTranslateX (@ DeserializedJSONObjectValue (key = "zoom_translate_x" ) double value ) {
241
254
zoomTranslateX .set (value );
242
255
}
243
256
244
- @ SerializedJSONObjectValue (key = "zoom_translate_x" )
257
+ // @SerializedJSONObjectValue(key = "zoom_translate_x")
245
258
public final double getZoomTranslateX () {
246
259
return zoomTranslateX .get ();
247
260
}
@@ -250,21 +263,30 @@ public final DoubleProperty zoomTranslateYProperty() {
250
263
return zoomTranslateY ;
251
264
}
252
265
253
- @ DeserializedJSONTarget
266
+ // @DeserializedJSONTarget
254
267
public final void setZoomTranslateY (@ DeserializedJSONObjectValue (key = "zoom_translate_y" ) double value ) {
255
268
zoomTranslateY .set (value );
256
269
}
257
270
258
- @ SerializedJSONObjectValue (key = "zoom_translate_y" )
271
+ // @SerializedJSONObjectValue(key = "zoom_translate_y")
259
272
public final double getZoomTranslateY () {
260
273
return zoomTranslateY .get ();
261
274
}
262
275
263
- @ SerializedJSONObjectValue (key = "paths" )
276
+ // @SerializedJSONObjectValue(key = "paths")
264
277
public final ObservableList <HPath > getPaths () {
265
278
return paths ;
266
279
}
267
280
281
+ @ SerializedJSONObjectValue (key = "paths" )
282
+ public final Map <String , HPath > getPathsMap () {
283
+ Map <String , HPath > map = new HashMap <>(getPaths ().size ());
284
+ for (HPath path : getPaths ()) {
285
+ map .put (path .getName (), path );
286
+ }
287
+ return map ;
288
+ }
289
+
268
290
public final ReadOnlyIntegerProperty selectedPathIndexProperty () {
269
291
return selectedPathIndex .getReadOnlyProperty ();
270
292
}
0 commit comments