Revision 35547
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
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.symbology.swing.api</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>org.gvsig.symbology.swing.api</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.symbology.swing</artifactId> |
|
11 |
<version>2.0.0-SNAPSHOT</version> |
|
12 |
</parent> |
|
13 |
<dependencies> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.andami</artifactId> |
|
17 |
<scope>compile</scope> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
22 |
<version>2.0.0-SNAPSHOT</version> |
|
23 |
<scope>compile</scope> |
|
24 |
</dependency> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.ui</artifactId> |
|
28 |
<scope>compile</scope> |
|
29 |
</dependency> |
|
30 |
<dependency> |
|
31 |
<groupId>org.gvsig</groupId> |
|
32 |
<artifactId>org.gvsig.fmap.mapcontext</artifactId> |
|
33 |
<scope>compile</scope> |
|
34 |
</dependency> |
|
35 |
<dependency> |
|
36 |
<groupId>org.gvsig</groupId> |
|
37 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
|
38 |
<scope>compile</scope> |
|
39 |
</dependency> |
|
40 |
<dependency> |
|
41 |
<groupId>org.gvsig</groupId> |
|
42 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
43 |
<scope>compile</scope> |
|
44 |
</dependency> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.i18n</artifactId> |
|
48 |
<scope>compile</scope> |
|
49 |
</dependency> |
|
50 |
<dependency> |
|
51 |
<groupId>org.gvsig</groupId> |
|
52 |
<artifactId>org.gvsig.utils</artifactId> |
|
53 |
<scope>compile</scope> |
|
54 |
</dependency> |
|
55 |
<dependency> |
|
56 |
<groupId>org.gvsig</groupId> |
|
57 |
<artifactId>org.gvsig.compat</artifactId> |
|
58 |
<scope>compile</scope> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>org.slf4j</groupId> |
|
62 |
<artifactId>slf4j-api</artifactId> |
|
63 |
<scope>compile</scope> |
|
64 |
</dependency> |
|
65 |
<dependency> |
|
66 |
<groupId>castor</groupId> |
|
67 |
<artifactId>castor</artifactId> |
|
68 |
<scope>compile</scope> |
|
69 |
</dependency> |
|
70 |
<dependency> |
|
71 |
<groupId>org.apache.xmlgraphics</groupId> |
|
72 |
<artifactId>batik-gvt</artifactId> |
|
73 |
<scope>compile</scope> |
|
74 |
</dependency> |
|
75 |
<dependency> |
|
76 |
<groupId>org.apache.xmlgraphics</groupId> |
|
77 |
<artifactId>batik-bridge</artifactId> |
|
78 |
<scope>compile</scope> |
|
79 |
</dependency> |
|
80 |
<dependency> |
|
81 |
<groupId>org.apache.xmlgraphics</groupId> |
|
82 |
<artifactId>batik-script</artifactId> |
|
83 |
<scope>compile</scope> |
|
84 |
</dependency> |
|
85 |
<dependency> |
|
86 |
<groupId>org.gvsig</groupId> |
|
87 |
<artifactId>batik-ext-gvsig-custom</artifactId> |
|
88 |
<scope>compile</scope> |
|
89 |
</dependency> |
|
90 |
<dependency> |
|
91 |
<groupId>xml-apis</groupId> |
|
92 |
<artifactId>xml-apis-ext</artifactId> |
|
93 |
<scope>compile</scope> |
|
94 |
</dependency> |
|
95 |
</dependencies> |
|
96 |
<build> |
|
97 |
<plugins> |
|
98 |
<plugin> |
|
99 |
<groupId>org.apache.maven.plugins</groupId> |
|
100 |
<artifactId>maven-jar-plugin</artifactId> |
|
101 |
<configuration> |
|
102 |
</configuration> |
|
103 |
<executions> |
|
104 |
<!-- Generates a jar file only with the test classes --> |
|
105 |
<execution> |
|
106 |
<goals> |
|
107 |
<goal>test-jar</goal> |
|
108 |
</goals> |
|
109 |
</execution> |
|
110 |
</executions> |
|
111 |
</plugin> |
|
112 |
</plugins> |
|
113 |
</build> |
|
114 |
<properties> |
|
115 |
<build-dir>${basedir}/../../../build</build-dir> |
|
116 |
</properties> |
|
117 |
</project> |
|
0 | 118 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/symbology/swing/SymbologySwingManager.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 |
package org.gvsig.symbology.swing; |
|
23 |
|
|
24 |
import org.gvsig.gui.IColorTables; |
|
25 |
import org.gvsig.gui.IColorTablesFactory; |
|
26 |
import org.gvsig.symbology.SymbologyManager; |
|
27 |
|
|
28 |
/** |
|
29 |
* This class is responsible of the management of the library's swing user |
|
30 |
* interface. It is the swing library's main entry point, and provides all the |
|
31 |
* services to manage library swing components. |
|
32 |
* |
|
33 |
* @see SymbologyWindowManager |
|
34 |
* @see JSymbologyServicePanel |
|
35 |
* @author gvSIG team |
|
36 |
* @version $Id$ |
|
37 |
*/ |
|
38 |
public interface SymbologySwingManager { |
|
39 |
|
|
40 |
/** |
|
41 |
* Returns the {@link SymbologyManager}. |
|
42 |
* |
|
43 |
* @return {@link SymbologyManager} |
|
44 |
* @see {@link SymbologyManager} |
|
45 |
*/ |
|
46 |
public SymbologyManager getManager(); |
|
47 |
|
|
48 |
/** |
|
49 |
* Returns the translation of a string. |
|
50 |
* |
|
51 |
* @param key |
|
52 |
* String to translate |
|
53 |
* @return a String with the translation of the string passed by parameter |
|
54 |
*/ |
|
55 |
public String getTranslation(String key); |
|
56 |
|
|
57 |
/** |
|
58 |
* Registers a new instance of a WindowManager which provides services to |
|
59 |
* the management of the application windows. |
|
60 |
* |
|
61 |
* @param manager |
|
62 |
* {@link SymbologyWindowManager} to register in the |
|
63 |
* ScriptingUIManager. |
|
64 |
* @see SymbologyWindowManager |
|
65 |
*/ |
|
66 |
public void registerWindowManager(SymbologyWindowManager manager); |
|
67 |
|
|
68 |
/** |
|
69 |
* Returns the {@link SymbologyWindowManager}. |
|
70 |
* |
|
71 |
* @return {@link SymbologyWindowManager} |
|
72 |
* @see {@link SymbologyWindowManager} |
|
73 |
*/ |
|
74 |
public SymbologyWindowManager getWindowManager(); |
|
75 |
|
|
76 |
public void setColorTablesFactory(IColorTablesFactory factory); |
|
77 |
|
|
78 |
public IColorTables createColorTables(); |
|
79 |
} |
|
0 | 80 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/symbology/swing/SymbologyWindowManager.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 |
package org.gvsig.symbology.swing; |
|
23 |
|
|
24 |
import javax.swing.JPanel; |
|
25 |
|
|
26 |
/** |
|
27 |
* Responsible of the window management to show the panels of the |
|
28 |
* Symbology swing library. |
|
29 |
* |
|
30 |
* @see SymbologySwingManager |
|
31 |
* @see JSymbologyServicePanel |
|
32 |
* @author gvSIG Team |
|
33 |
* @version $Id$ |
|
34 |
*/ |
|
35 |
public interface SymbologyWindowManager { |
|
36 |
|
|
37 |
public static final int MODE_DIALOG = 1; |
|
38 |
public static final int MODE_WINDOW = 2; |
|
39 |
public static final int MODE_TOOL = 3; |
|
40 |
|
|
41 |
/** |
|
42 |
* Inserts a Panel in a window with a characteristic properties. |
|
43 |
* |
|
44 |
* @param panel |
|
45 |
* JPanel with the content of the window |
|
46 |
* @param title |
|
47 |
* String with the title of the window |
|
48 |
* @param mode |
|
49 |
* int that defines the type of window |
|
50 |
*/ |
|
51 |
public void showWindow(JPanel panel, String title, int mode); |
|
52 |
} |
|
0 | 53 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/symbology/swing/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.symbology package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>Symbology swing library API.</p> |
|
11 |
|
|
12 |
<p> |
|
13 |
It allows to get swing panels to show Symbology, and to include them in windows. |
|
14 |
</p> |
|
15 |
|
|
16 |
</body> |
|
17 |
</html> |
|
0 | 18 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/symbology/swing/SymbologySwingLocator.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 |
package org.gvsig.symbology.swing; |
|
23 |
|
|
24 |
import org.gvsig.tools.locator.BaseLocator; |
|
25 |
|
|
26 |
/** |
|
27 |
* This locator is the entry point for the Symbology swing library, |
|
28 |
* providing access to all Symbology swing services through the |
|
29 |
* {@link SymbologySwingManager} . |
|
30 |
* |
|
31 |
* @author gvSIG team |
|
32 |
* @version $Id$ |
|
33 |
*/ |
|
34 |
public class SymbologySwingLocator extends BaseLocator { |
|
35 |
|
|
36 |
/** |
|
37 |
* Symbology swing manager name. |
|
38 |
*/ |
|
39 |
public static final String SWING_MANAGER_NAME = |
|
40 |
"Symbology.swing.manager"; |
|
41 |
|
|
42 |
/** |
|
43 |
* Symbology swing manager description. |
|
44 |
*/ |
|
45 |
public static final String SWING_MANAGER_DESCRIPTION = |
|
46 |
"Symbology UIManager"; |
|
47 |
|
|
48 |
private static final String LOCATOR_NAME = "Symbology.swing.locator"; |
|
49 |
|
|
50 |
/** |
|
51 |
* Unique instance. |
|
52 |
*/ |
|
53 |
private static final SymbologySwingLocator INSTANCE = |
|
54 |
new SymbologySwingLocator(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Return the singleton instance. |
|
58 |
* |
|
59 |
* @return the singleton instance |
|
60 |
*/ |
|
61 |
public static SymbologySwingLocator getInstance() { |
|
62 |
return INSTANCE; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Return the Locator's name |
|
67 |
* |
|
68 |
* @return a String with the Locator's name |
|
69 |
*/ |
|
70 |
public final String getLocatorName() { |
|
71 |
return LOCATOR_NAME; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Registers the Class implementing the PersistenceManager interface. |
|
76 |
* |
|
77 |
* @param clazz |
|
78 |
* implementing the PersistenceManager interface |
|
79 |
*/ |
|
80 |
public static void registerSwingManager( |
|
81 |
Class<? extends SymbologySwingManager> clazz) { |
|
82 |
getInstance().register(SWING_MANAGER_NAME, SWING_MANAGER_DESCRIPTION, |
|
83 |
clazz); |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Gets the instance of the {@link ScriptingUIManager} registered. |
|
88 |
* |
|
89 |
* @return {@link ScriptingUIManager} |
|
90 |
*/ |
|
91 |
public static SymbologySwingManager getSwingManager() { |
|
92 |
return (SymbologySwingManager) getInstance() |
|
93 |
.get(SWING_MANAGER_NAME); |
|
94 |
} |
|
95 |
|
|
96 |
} |
|
0 | 97 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/symbology/swing/SymbologySwingLibrary.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 |
package org.gvsig.symbology.swing; |
|
23 |
|
|
24 |
import org.gvsig.tools.library.AbstractLibrary; |
|
25 |
import org.gvsig.tools.library.LibraryException; |
|
26 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
27 |
|
|
28 |
/** |
|
29 |
* Library for Swing API initialization and configuration. |
|
30 |
* |
|
31 |
* @author gvSIG team |
|
32 |
* @version $Id$ |
|
33 |
*/ |
|
34 |
public class SymbologySwingLibrary extends AbstractLibrary { |
|
35 |
|
|
36 |
@Override |
|
37 |
public void doRegistration() { |
|
38 |
registerAsAPI(SymbologySwingLibrary.class); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
protected void doInitialize() throws LibraryException { |
|
43 |
// Do nothing |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected void doPostInitialize() throws LibraryException { |
|
48 |
// Validate there is any implementation registered. |
|
49 |
SymbologySwingManager manager = |
|
50 |
SymbologySwingLocator.getSwingManager(); |
|
51 |
if (manager == null) { |
|
52 |
throw new ReferenceNotRegisteredException( |
|
53 |
SymbologySwingLocator.SWING_MANAGER_NAME, |
|
54 |
SymbologySwingLocator.getInstance()); |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
} |
|
0 | 59 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/panels/ImageSizePanel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.app.gui.panels; |
|
42 |
|
|
43 |
import java.awt.BorderLayout; |
|
44 |
import java.awt.Color; |
|
45 |
import java.awt.Dimension; |
|
46 |
import java.awt.Graphics; |
|
47 |
import java.awt.event.ActionEvent; |
|
48 |
import java.awt.event.ActionListener; |
|
49 |
import java.awt.event.FocusEvent; |
|
50 |
import java.awt.event.FocusListener; |
|
51 |
import java.awt.event.KeyEvent; |
|
52 |
import java.awt.event.KeyListener; |
|
53 |
import java.awt.event.MouseEvent; |
|
54 |
import java.awt.event.MouseListener; |
|
55 |
import java.util.ArrayList; |
|
56 |
|
|
57 |
import javax.swing.Icon; |
|
58 |
import javax.swing.JPanel; |
|
59 |
import javax.swing.JToggleButton; |
|
60 |
|
|
61 |
import org.gvsig.andami.PluginServices; |
|
62 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
63 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
|
64 |
import org.gvsig.i18n.Messages; |
|
65 |
|
|
66 |
|
|
67 |
/** |
|
68 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
69 |
*/ |
|
70 |
public class ImageSizePanel extends JPanel implements KeyListener, MouseListener, ActionListener, FocusListener{ |
|
71 |
/** |
|
72 |
* |
|
73 |
*/ |
|
74 |
private static final long serialVersionUID = 4810686805894198593L; |
|
75 |
private static final Icon iconSelected = PluginServices.getIconTheme().get("chain"); |
|
76 |
private static final Icon iconUnselected = PluginServices.getIconTheme().get("broken-chain"); |
|
77 |
|
|
78 |
private JIncrementalNumberField widthTxt; |
|
79 |
private JIncrementalNumberField heightTxt; |
|
80 |
private double width, height; |
|
81 |
private JToggleButton lock; |
|
82 |
private double ratio; |
|
83 |
private boolean performing; |
|
84 |
private boolean locked = true; |
|
85 |
private ArrayList<ActionListener> listeners = new ArrayList<ActionListener>(); |
|
86 |
|
|
87 |
public ImageSizePanel(){ |
|
88 |
super(); |
|
89 |
initialize(); |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
/** |
|
94 |
* This method initializes this |
|
95 |
* |
|
96 |
*/ |
|
97 |
private void initialize() { |
|
98 |
final GridBagLayoutPanel aux = new GridBagLayoutPanel(); |
|
99 |
setLayout(new BorderLayout()); |
|
100 |
aux.addComponent(Messages.getText("width")+":", |
|
101 |
widthTxt = new JIncrementalNumberField(null, 5, 0, Double.MAX_VALUE, 1)); |
|
102 |
aux.addComponent(Messages.getText("height")+":", |
|
103 |
heightTxt = new JIncrementalNumberField(null, 5, 0, Double.MAX_VALUE, 1)); |
|
104 |
setLayout(new BorderLayout()); |
|
105 |
add(aux, BorderLayout.CENTER); |
|
106 |
JPanel lockPanel = new JPanel(null) { |
|
107 |
private static final long serialVersionUID = -415551033800811412L; |
|
108 |
protected void paintComponent(Graphics g) { |
|
109 |
int y1 = widthTxt.getY() + widthTxt.getHeight()/2-3; |
|
110 |
int y2 = heightTxt.getY() + heightTxt.getHeight()/2+3; |
|
111 |
g.setColor(Color.DARK_GRAY); |
|
112 |
g.drawLine(2, y1, getWidth()/2+2, y1); |
|
113 |
g.drawLine(getWidth()/2+2, y1, getWidth()/2+2, y2); |
|
114 |
g.drawLine(2, y2, getWidth()/2+2, y2); |
|
115 |
lock.setBounds(3, widthTxt.getY()+13, getWidth()-2, 22); |
|
116 |
} |
|
117 |
}; |
|
118 |
lockPanel.setPreferredSize(new Dimension(20, 20)); |
|
119 |
lock = new JToggleButton() { |
|
120 |
private static final long serialVersionUID = 1668046192113822412L; |
|
121 |
protected void paintComponent(Graphics g) { |
|
122 |
setIcon(isSelected() ? iconSelected : iconUnselected); |
|
123 |
super.paintComponent(g); |
|
124 |
} |
|
125 |
}; |
|
126 |
lock.setSelected(locked); |
|
127 |
lockPanel.add(lock); |
|
128 |
add(lockPanel, BorderLayout.EAST); |
|
129 |
widthTxt.addKeyListener(this); |
|
130 |
widthTxt.addMouseListener(this); |
|
131 |
widthTxt.addActionListener(this); |
|
132 |
widthTxt.addFocusListener(this); |
|
133 |
heightTxt.addKeyListener(this); |
|
134 |
heightTxt.addMouseListener(this); |
|
135 |
heightTxt.addActionListener(this); |
|
136 |
heightTxt.addFocusListener(this); |
|
137 |
|
|
138 |
lock.addMouseListener(this); |
|
139 |
} |
|
140 |
|
|
141 |
public void setImageSize(double width, double height) { |
|
142 |
this.width = width; |
|
143 |
widthTxt.setDouble(width); |
|
144 |
this.height = height; |
|
145 |
heightTxt.setDouble(height); |
|
146 |
this.ratio = width / height; |
|
147 |
} |
|
148 |
|
|
149 |
public void setImageSize(Dimension sz) { |
|
150 |
setImageSize(sz.getWidth(), sz.getHeight()); |
|
151 |
} |
|
152 |
|
|
153 |
|
|
154 |
public double[] getImageDimension() { |
|
155 |
double[] d = new double[2]; |
|
156 |
d[0] = width; |
|
157 |
d[1] = height; |
|
158 |
return d; |
|
159 |
} |
|
160 |
|
|
161 |
public void addActionListener(ActionListener l) { |
|
162 |
listeners.add(l); |
|
163 |
} |
|
164 |
|
|
165 |
public void keyPressed(KeyEvent e) { doIt(); } |
|
166 |
public void keyReleased(KeyEvent e) { doIt(); } |
|
167 |
public void keyTyped(KeyEvent e) { doIt(); } |
|
168 |
public void mouseClicked(MouseEvent e) { e.consume(); doIt(); } |
|
169 |
public void actionPerformed(ActionEvent e) { doIt(); } |
|
170 |
|
|
171 |
private void doIt() { |
|
172 |
if (!performing) { |
|
173 |
performing = true; |
|
174 |
if (locked != lock.isSelected()) { |
|
175 |
locked = lock.isSelected(); |
|
176 |
ratio = widthTxt.getDouble() / heightTxt.getDouble(); |
|
177 |
} else if (locked && width != widthTxt.getDouble()){ |
|
178 |
width = widthTxt.getDouble(); |
|
179 |
height = width/ratio; |
|
180 |
height = Math.round(height*100)/100; |
|
181 |
heightTxt.setDouble(height); |
|
182 |
fireActionPerformed(); |
|
183 |
} else if (locked && height != heightTxt.getDouble()) { |
|
184 |
height = heightTxt.getDouble(); |
|
185 |
width = height*ratio; |
|
186 |
width = Math.round(width*100)/100; |
|
187 |
widthTxt.setDouble(width); |
|
188 |
fireActionPerformed(); |
|
189 |
|
|
190 |
} |
|
191 |
|
|
192 |
performing = false; |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
|
|
197 |
private void fireActionPerformed() { |
|
198 |
for (int i = 0; i < listeners.size(); i++) { |
|
199 |
((ActionListener) listeners.get(i)).actionPerformed( |
|
200 |
new ActionEvent(this, 0, "IMAGE_RESIZED")); |
|
201 |
} |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
public void mouseEntered(MouseEvent e) { /* nothing */ } |
|
206 |
public void mouseExited(MouseEvent e) { /* nothing */ } |
|
207 |
public void mousePressed(MouseEvent e) { /* nothing */ } |
|
208 |
public void mouseReleased(MouseEvent e) { /* nothing */ } |
|
209 |
|
|
210 |
|
|
211 |
public void focusGained(FocusEvent arg0) { |
|
212 |
// TODO Auto-generated method stub |
|
213 |
|
|
214 |
} |
|
215 |
|
|
216 |
|
|
217 |
public void focusLost(FocusEvent arg0) { |
|
218 |
doIt(); |
|
219 |
} |
|
220 |
} |
|
221 |
|
|
0 | 222 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/styling/JUrlFileChooser.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.app.gui.styling; |
|
42 |
|
|
43 |
import java.io.File; |
|
44 |
import java.net.MalformedURLException; |
|
45 |
import java.net.URL; |
|
46 |
|
|
47 |
import javax.swing.filechooser.FileFilter; |
|
48 |
|
|
49 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
50 |
import org.gvsig.i18n.Messages; |
|
51 |
|
|
52 |
import org.gvsig.andami.PluginServices; |
|
53 |
|
|
54 |
public class JUrlFileChooser extends JFileChooser { |
|
55 |
|
|
56 |
private static final long serialVersionUID = 1844355534608274984L; |
|
57 |
|
|
58 |
public JUrlFileChooser(String fileChooserID, String defaultDirectory) { |
|
59 |
super(fileChooserID, defaultDirectory); |
|
60 |
this.setFileFilter(ff); |
|
61 |
this.setFileSelectionMode(JFileChooser.FILES_ONLY); |
|
62 |
this.setMultiSelectionEnabled(false); |
|
63 |
} |
|
64 |
|
|
65 |
FileFilter ff = new FileFilter() { |
|
66 |
public boolean accept(File f) { |
|
67 |
if (f.isDirectory()) return true; |
|
68 |
String fName = f.getAbsolutePath(); |
|
69 |
if (fName!=null) { |
|
70 |
fName = fName.toLowerCase(); |
|
71 |
return fName.endsWith(".png") |
|
72 |
|| fName.endsWith(".gif") |
|
73 |
|| fName.endsWith(".jpg") |
|
74 |
|| fName.endsWith(".jpeg") |
|
75 |
|| fName.endsWith(".bmp") |
|
76 |
|| fName.endsWith(".svg"); |
|
77 |
} |
|
78 |
return false; |
|
79 |
} |
|
80 |
|
|
81 |
public String getDescription() { |
|
82 |
return Messages.getText("bitmap_and_svg_image_files")+ "," + |
|
83 |
Messages.getText("URL"); |
|
84 |
} |
|
85 |
}; |
|
86 |
|
|
87 |
public URL getSelectedURL() { |
|
88 |
String path; |
|
89 |
File f = getSelectedFile(); |
|
90 |
|
|
91 |
try { |
|
92 |
if(f.canRead()) { |
|
93 |
return f.toURI().toURL(); |
|
94 |
} |
|
95 |
else { |
|
96 |
path = f.toString(); |
|
97 |
|
|
98 |
if (!path.startsWith("http")) |
|
99 |
if(path.contains("http") && |
|
100 |
(path.endsWith(".png") |
|
101 |
|| path.endsWith(".gif") |
|
102 |
|| path.endsWith(".jpg") |
|
103 |
|| path.endsWith(".jpeg") |
|
104 |
|| path.endsWith(".bmp") |
|
105 |
|| path.endsWith(".svg"))) { |
|
106 |
|
|
107 |
path = path.substring(path.indexOf("http"), path.length()); |
|
108 |
path = path.replace('\\', '/'); |
|
109 |
path = path.replaceFirst("/", "//"); |
|
110 |
|
|
111 |
return new URL(path); |
|
112 |
} |
|
113 |
} |
|
114 |
} catch (MalformedURLException e) { |
|
115 |
return null; |
|
116 |
} |
|
117 |
return null; |
|
118 |
} |
|
119 |
|
|
120 |
|
|
121 |
} |
|
0 | 122 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/styling/StyleSelector.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: StyleSelector.java 30289 2009-07-31 11:10:41Z jpiera $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.11 2007-08-21 09:32:53 jvidal |
|
47 |
* javadoc |
|
48 |
* |
|
49 |
* Revision 1.10 2007/05/31 09:36:22 jaume |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
52 |
* Revision 1.9 2007/05/10 09:47:50 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.8 2007/05/08 15:44:07 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.7 2007/04/27 12:10:17 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.6 2007/04/11 16:02:43 jaume |
|
62 |
* file filter |
|
63 |
* |
|
64 |
* Revision 1.5 2007/04/05 16:08:34 jaume |
|
65 |
* Styled labeling stuff |
|
66 |
* |
|
67 |
* Revision 1.4 2007/04/04 16:01:14 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.2 2007/03/09 11:25:00 jaume |
|
71 |
* Advanced symbology (start committing) |
|
72 |
* |
|
73 |
* Revision 1.1.2.4 2007/02/21 07:35:14 jaume |
|
74 |
* *** empty log message *** |
|
75 |
* |
|
76 |
* Revision 1.1.2.3 2007/02/08 15:43:04 jaume |
|
77 |
* some bug fixes in the editor and removed unnecessary imports |
|
78 |
* |
|
79 |
* Revision 1.1.2.2 2007/01/30 18:10:10 jaume |
|
80 |
* start commiting labeling stuff |
|
81 |
* |
|
82 |
* Revision 1.1.2.1 2007/01/26 13:49:03 jaume |
|
83 |
* *** empty log message *** |
|
84 |
* |
|
85 |
* |
|
86 |
*/ |
|
87 |
package org.gvsig.app.gui.styling; |
|
88 |
|
|
89 |
import java.awt.BorderLayout; |
|
90 |
import java.awt.Color; |
|
91 |
import java.awt.Component; |
|
92 |
import java.awt.Dimension; |
|
93 |
import java.awt.FlowLayout; |
|
94 |
import java.awt.event.ActionEvent; |
|
95 |
import java.awt.event.ActionListener; |
|
96 |
import java.io.File; |
|
97 |
import java.io.FileWriter; |
|
98 |
import java.util.prefs.Preferences; |
|
99 |
|
|
100 |
import javax.swing.BorderFactory; |
|
101 |
import javax.swing.BoxLayout; |
|
102 |
import javax.swing.JComponent; |
|
103 |
import javax.swing.JFileChooser; |
|
104 |
import javax.swing.JLabel; |
|
105 |
import javax.swing.JList; |
|
106 |
import javax.swing.JOptionPane; |
|
107 |
import javax.swing.JPanel; |
|
108 |
import javax.swing.JTextField; |
|
109 |
import javax.swing.ListCellRenderer; |
|
110 |
import javax.swing.event.ListSelectionEvent; |
|
111 |
import javax.swing.event.ListSelectionListener; |
|
112 |
|
|
113 |
import org.exolab.castor.xml.Marshaller; |
|
114 |
import org.gvsig.andami.PluginServices; |
|
115 |
import org.gvsig.andami.messages.NotificationManager; |
|
116 |
import org.gvsig.app.gui.JComboBoxUnits; |
|
117 |
import org.gvsig.app.gui.panels.ImageSizePanel; |
|
118 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
|
119 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.ILabelStyle; |
|
120 |
import org.gvsig.fmap.mapcontext.rendering.symbols.styles.IStyle; |
|
121 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
|
122 |
import org.gvsig.gui.beans.controls.dnd.JDnDList; |
|
123 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
124 |
import org.gvsig.i18n.Messages; |
|
125 |
import org.gvsig.utils.XMLEntity; |
|
126 |
|
|
127 |
|
|
128 |
/** |
|
129 |
* Creates a panel where the user can select a style for an object that allows |
|
130 |
* to manage this property.This panel will be similar to the symbol selector panel |
|
131 |
* and, on it, the user will have a previsualization of the style of objects |
|
132 |
* stored and posibilities to modify an existing one, to create a new one |
|
133 |
* and so on. |
|
134 |
* |
|
135 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
136 |
* |
|
137 |
*/ |
|
138 |
public class StyleSelector extends SymbolSelector { |
|
139 |
private static final long serialVersionUID = -7476555713446755512L; |
|
140 |
private ImageSizePanel isp; |
|
141 |
|
|
142 |
public StyleSelector(IStyle style, int shapeType) { |
|
143 |
this(style, shapeType, new SelectorFilter() { |
|
144 |
public boolean accepts(Object obj) { |
|
145 |
return obj instanceof IStyle; |
|
146 |
} |
|
147 |
}); |
|
148 |
} |
|
149 |
/** |
|
150 |
* Constructor method |
|
151 |
* |
|
152 |
* @param style |
|
153 |
* @param shapeType |
|
154 |
* @param filter |
|
155 |
*/ |
|
156 |
public StyleSelector(IStyle style, int shapeType, SelectorFilter filter) { |
|
157 |
super(null, shapeType, filter, false); |
|
158 |
|
|
159 |
Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" ); |
|
160 |
rootDir = new File(prefs.get("SymbolStylesFolder", System.getProperty("user.home")+"/gvSIG/Styles")); |
|
161 |
if (!rootDir.exists()) |
|
162 |
rootDir.mkdir(); |
|
163 |
|
|
164 |
try { |
|
165 |
initialize(style); |
|
166 |
} catch (ClassNotFoundException e) { |
|
167 |
throw new Error(e); |
|
168 |
} |
|
169 |
lblTitle.setText(Messages.getText("label_styles")); |
|
170 |
treeRootName = Messages.getText("style_library"); |
|
171 |
|
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
protected void initialize(Object currentElement) throws ClassNotFoundException { |
|
176 |
library = new StyleLibrary(rootDir); |
|
177 |
|
|
178 |
this.setLayout(new BorderLayout()); |
|
179 |
this.setSize(400, 221); |
|
180 |
|
|
181 |
this.add(getJNorthPanel(), BorderLayout.NORTH); |
|
182 |
this.add(getJSplitPane(), BorderLayout.CENTER); |
|
183 |
this.add(getJEastPanel(), BorderLayout.EAST); |
|
184 |
ActionListener okAction = new ActionListener() { |
|
185 |
public void actionPerformed(ActionEvent e) { |
|
186 |
accepted = true; |
|
187 |
PluginServices.getMDIManager().closeWindow(StyleSelector.this); |
|
188 |
} |
|
189 |
}, cancelAction = new ActionListener() { |
|
190 |
public void actionPerformed(ActionEvent e) { |
|
191 |
setSymbol(null); |
|
192 |
PluginServices.getMDIManager().closeWindow(StyleSelector.this); |
|
193 |
} |
|
194 |
}; |
|
195 |
|
|
196 |
okCancelPanel = new AcceptCancelPanel(); |
|
197 |
okCancelPanel.setOkButtonActionListener(okAction); |
|
198 |
okCancelPanel.setCancelButtonActionListener(cancelAction); |
|
199 |
|
|
200 |
this.add(okCancelPanel, BorderLayout.SOUTH); |
|
201 |
libraryBrowser.setSelectionRow(0); |
|
202 |
|
|
203 |
SillyDragNDropAction dndAction = new SillyDragNDropAction(); |
|
204 |
libraryBrowser.addMouseListener(dndAction); |
|
205 |
libraryBrowser.addMouseMotionListener(dndAction); |
|
206 |
getJListSymbols().addMouseListener(dndAction); |
|
207 |
getJListSymbols().addMouseMotionListener(dndAction); |
|
208 |
setSymbol(currentElement); |
|
209 |
} |
|
210 |
|
|
211 |
@Override |
|
212 |
public void setSymbol(Object style) { |
|
213 |
((StylePreviewer) jPanelPreview).setStyle((IStyle) style); |
|
214 |
updateOptionsPanel(); |
|
215 |
} |
|
216 |
|
|
217 |
@Override |
|
218 |
public Object getSelectedObject() { |
|
219 |
if (!accepted) return null; |
|
220 |
Object mySelectedElement = ((StylePreviewer) jPanelPreview).getStyle(); |
|
221 |
|
|
222 |
if (mySelectedElement instanceof CartographicSupport) { |
|
223 |
CartographicSupport csSym = (CartographicSupport) mySelectedElement; |
|
224 |
csSym.setUnit(cmbUnits.getSelectedUnitIndex()); |
|
225 |
csSym.setReferenceSystem(cmbReferenceSystem.getSelectedIndex()); |
|
226 |
} |
|
227 |
|
|
228 |
return mySelectedElement; |
|
229 |
} |
|
230 |
|
|
231 |
protected SymbolSelectorListModel newListModel() { |
|
232 |
StyleSelectorListModel listModel = new StyleSelectorListModel( |
|
233 |
dir, |
|
234 |
// selectedElement, |
|
235 |
sFilter, |
|
236 |
StyleSelectorListModel.STYLE_FILE_EXTENSION); |
|
237 |
return listModel; |
|
238 |
|
|
239 |
} |
|
240 |
|
|
241 |
protected JPanel getJPanelOptions() { |
|
242 |
if (jPanelOptions == null) { |
|
243 |
jPanelOptions = new GridBagLayoutPanel(); |
|
244 |
jPanelOptions.setBorder(BorderFactory.createTitledBorder(null, Messages.getText("options"))); |
|
245 |
jPanelOptions.addComponent(getImageSizePanel()); |
|
246 |
jPanelOptions.addComponent(Messages.getText("units"), |
|
247 |
cmbUnits = new JComboBoxUnits(true)); |
|
248 |
jPanelOptions.addComponent("", |
|
249 |
cmbReferenceSystem = new JComboBoxUnitsReferenceSystem()); |
|
250 |
} |
|
251 |
return jPanelOptions; |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* |
|
256 |
* This method initializes ImageSizePanel |
|
257 |
* |
|
258 |
* @return isp ImageSizePanel |
|
259 |
*/ |
|
260 |
private ImageSizePanel getImageSizePanel() { |
|
261 |
if (isp == null) { |
|
262 |
isp = new ImageSizePanel(); |
|
263 |
isp.addActionListener(new ActionListener() { |
|
264 |
public void actionPerformed(ActionEvent e) { |
|
265 |
ILabelStyle st = (ILabelStyle) getSelectedObject(); |
|
266 |
if (st != null) { |
|
267 |
double[] sz = isp.getImageDimension(); |
|
268 |
st.setSize(sz[0], sz[1]); |
|
269 |
} |
|
270 |
} |
|
271 |
}); |
|
272 |
} |
|
273 |
|
|
274 |
return isp; |
|
275 |
} |
|
276 |
|
|
277 |
protected void updateOptionsPanel() { |
|
278 |
IStyle s = ((StylePreviewer) jPanelPreview).getStyle(); |
|
279 |
if (s instanceof ILabelStyle) { |
|
280 |
ILabelStyle lab = (ILabelStyle) s; |
|
281 |
Dimension sz = lab.getSize(); |
|
282 |
getImageSizePanel().setImageSize(sz); |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
|
|
287 |
/** |
|
288 |
* This method initializes jList |
|
289 |
* |
|
290 |
* @return javax.swing.JList |
|
291 |
*/ |
|
292 |
protected JList getJListSymbols() { |
|
293 |
if (jListSymbols == null) { |
|
294 |
jListSymbols = new JDnDList(); |
|
295 |
jListSymbols.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
|
296 |
jListSymbols.setLayoutOrientation(JList.HORIZONTAL_WRAP); |
|
297 |
jListSymbols.setVisibleRowCount(-1); |
|
298 |
jListSymbols.addListSelectionListener(new ListSelectionListener() { |
|
299 |
public void valueChanged(ListSelectionEvent e) { |
|
300 |
setStyle(jListSymbols.getSelectedValue()); |
|
301 |
updateOptionsPanel(); |
|
302 |
} |
|
303 |
}); |
|
304 |
ListCellRenderer renderer = new ListCellRenderer() { |
|
305 |
private Color mySelectedBGColor = new Color(255,145,100,255); |
|
306 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
307 |
IStyle sty = (IStyle) value; |
|
308 |
JPanel pnl = new JPanel(); |
|
309 |
BoxLayout layout = new BoxLayout(pnl, BoxLayout.Y_AXIS); |
|
310 |
pnl.setLayout(layout); |
|
311 |
Color bgColor = (isSelected) ? mySelectedBGColor |
|
312 |
: getJListSymbols().getBackground(); |
|
313 |
|
|
314 |
pnl.setBackground(bgColor); |
|
315 |
StylePreviewer sp = new StylePreviewer(); |
|
316 |
sp.setShowOutline(false); |
|
317 |
sp.setAlignmentX(Component.CENTER_ALIGNMENT); |
|
318 |
sp.setPreferredSize(new Dimension(50, 50)); |
|
319 |
sp.setStyle(sty); |
|
320 |
sp.setBackground(bgColor); |
|
321 |
pnl.add(sp); |
|
322 |
JLabel lbl = new JLabel(sty.getDescription()); |
|
323 |
lbl.setBackground(bgColor); |
|
324 |
lbl.setAlignmentX(Component.CENTER_ALIGNMENT); |
|
325 |
pnl.add(lbl); |
|
326 |
|
|
327 |
return pnl; |
|
328 |
} |
|
329 |
|
|
330 |
}; |
|
331 |
jListSymbols.setCellRenderer(renderer); |
|
332 |
} |
|
333 |
return jListSymbols; |
|
334 |
} |
|
335 |
/** |
|
336 |
* Modify the previsualization showed in the panel with the style of the |
|
337 |
* new object selected. |
|
338 |
* |
|
339 |
* @param selectedValue |
|
340 |
*/ |
|
341 |
protected void setStyle(Object selectedValue) { |
|
342 |
//selectedElement = selectedValue; |
|
343 |
((StylePreviewer) jPanelPreview).setStyle((IStyle) selectedValue); |
|
344 |
doLayout(); |
|
345 |
repaint(); |
|
346 |
} |
|
347 |
|
|
348 |
protected void propertiesPressed() { |
|
349 |
StyleEditor se = new StyleEditor((IStyle) getSelectedObject()); |
|
350 |
PluginServices.getMDIManager().addWindow(se); |
|
351 |
setStyle(se.getStyle()); |
|
352 |
} |
|
353 |
|
|
354 |
protected void savePressed() { |
|
355 |
if (getSelectedObject() ==null) |
|
356 |
return; |
|
357 |
|
|
358 |
JFileChooser jfc = new JFileChooser(rootDir); |
|
359 |
javax.swing.filechooser.FileFilter ff = new javax.swing.filechooser.FileFilter() { |
|
360 |
public boolean accept(File f) { |
|
361 |
return f.getAbsolutePath(). |
|
362 |
toLowerCase(). |
|
363 |
endsWith(StyleSelectorListModel.STYLE_FILE_EXTENSION); |
|
364 |
} |
|
365 |
|
|
366 |
public String getDescription() { |
|
367 |
return Messages.getText("gvSIG_style_definition_file")+ " ("+StyleSelectorListModel.STYLE_FILE_EXTENSION+")"; |
|
368 |
} |
|
369 |
}; |
|
370 |
jfc.setFileFilter(ff); |
|
371 |
JPanel accessory = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 5)); |
|
372 |
accessory.add(new JLabel(Messages.getText("enter_description"))); |
|
373 |
JTextField txtDesc = new JTextField(25); |
|
374 |
txtDesc.setText(((IStyle) getSelectedObject()).getDescription()); |
|
375 |
accessory.add(txtDesc); |
|
376 |
jfc.setAccessory(accessory); |
|
377 |
if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { |
|
378 |
File targetFile = jfc.getSelectedFile(); |
|
379 |
|
|
380 |
String fExtension = StyleSelectorListModel.STYLE_FILE_EXTENSION; |
|
381 |
|
|
382 |
// apply description |
|
383 |
String desc; |
|
384 |
if (txtDesc.getText()==null || txtDesc.getText().trim().equals("")) { |
|
385 |
// default to file name |
|
386 |
String s = targetFile.getAbsolutePath(); |
|
387 |
desc = s.substring(s.lastIndexOf(File.separator)+1).replaceAll(fExtension, ""); |
|
388 |
} else { |
|
389 |
desc = txtDesc.getText().trim(); |
|
390 |
} |
|
391 |
IStyle s = (IStyle) getSelectedObject(); |
|
392 |
s.setDescription(desc); |
|
393 |
|
|
394 |
// save it |
|
395 |
XMLEntity xml=null; |
|
396 |
//XMLENTITY-UPDATED |
|
397 |
// try { |
|
398 |
// |
|
399 |
// xml = s.getXMLEntity(); |
|
400 |
// } catch (XMLException e) { |
|
401 |
// NotificationManager.addWarning("Symbol layer", e); |
|
402 |
// } |
|
403 |
if (!targetFile. |
|
404 |
getAbsolutePath(). |
|
405 |
toLowerCase(). |
|
406 |
endsWith(fExtension)) |
|
407 |
targetFile = new File(targetFile.getAbsolutePath() + fExtension); |
|
408 |
if(targetFile.exists()){ |
|
409 |
int resp = JOptionPane.showConfirmDialog( |
|
410 |
(Component) PluginServices.getMainFrame(), |
|
411 |
Messages.getText("fichero_ya_existe_seguro_desea_guardarlo"), |
|
412 |
Messages.getText("guardar"), JOptionPane.YES_NO_OPTION); |
|
413 |
if (resp != JOptionPane.YES_OPTION) { |
|
414 |
return; |
|
415 |
} |
|
416 |
} |
|
417 |
FileWriter writer; |
|
418 |
try { |
|
419 |
writer = new FileWriter(targetFile.getAbsolutePath()); |
|
420 |
Marshaller m = new Marshaller(writer); |
|
421 |
m.setEncoding("ISO-8859-1"); |
|
422 |
m.marshal(xml.getXmlTag()); |
|
423 |
|
|
424 |
} catch (Exception ex) { |
|
425 |
NotificationManager.addError( |
|
426 |
Messages.getText("save_error"), ex); |
|
427 |
} |
|
428 |
getJListSymbols().setModel(newListModel()); |
|
429 |
} |
|
430 |
} |
|
431 |
|
|
432 |
/** |
|
433 |
* This method initializes jPanelPreview |
|
434 |
* |
|
435 |
* @return javax.swing.JComponent |
|
436 |
*/ |
|
437 |
protected JComponent getJPanelPreview() { |
|
438 |
if (jPanelPreview == null) { |
|
439 |
jPanelPreview = new StylePreviewer(); |
|
440 |
jPanelPreview.setPreferredSize(new java.awt.Dimension(100,100)); |
|
441 |
jPanelPreview.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); |
|
442 |
((StylePreviewer) jPanelPreview).setShowOutline(true); |
|
443 |
} |
|
444 |
return jPanelPreview; |
|
445 |
} |
|
446 |
|
|
447 |
@Override |
|
448 |
public void actionPerformed(ActionEvent e) { |
|
449 |
if (!act) return; |
|
450 |
Object selectedElement = ((StylePreviewer) jPanelPreview).getStyle();//getSelectedObject(); |
|
451 |
performActionOn(selectedElement, e); |
|
452 |
StyleSelector.this.repaint(); |
|
453 |
} |
|
454 |
|
|
455 |
public int getUnit() { |
|
456 |
return cmbUnits.getSelectedUnitIndex(); |
|
457 |
} |
|
458 |
|
|
459 |
public int getReferenceSystem() { |
|
460 |
return cmbReferenceSystem.getSelectedIndex(); |
|
461 |
} |
|
462 |
|
|
463 |
public void setUnit(int unit) { |
|
464 |
cmbUnits.setSelectedUnitIndex(unit); |
|
465 |
} |
|
466 |
|
|
467 |
public void setReferenceSystem(int referenceSystem) { |
|
468 |
cmbReferenceSystem.setSelectedIndex(referenceSystem); |
|
469 |
} |
|
470 |
} |
|
0 | 471 |
tags/v2_0_0_Build_2028/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/styling/SimpleLine.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 |
package org.gvsig.app.gui.styling; |
|
23 |
|
|
24 |
import java.awt.BasicStroke; |
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.FlowLayout; |
|
28 |
import java.awt.event.ActionEvent; |
|
29 |
import java.awt.event.ActionListener; |
|
30 |
import java.util.ArrayList; |
|
31 |
|
|
32 |
import javax.swing.JPanel; |
|
33 |
|
|
34 |
import org.gvsig.andami.messages.NotificationManager; |
|
35 |
import org.gvsig.app.gui.panels.ColorChooserPanel; |
|
36 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
37 |
import org.gvsig.gui.beans.listeners.BeanListener; |
|
38 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
39 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
|
40 |
import org.gvsig.i18n.Messages; |
|
41 |
import org.gvsig.symbology.SymbologyLocator; |
|
42 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ISimpleLineSymbol; |
|
43 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IArrowDecoratorStyle; |
|
44 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ILineStyle; |
|
45 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ISimpleLineStyle; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* SimpleLine allows the user to store and modify the main properties that |
|
50 |
* define a <b>simple line</b>.<p> |
|
51 |
* <p> |
|
52 |
* This functionality is carried out thanks to two tabs (simple line and arrow |
|
53 |
* decorator)which are included in the panel to edit the properities of a symbol |
|
54 |
* (SymbolEditor)how is explained in AbstractTypeSymbolEditor.<p> |
|
55 |
* <p> |
|
56 |
* The first tab (Simple Line)allows the user to change the color (<b>jccColor</b>), |
|
57 |
* the width (<b>txtWidth</b>) and the style of the line (<b>cmbLinStyles</b>).<p> |
|
58 |
* <p> |
|
59 |
* The second tab (<b>arrowDecorator</b>)allows the user to insert a symbol in the |
|
60 |
* line (for example an arrow to specify its orientation)and to modify it. |
|
61 |
* |
|
62 |
*@see ArrowDecorator |
|
63 |
*@see AbstractTypeSymbolEditor |
|
64 |
*@author jaume dominguez faus - jaume.dominguez@iver.es |
|
65 |
*/ |
|
66 |
public class SimpleLine extends AbstractTypeSymbolEditor implements ActionListener { |
|
67 |
|
|
68 |
private ColorChooserPanel jccColor; |
|
69 |
private JIncrementalNumberField txtWidth; |
|
70 |
private ArrayList<JPanel> tabs = new ArrayList<JPanel>(); |
|
71 |
private ArrowDecorator arrowDecorator; |
|
72 |
private LineProperties lineProperties; |
|
73 |
private JIncrementalNumberField txtOffset; |
|
74 |
|
|
75 |
|
|
76 |
public SimpleLine(SymbolEditor owner) { |
|
77 |
super(owner); |
|
78 |
initialize(); |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
/** |
|
83 |
* Initializes the parameters that define a simpleline.To do it, two tabs |
|
84 |
* are created inside the SymbolEditor panel with default values for the |
|
85 |
* different attributes of the simple line.This two tabs will be simple |
|
86 |
* line tab (options of color, width and style of the line)and arrow |
|
87 |
* decorator tab (options to "decorate" the line with a symbol). |
|
88 |
*/ |
|
89 |
private void initialize() { |
|
90 |
JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5)); |
|
91 |
myTab.setName(Messages.getText("simple_line")); |
|
92 |
GridBagLayoutPanel aux = new GridBagLayoutPanel(); |
|
93 |
|
|
94 |
// color chooser |
|
95 |
jccColor = new ColorChooserPanel(true); |
|
96 |
jccColor.setAlpha(255); |
|
97 |
aux.addComponent(Messages.getText("color"), |
|
98 |
jccColor ); |
|
99 |
|
|
100 |
// line width |
|
101 |
txtWidth = new JIncrementalNumberField("3", 25, 0, Double.POSITIVE_INFINITY, 1); |
|
102 |
aux.addComponent(Messages.getText("width")+":", |
|
103 |
txtWidth ); |
|
104 |
|
|
105 |
// line offset |
|
106 |
txtOffset = new JIncrementalNumberField("0", 25, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 1); |
|
107 |
aux.addComponent(Messages.getText("offset")+":", |
|
108 |
txtOffset ); |
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
aux.setPreferredSize(new Dimension(300, 300)); |
|
113 |
myTab.add(aux); |
|
114 |
|
|
115 |
// initialize defaults |
|
116 |
jccColor.setColor(Color.BLACK); |
|
117 |
txtWidth.setDouble(1.0); |
|
118 |
jccColor.addActionListener(this); |
|
119 |
txtWidth.addActionListener(this); |
|
120 |
txtOffset.addActionListener(this); |
|
121 |
tabs.add(myTab); |
|
122 |
|
|
123 |
// Arrow Decorator |
|
124 |
arrowDecorator = new ArrowDecorator(); |
|
125 |
arrowDecorator.addListener(new BeanListener() { |
|
126 |
|
|
127 |
public void beanValueChanged(Object value) { |
|
128 |
fireSymbolChangedEvent(); |
|
129 |
} |
|
130 |
|
|
131 |
}); |
|
132 |
tabs.add(arrowDecorator); |
|
133 |
|
|
134 |
lineProperties = new LineProperties((float) txtWidth.getDouble()); |
|
135 |
lineProperties.addListener(new BeanListener(){ |
|
136 |
|
|
137 |
public void beanValueChanged(Object value) { |
|
138 |
fireSymbolChangedEvent(); |
|
139 |
} |
|
140 |
}); |
|
141 |
tabs.add(lineProperties); |
|
142 |
} |
|
143 |
|
|
144 |
|
|
145 |
public ISymbol getLayer() { |
|
146 |
ISimpleLineSymbol layer = SymbologyLocator.getSymbologyManager().createSimpleLineSymbol(); |
|
147 |
layer.setLineColor(jccColor.getColor()); |
|
148 |
// layer.setIsShapeVisible(true); //true is the default value for this property |
|
149 |
// clone the selected style in the combo box |
|
150 |
|
|
151 |
ISimpleLineStyle simplLine= SymbologyLocator.getSymbologyManager().createSimpleLineStyle(); //new SimpleLineStyle(); |
|
152 |
|
|
153 |
simplLine.setStroke(lineProperties.getLinePropertiesStyle()); |
|
154 |
simplLine.setOffset(-txtOffset.getDouble()); |
|
155 |
|
|
156 |
IArrowDecoratorStyle ads= arrowDecorator.getArrowDecoratorStyle(); |
|
157 |
if (ads != null) { |
|
158 |
ads.getMarker().setColor(jccColor.getColor()); |
|
159 |
} |
|
160 |
simplLine.setArrowDecorator(arrowDecorator.getArrowDecoratorStyle()); |
|
161 |
layer.setLineStyle(simplLine); |
|
162 |
layer.setLineWidth((float) txtWidth.getDouble()); |
|
163 |
|
|
164 |
return layer; |
Also available in: Unified diff