svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.tiff / src / main / java / org / gvsig / fmap / dal / file / tiff / TiffLibrary.java @ 43867
History | View | Annotate | Download (4.41 KB)
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.tiff; |
24 |
|
25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
27 |
|
28 |
import org.gvsig.fmap.dal.DALFileLibrary; |
29 |
import org.gvsig.fmap.dal.DALFileLocator; |
30 |
import org.gvsig.fmap.dal.DALLibrary; |
31 |
import org.gvsig.fmap.dal.FileHelper; |
32 |
import org.gvsig.fmap.dal.file.imageio.ImageIOFileSystemServerProviderFactory; |
33 |
import org.gvsig.fmap.dal.file.imageio.ImageIOStoreProvider; |
34 |
import org.gvsig.fmap.dal.file.imageio.ImageIOStoreProviderFactory; |
35 |
import org.gvsig.fmap.dal.file.imageio.ImageIOStoreProviderParameters; |
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerManager; |
37 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
38 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
39 |
import org.gvsig.metadata.MetadataLocator; |
40 |
import org.gvsig.metadata.MetadataManager; |
41 |
import org.gvsig.metadata.exceptions.MetadataException; |
42 |
import org.gvsig.tools.dynobject.DynClass; |
43 |
import org.gvsig.tools.library.AbstractLibrary; |
44 |
import org.gvsig.tools.library.LibraryException; |
45 |
|
46 |
/**
|
47 |
* Tiff Library to register provider components
|
48 |
*
|
49 |
*/
|
50 |
public class TiffLibrary extends AbstractLibrary { |
51 |
|
52 |
public static String NAME = "TIFF"; |
53 |
public static String DESCRIPTION = "TIFF provider"; |
54 |
public static String[] FILE_EXTENSIONS = new String[]{"tif", "tiff"}; |
55 |
|
56 |
@Override
|
57 |
public void doRegistration() { |
58 |
registerAsServiceOf(DALLibrary.class); |
59 |
require(DALFileLibrary.class); |
60 |
|
61 |
} |
62 |
|
63 |
@Override
|
64 |
protected void doInitialize() throws LibraryException { |
65 |
} |
66 |
|
67 |
@Override
|
68 |
protected void doPostInitialize() throws LibraryException { |
69 |
List<Throwable> exs = new ArrayList<>(); |
70 |
|
71 |
|
72 |
FileHelper.registerParametersDefinition( |
73 |
NAME + "StoreProviderParameters",
|
74 |
ImageIOStoreProviderParameters.class, |
75 |
this.getClass().getClassLoader(),
|
76 |
this.getClass().getResource(NAME + "Parameters.xml")); |
77 |
try {
|
78 |
try {
|
79 |
FileHelper.registerMetadataDefinition( |
80 |
NAME, |
81 |
ImageIOStoreProvider.class, |
82 |
this.getClass().getClassLoader(),
|
83 |
this.getClass().getResource(NAME + "Metadata.xml")); |
84 |
} catch (MetadataException e) {
|
85 |
exs.add(e); |
86 |
} |
87 |
|
88 |
DataManagerProviderServices datamanager = DALSPILocator.getDataManagerProviderServices(); |
89 |
FilesystemServerExplorerManager explorerManager = DALFileLocator.getFilesystemServerExplorerManager(); |
90 |
|
91 |
if (!datamanager.getStoreProviders().contains(NAME)) {
|
92 |
datamanager.registerStoreProviderFactory( |
93 |
new ImageIOStoreProviderFactory(
|
94 |
NAME, |
95 |
DESCRIPTION)); |
96 |
} |
97 |
explorerManager.registerProviderFactory( |
98 |
new ImageIOFileSystemServerProviderFactory(
|
99 |
NAME, |
100 |
DESCRIPTION, |
101 |
FILE_EXTENSIONS, |
102 |
true
|
103 |
) |
104 |
); |
105 |
} catch (Exception e) { |
106 |
exs.add(e); |
107 |
} |
108 |
|
109 |
if (exs.size() > 0) { |
110 |
throw new LibraryException(this.getClass(), exs); |
111 |
} |
112 |
} |
113 |
|
114 |
public static DynClass getMatadataDefinition() { |
115 |
MetadataManager metadataManager = MetadataLocator.getMetadataManager(); |
116 |
DynClass metadataDefinition = (DynClass) metadataManager.getDefinition(NAME); |
117 |
return metadataDefinition;
|
118 |
}} |