Skip to content

Method: static {...}

1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * blueMarine III: Semantic DAM
5: * http://tidalwave.it/projects/bluemarine3
6: *
7: * Copyright (C) 2024 - 2025 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/bluemarine3-src
22: * git clone https://github.com/tidalwave-it/bluemarine3-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.geo;
27:
28: import jakarta.annotation.Nonnull;
29: import java.util.Set;
30: import java.io.IOException;
31: import java.nio.file.Path;
32: import it.tidalwave.dam.model.Entity;
33: import it.tidalwave.dam.model.MimeType;
34: import it.tidalwave.dam.model.io.FileEntity;
35: import it.tidalwave.dam.model.spi.EntitySupport;
36: import it.tidalwave.dam.model.role.Loadable;
37: import it.tidalwave.ui.core.role.Displayable;
38: import it.tidalwave.util.As;
39: import it.tidalwave.util.Finder;
40:
41: /***************************************************************************************************************************************************************
42: *
43: * A set of segments composed by points, representing a track.
44: *
45: * @author Fabrizio Giudici
46: *
47: **************************************************************************************************************************************************************/
48: public interface GeoTrack extends Entity, Displayable
49: {
50: static class Prototype extends EntitySupport implements GeoTrack
51: {
52: @Override @Nonnull
53: public Finder<GeoTrackSegment> findSegments()
54: {
55: return Finder.empty();
56: }
57:
58: @Override @Nonnull
59: public RectangularArea getBoundingArea()
60: {
61: return Area.emptyRectangularArea();
62: }
63:
64: @Override @Nonnull
65: public String getDisplayName()
66: {
67: return "<prototype>";
68: }
69: }
70:
71: public static final As.Type<Loadable<GeoTrack>> _GeoTrackLoadable_ = As.type(Loadable.class);
72:
73: public static final GeoTrack PROTOTYPE = new Prototype();
74:
75: /***********************************************************************************************************************************************************
76: * {@return a prototype}.
77: **********************************************************************************************************************************************************/
78: @Nonnull
79: public static GeoTrack prototype()
80: {
81: return PROTOTYPE;
82: }
83:
84: /***********************************************************************************************************************************************************
85: * {@return a new instance loaded from the given file}.
86: * @param file the file
87: **********************************************************************************************************************************************************/
88: @Nonnull
89: public static GeoTrack of (@Nonnull final FileEntity file)
90: throws IOException
91: {
92: return (GeoTrack)Entity.of(prototype(), file);
93: }
94:
95: /***********************************************************************************************************************************************************
96: * {@return a new instance loaded from the given file}.
97: * @param path the file
98: **********************************************************************************************************************************************************/
99: @Nonnull
100: public static GeoTrack of (@Nonnull final Path path)
101: throws IOException
102: {
103: return of(FileEntity.of(path));
104: }
105:
106: /***********************************************************************************************************************************************************
107: * {@return the supported MIME types}.
108: **********************************************************************************************************************************************************/
109: @Nonnull
110: public static Set<MimeType> getSupportedMimeTypes()
111: {
112: return EntitySupport.getSupportedMimeTypes(prototype());
113: }
114:
115: /***********************************************************************************************************************************************************
116: * {@return the supported extensions}.
117: **********************************************************************************************************************************************************/
118: @Nonnull
119: public static Set<String> getSupportedExtensions()
120: {
121: return EntitySupport.getSupportedExtensions(prototype());
122: }
123:
124: /***********************************************************************************************************************************************************
125: * {@return a {@link Finder} for {@link GeoTrackSegment } children}.
126: **********************************************************************************************************************************************************/
127: @Nonnull
128: public Finder<GeoTrackSegment> findSegments();
129:
130: /***********************************************************************************************************************************************************
131: * {@return the smaller area containing the track}.
132: **********************************************************************************************************************************************************/
133: @Nonnull
134: public RectangularArea getBoundingArea();
135: }