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.png / src / main / java / org / gvsig / fmap / dal / file / png / PngLibrary.java @ 43867
History | View | Annotate | Download (4.4 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.png; |
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 |
* Png Library to register provider components
|
48 |
*
|
49 |
* @author fdiaz
|
50 |
*
|
51 |
*/
|
52 |
public class PngLibrary extends AbstractLibrary { |
53 |
|
54 |
public static String NAME = "PNG"; |
55 |
public static String DESCRIPTION = "PNG provider"; |
56 |
public static String[] FILE_EXTENSIONS = new String[]{"png"}; |
57 |
|
58 |
@Override
|
59 |
public void doRegistration() { |
60 |
registerAsServiceOf(DALLibrary.class); |
61 |
require(DALFileLibrary.class); |
62 |
|
63 |
} |
64 |
|
65 |
@Override
|
66 |
protected void doInitialize() throws LibraryException { |
67 |
} |
68 |
|
69 |
@Override
|
70 |
protected void doPostInitialize() throws LibraryException { |
71 |
List<Throwable> exs = new ArrayList<>(); |
72 |
|
73 |
FileHelper.registerParametersDefinition( |
74 |
NAME + "StoreProviderParameters",
|
75 |
ImageIOStoreProviderParameters.class, |
76 |
this.getClass().getClassLoader(),
|
77 |
this.getClass().getResource(NAME + "Parameters.xml")); |
78 |
try {
|
79 |
try {
|
80 |
FileHelper.registerMetadataDefinition( |
81 |
NAME, |
82 |
ImageIOStoreProvider.class, |
83 |
this.getClass().getClassLoader(),
|
84 |
this.getClass().getResource(NAME + "Metadata.xml")); |
85 |
} catch (MetadataException e) {
|
86 |
exs.add(e); |
87 |
} |
88 |
|
89 |
DataManagerProviderServices datamanager = DALSPILocator.getDataManagerProviderServices(); |
90 |
FilesystemServerExplorerManager explorerManager = DALFileLocator.getFilesystemServerExplorerManager(); |
91 |
|
92 |
if (!datamanager.getStoreProviders().contains(NAME)) {
|
93 |
datamanager.registerStoreProviderFactory( |
94 |
new ImageIOStoreProviderFactory(
|
95 |
NAME, |
96 |
DESCRIPTION)); |
97 |
} |
98 |
explorerManager.registerProviderFactory( |
99 |
new ImageIOFileSystemServerProviderFactory(
|
100 |
NAME, |
101 |
DESCRIPTION, |
102 |
FILE_EXTENSIONS, |
103 |
true
|
104 |
) |
105 |
); |
106 |
} catch (Exception e) { |
107 |
exs.add(e); |
108 |
} |
109 |
|
110 |
if (exs.size() > 0) { |
111 |
throw new LibraryException(this.getClass(), exs); |
112 |
} |
113 |
|
114 |
} |
115 |
|
116 |
public static DynClass getMatadataDefinition() { |
117 |
MetadataManager metadataManager = MetadataLocator.getMetadataManager(); |
118 |
DynClass metadataDefinition = (DynClass) metadataManager.getDefinition(NAME); |
119 |
return metadataDefinition;
|
120 |
} |
121 |
} |