Revision 8828
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg.legend/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.fmap.dal.file.jpg.legend.JpgLegendLibrary |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg.legend/src/main/java/org/gvsig/fmap/dal/file/jpg/legend/JpgGetLegend.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.file.jpg.legend; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.file.jpg.JpgStoreProvider; |
|
4 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
5 |
import org.gvsig.raster.lib.legend.api.RasterLegend; |
|
6 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
7 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
8 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
|
9 |
import org.gvsig.tools.ToolsLocator; |
|
10 |
import org.gvsig.tools.dynobject.DynClass; |
|
11 |
import org.gvsig.tools.dynobject.DynMethod; |
|
12 |
import org.gvsig.tools.dynobject.DynObject; |
|
13 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
14 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
15 |
|
|
16 |
/** |
|
17 |
* @author fdiaz |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class JpgGetLegend implements DynMethod { |
|
21 |
|
|
22 |
private static Integer code = null; |
|
23 |
|
|
24 |
|
|
25 |
static void register(DynClass storeClass) { |
|
26 |
if (code != null) { |
|
27 |
return; |
|
28 |
} |
|
29 |
code = ToolsLocator.getDynObjectManager() |
|
30 |
.registerDynMethod(storeClass, new JpgGetLegend()); |
|
31 |
|
|
32 |
} |
|
33 |
|
|
34 |
@Override |
|
35 |
public int getCode() throws DynMethodNotSupportedException { |
|
36 |
return code; |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public String getDescription() { |
|
41 |
return "JPG Legend"; |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public String getName() { |
|
46 |
return RasterStore.DYNMETHOD_GETLEGEND_NAME; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public Object invoke(DynObject self, Object[] args) |
|
51 |
throws DynMethodException { |
|
52 |
try { |
|
53 |
JpgStoreProvider provider=(JpgStoreProvider)self; |
|
54 |
RasterLegendManager legendManager=RasterLegendLocator.getRasterLegendManager(); |
|
55 |
|
|
56 |
ColorInterpretation colorInterpretation =(ColorInterpretation)provider. |
|
57 |
invokeDynMethod(RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME, null); |
|
58 |
|
|
59 |
RasterLegend legend= legendManager.createLegend(colorInterpretation); |
|
60 |
|
|
61 |
return legend; |
|
62 |
|
|
63 |
} catch (DynMethodNotSupportedException e) { |
|
64 |
//FIXME |
|
65 |
throw new RuntimeException(e); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public Object clone() throws CloneNotSupportedException { |
|
71 |
return super.clone(); |
|
72 |
} |
|
73 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg.legend/src/main/java/org/gvsig/fmap/dal/file/jpg/legend/JpgLegendLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
*/ |
|
31 |
package org.gvsig.fmap.dal.file.jpg.legend; |
|
32 |
|
|
33 |
import org.gvsig.fmap.dal.DALLibrary; |
|
34 |
import org.gvsig.fmap.dal.file.jpg.JpgLibrary; |
|
35 |
import org.gvsig.fmap.dal.file.jpg.JpgStoreProvider; |
|
36 |
import org.gvsig.metadata.MetadataLibrary; |
|
37 |
import org.gvsig.metadata.MetadataLocator; |
|
38 |
import org.gvsig.tools.dynobject.DynClass; |
|
39 |
import org.gvsig.tools.library.AbstractLibrary; |
|
40 |
import org.gvsig.tools.library.LibraryException; |
|
41 |
|
|
42 |
/** |
|
43 |
* @author fdiaz |
|
44 |
* |
|
45 |
*/ |
|
46 |
public class JpgLegendLibrary extends AbstractLibrary { |
|
47 |
|
|
48 |
@Override |
|
49 |
public void doRegistration() { |
|
50 |
registerAsServiceOf(DALLibrary.class); |
|
51 |
require(MetadataLibrary.class); |
|
52 |
require(JpgLibrary.class); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
protected void doInitialize() throws LibraryException { |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
protected void doPostInitialize() throws LibraryException { |
|
62 |
DynClass metadataDefinition = (DynClass) MetadataLocator.getMetadataManager() |
|
63 |
.getDefinition(JpgStoreProvider.METADATA_DEFINITION_NAME); |
|
64 |
JpgGetLegend.register(metadataDefinition); |
|
65 |
JpgGetColorInterpretation.register(metadataDefinition); |
|
66 |
} |
|
67 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg.legend/src/main/java/org/gvsig/fmap/dal/file/jpg/legend/JpgGetColorInterpretation.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.file.jpg.legend; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.image.BufferedImage; |
|
5 |
import java.awt.image.ColorModel; |
|
6 |
import java.awt.image.ComponentColorModel; |
|
7 |
import java.awt.image.IndexColorModel; |
|
8 |
import java.awt.image.WritableRaster; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.List; |
|
11 |
|
|
12 |
import org.gvsig.fmap.dal.file.jpg.JpgStoreProvider; |
|
13 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
14 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
15 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
16 |
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation; |
|
17 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
18 |
import org.gvsig.raster.lib.legend.api.colortable.colortableclass.ColorTableClass; |
|
19 |
import org.gvsig.tools.ToolsLocator; |
|
20 |
import org.gvsig.tools.dynobject.DynClass; |
|
21 |
import org.gvsig.tools.dynobject.DynMethod; |
|
22 |
import org.gvsig.tools.dynobject.DynObject; |
|
23 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
24 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author dmartinezizquierdo |
|
28 |
* |
|
29 |
*/ |
|
30 |
public class JpgGetColorInterpretation implements DynMethod { |
|
31 |
|
|
32 |
private static Integer code = null; |
|
33 |
|
|
34 |
static void register(DynClass storeClass) { |
|
35 |
if (code != null) { |
|
36 |
return; |
|
37 |
} |
|
38 |
code = ToolsLocator.getDynObjectManager() |
|
39 |
.registerDynMethod(storeClass, new JpgGetColorInterpretation()); |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public int getCode() throws DynMethodNotSupportedException { |
|
45 |
return code; |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public String getDescription() { |
|
50 |
return "JPG Color Interpretation"; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public String getName() { |
|
55 |
return RasterStore.DYNMETHOD_GETCOLORINTERPRETATION_NAME; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public Object invoke(DynObject self, Object[] args) throws DynMethodException { |
|
60 |
ColorInterpretation colorInterpretation = null; |
|
61 |
// try { |
|
62 |
JpgStoreProvider provider = (JpgStoreProvider) self; |
|
63 |
|
|
64 |
RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager(); |
|
65 |
BufferedImage image = provider.getImage(); |
|
66 |
ColorModel colorModel = image.getColorModel(); |
|
67 |
|
|
68 |
if (colorModel instanceof ComponentColorModel) { //DirectColorModel) { |
|
69 |
WritableRaster raster = image.getRaster(); |
|
70 |
if (raster.getNumBands() == 3) { |
|
71 |
colorInterpretation = legendManager.createColorInterpretation(ColorInterpretation.RGB); |
|
72 |
} else if (raster.getNumBands() == 4) { |
|
73 |
colorInterpretation = legendManager.createColorInterpretation(ColorInterpretation.ARGB); |
|
74 |
} |
|
75 |
} else if (colorModel instanceof IndexColorModel) { |
|
76 |
colorInterpretation = legendManager.createColorInterpretation(ColorInterpretation.PALETTE); |
|
77 |
|
|
78 |
ColorTable colorTable = null; |
|
79 |
IndexColorModel indexColorModel = (IndexColorModel) colorModel; |
|
80 |
int[] rgbs = new int[indexColorModel.getMapSize()]; |
|
81 |
boolean hasalpha = indexColorModel.hasAlpha(); |
|
82 |
indexColorModel.getRGBs(rgbs); |
|
83 |
|
|
84 |
List<ColorTableClass> colorTableClasses = new ArrayList<ColorTableClass>(); |
|
85 |
|
|
86 |
for (int i = 0; i < rgbs.length; i++) { |
|
87 |
String className = i + ""; |
|
88 |
double value = ((byte) i); |
|
89 |
double interpolation = 50.0; |
|
90 |
Color color = new Color(rgbs[i], hasalpha); |
|
91 |
ColorTableClass colorTableClass = |
|
92 |
legendManager.createColorTableClass(className, value, interpolation, color); |
|
93 |
colorTableClasses.add(colorTableClass); |
|
94 |
} |
|
95 |
String colorTableName = provider.getName() + "_color_table"; |
|
96 |
colorTable = legendManager.createColorTable(colorTableName, colorTableClasses, true); |
|
97 |
|
|
98 |
colorInterpretation.setPalette(colorTable); |
|
99 |
colorInterpretation.setPaletteBand(0); |
|
100 |
|
|
101 |
} |
|
102 |
|
|
103 |
return colorInterpretation; |
|
104 |
} |
|
105 |
|
|
106 |
@Override |
|
107 |
public Object clone() throws CloneNotSupportedException { |
|
108 |
return super.clone(); |
|
109 |
} |
|
110 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg.legend/src/main/java/org/gvsig/fmap/dal/file/jpg/legend/JpgGetColorTable.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.file.jpg.legend; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.image.ColorModel; |
|
5 |
import java.awt.image.IndexColorModel; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.gvsig.fmap.dal.file.jpg.JpgStoreProvider; |
|
10 |
import org.gvsig.fmap.dal.raster.api.RasterStore; |
|
11 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
12 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
13 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
14 |
import org.gvsig.raster.lib.legend.api.colortable.colortableclass.ColorTableClass; |
|
15 |
import org.gvsig.tools.ToolsLocator; |
|
16 |
import org.gvsig.tools.dynobject.DynClass; |
|
17 |
import org.gvsig.tools.dynobject.DynMethod; |
|
18 |
import org.gvsig.tools.dynobject.DynObject; |
|
19 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
|
20 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
|
21 |
|
|
22 |
/** |
|
23 |
* @author fdiaz |
|
24 |
* |
|
25 |
*/ |
|
26 |
public class JpgGetColorTable implements DynMethod { |
|
27 |
|
|
28 |
private static Integer code = null; |
|
29 |
|
|
30 |
static void register(DynClass storeClass) { |
|
31 |
if (code != null) { |
|
32 |
return; |
|
33 |
} |
|
34 |
code = ToolsLocator.getDynObjectManager() |
|
35 |
.registerDynMethod(storeClass, new JpgGetColorTable()); |
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public int getCode() throws DynMethodNotSupportedException { |
|
41 |
return code; |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public String getDescription() { |
|
46 |
return "JPG Color Table"; |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public String getName() { |
|
51 |
return RasterStore.DYNMETHOD_GETCOLORTABLE_NAME; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public Object invoke(DynObject self, Object[] args) |
|
56 |
throws DynMethodException { |
|
57 |
ColorTable colorTable = null; |
|
58 |
// try { |
|
59 |
JpgStoreProvider provider = (JpgStoreProvider) self; |
|
60 |
|
|
61 |
RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager(); |
|
62 |
ColorModel colorModel = provider.getImage().getColorModel(); |
|
63 |
|
|
64 |
if (colorModel instanceof IndexColorModel) { |
|
65 |
IndexColorModel indexColorModel = (IndexColorModel) colorModel; |
|
66 |
int[] rgbs = new int[indexColorModel.getMapSize()]; |
|
67 |
boolean hasalpha = indexColorModel.hasAlpha(); |
|
68 |
indexColorModel.getRGBs(rgbs); |
|
69 |
|
|
70 |
List<ColorTableClass> colorTableClasses = new ArrayList<ColorTableClass>(); |
|
71 |
|
|
72 |
for (int i = 0; i < rgbs.length; i++) { |
|
73 |
String className = i + ""; |
|
74 |
double value = ((byte) i); |
|
75 |
double interpolation = 50.0; |
|
76 |
Color color = new Color(rgbs[i], hasalpha); |
|
77 |
ColorTableClass colorTableClass = |
|
78 |
legendManager.createColorTableClass(className, value, interpolation, color); |
|
79 |
colorTableClasses.add(colorTableClass); |
|
80 |
} |
|
81 |
String colorTableName = provider.getName() + "_color_table"; |
|
82 |
colorTable = legendManager.createColorTable(colorTableName, colorTableClasses, true); |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
return colorTable; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public Object clone() throws CloneNotSupportedException { |
|
91 |
return super.clone(); |
|
92 |
} |
|
93 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg.legend/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.raster</artifactId> |
|
6 |
<version>2.4.1-SNAPSHOT</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.fmap.dal.file.jpg.legend</artifactId> |
|
9 |
<name>org.gvsig.fmap.dal.file.jpg.legend</name> |
|
10 |
<description>Legend for JPG provider</description> |
|
11 |
<dependencies> |
|
12 |
<dependency> |
|
13 |
<groupId>org.gvsig</groupId> |
|
14 |
<artifactId>org.gvsig.fmap.dal.file.jpg</artifactId> |
|
15 |
<scope>compile</scope> |
|
16 |
</dependency> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.raster.lib.legend.api</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
22 |
</dependencies> |
|
23 |
|
|
24 |
</project> |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.raster</artifactId> |
|
6 |
<version>2.4.1-SNAPSHOT</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.fmap.dal.file.jpg</artifactId> |
|
9 |
<name>org.gvsig.fmap.dal.file.jpg</name> |
|
10 |
<description>JPG Provider</description> |
|
11 |
<dependencies> |
|
12 |
<dependency> |
|
13 |
<groupId>org.gvsig</groupId> |
|
14 |
<artifactId>org.gvsig.fmap.dal.raster.spi</artifactId> |
|
15 |
<scope>compile</scope> |
|
16 |
</dependency> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
22 |
|
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.raster.lib.buffer.spi</artifactId> |
|
26 |
<scope>compile</scope> |
|
27 |
</dependency> |
|
28 |
</dependencies> |
|
29 |
</project> |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/java/org/gvsig/fmap/dal/file/jpg/JpgFileSystemServerProviderFactory.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2018 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.fmap.dal.file.jpg; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import org.apache.commons.io.FilenameUtils; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
30 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProviderFactory; |
|
31 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemProviderServices; |
|
32 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* @author fdiaz |
|
37 |
* |
|
38 |
*/ |
|
39 |
public class JpgFileSystemServerProviderFactory extends AbstractFilesystemServerExplorerProviderFactory{ |
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* @param services |
|
44 |
*/ |
|
45 |
public JpgFileSystemServerProviderFactory(FilesystemProviderServices services) { |
|
46 |
super(services); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
public FilesystemServerExplorerProvider createProvider() throws InitializeException { |
|
51 |
return new JpgFileSystemServerProvider(); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public boolean accept(File pathname) { |
|
56 |
return FilenameUtils.isExtension(pathname.getName().toLowerCase(), "jpg"); |
|
57 |
} |
|
58 |
|
|
59 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/java/org/gvsig/fmap/dal/file/jpg/JpgStoreProviderFactory.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.fmap.dal.file.jpg; |
|
24 |
|
|
25 |
import org.slf4j.Logger; |
|
26 |
import org.slf4j.LoggerFactory; |
|
27 |
|
|
28 |
import org.gvsig.fmap.dal.DataParameters; |
|
29 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
30 |
import org.gvsig.fmap.dal.raster.spi.AbstractRasterStoreProviderFactory; |
|
31 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
32 |
|
|
33 |
/** |
|
34 |
* Factory for Jpg provider |
|
35 |
* @author fdiaz |
|
36 |
* |
|
37 |
*/ |
|
38 |
public class JpgStoreProviderFactory extends AbstractRasterStoreProviderFactory { |
|
39 |
|
|
40 |
private static final Logger logger = LoggerFactory.getLogger(JpgStoreProviderFactory.class); |
|
41 |
|
|
42 |
protected JpgStoreProviderFactory(String name, String description) { |
|
43 |
super(name, description); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public JpgStoreProvider createProvider(DataParameters parameters, |
|
48 |
DataStoreProviderServices providerServices) throws InitializeException { |
|
49 |
return new JpgStoreProvider((JpgStoreProviderParameters)parameters,providerServices); |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public JpgStoreProviderParameters createParameters() { |
|
54 |
return new JpgStoreProviderParameters(); |
|
55 |
} |
|
56 |
|
|
57 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/java/org/gvsig/fmap/dal/file/jpg/JpgLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
|
|
24 |
package org.gvsig.fmap.dal.file.jpg; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.DALFileLibrary; |
|
30 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
31 |
import org.gvsig.fmap.dal.DALLibrary; |
|
32 |
import org.gvsig.fmap.dal.FileHelper; |
|
33 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
|
34 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
35 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
36 |
import org.gvsig.tools.library.AbstractLibrary; |
|
37 |
import org.gvsig.tools.library.LibraryException; |
|
38 |
|
|
39 |
/** |
|
40 |
* Jpg Library to register provider components |
|
41 |
* @author fdiaz |
|
42 |
* |
|
43 |
*/ |
|
44 |
public class JpgLibrary extends AbstractLibrary { |
|
45 |
|
|
46 |
@Override |
|
47 |
public void doRegistration() { |
|
48 |
registerAsServiceOf(DALLibrary.class); |
|
49 |
require(DALFileLibrary.class); |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
protected void doInitialize() throws LibraryException { |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
protected void doPostInitialize() throws LibraryException { |
|
59 |
List<Throwable> exs = new ArrayList<Throwable>(); |
|
60 |
|
|
61 |
FileHelper.registerParametersDefinition( |
|
62 |
JpgStoreProviderParameters.PARAMETERS_DEFINITION_NAME, |
|
63 |
JpgStoreProviderParameters.class, JpgStoreProvider.NAME+"Parameters.xml"); |
|
64 |
try { |
|
65 |
FileHelper.registerMetadataDefinition( |
|
66 |
JpgStoreProvider.METADATA_DEFINITION_NAME, |
|
67 |
JpgStoreProvider.class, JpgStoreProvider.NAME+"Metadata.xml"); |
|
68 |
} catch (MetadataException e) { |
|
69 |
exs.add(e); |
|
70 |
} |
|
71 |
|
|
72 |
DataManagerProviderServices dataman = DALSPILocator.getDataManagerProviderServices(); |
|
73 |
|
|
74 |
|
|
75 |
try { |
|
76 |
if (!dataman.getStoreProviders() |
|
77 |
.contains(JpgStoreProvider.NAME)) { |
|
78 |
dataman.registerStoreProviderFactory( |
|
79 |
new JpgStoreProviderFactory( |
|
80 |
JpgStoreProvider.NAME, |
|
81 |
JpgStoreProvider.DESCRIPTION)); |
|
82 |
} |
|
83 |
} catch (RuntimeException e) { |
|
84 |
exs.add(e); |
|
85 |
} |
|
86 |
|
|
87 |
try { |
|
88 |
DALFileLocator.getFilesystemServerExplorerManager() |
|
89 |
.registerProvider(JpgStoreProvider.NAME, |
|
90 |
JpgStoreProvider.DESCRIPTION, |
|
91 |
JpgFileSystemServerProvider.class); |
|
92 |
} catch (RuntimeException e) { |
|
93 |
exs.add(e); |
|
94 |
} |
|
95 |
|
|
96 |
if (exs.size() > 0) { |
|
97 |
throw new LibraryException(this.getClass(), exs); |
|
98 |
} |
|
99 |
} |
|
100 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/java/org/gvsig/fmap/dal/file/jpg/JpgFileSystemServerProvider.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.fmap.dal.file.jpg; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.io.IOException; |
|
27 |
|
|
28 |
import org.apache.commons.io.FilenameUtils; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
31 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
32 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
33 |
import org.gvsig.fmap.dal.exception.CreateException; |
|
34 |
import org.gvsig.fmap.dal.exception.DataException; |
|
35 |
import org.gvsig.fmap.dal.exception.FileNotFoundException; |
|
36 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
37 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
|
38 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
39 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider; |
|
40 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
|
41 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
|
42 |
|
|
43 |
/** |
|
44 |
* Filesystem Provider for Jpg. |
|
45 |
* @author fdiaz |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class JpgFileSystemServerProvider extends AbstractFilesystemServerExplorerProvider |
|
49 |
implements FilesystemServerExplorerProvider, ResourceConsumer{ |
|
50 |
|
|
51 |
protected FilesystemServerExplorerProviderServices serverExplorer; |
|
52 |
|
|
53 |
@Override |
|
54 |
public int getMode() { |
|
55 |
return DataServerExplorer.MODE_RASTER; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public boolean canCreate() { |
|
60 |
return false; |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public boolean canCreate(NewDataStoreParameters arg0) { |
|
65 |
return false; |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public void create(NewDataStoreParameters arg0, boolean arg1) |
|
70 |
throws CreateException { |
|
71 |
throw new UnsupportedOperationException(); |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
76 |
public NewDataStoreParameters getCreateParameters() throws DataException { |
|
77 |
throw new UnsupportedOperationException(); |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public void initialize(FilesystemServerExplorerProviderServices serverExplorer) { |
|
82 |
this.serverExplorer = serverExplorer; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
|
87 |
JpgStoreProviderParameters params = (JpgStoreProviderParameters) parameters; |
|
88 |
File file = params.getFile(); |
|
89 |
if (!file.exists()) { |
|
90 |
throw new RemoveException(this.getDataStoreProviderName(), |
|
91 |
new FileNotFoundException(params.getFile())); |
|
92 |
} |
|
93 |
if (!file.delete()) { |
|
94 |
throw new RemoveException(this.getDataStoreProviderName(), |
|
95 |
new IOException("Error deleting file: "+file.getName())); |
|
96 |
} |
|
97 |
|
|
98 |
} |
|
99 |
|
|
100 |
@Override |
|
101 |
public String getDataStoreProviderName() { |
|
102 |
return JpgStoreProvider.NAME; |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public String getDescription() { |
|
107 |
return JpgStoreProvider.DESCRIPTION; |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public boolean accept(File pathname) { |
|
112 |
return FilenameUtils.isExtension(pathname.getName().toLowerCase(), "jpg"); |
|
113 |
|
|
114 |
} |
|
115 |
|
|
116 |
@Override |
|
117 |
public boolean closeResourceRequested(ResourceProvider resource) { |
|
118 |
return !(this.equals(resource)); |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
122 |
public void resourceChanged(ResourceProvider resource) { |
|
123 |
//Do nothing |
|
124 |
} |
|
125 |
|
|
126 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/java/org/gvsig/fmap/dal/file/jpg/JpgStoreProvider.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.fmap.dal.file.jpg; |
|
24 |
|
|
25 |
import java.awt.image.BufferedImage; |
|
26 |
import java.io.File; |
|
27 |
|
|
28 |
import javax.imageio.ImageIO; |
|
29 |
|
|
30 |
import org.apache.commons.io.FilenameUtils; |
|
31 |
import org.slf4j.Logger; |
|
32 |
import org.slf4j.LoggerFactory; |
|
33 |
|
|
34 |
import org.gvsig.fmap.dal.DALLocator; |
|
35 |
import org.gvsig.fmap.dal.DataManager; |
|
36 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
37 |
import org.gvsig.fmap.dal.DataStoreNotification; |
|
38 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
39 |
import org.gvsig.fmap.dal.FileHelper; |
|
40 |
import org.gvsig.fmap.dal.exception.DataException; |
|
41 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
42 |
import org.gvsig.fmap.dal.exception.OpenException; |
|
43 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
44 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
45 |
import org.gvsig.fmap.dal.raster.spi.AbstractAwtRasterStoreProvider; |
|
46 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
|
47 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
|
48 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
|
49 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
|
50 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
51 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
52 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
53 |
import org.gvsig.metadata.MetadataLocator; |
|
54 |
import org.gvsig.metadata.MetadataManager; |
|
55 |
import org.gvsig.metadata.exceptions.MetadataException; |
|
56 |
import org.gvsig.tools.ToolsLocator; |
|
57 |
import org.gvsig.tools.dynobject.DynObject; |
|
58 |
import org.gvsig.tools.exception.BaseException; |
|
59 |
import org.gvsig.tools.task.TaskStatusManager; |
|
60 |
|
|
61 |
/** |
|
62 |
* Provider for Jpg files |
|
63 |
* @author fdiaz |
|
64 |
* |
|
65 |
*/ |
|
66 |
public class JpgStoreProvider extends AbstractAwtRasterStoreProvider implements ResourceConsumer{ |
|
67 |
|
|
68 |
private static final Logger logger = |
|
69 |
LoggerFactory.getLogger(JpgStoreProvider.class); |
|
70 |
|
|
71 |
public static String NAME = "JPG"; |
|
72 |
public static String DESCRIPTION = "JPG provider"; |
|
73 |
public static final String METADATA_DEFINITION_NAME = NAME; |
|
74 |
|
|
75 |
private ResourceProvider resource; |
|
76 |
private BufferedImage image; |
|
77 |
|
|
78 |
protected static void registerMetadataDefinition() |
|
79 |
throws MetadataException { |
|
80 |
MetadataManager manager = MetadataLocator.getMetadataManager(); |
|
81 |
if (manager.getDefinition(METADATA_DEFINITION_NAME) == null) { |
|
82 |
manager.addDefinition(METADATA_DEFINITION_NAME, |
|
83 |
JpgStoreProviderParameters.class |
|
84 |
.getResourceAsStream(JpgStoreProvider.NAME+"Metadata.xml"), |
|
85 |
JpgStoreProviderParameters.class.getClassLoader()); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* @param params |
|
91 |
* @param storeServices |
|
92 |
* @throws InitializeException |
|
93 |
*/ |
|
94 |
public JpgStoreProvider(JpgStoreProviderParameters params, |
|
95 |
DataStoreProviderServices storeServices) |
|
96 |
throws InitializeException { |
|
97 |
super( |
|
98 |
params, |
|
99 |
storeServices, |
|
100 |
FileHelper.newMetadataContainer(METADATA_DEFINITION_NAME) |
|
101 |
); |
|
102 |
this.init(params, storeServices); |
|
103 |
} |
|
104 |
|
|
105 |
protected JpgStoreProvider(JpgStoreProviderParameters params, |
|
106 |
DataStoreProviderServices storeServices, DynObject metadata) |
|
107 |
throws InitializeException { |
|
108 |
super(params, storeServices, metadata); |
|
109 |
this.init(params, storeServices); |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public String getProviderName() { |
|
114 |
return NAME; |
|
115 |
} |
|
116 |
|
|
117 |
@Override |
|
118 |
protected void init(DataStoreParameters params, DataStoreProviderServices storeServices) throws InitializeException { |
|
119 |
super.init(params, storeServices); |
|
120 |
|
|
121 |
File file = getParameters().getFile(); |
|
122 |
if (file == null) { |
|
123 |
throw new InitializeException( |
|
124 |
new NullPointerException(NAME +" file is null")); |
|
125 |
} |
|
126 |
|
|
127 |
resource = this.createResource( |
|
128 |
FileResource.NAME, |
|
129 |
new Object[] { file.getAbsolutePath() } |
|
130 |
); |
|
131 |
|
|
132 |
resource.addConsumer(this); |
|
133 |
|
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
@Override |
|
138 |
public ResourceProvider getResource() { |
|
139 |
return this.resource; |
|
140 |
} |
|
141 |
|
|
142 |
@Override |
|
143 |
public Object getSourceId() { |
|
144 |
return this.getParameters().getFile(); |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
public String getName() { |
|
149 |
String name = this.getParameters().getFile().getName(); |
|
150 |
return FilenameUtils.getBaseName(name); |
|
151 |
} |
|
152 |
|
|
153 |
@Override |
|
154 |
public String getFullName() { |
|
155 |
return this.getParameters().getFile().getAbsolutePath(); |
|
156 |
} |
|
157 |
|
|
158 |
@Override |
|
159 |
public boolean closeResourceRequested(ResourceProvider resource) { |
|
160 |
return true; |
|
161 |
} |
|
162 |
|
|
163 |
@Override |
|
164 |
public void resourceChanged(ResourceProvider resource) { |
|
165 |
this.getStoreServices().notifyChange( |
|
166 |
DataStoreNotification.RESOURCE_CHANGED, |
|
167 |
resource); |
|
168 |
} |
|
169 |
|
|
170 |
@Override |
|
171 |
protected void doDispose() throws BaseException { |
|
172 |
super.doDispose(); |
|
173 |
resource.removeConsumer(this); |
|
174 |
} |
|
175 |
|
|
176 |
@Override |
|
177 |
public JpgStoreProviderParameters getParameters() { |
|
178 |
return (JpgStoreProviderParameters) super.getParameters(); |
|
179 |
} |
|
180 |
|
|
181 |
@Override |
|
182 |
public void open() throws OpenException { |
|
183 |
if (this.isOpen()) { |
|
184 |
return; |
|
185 |
} |
|
186 |
try { |
|
187 |
image = ImageIO.read((File) getResource().getParameters().getDynValue(FileResource.NAME)); |
|
188 |
open(image.getRaster()); |
|
189 |
|
|
190 |
} catch (Exception e) { |
|
191 |
try { |
|
192 |
throw new OpenException(resource.getName(), e); |
|
193 |
} catch (AccessResourceException e1) { |
|
194 |
throw new OpenException(getProviderName(), e); |
|
195 |
} |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
@Override |
|
200 |
public DataServerExplorer getExplorer() throws ReadException, ValidateDataParametersException { |
|
201 |
DataManager manager = DALLocator.getDataManager(); |
|
202 |
FilesystemServerExplorerParameters params; |
|
203 |
try { |
|
204 |
params = (FilesystemServerExplorerParameters) manager |
|
205 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME); |
|
206 |
params.setRoot(this.getParameters().getFile().getParent()); |
|
207 |
return manager.openServerExplorer(FilesystemServerExplorer.NAME,params); |
|
208 |
} catch (DataException e) { |
|
209 |
throw new ReadException(this.getProviderName(), e); |
|
210 |
} catch (ValidateDataParametersException e) { |
|
211 |
throw new ReadException(this.getProviderName(), e); |
|
212 |
} |
|
213 |
|
|
214 |
} |
|
215 |
|
|
216 |
/** |
|
217 |
* @return BufferedImage |
|
218 |
* @throws OpenException |
|
219 |
*/ |
|
220 |
public BufferedImage getImage() { |
|
221 |
autoOpen(); |
|
222 |
return this.image; |
|
223 |
} |
|
224 |
|
|
225 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/java/org/gvsig/fmap/dal/file/jpg/JpgStoreProviderParameters.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2016 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.fmap.dal.file.jpg; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import org.slf4j.Logger; |
|
28 |
import org.slf4j.LoggerFactory; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.FileHelper; |
|
31 |
import org.gvsig.fmap.dal.raster.OpenRasterStoreParameters; |
|
32 |
import org.gvsig.fmap.dal.raster.spi.AbstractOpenRasterStoreParameters; |
|
33 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
34 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
35 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
36 |
|
|
37 |
/** |
|
38 |
* Parameters to create a Jpg Provider |
|
39 |
* @author fdiaz |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class JpgStoreProviderParameters extends AbstractOpenRasterStoreParameters implements |
|
43 |
OpenRasterStoreParameters, FilesystemStoreParameters{ |
|
44 |
|
|
45 |
private static final Logger logger = LoggerFactory.getLogger(JpgStoreProviderParameters.class); |
|
46 |
|
|
47 |
public static final String PARAMETERS_DEFINITION_NAME = "JPGStoreProviderParameters"; |
|
48 |
public static final String FILE_PARAMTER_NAME = "file"; |
|
49 |
|
|
50 |
|
|
51 |
private DelegatedDynObject parameters; |
|
52 |
|
|
53 |
/** |
|
54 |
* Constructor |
|
55 |
*/ |
|
56 |
public JpgStoreProviderParameters() { |
|
57 |
this(PARAMETERS_DEFINITION_NAME); |
|
58 |
} |
|
59 |
|
|
60 |
protected JpgStoreProviderParameters(String parametersDefinitionName) { |
|
61 |
this(parametersDefinitionName, JpgStoreProvider.NAME); |
|
62 |
} |
|
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* Constructor |
|
67 |
* @param parametersDefinitionName |
|
68 |
* @param name |
|
69 |
*/ |
|
70 |
public JpgStoreProviderParameters(String parametersDefinitionName, String name) { |
|
71 |
super(); |
|
72 |
this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName); |
|
73 |
this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name); |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public String getDataStoreName() { |
|
78 |
return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public boolean isValid() { |
|
83 |
return (this.getFile() != null); |
|
84 |
} |
|
85 |
|
|
86 |
@Override |
|
87 |
public String getDescription() { |
|
88 |
return this.getDynClass().getDescription(); |
|
89 |
} |
|
90 |
|
|
91 |
@Override |
|
92 |
public File getFile() { |
|
93 |
return (File) this.getDynValue(FILE_PARAMTER_NAME); |
|
94 |
} |
|
95 |
|
|
96 |
@Override |
|
97 |
public void setFile(File file) { |
|
98 |
this.setDynValue(FILE_PARAMTER_NAME, file); |
|
99 |
loadWLD(file); |
|
100 |
if (getCRS()==null){ |
|
101 |
loadPRJ(file); |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
107 |
return parameters; |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public void setDynValue(String name, Object value) { |
|
112 |
super.setDynValue(name, value); |
|
113 |
if(name.equals(FILE_PARAMTER_NAME)){ |
|
114 |
loadWLD((File) value); |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
} |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.fmap.dal.file.jpg.JpgLibrary |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/resources/org/gvsig/fmap/dal/file/jpg/JPGParameters.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<definitions> |
|
3 |
<version>1.0.0</version> |
|
4 |
<classes> |
|
5 |
<class name="JPGStoreProviderParameters"> |
|
6 |
<extends> |
|
7 |
<class namespace="dal" name="ProviderParameters"/> |
|
8 |
</extends> |
|
9 |
<description>Store the parameters need to open a png file</description> |
|
10 |
<fields> |
|
11 |
<field name="file" type="file" mandatory="true" group="Basic"> |
|
12 |
<description>png file</description> |
|
13 |
</field> |
|
14 |
<field name="crs" type="crs" mandatory="true" group="Basic"> |
|
15 |
<description>The coordinate reference system used in this jpg file</description> |
|
16 |
</field> |
|
17 |
<field name="wldParams" type="object" mandatory="false" group="Basic" classOfValue="java.util.List"> |
|
18 |
<description>Info given by a wld file with geolocation</description> |
|
19 |
</field> |
|
20 |
</fields> |
|
21 |
</class> |
|
22 |
</classes> |
|
23 |
</definitions> |
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.dal.file.jpg/src/main/resources/org/gvsig/fmap/dal/file/jpg/JPGMetadata.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
Definitions of metadata fields of a JIMI file. |
|
4 |
--> |
|
5 |
<definitions> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
|
|
9 |
<class name="JPG" namespace="Metadata"> |
|
10 |
<extends> |
|
11 |
<class namespace="Metadata" name="SpatialProvider"/> |
|
12 |
</extends> |
|
13 |
<description>Metadata of a JPG store</description> |
|
14 |
<fields> |
|
15 |
</fields> |
|
16 |
</class> |
|
17 |
|
|
18 |
</classes> |
|
19 |
</definitions> |
Also available in: Unified diff