Revision 342
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<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/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.hyperlink.app.extension</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>${project.artifactId}</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.hyperlink.app</artifactId> |
|
11 |
<version>1.0.64</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
<dependencies> |
|
15 |
<dependency> |
|
16 |
<groupId>org.gvsig</groupId> |
|
17 |
<artifactId>org.gvsig.andami</artifactId> |
|
18 |
<scope>compile</scope> |
|
19 |
</dependency> |
|
20 |
<dependency> |
|
21 |
<groupId>org.gvsig</groupId> |
|
22 |
<artifactId>org.gvsig.i18n</artifactId> |
|
23 |
<scope>compile</scope> |
|
24 |
</dependency> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
28 |
<scope>compile</scope> |
|
29 |
</dependency> |
|
30 |
|
|
31 |
<dependency> |
|
32 |
<groupId>org.gvsig</groupId> |
|
33 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
34 |
<scope>compile</scope> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
39 |
<scope>compile</scope> |
|
40 |
</dependency> |
|
41 |
|
|
42 |
<dependency> |
|
43 |
<groupId>org.gvsig</groupId> |
|
44 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
45 |
<scope>compile</scope> |
|
46 |
</dependency> |
|
47 |
|
|
48 |
<dependency> |
|
49 |
<groupId>org.gvsig</groupId> |
|
50 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
51 |
<scope>compile</scope> |
|
52 |
</dependency> |
|
53 |
|
|
54 |
<dependency> |
|
55 |
<groupId>org.gvsig</groupId> |
|
56 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
57 |
<scope>compile</scope> |
|
58 |
</dependency> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
62 |
<scope>compile</scope> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.utils</artifactId> |
|
67 |
<scope>compile</scope> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>org.gvsig</groupId> |
|
71 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
72 |
<scope>compile</scope> |
|
73 |
</dependency> |
|
74 |
<dependency> |
|
75 |
<groupId>org.gvsig</groupId> |
|
76 |
<artifactId>org.gvsig.ui</artifactId> |
|
77 |
<scope>compile</scope> |
|
78 |
</dependency> |
|
79 |
<dependency> |
|
80 |
<groupId>org.slf4j</groupId> |
|
81 |
<artifactId>slf4j-api</artifactId> |
|
82 |
<scope>compile</scope> |
|
83 |
</dependency> |
|
84 |
|
|
85 |
<!-- External libraries --> |
|
86 |
|
|
87 |
<dependency> |
|
88 |
<groupId>org.jpedal</groupId> |
|
89 |
<artifactId>jpedal_lgpl</artifactId> |
|
90 |
<scope>compile</scope> |
|
91 |
</dependency> |
|
92 |
<dependency> |
|
93 |
<groupId>com.sun</groupId> |
|
94 |
<artifactId>jimi</artifactId> |
|
95 |
<scope>compile</scope> |
|
96 |
</dependency> |
|
97 |
<dependency> |
|
98 |
<groupId>org.apache.xmlgraphics</groupId> |
|
99 |
<artifactId>batik-gvt</artifactId> |
|
100 |
<scope>compile</scope> |
|
101 |
</dependency> |
|
102 |
<dependency> |
|
103 |
<groupId>org.apache.xmlgraphics</groupId> |
|
104 |
<artifactId>batik-bridge</artifactId> |
|
105 |
<scope>compile</scope> |
|
106 |
</dependency> |
|
107 |
<dependency> |
|
108 |
<groupId>org.apache.xmlgraphics</groupId> |
|
109 |
<artifactId>batik-script</artifactId> |
|
110 |
<scope>compile</scope> |
|
111 |
</dependency> |
|
112 |
<dependency> |
|
113 |
<groupId>xml-apis</groupId> |
|
114 |
<artifactId>xml-apis-ext</artifactId> |
|
115 |
<scope>compile</scope> |
|
116 |
</dependency> |
|
117 |
|
|
118 |
|
|
119 |
</dependencies> |
|
120 |
|
|
121 |
<build> |
|
122 |
<plugins> |
|
123 |
<plugin> |
|
124 |
<!-- Set java compatibility --> |
|
125 |
<groupId>org.apache.maven.plugins</groupId> |
|
126 |
<artifactId>maven-compiler-plugin</artifactId> |
|
127 |
<configuration> |
|
128 |
<source>1.6</source> |
|
129 |
<target>1.6</target> |
|
130 |
<encoding>ISO-8859-1</encoding> |
|
131 |
</configuration> |
|
132 |
</plugin> |
|
133 |
|
|
134 |
<!-- |
|
135 |
<plugin> |
|
136 |
<groupId>org.codehaus.mojo</groupId> |
|
137 |
<artifactId>animal-sniffer-maven-plugin</artifactId> |
|
138 |
<executions> |
|
139 |
<execution> |
|
140 |
<id>check-java-api</id> |
|
141 |
<phase>package</phase> |
|
142 |
<goals> |
|
143 |
<goal>check</goal> |
|
144 |
</goals> |
|
145 |
<configuration> |
|
146 |
<skip>false</skip> |
|
147 |
<signature> |
|
148 |
<groupId>org.codehaus.mojo.signature</groupId> |
|
149 |
<artifactId>java16</artifactId> |
|
150 |
<version>1.0</version> |
|
151 |
</signature> |
|
152 |
</configuration> |
|
153 |
</execution> |
|
154 |
</executions> |
|
155 |
</plugin> |
|
156 |
--> |
|
157 |
</plugins> |
|
158 |
</build> |
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
<properties> |
|
163 |
<gvsig.package.info.name>Tools: Hyperlink</gvsig.package.info.name> |
|
164 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
165 |
<gvsig.package.info.categories>View</gvsig.package.info.categories> |
|
166 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
167 |
<gvsig.package.info.dependencies>required: org.gvsig.app.mainplugin -ge 2</gvsig.package.info.dependencies> |
|
168 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-hyperlink/pool</gvsig.package.info.poolURL> |
|
169 |
<gvsig.package.info.javaVM>j1_6</gvsig.package.info.javaVM> |
|
170 |
|
|
171 |
</properties> |
|
172 |
|
|
173 |
|
|
174 |
</project> |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/buildNumber.properties | ||
---|---|---|
1 |
#Sun Oct 15 10:58:22 CEST 2017 |
|
2 |
buildNumber=2151 |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<!-- org.gvsig.app.mainplugin provides these libraries |
|
26 |
<dependencySets> |
|
27 |
|
|
28 |
<dependencySet> |
|
29 |
<useProjectArtifact>false</useProjectArtifact> |
|
30 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
31 |
<outputDirectory>lib</outputDirectory> |
|
32 |
<includes> |
|
33 |
<include>org.jpedal:jpedal_lgpl</include> |
|
34 |
<include>com.sun:jimi</include> |
|
35 |
<include>org.apache.xmlgraphics:batik-gvt</include> |
|
36 |
<include>org.apache.xmlgraphics:batik-bridge</include> |
|
37 |
<include>org.apache.xmlgraphics:batik-script</include> |
|
38 |
<include>xml-apis:xml-apis-ext</include> |
|
39 |
</includes> |
|
40 |
</dependencySet> |
|
41 |
</dependencySets> |
|
42 |
--> |
|
43 |
|
|
44 |
</assembly> |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/LinkConfigExtension.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 |
package org.gvsig.hyperlink.app.extension; |
|
24 |
|
|
25 |
import org.gvsig.andami.PluginServices; |
|
26 |
import org.gvsig.andami.plugins.Extension; |
|
27 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
28 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
29 |
import org.gvsig.app.project.documents.view.gui.IView; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
32 |
import org.gvsig.hyperlink.app.extension.config.gui.ConfigTab; |
|
33 |
import org.gvsig.hyperlink.app.extension.layers.ManagerRegistry; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
/** |
|
38 |
* Extensi?n para gestionar los hiperlinks. |
|
39 |
* |
|
40 |
* @author Vicente Caballero Navarro |
|
41 |
*/ |
|
42 |
public class LinkConfigExtension extends Extension { |
|
43 |
|
|
44 |
private static final Logger logger = |
|
45 |
LoggerFactory.getLogger(LinkConfigExtension.class); |
|
46 |
ManagerRegistry layerManager; |
|
47 |
|
|
48 |
/** |
|
49 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
50 |
*/ |
|
51 |
public void execute(String s) { |
|
52 |
logger.debug("Command : " + s); |
|
53 |
|
|
54 |
if (s.compareTo("LINK_SETTINGS") == 0) { |
|
55 |
IView view = |
|
56 |
(IView) PluginServices.getMDIManager().getActiveWindow(); |
|
57 |
HyperlinkExtension ext = |
|
58 |
(HyperlinkExtension) PluginServices.getExtension(HyperlinkExtension.class); |
|
59 |
// init tool and load legacy config in case it has been not done |
|
60 |
ext.initTool(view); |
|
61 |
FLayer[] activas = |
|
62 |
view.getMapControl().getMapContext().getLayers().getActives(); |
|
63 |
for (int i = 0; i < activas.length; i++) { |
|
64 |
if (!activas[i].isAvailable()) { |
|
65 |
return; |
|
66 |
} |
|
67 |
|
|
68 |
if (layerManager.hasManager(activas[i])) { |
|
69 |
ConfigTab configWindow = new ConfigTab(); |
|
70 |
configWindow.setModel(activas[i]); |
|
71 |
PluginServices.getMDIManager() |
|
72 |
.addCentredWindow(configWindow); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible() |
|
81 |
*/ |
|
82 |
public boolean isVisible() { |
|
83 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
84 |
|
|
85 |
if (window == null) { |
|
86 |
return false; |
|
87 |
} |
|
88 |
|
|
89 |
if (window instanceof IView) { |
|
90 |
|
|
91 |
MapContext mapa = |
|
92 |
((IView) window).getViewDocument().getMapContext(); |
|
93 |
|
|
94 |
return mapa.getLayers().getLayersCount() > 0; |
|
95 |
} else { |
|
96 |
return false; |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
102 |
*/ |
|
103 |
public boolean isEnabled() { |
|
104 |
// it will be enabled when there is only ONE active layer, and this |
|
105 |
// layer |
|
106 |
// is available and has a valid ILayerLinkManager |
|
107 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
|
108 |
|
|
109 |
if (window == null) { |
|
110 |
return false; |
|
111 |
} |
|
112 |
|
|
113 |
if (window instanceof IView) { |
|
114 |
IView view = (IView) window; |
|
115 |
ViewDocument model = view.getViewDocument(); |
|
116 |
FLayer[] activas = model.getMapContext().getLayers().getActives(); |
|
117 |
if (activas.length == 1) { |
|
118 |
if (activas[0].isAvailable() |
|
119 |
&& layerManager.hasManager(activas[0])) { |
|
120 |
return true; |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
return false; |
|
125 |
} |
|
126 |
|
|
127 |
public void postInitialize() { |
|
128 |
HyperlinkExtension ext = |
|
129 |
(HyperlinkExtension) PluginServices.getExtension(HyperlinkExtension.class); |
|
130 |
layerManager = ext.getLayerManager(); |
|
131 |
} |
|
132 |
|
|
133 |
public void initialize() { |
|
134 |
//Do nothing |
|
135 |
} |
|
136 |
|
|
137 |
} |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/ShowPanel.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 |
package org.gvsig.hyperlink.app.extension; |
|
24 |
|
|
25 |
import java.awt.BorderLayout; |
|
26 |
import java.awt.event.ComponentEvent; |
|
27 |
import java.awt.event.ComponentListener; |
|
28 |
import java.io.File; |
|
29 |
import java.net.MalformedURLException; |
|
30 |
|
|
31 |
import javax.swing.JPanel; |
|
32 |
import javax.swing.JScrollPane; |
|
33 |
|
|
34 |
import org.gvsig.andami.PluginServices; |
|
35 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
36 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
37 |
|
|
38 |
/** |
|
39 |
* This class extends JPanel. This class implements a Panel to show the content |
|
40 |
* of the URI |
|
41 |
* that the constructor of the class receives. This panel invokes a new one with |
|
42 |
* the content |
|
43 |
* of the URI. The type of the supported URI should be added like extension |
|
44 |
* point in the |
|
45 |
* initialization of the extension. |
|
46 |
* |
|
47 |
* @author Vicente Caballero Navarro |
|
48 |
* @author Eustaquio Vercher |
|
49 |
* |
|
50 |
*/ |
|
51 |
public class ShowPanel extends JPanel implements IWindow, ComponentListener { |
|
52 |
|
|
53 |
private JScrollPane jScrollPane = null; |
|
54 |
private WindowInfo m_ViewInfo = null; |
|
55 |
private AbstractHyperLinkPanel contents = null; |
|
56 |
private static int xpos = 0; |
|
57 |
private static int ypos = 0; |
|
58 |
|
|
59 |
public ShowPanel(AbstractHyperLinkPanel contents) { |
|
60 |
super(); |
|
61 |
this.contents = contents; |
|
62 |
initialize(); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* This method initializes this |
|
67 |
*/ |
|
68 |
private void initialize() { |
|
69 |
this.setLayout(new BorderLayout()); |
|
70 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
|
71 |
getJScrollPane().setViewportView(contents); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Returns a Scroll Pane with the content of the HyperLink |
|
76 |
* |
|
77 |
* @return jScrollPane |
|
78 |
*/ |
|
79 |
private JScrollPane getJScrollPane() { |
|
80 |
if (jScrollPane == null) { |
|
81 |
jScrollPane = new JScrollPane(); |
|
82 |
// jScrollPane.setPreferredSize(new java.awt.Dimension(300, 400)); |
|
83 |
} |
|
84 |
return jScrollPane; |
|
85 |
} |
|
86 |
|
|
87 |
/* |
|
88 |
* (non-Javadoc) |
|
89 |
* |
|
90 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
|
91 |
*/ |
|
92 |
public WindowInfo getWindowInfo() { |
|
93 |
if (m_ViewInfo == null) { |
|
94 |
m_ViewInfo = |
|
95 |
new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE |
|
96 |
| WindowInfo.ICONIFIABLE | WindowInfo.PALETTE); |
|
97 |
if (contents.getURI().toString().startsWith("file:") |
|
98 |
&& contents.getURI().isAbsolute()) { |
|
99 |
try { |
|
100 |
File file = new File(contents.getURI().toURL().getFile()); |
|
101 |
m_ViewInfo.setTitle(PluginServices.getText(this, |
|
102 |
"Hyperlink") + " - " + file.getName()); |
|
103 |
} catch (MalformedURLException e) { |
|
104 |
m_ViewInfo.setTitle(PluginServices.getText(this, |
|
105 |
"Hyperlink") + " - " + contents.getURI().toString()); |
|
106 |
} catch (NullPointerException e) { |
|
107 |
m_ViewInfo.setTitle(PluginServices.getText(this, |
|
108 |
"Hyperlink") + " - " + contents.getURI().toString()); |
|
109 |
} |
|
110 |
} else { |
|
111 |
m_ViewInfo.setTitle(PluginServices.getText(this, "Hyperlink") |
|
112 |
+ " - " + contents.getURI().toString()); |
|
113 |
} |
|
114 |
int height = (int) contents.getPreferredSize().getHeight() + 15; |
|
115 |
if (height > 650) |
|
116 |
height = 650; |
|
117 |
else |
|
118 |
if (height < 450) |
|
119 |
height = 450; |
|
120 |
int width = (int) contents.getPreferredSize().getWidth() + 20; |
|
121 |
if (width > 800) |
|
122 |
width = 800; |
|
123 |
else |
|
124 |
if (width < 450) |
|
125 |
width = 450; |
|
126 |
m_ViewInfo.setWidth(width); |
|
127 |
m_ViewInfo.setHeight(height); |
|
128 |
m_ViewInfo.setX(xpos); |
|
129 |
xpos = (xpos + 20) % 270; |
|
130 |
m_ViewInfo.setY(ypos); |
|
131 |
ypos = (ypos + 15) % 150; |
|
132 |
} |
|
133 |
return m_ViewInfo; |
|
134 |
} |
|
135 |
|
|
136 |
/* |
|
137 |
* (non-Javadoc) |
|
138 |
* |
|
139 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event. |
|
140 |
* ComponentEvent) |
|
141 |
*/ |
|
142 |
public void componentResized(ComponentEvent e) { |
|
143 |
|
|
144 |
} |
|
145 |
|
|
146 |
/* |
|
147 |
* (non-Javadoc) |
|
148 |
* |
|
149 |
* @see |
|
150 |
* java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent |
|
151 |
* ) |
|
152 |
*/ |
|
153 |
public void componentMoved(ComponentEvent e) { |
|
154 |
|
|
155 |
} |
|
156 |
|
|
157 |
/* |
|
158 |
* (non-Javadoc) |
|
159 |
* |
|
160 |
* @see |
|
161 |
* java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent |
|
162 |
* ) |
|
163 |
*/ |
|
164 |
public void componentShown(ComponentEvent e) { |
|
165 |
|
|
166 |
} |
|
167 |
|
|
168 |
/* |
|
169 |
* (non-Javadoc) |
|
170 |
* |
|
171 |
* @see java.awt.event.ComponentListener#componentHidden(java.awt.event. |
|
172 |
* ComponentEvent) |
|
173 |
*/ |
|
174 |
public void componentHidden(ComponentEvent e) { |
|
175 |
|
|
176 |
} |
|
177 |
|
|
178 |
public Object getWindowProfile() { |
|
179 |
return WindowInfo.EDITOR_PROFILE; |
|
180 |
} |
|
181 |
} |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/ImgPanel.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 |
package org.gvsig.hyperlink.app.extension.actions; |
|
24 |
|
|
25 |
import java.awt.BorderLayout; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.net.MalformedURLException; |
|
28 |
import java.net.URI; |
|
29 |
|
|
30 |
import javax.swing.ImageIcon; |
|
31 |
import javax.swing.JLabel; |
|
32 |
|
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.messages.NotificationManager; |
|
35 |
import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel; |
|
36 |
|
|
37 |
import com.sun.jimi.core.Jimi; |
|
38 |
|
|
39 |
/** |
|
40 |
* This class extends AbstractHyperLink, and provides suppot to open images of |
|
41 |
* many formats. |
|
42 |
* The common supported formats are JPG, ICO, BMP, TIFF, GIF and PNG. Implements |
|
43 |
* methods from |
|
44 |
* IExtensionBuilder to make it extending. |
|
45 |
* |
|
46 |
* @author Eustaquio Vercher (IVER) |
|
47 |
* @author Cesar Martinez Izquierdo (IVER) |
|
48 |
*/ |
|
49 |
public class ImgPanel extends AbstractHyperLinkPanel { |
|
50 |
|
|
51 |
private static final long serialVersionUID = -5200841105188251551L; |
|
52 |
|
|
53 |
/** |
|
54 |
* Default constructor. |
|
55 |
*/ |
|
56 |
public ImgPanel(URI doc) { |
|
57 |
super(doc); |
|
58 |
initialize(); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Initializes this panel. |
|
63 |
*/ |
|
64 |
void initialize() { |
|
65 |
this.setLayout(new BorderLayout()); |
|
66 |
showDocument(); |
|
67 |
// this.setSize(600, 400); |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Implements the necessary code to open images in this panel. |
|
72 |
*/ |
|
73 |
protected void showDocument() { |
|
74 |
if (!checkAndNormalizeURI()) { |
|
75 |
return; |
|
76 |
} |
|
77 |
ImageIcon image = null; |
|
78 |
String iString = document.toString(); |
|
79 |
iString = iString.toLowerCase(); |
|
80 |
|
|
81 |
if (iString.endsWith("jpg") || iString.endsWith("jpeg") |
|
82 |
|| iString.endsWith("gif") || iString.endsWith("jp2")) { |
|
83 |
// note: it seems jimi si not able to load .jp2 (jpeg2000) |
|
84 |
try { |
|
85 |
image = new ImageIcon(Jimi.getImage(document.toURL())); |
|
86 |
} catch (MalformedURLException e) { |
|
87 |
NotificationManager.addWarning(PluginServices.getText(this, |
|
88 |
"Hyperlink_linked_field_doesnot_exist"), e); |
|
89 |
} |
|
90 |
} else |
|
91 |
if (iString.endsWith("png") || iString.endsWith("tiff") |
|
92 |
|| iString.endsWith("tif") || iString.endsWith("jpg") |
|
93 |
|| iString.endsWith("ico") || iString.endsWith("xpm") |
|
94 |
|| iString.endsWith("bmp")) { |
|
95 |
// note: it seems jimi si not able to load .tiff images |
|
96 |
try { |
|
97 |
image = new ImageIcon(Jimi.getImage(document.toURL())); |
|
98 |
} catch (MalformedURLException e) { |
|
99 |
NotificationManager.addWarning(PluginServices.getText(this, |
|
100 |
"Hyperlink_linked_field_doesnot_exist"), e); |
|
101 |
} |
|
102 |
} else { |
|
103 |
try { |
|
104 |
image = new ImageIcon(document.toURL()); |
|
105 |
} catch (MalformedURLException e) { |
|
106 |
NotificationManager.addWarning(PluginServices.getText(this, |
|
107 |
"Hyperlink_linked_field_doesnot_exist"), e); |
|
108 |
} |
|
109 |
} |
|
110 |
if (image == null) |
|
111 |
; // Incluir error |
|
112 |
this.setPreferredSize(new Dimension(image.getIconWidth(), |
|
113 |
image.getIconHeight())); |
|
114 |
this.setSize(new Dimension(image.getIconWidth(), image.getIconHeight())); |
|
115 |
JLabel label = new JLabel(image); |
|
116 |
this.add(label); |
|
117 |
} |
|
118 |
|
|
119 |
} |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/ExternTxtFormat.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 |
package org.gvsig.hyperlink.app.extension.actions; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.io.Serializable; |
|
27 |
import java.net.URI; |
|
28 |
import javax.swing.JOptionPane; |
|
29 |
|
|
30 |
import org.gvsig.andami.PluginServices; |
|
31 |
import org.gvsig.hyperlink.app.extension.AbstractActionManager; |
|
32 |
import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel; |
|
33 |
|
|
34 |
public class ExternTxtFormat extends AbstractActionManager implements Serializable { |
|
35 |
|
|
36 |
public static final String actionCode = "TxtExtern_format"; |
|
37 |
|
|
38 |
public AbstractHyperLinkPanel createPanel(URI doc) throws UnsupportedOperationException { |
|
39 |
return null; |
|
40 |
} |
|
41 |
|
|
42 |
public String getActionCode() { |
|
43 |
return actionCode; |
|
44 |
} |
|
45 |
|
|
46 |
public boolean hasPanel() { |
|
47 |
return false; |
|
48 |
} |
|
49 |
|
|
50 |
public void showDocument(URI doc) { |
|
51 |
DesktopApi.browse(doc); |
|
52 |
} |
|
53 |
|
|
54 |
public String getDescription() { |
|
55 |
return PluginServices.getText(this, "Shows_HTML_or_text_files_in_system_application"); |
|
56 |
} |
|
57 |
|
|
58 |
public String getName() { |
|
59 |
return PluginServices.getText(this, "HTML_and_text_formats_in_system_application"); |
|
60 |
} |
|
61 |
|
|
62 |
} |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/PdfHyperlinkPanel.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 |
package org.gvsig.hyperlink.app.extension.actions; |
|
24 |
|
|
25 |
import java.awt.BorderLayout; |
|
26 |
import java.awt.Component; |
|
27 |
import java.awt.Container; |
|
28 |
import java.awt.Dimension; |
|
29 |
import java.awt.FlowLayout; |
|
30 |
import java.awt.Toolkit; |
|
31 |
import java.awt.event.ActionEvent; |
|
32 |
import java.awt.event.ActionListener; |
|
33 |
import java.awt.print.PageFormat; |
|
34 |
import java.awt.print.Paper; |
|
35 |
import java.awt.print.PrinterException; |
|
36 |
import java.awt.print.PrinterJob; |
|
37 |
import java.beans.PropertyChangeEvent; |
|
38 |
import java.beans.PropertyChangeListener; |
|
39 |
import java.net.URI; |
|
40 |
|
|
41 |
import javax.print.attribute.HashPrintRequestAttributeSet; |
|
42 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
43 |
import javax.print.attribute.SetOfIntegerSyntax; |
|
44 |
import javax.print.attribute.standard.PageRanges; |
|
45 |
import javax.swing.JButton; |
|
46 |
import javax.swing.JLabel; |
|
47 |
import javax.swing.JOptionPane; |
|
48 |
import javax.swing.JPanel; |
|
49 |
import javax.swing.JScrollPane; |
|
50 |
import javax.swing.JTextField; |
|
51 |
|
|
52 |
import org.gvsig.andami.IconThemeHelper; |
|
53 |
import org.gvsig.andami.PluginServices; |
|
54 |
import org.gvsig.andami.messages.NotificationManager; |
|
55 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
56 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
57 |
import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel; |
|
58 |
import org.jpedal.Display; |
|
59 |
import org.jpedal.PdfDecoder; |
|
60 |
import org.jpedal.exception.PdfException; |
|
61 |
import org.jpedal.objects.PrinterOptions; |
|
62 |
|
|
63 |
public class PdfHyperlinkPanel extends AbstractHyperLinkPanel implements |
|
64 |
PropertyChangeListener, IWindow { |
|
65 |
|
|
66 |
private static final long serialVersionUID = 1L; |
|
67 |
private WindowInfo m_viewInfo; |
|
68 |
private PdfDecoder pf = null; |
|
69 |
|
|
70 |
private int currentPage = 1; |
|
71 |
private final JLabel pageCounter1 = new JLabel(" " |
|
72 |
+ PluginServices.getText(this, "Pagina") + " "); |
|
73 |
private JTextField pageCounter2 = new JTextField(4); |
|
74 |
private JLabel pageCounter3 = |
|
75 |
new JLabel(PluginServices.getText(this, "de")); |
|
76 |
|
|
77 |
public static void initializeIcons() { |
|
78 |
IconThemeHelper.registerIcon("toolbar-go", "go-next", PdfHyperlinkPanel.class); |
|
79 |
IconThemeHelper.registerIcon("toolbar-go", "go-previous", PdfHyperlinkPanel.class); |
|
80 |
IconThemeHelper.registerIcon("toolbar-go", "go-next-fast", PdfHyperlinkPanel.class); |
|
81 |
IconThemeHelper.registerIcon("toolbar-go", "go-previous-fast", PdfHyperlinkPanel.class); |
|
82 |
IconThemeHelper.registerIcon("toolbar-go", "go-first", PdfHyperlinkPanel.class); |
|
83 |
IconThemeHelper.registerIcon("toolbar-go", "go-last", PdfHyperlinkPanel.class); |
|
84 |
IconThemeHelper.registerIcon("action", "document-print", PdfHyperlinkPanel.class); |
|
85 |
} |
|
86 |
|
|
87 |
public PdfHyperlinkPanel(URI doc) { |
|
88 |
super(doc); |
|
89 |
initialize(); |
|
90 |
} |
|
91 |
|
|
92 |
private void initialize() { |
|
93 |
|
|
94 |
pf = new PdfDecoder(); |
|
95 |
|
|
96 |
try { |
|
97 |
if (document != null && document.isAbsolute()) { |
|
98 |
String urlString = document.toURL().toString(); |
|
99 |
// avoid the openPdfFileFromURL method in first term, to avoid |
|
100 |
// the download dialog |
|
101 |
if (urlString.startsWith("file:")) { |
|
102 |
urlString = urlString.replaceFirst("file:/*", "/"); // keep |
|
103 |
// just |
|
104 |
// one |
|
105 |
// slash |
|
106 |
// at |
|
107 |
// the |
|
108 |
// beginning |
|
109 |
urlString = urlString.replaceAll("%20", " "); // PdfDecoder |
|
110 |
// doesn't |
|
111 |
// correctly |
|
112 |
// digest %20 |
|
113 |
// spaces |
|
114 |
pf.openPdfFile(urlString); |
|
115 |
} else { |
|
116 |
pf.openPdfFileFromURL(urlString, true); |
|
117 |
} |
|
118 |
} else { |
|
119 |
PluginServices.getLogger().warn(PluginServices.getText(this, |
|
120 |
"Hyperlink_linked_field_doesnot_exist")); |
|
121 |
return; |
|
122 |
} |
|
123 |
|
|
124 |
// these 2 lines opens page 1 at 100% scaling |
|
125 |
pf.decodePage(currentPage); |
|
126 |
float scaling = (float) 1.5; |
|
127 |
pf.setPageParameters(scaling, 1); // values scaling (1=100%). page |
|
128 |
// number |
|
129 |
pf.setDisplayView(Display.SINGLE_PAGE, Display.DISPLAY_CENTERED); |
|
130 |
} catch (Exception e) { |
|
131 |
NotificationManager.addWarning(PluginServices.getText(this, |
|
132 |
"Hyperlink_linked_field_doesnot_exist"), e); |
|
133 |
return; |
|
134 |
} |
|
135 |
|
|
136 |
// setup our GUI display |
|
137 |
initializeViewer(); |
|
138 |
|
|
139 |
// set page number display |
|
140 |
pageCounter2.setText(currentPage + ""); |
|
141 |
pageCounter3.setText(PluginServices.getText(this, "de") + " " |
|
142 |
+ pf.getPageCount() + " "); |
|
143 |
} |
|
144 |
|
|
145 |
public void setCurrentURL(URI currentURL) { |
|
146 |
document = currentURL; |
|
147 |
} |
|
148 |
|
|
149 |
private void initializeViewer() { |
|
150 |
|
|
151 |
Container cPane = this; |
|
152 |
cPane.setLayout(new BorderLayout()); |
|
153 |
|
|
154 |
// JButton open = initOpenBut();//setup open button |
|
155 |
Component[] itemsToAdd = initChangerPanel();// setup page display and |
|
156 |
// changer |
|
157 |
|
|
158 |
JPanel topBar = new JPanel(); |
|
159 |
topBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); |
|
160 |
// topBar.add(pageChanger); |
|
161 |
for (int i = 0; i < itemsToAdd.length; i++) { |
|
162 |
topBar.add(itemsToAdd[i]); |
|
163 |
} |
|
164 |
|
|
165 |
cPane.add(topBar, BorderLayout.NORTH); |
|
166 |
|
|
167 |
JScrollPane display = getJPaneViewer();// setup scrollpane with pdf |
|
168 |
// display inside |
|
169 |
cPane.add(display, BorderLayout.CENTER); |
|
170 |
|
|
171 |
// pack(); |
|
172 |
|
|
173 |
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); |
|
174 |
setSize(screen.width / 2, screen.height / 2); |
|
175 |
// <start-13> |
|
176 |
// setLocationRelativeTo(null);//centre on screen |
|
177 |
// <end-13> |
|
178 |
setVisible(true); |
|
179 |
} |
|
180 |
|
|
181 |
private Component[] initChangerPanel() { |
|
182 |
|
|
183 |
Component[] list = new Component[12]; |
|
184 |
|
|
185 |
/** back to page 1 */ |
|
186 |
JButton start = new JButton(); |
|
187 |
start.setBorderPainted(false); |
|
188 |
start.setIcon( IconThemeHelper.getImageIcon("go-first")); |
|
189 |
start.setToolTipText(PluginServices.getText(this, "primera_pagina")); |
|
190 |
// currentBar1.add(start); |
|
191 |
list[0] = start; |
|
192 |
start.addActionListener(new ActionListener() { |
|
193 |
|
|
194 |
public void actionPerformed(ActionEvent e) { |
|
195 |
if (pf != null && currentPage != 1) { |
|
196 |
currentPage = 1; |
|
197 |
try { |
|
198 |
pf.decodePage(currentPage); |
|
199 |
pf.invalidate(); |
|
200 |
repaint(); |
|
201 |
} catch (Exception e1) { |
|
202 |
System.err.println("back to page 1"); |
|
203 |
e1.printStackTrace(); |
|
204 |
} |
|
205 |
|
|
206 |
// set page number display |
|
207 |
pageCounter2.setText(currentPage + ""); |
|
208 |
} |
|
209 |
} |
|
210 |
}); |
|
211 |
|
|
212 |
/** back 10 icon */ |
|
213 |
JButton fback = new JButton(); |
|
214 |
fback.setBorderPainted(false); |
|
215 |
fback.setIcon( IconThemeHelper.getImageIcon("go-previous-fast")); |
|
216 |
fback.setToolTipText(PluginServices.getText(this, "diez_paginas_atras")); |
|
217 |
// currentBar1.add(fback); |
|
218 |
list[1] = fback; |
|
219 |
fback.addActionListener(new ActionListener() { |
|
220 |
|
|
221 |
public void actionPerformed(ActionEvent e) { |
|
222 |
if (pf != null && currentPage > 10) { |
|
223 |
currentPage -= 10; |
|
224 |
try { |
|
225 |
pf.decodePage(currentPage); |
|
226 |
pf.invalidate(); |
|
227 |
repaint(); |
|
228 |
} catch (Exception e1) { |
|
229 |
System.err.println("back 10 pages"); |
|
230 |
e1.printStackTrace(); |
|
231 |
} |
|
232 |
|
|
233 |
// set page number display |
|
234 |
pageCounter2.setText(currentPage + ""); |
|
235 |
} |
|
236 |
} |
|
237 |
}); |
|
238 |
|
|
239 |
/** back icon */ |
|
240 |
JButton back = new JButton(); |
|
241 |
back.setBorderPainted(false); |
|
242 |
back.setIcon( IconThemeHelper.getImageIcon("go-previous")); |
|
243 |
|
|
244 |
back.setToolTipText(PluginServices.getText(this, "pagina_atras")); |
|
245 |
// currentBar1.add(back); |
|
246 |
list[2] = back; |
|
247 |
back.addActionListener(new ActionListener() { |
|
248 |
|
|
249 |
public void actionPerformed(ActionEvent e) { |
|
250 |
if (pf != null && currentPage > 1) { |
|
251 |
currentPage -= 1; |
|
252 |
try { |
|
253 |
pf.decodePage(currentPage); |
|
254 |
pf.invalidate(); |
|
255 |
repaint(); |
|
256 |
} catch (Exception e1) { |
|
257 |
System.err.println("back 1 page"); |
|
258 |
e1.printStackTrace(); |
|
259 |
} |
|
260 |
|
|
261 |
// set page number display |
|
262 |
pageCounter2.setText(currentPage + ""); |
|
263 |
} |
|
264 |
} |
|
265 |
}); |
|
266 |
|
|
267 |
pageCounter2.setEditable(true); |
|
268 |
pageCounter2.addActionListener(new ActionListener() { |
|
269 |
|
|
270 |
public void actionPerformed(ActionEvent a) { |
|
271 |
|
|
272 |
String value = pageCounter2.getText().trim(); |
|
273 |
int newPage; |
|
274 |
|
|
275 |
// allow for bum values |
|
276 |
try { |
|
277 |
newPage = Integer.parseInt(value); |
|
278 |
|
|
279 |
if ((newPage > pf.getPageCount()) | (newPage < 1)) { |
|
280 |
return; |
|
281 |
} |
|
282 |
|
|
283 |
currentPage = newPage; |
|
284 |
try { |
|
285 |
pf.decodePage(currentPage); |
|
286 |
pf.invalidate(); |
|
287 |
repaint(); |
|
288 |
} catch (Exception e) { |
|
289 |
System.err.println("page number entered"); |
|
290 |
e.printStackTrace(); |
|
291 |
} |
|
292 |
|
|
293 |
} catch (Exception e) { |
|
294 |
JOptionPane.showMessageDialog(null, |
|
295 |
">" + value + "< " |
|
296 |
+ PluginServices.getText(this, "valor_incorrecto") |
|
297 |
+ pf.getPageCount()); |
|
298 |
} |
|
299 |
|
|
300 |
} |
|
301 |
|
|
302 |
}); |
|
303 |
|
|
304 |
/** put page count in middle of forward and back */ |
|
305 |
// currentBar1.add(pageCounter1); |
|
306 |
// currentBar1.add(new JPanel());//add gap |
|
307 |
// currentBar1.add(pageCounter2); |
|
308 |
// currentBar1.add(new JPanel());//add gap |
|
309 |
// currentBar1.add(pageCounter3); |
|
310 |
list[3] = pageCounter1; |
|
311 |
list[4] = new JPanel(); |
|
312 |
list[5] = pageCounter2; |
|
313 |
list[6] = new JPanel(); |
|
314 |
list[7] = pageCounter3; |
|
315 |
|
|
316 |
/** forward icon */ |
|
317 |
JButton forward = new JButton(); |
|
318 |
forward.setBorderPainted(false); |
|
319 |
forward.setIcon( IconThemeHelper.getImageIcon("go-next")); |
|
320 |
forward.setToolTipText(PluginServices.getText(this, "pagina_delante")); |
|
321 |
// currentBar1.add(forward); |
|
322 |
list[8] = forward; |
|
323 |
forward.addActionListener(new ActionListener() { |
|
324 |
|
|
325 |
public void actionPerformed(ActionEvent e) { |
|
326 |
if (pf != null && currentPage < pf.getPageCount()) { |
|
327 |
currentPage += 1; |
|
328 |
try { |
|
329 |
pf.decodePage(currentPage); |
|
330 |
pf.invalidate(); |
|
331 |
repaint(); |
|
332 |
} catch (Exception e1) { |
|
333 |
System.err.println("forward 1 page"); |
|
334 |
e1.printStackTrace(); |
|
335 |
} |
|
336 |
|
|
337 |
// set page number display |
|
338 |
pageCounter2.setText(currentPage + ""); |
|
339 |
} |
|
340 |
} |
|
341 |
}); |
|
342 |
|
|
343 |
/** fast forward icon */ |
|
344 |
JButton fforward = new JButton(); |
|
345 |
fforward.setBorderPainted(false); |
|
346 |
fforward.setIcon( IconThemeHelper.getImageIcon("go-next-fast")); |
|
347 |
fforward.setToolTipText(PluginServices.getText(this, |
|
348 |
"10_paginas_delante")); |
|
349 |
// currentBar1.add(fforward); |
|
350 |
list[9] = fforward; |
|
351 |
fforward.addActionListener(new ActionListener() { |
|
352 |
|
|
353 |
public void actionPerformed(ActionEvent e) { |
|
354 |
if (pf != null && currentPage < pf.getPageCount() - 9) { |
|
355 |
currentPage += 10; |
|
356 |
try { |
|
357 |
pf.decodePage(currentPage); |
|
358 |
pf.invalidate(); |
|
359 |
repaint(); |
|
360 |
} catch (Exception e1) { |
|
361 |
System.err.println("forward 10 pages"); |
|
362 |
e1.printStackTrace(); |
|
363 |
} |
|
364 |
|
|
365 |
// set page number display |
|
366 |
pageCounter2.setText(currentPage + ""); |
|
367 |
} |
|
368 |
} |
|
369 |
}); |
|
370 |
|
|
371 |
/** goto last page */ |
|
372 |
JButton end = new JButton(); |
|
373 |
end.setBorderPainted(false); |
|
374 |
end.setIcon( IconThemeHelper.getImageIcon("go-last")); |
|
375 |
end.setToolTipText(PluginServices.getText(this, "ultima_pagina")); |
|
376 |
// currentBar1.add(end); |
|
377 |
list[10] = end; |
|
378 |
end.addActionListener(new ActionListener() { |
|
379 |
|
|
380 |
public void actionPerformed(ActionEvent e) { |
|
381 |
if (pf != null && currentPage < pf.getPageCount()) { |
|
382 |
currentPage = pf.getPageCount(); |
|
383 |
try { |
|
384 |
pf.decodePage(currentPage); |
|
385 |
pf.invalidate(); |
|
386 |
repaint(); |
|
387 |
} catch (Exception e1) { |
|
388 |
System.err.println("forward to last page"); |
|
389 |
e1.printStackTrace(); |
|
390 |
} |
|
391 |
|
|
392 |
// set page number display |
|
393 |
pageCounter2.setText(currentPage + ""); |
|
394 |
} |
|
395 |
} |
|
396 |
}); |
|
397 |
|
|
398 |
/** Print */ |
|
399 |
JButton print = new JButton(); |
|
400 |
print.setBorderPainted(false); |
|
401 |
print.setIcon( IconThemeHelper.getImageIcon("document-print")); |
|
402 |
print.setToolTipText(PluginServices.getText(this, "imprimir")); |
|
403 |
// currentBar1.add(end); |
|
404 |
list[11] = print; |
|
405 |
print.addActionListener(new ActionListener() { |
|
406 |
|
|
407 |
public void actionPerformed(ActionEvent e) { |
|
408 |
printPDF(); |
|
409 |
} |
|
410 |
}); |
|
411 |
return list; |
|
412 |
} |
|
413 |
|
|
414 |
public void printPDF() { |
|
415 |
PrinterJob printJob = PrinterJob.getPrinterJob(); |
|
416 |
|
|
417 |
printJob.setPageable(pf); |
|
418 |
// decode_pdf.setPageFormat(pf); |
|
419 |
|
|
420 |
/** |
|
421 |
* this additional functionality is available under printable interface |
|
422 |
*/ |
|
423 |
// setup default values to add into JPS |
|
424 |
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); |
|
425 |
aset.add(new PageRanges(1, pf.getPageCount())); |
|
426 |
|
|
427 |
boolean printFile = printJob.printDialog(aset); |
|
428 |
|
|
429 |
// set page range |
|
430 |
PageRanges r = (PageRanges) aset.get(PageRanges.class); |
|
431 |
if (r != null) |
|
432 |
try { |
|
433 |
PageFormat pformat = printJob.defaultPage(); |
|
434 |
|
|
435 |
Paper paper = new Paper(); |
|
436 |
paper.setSize(595, 842); // default A4 |
|
437 |
paper.setImageableArea(43, 43, 545, 792); // actual print 'zone' |
|
438 |
|
|
439 |
pformat.setPaper(paper); |
|
440 |
|
|
441 |
// pageable provides a method getPageFormat(int p) - this method |
|
442 |
// allows it to be set by JPedal |
|
443 |
pf.setPageFormat(pformat); |
|
444 |
pf.setPagePrintRange((SetOfIntegerSyntax) r); |
|
445 |
} catch (PdfException e) { |
|
446 |
// TODO Auto-generated catch block |
|
447 |
e.printStackTrace(); |
|
448 |
} |
|
449 |
|
|
450 |
/** |
|
451 |
* generic call to both Pageable and printable |
|
452 |
*/ |
|
453 |
if (printFile) |
|
454 |
try { |
|
455 |
pf.setPrintPageScalingMode(PrinterOptions.PAGE_SCALING_FIT_TO_PRINTER_MARGINS); |
|
456 |
printJob.print(); |
|
457 |
} catch (PrinterException e) { |
|
458 |
// TODO Auto-generated catch block |
|
459 |
e.printStackTrace(); |
|
460 |
} |
|
461 |
} |
|
462 |
|
|
463 |
private JScrollPane getJPaneViewer() { |
|
464 |
JScrollPane currentScroll = new JScrollPane(); |
|
465 |
currentScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
466 |
currentScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
467 |
|
|
468 |
currentScroll.setViewportView(pf); |
|
469 |
return currentScroll; |
|
470 |
} |
|
471 |
|
|
472 |
/** |
|
473 |
* This is not used by hyperlink, but it's kept as it may be |
|
474 |
* useful to get a quick PDF window in gvSIG. |
|
475 |
*/ |
|
476 |
public WindowInfo getWindowInfo() { |
|
477 |
if (m_viewInfo == null) { |
|
478 |
m_viewInfo = new WindowInfo(WindowInfo.PALETTE); |
|
479 |
m_viewInfo.setMaximizable(true); |
|
480 |
m_viewInfo.setWidth(this.getWidth()); |
|
481 |
m_viewInfo.setHeight(this.getHeight()); |
|
482 |
m_viewInfo.setTitle(PluginServices.getText(this, "pdf_viewer")); |
|
483 |
} |
|
484 |
return m_viewInfo; |
|
485 |
} |
|
486 |
|
|
487 |
public void propertyChange(PropertyChangeEvent arg0) { |
|
488 |
// TODO Auto-generated method stub |
|
489 |
|
|
490 |
} |
|
491 |
|
|
492 |
public Object getWindowProfile() { |
|
493 |
return WindowInfo.EDITOR_PROFILE; |
|
494 |
} |
|
495 |
} |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/SvgPanel.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 |
package org.gvsig.hyperlink.app.extension.actions; |
|
24 |
|
|
25 |
import java.awt.BorderLayout; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.Graphics2D; |
|
28 |
import java.awt.Image; |
|
29 |
import java.awt.RenderingHints; |
|
30 |
import java.awt.geom.AffineTransform; |
|
31 |
import java.awt.geom.Rectangle2D; |
|
32 |
import java.awt.image.BufferedImage; |
|
33 |
import java.net.URI; |
|
34 |
|
|
35 |
import javax.swing.ImageIcon; |
|
36 |
import javax.swing.JLabel; |
|
37 |
|
|
38 |
import org.apache.batik.bridge.BridgeContext; |
|
39 |
import org.apache.batik.bridge.DocumentLoader; |
|
40 |
import org.apache.batik.bridge.GVTBuilder; |
|
41 |
import org.apache.batik.bridge.UserAgentAdapter; |
|
42 |
import org.apache.batik.bridge.ViewBox; |
|
43 |
import org.apache.batik.gvt.GraphicsNode; |
|
44 |
import org.apache.batik.gvt.renderer.StaticRenderer; |
|
45 |
import org.w3c.dom.Document; |
|
46 |
import org.w3c.dom.Element; |
|
47 |
import org.w3c.dom.svg.SVGDocument; |
|
48 |
|
|
49 |
import org.gvsig.andami.PluginServices; |
|
50 |
import org.gvsig.andami.messages.NotificationManager; |
|
51 |
import org.gvsig.hyperlink.app.extension.AbstractHyperLinkPanel; |
|
52 |
|
|
53 |
/** |
|
54 |
* This class extends AbstractHyperLink, and provides suppot to open images of |
|
55 |
* many formats. |
|
56 |
* The common supported formats are JPG, ICO, BMP, TIFF, GIF and PNG. Implements |
|
57 |
* methods from |
|
58 |
* IExtensionBuilder to make it extending. |
|
59 |
* |
|
60 |
* @author Eustaquio Vercher (IVER) |
|
61 |
* @author Cesar Martinez Izquierdo (IVER) |
|
62 |
*/ |
|
63 |
public class SvgPanel extends AbstractHyperLinkPanel { |
|
64 |
|
|
65 |
private static final long serialVersionUID = -5200841105188251551L; |
|
66 |
private GVTBuilder gvtBuilder = new GVTBuilder(); |
|
67 |
private GraphicsNode gvtRoot = null; |
|
68 |
private BridgeContext ctx = null; |
|
69 |
private StaticRenderer renderer = new StaticRenderer(); |
|
70 |
private Element elt; |
|
71 |
protected static RenderingHints defaultRenderingHints; |
|
72 |
static { |
|
73 |
defaultRenderingHints = new RenderingHints(null); |
|
74 |
defaultRenderingHints.put(RenderingHints.KEY_ANTIALIASING, |
|
75 |
RenderingHints.VALUE_ANTIALIAS_ON); |
|
76 |
|
|
77 |
defaultRenderingHints.put(RenderingHints.KEY_INTERPOLATION, |
|
78 |
RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Default constructor. |
|
83 |
*/ |
|
84 |
public SvgPanel(URI doc) { |
|
85 |
super(doc); |
|
86 |
initialize(); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Initializes this panel. |
|
91 |
*/ |
|
92 |
void initialize() { |
|
93 |
this.setLayout(new BorderLayout()); |
|
94 |
showDocument(); |
|
95 |
// this.setSize(600, 400); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Implements the necessary code to open images in this panel. |
|
100 |
*/ |
|
101 |
protected void showDocument() { |
|
102 |
if (!checkAndNormalizeURI()) { |
|
103 |
return; |
|
104 |
} |
|
105 |
|
|
106 |
ImageIcon image; |
|
107 |
// try { |
|
108 |
image = new ImageIcon(getSvgAsImage(document.toString())); |
|
109 |
|
|
110 |
if (image == null) |
|
111 |
; // Incluir error |
|
112 |
this.setPreferredSize(new Dimension(image.getIconWidth(), |
|
113 |
image.getIconHeight())); |
|
114 |
this.setSize(new Dimension(image.getIconWidth(), image.getIconHeight())); |
|
115 |
JLabel label = new JLabel(image); |
|
116 |
this.add(label); |
|
117 |
|
|
118 |
// } catch (MalformedURLException e) { |
|
119 |
// |
|
120 |
// } |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Allows paint SVG images in the panel. |
|
125 |
* |
|
126 |
* @param file |
|
127 |
* , this file has been extracted from the URI |
|
128 |
*/ |
|
129 |
private Image getSvgAsImage(String uri) { |
|
130 |
BufferedImage img = |
|
131 |
new BufferedImage(400, 400, BufferedImage.TYPE_INT_ARGB); |
|
132 |
Graphics2D g = img.createGraphics(); |
|
133 |
Rectangle2D rect = new Rectangle2D.Double(); |
|
134 |
rect.setFrame(0, 0, 400, 400); |
|
135 |
obtainStaticRenderer(uri); |
|
136 |
drawSVG(g, rect, null); |
|
137 |
return img; |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* Render the image to add to the panel. |
|
142 |
* |
|
143 |
* @param file |
|
144 |
* , this file has been extracted from the URI |
|
145 |
*/ |
|
146 |
private void obtainStaticRenderer(String uri) { |
|
147 |
try { |
|
148 |
UserAgentAdapter userAgent = new UserAgentAdapter(); |
|
149 |
DocumentLoader loader = new DocumentLoader(userAgent); |
|
150 |
ctx = new BridgeContext(userAgent, loader); |
|
151 |
// Document svgDoc = loader.loadDocument(file.toURI().toString()); |
|
152 |
Document svgDoc = loader.loadDocument(uri); |
|
153 |
gvtRoot = gvtBuilder.build(ctx, svgDoc); |
|
154 |
renderer.setTree(gvtRoot); |
|
155 |
elt = ((SVGDocument) svgDoc).getRootElement(); |
|
156 |
} catch (Exception ex) { |
|
157 |
NotificationManager.addWarning(PluginServices.getText(this, |
|
158 |
"Hyperlink_linked_field_doesnot_exist"), ex); |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
/** |
|
163 |
* Draw SVG in the Graphics that receives like parameter. |
|
164 |
* |
|
165 |
* @param g |
|
166 |
* Graphics |
|
167 |
* @param rect |
|
168 |
* Rectangle that fills the Graphic. |
|
169 |
* @param rv |
|
170 |
* Rectangle. This forms the visible part in the Layout |
|
171 |
*/ |
|
172 |
private void drawSVG(Graphics2D g, Rectangle2D rect, Rectangle2D rv) { |
|
173 |
if ((rv == null) || rv.contains(rect)) { |
|
174 |
AffineTransform ataux = new AffineTransform(); |
|
175 |
|
|
176 |
ataux.translate(rect.getX(), rect.getY()); |
|
177 |
try { |
|
178 |
ataux.concatenate(ViewBox.getViewTransform(null, |
|
179 |
elt, |
|
180 |
(float) rect.getWidth(), |
|
181 |
(float) rect.getHeight(), |
|
182 |
ctx)); |
|
183 |
gvtRoot.setTransform(ataux); |
|
184 |
|
|
185 |
} catch (Exception e) { |
|
186 |
// TODO: handle exception |
|
187 |
} |
|
188 |
} else { |
|
189 |
AffineTransform ataux = new AffineTransform(); |
|
190 |
|
|
191 |
ataux.translate(rect.getX(), rect.getY()); |
|
192 |
ataux.concatenate(ViewBox.getViewTransform(null, |
|
193 |
elt, |
|
194 |
(float) rect.getWidth(), |
|
195 |
(float) rect.getHeight(), |
|
196 |
ctx)); |
|
197 |
|
|
198 |
gvtRoot.setTransform(ataux); |
|
199 |
} |
|
200 |
|
|
201 |
RenderingHints renderingHints = defaultRenderingHints; |
|
202 |
g.setRenderingHints(renderingHints); |
|
203 |
|
|
204 |
if (gvtRoot != null) { |
|
205 |
gvtRoot.paint(g); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
} |
org.gvsig.hyperlink.app/tags/org.gvsig.hyperlink.app-1.0.64/org.gvsig.hyperlink.app.extension/src/main/java/org/gvsig/hyperlink/app/extension/actions/TxtPanel.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 |
package org.gvsig.hyperlink.app.extension.actions; |
|
24 |
|
|
25 |
import java.awt.BorderLayout; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.net.MalformedURLException; |
Also available in: Unified diff