Revision 45424
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/json/GeometryTypeJsonSerializer.java | ||
---|---|---|
1 |
/* |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2020 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
18 |
* |
|
19 |
* For any additional information, do not hesitate to contact us |
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
21 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.fmap.geom.jts.json; |
|
24 |
|
|
25 |
import javax.json.JsonObject; |
|
26 |
import org.apache.commons.lang3.StringUtils; |
|
27 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
28 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
29 |
import org.gvsig.json.Json; |
|
30 |
import org.gvsig.json.JsonManager; |
|
31 |
import org.gvsig.json.JsonObjectBuilder; |
|
32 |
import org.gvsig.tools.util.IsApplicable; |
|
33 |
|
|
34 |
/** |
|
35 |
* |
|
36 |
* @author gvSIG Team |
|
37 |
*/ |
|
38 |
@SuppressWarnings("UseSpecificCatch") |
|
39 |
public class GeometryTypeJsonSerializer implements JsonManager.JsonSerializer, IsApplicable { |
|
40 |
|
|
41 |
@Override |
|
42 |
public Class getObjectClass() { |
|
43 |
return GeometryType.class; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public Object toObject(JsonObject json) { |
|
48 |
try { |
|
49 |
int type = json.getInt("type"); |
|
50 |
int subtype = json.getInt("subtype"); |
|
51 |
return GeometryLocator.getGeometryManager().getGeometryType(type, subtype); |
|
52 |
} catch (Exception ex) { |
|
53 |
throw new IllegalArgumentException("Can't retrieve a GeometryType from JsonObject.", ex); |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public JsonObjectBuilder toJsonBuilder(Object value) { |
|
59 |
GeometryType geomType = (GeometryType) value; |
|
60 |
JsonObjectBuilder builder = Json.createObjectBuilder(); |
|
61 |
builder.add_class(GeometryType.class); |
|
62 |
this.addAll(builder, value); |
|
63 |
return builder; |
|
64 |
} |
|
65 |
|
|
66 |
private void addAll(JsonObjectBuilder target, Object source) { |
|
67 |
GeometryType geomType = (GeometryType) source; |
|
68 |
target.add("type", geomType.getType()); |
|
69 |
target.add("subtype", geomType.getSubType()); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public boolean isApplicable(Object... args) { |
|
74 |
if( args[0] instanceof GeometryType) { |
|
75 |
return true; |
|
76 |
} |
|
77 |
if( !(args[0] instanceof JsonObject) ) { |
|
78 |
return false; |
|
79 |
} |
|
80 |
JsonObject json = (JsonObject) args[0]; |
|
81 |
String className = json.getString(JsonManager.ATTRIBUTE_NAME_CLASS, null); |
|
82 |
return StringUtils.equalsIgnoreCase(className, GeometryType.class.getName()); |
|
83 |
} |
|
84 |
|
|
85 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/srs/SRSJsonSerializer.java | ||
---|---|---|
1 |
/* |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2020 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
18 |
* |
|
19 |
* For any additional information, do not hesitate to contact us |
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
21 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.srs; |
|
24 |
|
|
25 |
import javax.json.JsonObject; |
|
26 |
import org.apache.commons.lang3.StringUtils; |
|
27 |
import org.cresques.cts.IProjection; |
|
28 |
import org.gvsig.fmap.crs.CRSFactory; |
|
29 |
import org.gvsig.json.Json; |
|
30 |
import org.gvsig.json.JsonManager; |
|
31 |
import org.gvsig.json.JsonObjectBuilder; |
|
32 |
import org.gvsig.tools.util.IsApplicable; |
|
33 |
|
|
34 |
/** |
|
35 |
* |
|
36 |
* @author gvSIG Team |
|
37 |
*/ |
|
38 |
public class SRSJsonSerializer implements JsonManager.JsonSerializer, IsApplicable { |
|
39 |
|
|
40 |
@Override |
|
41 |
public Class getObjectClass() { |
|
42 |
return IProjection.class; |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
public Object toObject(JsonObject json) { |
|
47 |
IProjection proj = CRSFactory.getCRS(json.getString("fullcode")); |
|
48 |
return proj; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public JsonObjectBuilder toJsonBuilder(Object value) { |
|
53 |
IProjection proj = (IProjection) value; |
|
54 |
JsonObjectBuilder builder = Json.createObjectBuilder(); |
|
55 |
builder.add_class(IProjection.class); |
|
56 |
builder.add("abrev", proj.getAbrev()); |
|
57 |
builder.add("fullcode", proj.getFullCode()); |
|
58 |
return builder; |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public boolean isApplicable(Object... args) { |
|
63 |
if( args[0] instanceof IProjection) { |
|
64 |
return true; |
|
65 |
} |
|
66 |
if( !(args[0] instanceof JsonObject) ) { |
|
67 |
return false; |
|
68 |
} |
|
69 |
JsonObject json = (JsonObject) args[0]; |
|
70 |
String className = json.getString(JsonManager.ATTRIBUTE_NAME_CLASS, null); |
|
71 |
return StringUtils.equalsIgnoreCase(className, IProjection.class.getName()); |
|
72 |
} |
|
73 |
|
|
74 |
public static void selfRegister() { |
|
75 |
Json.registerSerializer(new SRSJsonSerializer()); |
|
76 |
} |
|
77 |
|
|
78 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.api/src/main/java/org/gvsig/fmap/dal/swing/featuretable/SimpleFeaturesTableModel.java | ||
---|---|---|
1 |
/* |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2020 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
18 |
* |
|
19 |
* For any additional information, do not hesitate to contact us |
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
21 |
*/ |
|
22 |
package org.gvsig.fmap.dal.swing.featuretable; |
|
23 |
|
|
24 |
import java.util.Iterator; |
|
25 |
import java.util.List; |
|
26 |
import javax.swing.JTable; |
|
27 |
import javax.swing.table.TableModel; |
|
28 |
import org.gvsig.fmap.dal.feature.Feature; |
|
29 |
import org.gvsig.tools.dispose.Disposable; |
|
30 |
import org.gvsig.tools.util.UnmodifiableBasicList; |
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
*/ |
|
36 |
public interface SimpleFeaturesTableModel extends TableModel, Disposable, UnmodifiableBasicList<Feature> { |
|
37 |
|
|
38 |
public List<Feature> getFeatures(); |
|
39 |
|
|
40 |
public boolean hasErrors(); |
|
41 |
|
|
42 |
public void setCellRenderers(JTable table); |
|
43 |
|
|
44 |
} |
Also available in: Unified diff