Added the touring API.
Updownquark
13 years ago
0 | /* | |
1 | * AnimatedUpdate.java Created Oct 12, 2010 by Andrew Butler, PSL | |
2 | */ | |
3 | package org.boehn.kmlframework.kml.ext; | |
4 | ||
5 | public class AnimatedUpdate extends TourPrimitive | |
6 | { | |
7 | private Double duration; | |
8 | ||
9 | private org.boehn.kmlframework.kml.Update update; | |
10 | ||
11 | public AnimatedUpdate(org.boehn.kmlframework.kml.Update update) | |
12 | { | |
13 | this.update = update; | |
14 | if(this.update.getTargetHref() == null) | |
15 | this.update.setTargetHref(""); | |
16 | } | |
17 | ||
18 | public Double getDuration() | |
19 | { | |
20 | return duration; | |
21 | } | |
22 | ||
23 | public void setDuration(Double duration) | |
24 | { | |
25 | this.duration = duration; | |
26 | } | |
27 | ||
28 | public org.boehn.kmlframework.kml.Update getUpdate() | |
29 | { | |
30 | return update; | |
31 | } | |
32 | ||
33 | public void setUpdate(org.boehn.kmlframework.kml.Update update) | |
34 | { | |
35 | this.update = update; | |
36 | } | |
37 | ||
38 | @Override | |
39 | public void write(org.boehn.kmlframework.kml.Kml kml) | |
40 | throws org.boehn.kmlframework.kml.KmlException | |
41 | { | |
42 | kml.println("<gx:AnimatedUpdate" + getIdAndTargetIdFormatted(kml) + ">", 1); | |
43 | if(duration != null) | |
44 | kml.println("<gx:duration>" + duration + "</gx:duration>"); | |
45 | update.write(kml); | |
46 | kml.println(-1, "</gx:AnimatedUpdate>"); | |
47 | } | |
48 | } |
0 | /* | |
1 | * FlyTo.java Created Oct 12, 2010 by Andrew Butler, PSL | |
2 | */ | |
3 | package org.boehn.kmlframework.kml.ext; | |
4 | ||
5 | public class FlyTo extends TourPrimitive | |
6 | { | |
7 | public static enum FlyToMode | |
8 | { | |
9 | BOUNCE("bounce"), SMOOTH("smooth"); | |
10 | ||
11 | public final String kml; | |
12 | ||
13 | FlyToMode(String kml) | |
14 | { | |
15 | this.kml = kml; | |
16 | } | |
17 | } | |
18 | ||
19 | private Double duration; | |
20 | ||
21 | private FlyToMode flyToMode; | |
22 | ||
23 | private org.boehn.kmlframework.kml.AbstractView view; | |
24 | ||
25 | public FlyTo(org.boehn.kmlframework.kml.AbstractView view) | |
26 | { | |
27 | this.view = view; | |
28 | flyToMode = FlyToMode.BOUNCE; | |
29 | } | |
30 | ||
31 | public Double getDuration() | |
32 | { | |
33 | return duration; | |
34 | } | |
35 | ||
36 | public void setDuration(Double duration) | |
37 | { | |
38 | this.duration = duration; | |
39 | } | |
40 | ||
41 | public FlyToMode getFlyToMode() | |
42 | { | |
43 | return flyToMode; | |
44 | } | |
45 | ||
46 | public void setFlyToMode(FlyToMode flyToMode) | |
47 | { | |
48 | this.flyToMode = flyToMode; | |
49 | } | |
50 | ||
51 | public org.boehn.kmlframework.kml.AbstractView getView() | |
52 | { | |
53 | return view; | |
54 | } | |
55 | ||
56 | public void setView(org.boehn.kmlframework.kml.AbstractView view) | |
57 | { | |
58 | this.view = view; | |
59 | } | |
60 | ||
61 | public void write(org.boehn.kmlframework.kml.Kml kml) | |
62 | throws org.boehn.kmlframework.kml.KmlException | |
63 | { | |
64 | kml.println("<gx:FlyTo" + getIdAndTargetIdFormatted(kml) + ">", 1); | |
65 | if(duration != null) | |
66 | kml.println("<gx:duration>" + duration + "</gx:duration>"); | |
67 | if(flyToMode != null) | |
68 | kml.println("<gx:flyToMode>" + flyToMode.kml + "</gx:flyToMode>"); | |
69 | view.write(kml); | |
70 | kml.println(-1, "</gx:FlyTo>"); | |
71 | } | |
72 | ||
73 | public void writeDelete(org.boehn.kmlframework.kml.Kml kml) | |
74 | throws org.boehn.kmlframework.kml.KmlException | |
75 | { | |
76 | kml.println("<gx:FlyTo" + getIdAndTargetIdFormatted(kml) + "></gx:FlyTo>"); | |
77 | } | |
78 | } |
0 | /* | |
1 | * Playlist.java Created Oct 12, 2010 by Andrew Butler, PSL | |
2 | */ | |
3 | package org.boehn.kmlframework.kml.ext; | |
4 | ||
5 | public class Playlist extends org.boehn.kmlframework.kml.KmlObject | |
6 | { | |
7 | private final java.util.ArrayList<TourPrimitive> elements; | |
8 | ||
9 | public Playlist() | |
10 | { | |
11 | elements = new java.util.ArrayList<TourPrimitive>(); | |
12 | } | |
13 | ||
14 | public java.util.List<TourPrimitive> getElements() | |
15 | { | |
16 | return elements; | |
17 | } | |
18 | ||
19 | public void write(org.boehn.kmlframework.kml.Kml kml) | |
20 | throws org.boehn.kmlframework.kml.KmlException | |
21 | { | |
22 | kml.println("<gx:Playlist" + getIdAndTargetIdFormatted(kml) + ">", 1); | |
23 | for(TourPrimitive element : elements) | |
24 | element.write(kml); | |
25 | kml.println(-1, "</gx:Playlist>"); | |
26 | } | |
27 | ||
28 | public void writeDelete(org.boehn.kmlframework.kml.Kml kml) | |
29 | throws org.boehn.kmlframework.kml.KmlException | |
30 | { | |
31 | kml.println("<gx:Playlist" + getIdAndTargetIdFormatted(kml) + "></gx:Playlist>"); | |
32 | } | |
33 | } |
0 | /* | |
1 | * SoundCue.java Created Oct 12, 2010 by Andrew Butler, PSL | |
2 | */ | |
3 | package org.boehn.kmlframework.kml.ext; | |
4 | ||
5 | public class SoundCue extends TourPrimitive | |
6 | { | |
7 | private String href; | |
8 | ||
9 | public SoundCue(String href) | |
10 | { | |
11 | this.href = href; | |
12 | } | |
13 | ||
14 | public String getHref() | |
15 | { | |
16 | return href; | |
17 | } | |
18 | ||
19 | public void setHref(String href) | |
20 | { | |
21 | this.href = href; | |
22 | } | |
23 | ||
24 | @Override | |
25 | public void write(org.boehn.kmlframework.kml.Kml kml) | |
26 | throws org.boehn.kmlframework.kml.KmlException | |
27 | { | |
28 | kml.println("<gx:SoundCue" + getIdAndTargetIdFormatted(kml) + ">", 1); | |
29 | kml.println("<href>" + href + "</href>"); | |
30 | kml.println(-1, "</gx:SoundCue>"); | |
31 | } | |
32 | } |
0 | /* | |
1 | * Tour.java Created Oct 12, 2010 by Andrew Butler, PSL | |
2 | */ | |
3 | package org.boehn.kmlframework.kml.ext; | |
4 | ||
5 | import org.boehn.kmlframework.kml.Kml; | |
6 | ||
7 | public class Tour extends org.boehn.kmlframework.kml.Feature | |
8 | { | |
9 | private Playlist playlist; | |
10 | ||
11 | public Playlist getPlaylist() | |
12 | { | |
13 | return playlist; | |
14 | } | |
15 | ||
16 | public void setPlaylist(Playlist playlist) | |
17 | { | |
18 | this.playlist = playlist; | |
19 | } | |
20 | ||
21 | public void write(Kml kml) throws org.boehn.kmlframework.kml.KmlException | |
22 | { | |
23 | kml.println("<gx:Tour" + getIdAndTargetIdFormatted(kml) + ">", 1); | |
24 | if(getName() != null) | |
25 | kml.println("<name>" + getName() + "</name>"); | |
26 | if(getDescription() != null) | |
27 | kml.println("<description>" + getDescription() + "</description>"); | |
28 | if(playlist != null) | |
29 | playlist.write(kml); | |
30 | kml.println(-1, "</gx:Tour>"); | |
31 | } | |
32 | ||
33 | public void writeDelete(Kml kml) throws org.boehn.kmlframework.kml.KmlException | |
34 | { | |
35 | kml.println("<gx:Tour" + getIdAndTargetIdFormatted(kml) + "></gx:Tour>"); | |
36 | } | |
37 | } |
0 | /* | |
1 | * TourControl.java Created Oct 12, 2010 by Andrew Butler, PSL | |
2 | */ | |
3 | package org.boehn.kmlframework.kml.ext; | |
4 | ||
5 | public class TourControl extends TourPrimitive | |
6 | { | |
7 | public static enum PlayModeEnum | |
8 | { | |
9 | PAUSE("pause"); | |
10 | ||
11 | public final String kml; | |
12 | ||
13 | PlayModeEnum(String kml) | |
14 | { | |
15 | this.kml = kml; | |
16 | } | |
17 | } | |
18 | ||
19 | private PlayModeEnum playMode; | |
20 | ||
21 | /** Shortened form for creating a pause */ | |
22 | public TourControl() | |
23 | { | |
24 | this(PlayModeEnum.PAUSE); | |
25 | } | |
26 | ||
27 | public TourControl(PlayModeEnum playMode) | |
28 | { | |
29 | this.playMode = playMode; | |
30 | } | |
31 | ||
32 | @Override | |
33 | public void write(org.boehn.kmlframework.kml.Kml kml) | |
34 | throws org.boehn.kmlframework.kml.KmlException | |
35 | { | |
36 | kml.println("<gx:TourControl" + getIdAndTargetIdFormatted(kml) + ">", 1); | |
37 | kml.println("<gx:playMode>" + playMode.kml + "</gx:playMode>"); | |
38 | kml.println(-1, "</gx:TourControl>"); | |
39 | } | |
40 | } |
0 | /* | |
1 | * TourPrimitive.java Created Oct 12, 2010 by Andrew Butler, PSL | |
2 | */ | |
3 | package org.boehn.kmlframework.kml.ext; | |
4 | ||
5 | public abstract class TourPrimitive extends org.boehn.kmlframework.kml.KmlObject | |
6 | { | |
7 | } |
0 | /* | |
1 | * Wait.java Created Oct 12, 2010 by Andrew Butler, PSL | |
2 | */ | |
3 | package org.boehn.kmlframework.kml.ext; | |
4 | ||
5 | public class Wait extends TourPrimitive | |
6 | { | |
7 | private double duration; | |
8 | ||
9 | public Wait(double duration) | |
10 | { | |
11 | this.duration = duration; | |
12 | } | |
13 | ||
14 | public double getDuration() | |
15 | { | |
16 | return duration; | |
17 | } | |
18 | ||
19 | public void setDuration(double duration) | |
20 | { | |
21 | this.duration = duration; | |
22 | } | |
23 | ||
24 | public void write(org.boehn.kmlframework.kml.Kml kml) | |
25 | throws org.boehn.kmlframework.kml.KmlException | |
26 | { | |
27 | kml.println("<gx:Wait" + getIdAndTargetIdFormatted(kml) + ">", 1); | |
28 | kml.println("<gx:duration>" + duration + "</gx:duration>"); | |
29 | kml.println(-1, "</gx:Wait>"); | |
30 | } | |
31 | ||
32 | public void writeDelete(org.boehn.kmlframework.kml.Kml kml) | |
33 | throws org.boehn.kmlframework.kml.KmlException | |
34 | { | |
35 | kml.println("<gx:Wait" + getIdAndTargetIdFormatted(kml) + "></gx:Wait>"); | |
36 | } | |
37 | } |