Revision 1702
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.api/src/main/java/org/gvsig/tools/util/ToolsUtilLocator.java | ||
---|---|---|
1 | 1 |
package org.gvsig.tools.util; |
2 |
|
|
2 | 3 |
/** |
3 | 4 |
* gvSIG. Desktop Geographic Information System. |
4 | 5 |
* |
5 | 6 |
* Copyright (C) 2007-2013 gvSIG Association. |
6 | 7 |
* |
7 |
* This program is free software; you can redistribute it and/or |
|
8 |
* modify it under the terms of the GNU General Public License
|
|
9 |
* as published by the Free Software Foundation; either version 3
|
|
10 |
* of the License, or (at your option) any later version.
|
|
8 |
* This program is free software; you can redistribute it and/or modify it under
|
|
9 |
* the terms of the GNU General Public License as published by the Free Software
|
|
10 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
11 |
* version. |
|
11 | 12 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 |
* GNU General Public License for more details.
|
|
13 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
14 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
15 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
16 |
* details. |
|
16 | 17 |
* |
17 |
* You should have received a copy of the GNU General Public License |
|
18 |
* along with this program; if not, write to the Free Software |
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
* MA 02110-1301, USA. |
|
18 |
* You should have received a copy of the GNU General Public License along with |
|
19 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
20 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
21 | 21 |
* |
22 |
* For any additional information, do not hesitate to contact us |
|
23 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
22 |
* For any additional information, do not hesitate to contact us at info AT
|
|
23 |
* gvsig.com, or visit our website www.gvsig.com. |
|
24 | 24 |
*/ |
25 | 25 |
|
26 |
|
|
27 | 26 |
import org.gvsig.filedialogchooser.FileDialogChooserManager; |
27 |
import org.gvsig.imageviewer.ImageViewerManager; |
|
28 | 28 |
import org.gvsig.svgsupport.SVGSupportManager; |
29 | 29 |
import org.gvsig.tools.locator.AbstractLocator; |
30 | 30 |
import org.gvsig.tools.locator.Locator; |
31 | 31 |
import org.gvsig.tools.locator.LocatorException; |
32 | 32 |
|
33 | 33 |
/** |
34 |
* @author fdiaz
|
|
34 |
* @author gvSIG Team
|
|
35 | 35 |
* |
36 | 36 |
*/ |
37 | 37 |
@SuppressWarnings("rawtypes") |
38 | 38 |
public class ToolsUtilLocator extends AbstractLocator { |
39 | 39 |
|
40 |
private static final String LOCATOR_NAME = "ToolsUtilLocator";
|
|
40 |
private static final String LOCATOR_NAME = "ToolsUtilLocator";
|
|
41 | 41 |
|
42 |
public static final String TOOLS_UTIL_MANAGER_NAME = "org.gvsig.tools.util.manager";
|
|
43 |
private static final String TOOLS_UTIL_MANAGER_DESCRIPTION = "Tools utilities.";
|
|
42 |
public static final String TOOLS_UTIL_MANAGER_NAME = "org.gvsig.tools.util.manager";
|
|
43 |
private static final String TOOLS_UTIL_MANAGER_DESCRIPTION = "Tools utilities.";
|
|
44 | 44 |
|
45 | 45 |
public static final String FILE_DIALOG_CHOOSER_MANAGER_NAME = "org.gvsig.filedialogchooser.manager"; |
46 |
private static final String FILE_DIALOG_CHOOSER_MANAGER_DESCRIPTION = "File dialog chooser.";
|
|
46 |
private static final String FILE_DIALOG_CHOOSER_MANAGER_DESCRIPTION = "File dialog chooser.";
|
|
47 | 47 |
|
48 | 48 |
public static final String PLUGINS_SVGSUPPORT_MANAGER_NAME = "SVGSupportManager"; |
49 | 49 |
private static final String PLUGINS_SVGSUPPORT_MANAGER_DESCRIPTION = "SVGSupportManager"; |
50 | 50 |
|
51 |
private static final ToolsUtilLocator instance = new ToolsUtilLocator(); |
|
51 |
public static final String PLUGINS_IMAGEVIEWER_MANAGER_NAME = "ImageViewerManager"; |
|
52 |
private static final String PLUGINS_IMAGEVIEWER_MANAGER_DESCRIPTION = "ImageViewerManager"; |
|
52 | 53 |
|
53 |
private ToolsUtilLocator() {
|
|
54 |
private static final ToolsUtilLocator instance = new ToolsUtilLocator();
|
|
54 | 55 |
|
55 |
}
|
|
56 |
private ToolsUtilLocator() {
|
|
56 | 57 |
|
57 |
/** |
|
58 |
* Return the singleton instance. |
|
59 |
* |
|
60 |
* @return the singleton instance |
|
61 |
*/ |
|
62 |
public static ToolsUtilLocator getInstance() { |
|
63 |
return instance; |
|
64 |
} |
|
58 |
} |
|
65 | 59 |
|
66 |
public String getLocatorName() { |
|
67 |
return LOCATOR_NAME; |
|
68 |
} |
|
60 |
/** |
|
61 |
* Return the singleton instance. |
|
62 |
* |
|
63 |
* @return the singleton instance |
|
64 |
*/ |
|
65 |
public static ToolsUtilLocator getInstance() { |
|
66 |
return instance; |
|
67 |
} |
|
69 | 68 |
|
70 |
/** |
|
71 |
* Return a reference to ToolsUtilManager. |
|
72 |
* |
|
73 |
* @return a reference to ToolsUtilManager |
|
74 |
* @throws LocatorException |
|
75 |
* if there is no access to the class or the class cannot be |
|
76 |
* instantiated |
|
77 |
* @see Locator#get(String) |
|
78 |
*/ |
|
79 |
public static ToolsUtilManager getToolsUtilManager() |
|
80 |
throws LocatorException { |
|
81 |
return (ToolsUtilManager) getInstance().get(TOOLS_UTIL_MANAGER_NAME); |
|
82 |
} |
|
69 |
@Override |
|
70 |
public String getLocatorName() { |
|
71 |
return LOCATOR_NAME; |
|
72 |
} |
|
83 | 73 |
|
84 |
/** |
|
85 |
* Registers the Class implementing the ToolsUtilManager interface. |
|
86 |
* |
|
87 |
* @param clazz |
|
88 |
* implementing the ToolsUtilManager interface |
|
89 |
*/ |
|
90 |
public static void registerToolsUtilManager(Class clazz) { |
|
91 |
getInstance().register(TOOLS_UTIL_MANAGER_NAME, |
|
92 |
TOOLS_UTIL_MANAGER_DESCRIPTION, clazz); |
|
93 |
} |
|
74 |
/** |
|
75 |
* Return a reference to ToolsUtilManager. |
|
76 |
* |
|
77 |
* @return a reference to ToolsUtilManager |
|
78 |
* @throws LocatorException if there is no access to the class or the class |
|
79 |
* cannot be instantiated |
|
80 |
* @see Locator#get(String) |
|
81 |
*/ |
|
82 |
public static ToolsUtilManager getToolsUtilManager() |
|
83 |
throws LocatorException { |
|
84 |
return (ToolsUtilManager) getInstance().get(TOOLS_UTIL_MANAGER_NAME); |
|
85 |
} |
|
94 | 86 |
|
95 |
public static void registerDefaultToolsUtilManager(Class clazz) { |
|
96 |
getInstance().registerDefault(TOOLS_UTIL_MANAGER_NAME, |
|
97 |
TOOLS_UTIL_MANAGER_DESCRIPTION, clazz); |
|
98 |
} |
|
87 |
/** |
|
88 |
* Registers the Class implementing the ToolsUtilManager interface. |
|
89 |
* |
|
90 |
* @param clazz implementing the ToolsUtilManager interface |
|
91 |
*/ |
|
92 |
public static void registerToolsUtilManager(Class clazz) { |
|
93 |
getInstance().register(TOOLS_UTIL_MANAGER_NAME, |
|
94 |
TOOLS_UTIL_MANAGER_DESCRIPTION, clazz); |
|
95 |
} |
|
99 | 96 |
|
100 |
public static FileDialogChooserManager getFileDialogChooserManager()
|
|
101 |
throws LocatorException {
|
|
102 |
return (FileDialogChooserManager) getInstance().get(FILE_DIALOG_CHOOSER_MANAGER_NAME);
|
|
103 |
}
|
|
97 |
public static void registerDefaultToolsUtilManager(Class clazz) {
|
|
98 |
getInstance().registerDefault(TOOLS_UTIL_MANAGER_NAME,
|
|
99 |
TOOLS_UTIL_MANAGER_DESCRIPTION, clazz);
|
|
100 |
}
|
|
104 | 101 |
|
102 |
public static FileDialogChooserManager getFileDialogChooserManager() |
|
103 |
throws LocatorException { |
|
104 |
return (FileDialogChooserManager) getInstance().get(FILE_DIALOG_CHOOSER_MANAGER_NAME); |
|
105 |
} |
|
106 |
|
|
105 | 107 |
public static void registerFileDialogChooserManager(Class clazz) { |
106 |
getInstance().register(FILE_DIALOG_CHOOSER_MANAGER_NAME,
|
|
107 |
FILE_DIALOG_CHOOSER_MANAGER_DESCRIPTION, clazz);
|
|
108 |
}
|
|
108 |
getInstance().register(FILE_DIALOG_CHOOSER_MANAGER_NAME,
|
|
109 |
FILE_DIALOG_CHOOSER_MANAGER_DESCRIPTION, clazz);
|
|
110 |
}
|
|
109 | 111 |
|
110 |
public static void registerDefaultFileDialogChooserManager(Class clazz) {
|
|
111 |
getInstance().registerDefault(FILE_DIALOG_CHOOSER_MANAGER_NAME,
|
|
112 |
FILE_DIALOG_CHOOSER_MANAGER_DESCRIPTION, clazz);
|
|
113 |
}
|
|
112 |
public static void registerDefaultFileDialogChooserManager(Class clazz) {
|
|
113 |
getInstance().registerDefault(FILE_DIALOG_CHOOSER_MANAGER_NAME,
|
|
114 |
FILE_DIALOG_CHOOSER_MANAGER_DESCRIPTION, clazz);
|
|
115 |
}
|
|
114 | 116 |
|
115 |
//SVG support
|
|
117 |
//SVG support
|
|
116 | 118 |
public static SVGSupportManager getSVGSupportManager() throws LocatorException { |
117 | 119 |
return (SVGSupportManager) getInstance().get(PLUGINS_SVGSUPPORT_MANAGER_NAME); |
118 | 120 |
} |
... | ... | |
122 | 124 |
clazz); |
123 | 125 |
} |
124 | 126 |
|
125 |
public static void registerDefaultSVGSupportManager(Class clazz) {
|
|
126 |
getInstance().registerDefault(PLUGINS_SVGSUPPORT_MANAGER_NAME,
|
|
127 |
PLUGINS_SVGSUPPORT_MANAGER_DESCRIPTION, clazz);
|
|
128 |
}
|
|
127 |
public static void registerDefaultSVGSupportManager(Class clazz) {
|
|
128 |
getInstance().registerDefault(PLUGINS_SVGSUPPORT_MANAGER_NAME,
|
|
129 |
PLUGINS_SVGSUPPORT_MANAGER_DESCRIPTION, clazz);
|
|
130 |
}
|
|
129 | 131 |
|
132 |
public static ImageViewerManager getImageViewerManager() throws LocatorException { |
|
133 |
return (ImageViewerManager) getInstance().get(PLUGINS_IMAGEVIEWER_MANAGER_NAME); |
|
134 |
} |
|
135 |
|
|
136 |
public static void registerImageViewertManager(Class clazz) { |
|
137 |
getInstance().register(PLUGINS_IMAGEVIEWER_MANAGER_NAME, PLUGINS_IMAGEVIEWER_MANAGER_DESCRIPTION, |
|
138 |
clazz); |
|
139 |
} |
|
140 |
|
|
141 |
public static void registerDefaultImageViewerManager(Class clazz) { |
|
142 |
getInstance().registerDefault(PLUGINS_IMAGEVIEWER_MANAGER_NAME, |
|
143 |
PLUGINS_IMAGEVIEWER_MANAGER_DESCRIPTION, clazz); |
|
144 |
} |
|
130 | 145 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.api/src/main/java/org/gvsig/imageviewer/ImageViewerManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.gvsig.imageviewer; |
|
26 |
|
|
27 |
|
|
28 |
/** |
|
29 |
* @author gvSIG Team |
|
30 |
* |
|
31 |
*/ |
|
32 |
|
|
33 |
public interface ImageViewerManager { |
|
34 |
|
|
35 |
public ImageViewer createImageViewer(); |
|
36 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.api/src/main/java/org/gvsig/imageviewer/ImageViewer.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.gvsig.imageviewer; |
|
26 |
|
|
27 |
import java.io.File; |
|
28 |
import java.net.URL; |
|
29 |
import org.gvsig.tools.swing.api.Component; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* @author gvSIG Team |
|
34 |
* |
|
35 |
*/ |
|
36 |
|
|
37 |
public interface ImageViewer extends Component { |
|
38 |
|
|
39 |
public void setImage(URL image); |
|
40 |
|
|
41 |
public void setImage(File image); |
|
42 |
|
|
43 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.api/pom.xml | ||
---|---|---|
14 | 14 |
<artifactId>org.gvsig.tools.lib</artifactId> |
15 | 15 |
<scope>compile</scope> |
16 | 16 |
</dependency> |
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
17 | 22 |
</dependencies> |
18 | 23 |
</project> |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/imageviewer/DefaultImageViewerManager.java | ||
---|---|---|
1 |
package org.gvsig.imageviewer; |
|
2 |
|
|
3 |
|
|
4 |
public class DefaultImageViewerManager implements ImageViewerManager { |
|
5 |
|
|
6 |
@Override |
|
7 |
public ImageViewer createImageViewer() { |
|
8 |
return new DefaultImageViewer(); |
|
9 |
} |
|
10 |
|
|
11 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.util/org.gvsig.tools.util.impl/src/main/java/org/gvsig/imageviewer/DefaultImageViewer.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.imageviewer; |
|
3 |
|
|
4 |
import java.awt.BorderLayout; |
|
5 |
import java.awt.Dimension; |
|
6 |
import java.io.File; |
|
7 |
import java.net.URL; |
|
8 |
import javax.swing.ImageIcon; |
|
9 |
import javax.swing.JComponent; |
|
10 |
import javax.swing.JLabel; |
|
11 |
import javax.swing.JPanel; |
|
12 |
|
|
13 |
|
|
14 |
public class DefaultImageViewer extends JPanel implements ImageViewer { |
|
15 |
|
|
16 |
private JLabel label; |
|
17 |
|
|
18 |
public DefaultImageViewer() { |
|
19 |
this.initComponents(); |
|
20 |
} |
|
21 |
|
|
22 |
private void initComponents() { |
|
23 |
this.label = new JLabel(); |
|
24 |
this.setLayout(new BorderLayout()); |
|
25 |
this.add(this.label, BorderLayout.CENTER); |
|
26 |
|
|
27 |
this.setPreferredSize( new Dimension(200,350)); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public void setImage(URL image) { |
|
32 |
ImageIcon img = new ImageIcon(image); |
|
33 |
this.label.setIcon(img); |
|
34 |
this.setPreferredSize(new Dimension(img.getIconWidth(), img.getIconHeight())); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public void setImage(File image) { |
|
39 |
try { |
|
40 |
this.setImage(image.toURI().toURL()); |
|
41 |
} catch(Exception ex) { |
|
42 |
throw new IllegalArgumentException(ex); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public JComponent asJComponent() { |
|
48 |
return this; |
|
49 |
} |
|
50 |
|
|
51 |
|
|
52 |
} |
Also available in: Unified diff