Revision 22072
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toc/gui/TOC.java | ||
---|---|---|
629 | 629 |
// double click with left button ON A BRANCH/NODE (layer) |
630 | 630 |
if (e.getClickCount()>=2 && e.getButton() == MouseEvent.BUTTON1) { |
631 | 631 |
e.consume(); |
632 |
System.err.println("paso por aqu? en "+System.currentTimeMillis()); |
|
633 | 632 |
PluginServices.getMDIManager().setWaitCursor(); |
634 | 633 |
try { |
635 | 634 |
TocItemBranch leaf = (TocItemBranch) node.getUserObject(); |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/ThemeManagerWindow.java | ||
---|---|---|
135 | 135 |
}; |
136 | 136 |
}); |
137 | 137 |
add(getPanelButtons(), java.awt.BorderLayout.SOUTH); |
138 |
setSize(new Dimension(850, 540));
|
|
138 |
setSize(new Dimension(780, 540));
|
|
139 | 139 |
} |
140 | 140 |
|
141 | 141 |
private JPanel getPanelButtons() { |
... | ... | |
163 | 163 |
} |
164 | 164 |
|
165 | 165 |
public void actionPerformed(ActionEvent e) { |
166 |
|
|
166 | 167 |
if (e.getActionCommand() == "OK") { |
167 | 168 |
/* Causes all the tabs in the ThemeManagerWindow to perform THEIR apply-action |
168 | 169 |
* then fires the LegendChanged event that causes the view to be refreshed. |
... | ... | |
192 | 193 |
((AbstractThemeManagerPage) tabs.getSelectedComponent()).applyAction(); |
193 | 194 |
layer.getMapContext().callLegendChanged(); |
194 | 195 |
} else {} |
196 |
|
|
197 |
|
|
198 |
// Lots of temporary objects were create. |
|
199 |
// let's try some memory cleanup |
|
200 |
System.gc(); |
|
195 | 201 |
} |
196 | 202 |
|
197 | 203 |
private void close() { |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/ILabelingStrategyPanel.java | ||
---|---|---|
43 | 43 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
44 | 44 |
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.ILabelingStrategy; |
45 | 45 |
|
46 |
/** |
|
47 |
* Interface to be implemented for those panels whose purpose is to |
|
48 |
* set up labeling strategies. |
|
49 |
* |
|
50 |
* ILabelingStrategyPanel.java |
|
51 |
* |
|
52 |
* |
|
53 |
* @author jaume dominguez faus - jaume.dominguez@iver.es Jun 13, 2008 |
|
54 |
* |
|
55 |
*/ |
|
46 | 56 |
public interface ILabelingStrategyPanel { |
57 |
/** |
|
58 |
* Invoked when de user accepts the settings, the returned value |
|
59 |
* is a always ready-to-work labeling strategy. |
|
60 |
* |
|
61 |
* @return ILabelingStrategy, a labeling strategy completely set up. |
|
62 |
*/ |
|
47 | 63 |
public ILabelingStrategy getLabelingStrategy(); |
64 |
|
|
65 |
/** |
|
66 |
* Sets the model of the panel. As a general contract, after invoke |
|
67 |
* this method, the panel should be filled with all the values |
|
68 |
* needed and be able to be repainted successfully. |
|
69 |
* |
|
70 |
* @param layer, the layer to whom the labeling strategy is associated. |
|
71 |
* @param str, the current labeling strategy. |
|
72 |
*/ |
|
48 | 73 |
public void setModel(FLayer layer, ILabelingStrategy str); |
74 |
|
|
75 |
/** |
|
76 |
* A human-readable localized text to make this strategy easily |
|
77 |
* recognizable among all the available strategies. |
|
78 |
* @return |
|
79 |
*/ |
|
49 | 80 |
public String getLabelingStrategyName(); |
50 |
public Class getLabelingStrategyClass(); |
|
81 |
|
|
82 |
/** |
|
83 |
* <p> |
|
84 |
* The panel shown in the layer properties dialog is selected through |
|
85 |
* the class of the labeling strategy. This method returns such class. |
|
86 |
* <br> |
|
87 |
* </p> |
|
88 |
* <p> |
|
89 |
* <b>Note</b> that, as a collateral effect, the panel that sets up a labeling strategy |
|
90 |
* can be substituted programatically by other of your wish if |
|
91 |
* you return the same labeling strategy class than the one to |
|
92 |
* be replaced with your new one. The last panel installed, will |
|
93 |
* be the one to be shown. |
|
94 |
* </p> |
|
95 |
* @return Class, the labeling strategy's Class |
|
96 |
*/ |
|
97 |
public Class<? extends ILabelingStrategy> getLabelingStrategyClass(); |
|
51 | 98 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/General.java | ||
---|---|---|
155 | 155 |
aux.addComponent(getPnlLayerName()); |
156 | 156 |
aux.addComponent(new JBlank(10, 10)); |
157 | 157 |
aux.addComponent(getJCheckBoxSpatialIndex()); |
158 |
aux.addComponent(getPnlScale()); |
|
158 |
aux.addComponent("", getPnlScale());
|
|
159 | 159 |
JPanel aux2 = new JPanel(new GridLayout(1,2)); |
160 | 160 |
aux2.add(getPnlProperties()); |
161 | 161 |
aux2.add(getPnlHyperLink()); |
162 |
aux.addComponent(aux2); |
|
162 |
aux.addComponent("", aux2);
|
|
163 | 163 |
|
164 | 164 |
|
165 | 165 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SymbolLibrary.java | ||
---|---|---|
118 | 118 |
|
119 | 119 |
@Override |
120 | 120 |
public int getChildCount(Object parent) { |
121 |
return ((File) ((DefaultMutableTreeNode) parent).getUserObject()).listFiles(ff).length; |
|
121 |
File f = null; |
|
122 |
if (parent instanceof DefaultMutableTreeNode) { |
|
123 |
f = (File) ((DefaultMutableTreeNode) parent).getUserObject(); |
|
124 |
|
|
125 |
} else { |
|
126 |
f = (File) parent; |
|
127 |
} |
|
128 |
File[] files = f.listFiles(ff); |
|
129 |
return files == null ? 0 : files.length; |
|
122 | 130 |
} |
123 | 131 |
|
124 | 132 |
@Override |
... | ... | |
171 | 179 |
if (parent == null) |
172 | 180 |
return -1; |
173 | 181 |
File[] files = ((File) ((DefaultMutableTreeNode) parent).getUserObject()).listFiles(); |
174 |
for (int i = 0; i < files.length; i++) { |
|
182 |
for (int i = 0; files != null && i < files.length; i++) {
|
|
175 | 183 |
if (files[i].getName().equals(child)) |
176 | 184 |
return i; |
177 | 185 |
} |
... | ... | |
179 | 187 |
} |
180 | 188 |
|
181 | 189 |
public Object getElement(Object containerFolder, String elementName) { |
182 |
// System.out.println( container); |
|
190 |
if (containerFolder instanceof File) { |
|
191 |
containerFolder = new DefaultMutableTreeNode(containerFolder); |
|
192 |
} |
|
183 | 193 |
int index = getIndexOfChildFiles(containerFolder, elementName); |
184 | 194 |
if (index != -1) { |
185 | 195 |
return getChildFile(containerFolder, index); |
... | ... | |
235 | 245 |
parentFolder = rootDir; |
236 | 246 |
} |
237 | 247 |
try { |
238 |
System.out.println("SymbolLibrary.addFolder()"); |
|
239 | 248 |
File fParentFolder = (File) ((DefaultMutableTreeNode) parentFolder).getUserObject(); |
240 | 249 |
File f = new File(fParentFolder.getAbsolutePath()+File.separator+folderName); |
241 | 250 |
if (!f.exists()) |
... | ... | |
258 | 267 |
File fParentFolder = (File) containerFolder; |
259 | 268 |
File f = new File(fParentFolder.getAbsolutePath()+File.separator+(String) element); |
260 | 269 |
if (f.exists()) |
261 |
f.delete();
|
|
270 |
deleteRecursively(f);
|
|
262 | 271 |
|
263 | 272 |
} catch (Exception e) { |
264 | 273 |
throw new IllegalArgumentException( |
... | ... | |
281 | 290 |
} |
282 | 291 |
} |
283 | 292 |
|
284 |
|
|
293 |
private void deleteRecursively(File f) { |
|
294 |
if (f.isDirectory()) { |
|
295 |
for (int i = f.list().length-1; i >= 0; i--) { |
|
296 |
deleteRecursively(new File(f.getAbsolutePath()+File.separator+f.list()[i])); |
|
297 |
} |
|
298 |
} |
|
299 |
f.delete(); |
|
300 |
} |
|
285 | 301 |
|
286 | 302 |
private TreePath treePathNode(File f, File startingNode) { |
287 | 303 |
for (int i = 0; i < getChildCount(startingNode); i++) { |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/AbstractTypeSymbolEditor.java | ||
---|---|---|
232 | 232 |
* Returns the symbol class that is handled by this configuration panel. |
233 | 233 |
* @return <b>Class</b> (of the concrete ISymbol that this configuration panel deals with) |
234 | 234 |
*/ |
235 |
public abstract Class getSymbolClass(); |
|
235 |
public abstract Class<? extends ISymbol> getSymbolClass();
|
|
236 | 236 |
|
237 | 237 |
/** |
238 | 238 |
* Returns the editor tools that are handled by this configuration panel. |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/JComboBoxColorScheme.java | ||
---|---|---|
76 | 76 |
File.separator + |
77 | 77 |
"ColorSchemes"; |
78 | 78 |
|
79 |
private boolean interpolated = false; |
|
80 |
private ArrayList fileList = new ArrayList(); |
|
81 |
|
|
79 | 82 |
private ActionListener innerActionUpdateTooltip = new ActionListener() { |
80 | 83 |
public void actionPerformed(ActionEvent e) { |
81 | 84 |
Object o = getSelectedItem(); |
... | ... | |
94 | 97 |
*/ |
95 | 98 |
public JComboBoxColorScheme(boolean interpolateValues) { |
96 | 99 |
super(); |
100 |
interpolated = interpolateValues; |
|
97 | 101 |
setPreferredSize(new Dimension(150, 20)); |
98 | 102 |
ArrayList fileList = ColorTableLibraryPersistence.getPaletteFileList(palettesPath); |
99 | 103 |
|
... | ... | |
101 | 105 |
for (int i = 0; i < fileList.size(); i++) { |
102 | 106 |
ArrayList paletteItems = new ArrayList(); |
103 | 107 |
String paletteName = ColorTableLibraryPersistence.loadPalette( |
104 |
palettesPath,
|
|
105 |
(String) fileList.get(i),
|
|
106 |
paletteItems);
|
|
108 |
palettesPath, |
|
109 |
(String) fileList.get(i), |
|
110 |
paletteItems); |
|
107 | 111 |
|
108 | 112 |
if (paletteItems.size() <= 0) |
109 | 113 |
continue; |
... | ... | |
144 | 148 |
return (ColorItem[]) ct.getColorItems().toArray(new ColorItem[0]) ; |
145 | 149 |
} |
146 | 150 |
|
151 |
public void setSelectedColors(ColorItem[] colors) { |
|
147 | 152 |
|
153 |
fileList.clear(); |
|
154 |
|
|
155 |
if (colors == null) { |
|
156 |
setSelectedIndex(0); |
|
157 |
return; |
|
158 |
} |
|
159 |
else { |
|
160 |
|
|
161 |
for (int i = 0; i < getItemCount(); i++) { |
|
162 |
fileList.add(getItemAt(i)); |
|
163 |
} |
|
164 |
|
|
165 |
for (int i = 0; i < fileList.size(); i++) { |
|
166 |
Object o = fileList.get(i); |
|
167 |
ColorTable ct = ((ColorTablePaint) ((ArrayList) o).get(1)).colorTable; |
|
168 |
ColorItem[] myColors = (ColorItem[]) ct.getColorItems().toArray(new ColorItem[0]) ; |
|
169 |
|
|
170 |
boolean isEqual = true; |
|
171 |
if(myColors.length == colors.length) { |
|
172 |
for (int j = 0; isEqual && j < myColors.length; j++) { |
|
173 |
Color c1 = myColors[j].getColor(); |
|
174 |
Color c2 = colors[j].getColor(); |
|
175 |
isEqual = c1.getRGB() == c2.getRGB() && c1.getAlpha() == c2.getAlpha(); |
|
176 |
} |
|
177 |
if(isEqual) { |
|
178 |
setSelectedIndex(i); |
|
179 |
repaint(); |
|
180 |
return; |
|
181 |
} |
|
182 |
} |
|
183 |
} |
|
184 |
if(getItemCount()> 0) |
|
185 |
setSelectedItem(0); |
|
186 |
} |
|
187 |
|
|
188 |
} |
|
189 |
|
|
148 | 190 |
/** |
149 | 191 |
* |
150 | 192 |
* Class to paint a color palette in a box. It can be indicated if the palette |
trunk/applications/appgvSIG/src-test/com/iver/cit/gvsig/gui/styling/TestSymbolLibrary.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 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2008 IVER {{Task}} |
|
26 |
*/ |
|
27 |
package com.iver.cit.gvsig.gui.styling; |
|
28 |
|
|
29 |
import java.io.File; |
|
30 |
import java.io.FileNotFoundException; |
|
31 |
|
|
32 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
33 |
|
|
34 |
import junit.framework.TestCase; |
|
35 |
|
|
36 |
import org.exolab.castor.xml.MarshalException; |
|
37 |
import org.exolab.castor.xml.ValidationException; |
|
38 |
|
|
39 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
40 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
|
41 |
import com.iver.utiles.XMLEntity; |
|
42 |
import com.iver.utiles.xml.XMLEncodingUtils; |
|
43 |
import com.iver.utiles.xmlEntity.generate.XmlTag; |
|
44 |
|
|
45 |
/** |
|
46 |
* Test to check the correct operation of the symbol library. Adds a created symbol |
|
47 |
* and recovers it using a name. At the end the folder and the symbol will be eliminated |
|
48 |
* |
|
49 |
* @author Eustaquio Vercher G?mez |
|
50 |
*/ |
|
51 |
public class TestSymbolLibrary extends TestCase { |
|
52 |
private String folderTestName = "_____TestFolder_____/"; |
|
53 |
private String test_fileName = "____testsym____"+System.currentTimeMillis()+ SymbolLibrary.SYMBOL_FILE_EXTENSION; |
|
54 |
private SymbolLibrary lib = SymbolLibrary.getInstance(); |
|
55 |
private File testFolder = new File(SymbologyFactory.SymbolLibraryPath + File.separator + folderTestName); |
|
56 |
|
|
57 |
@Override |
|
58 |
protected void setUp() throws Exception { |
|
59 |
super.setUp(); |
|
60 |
// this only prepares the test, it is not the test itself |
|
61 |
File f = new File(SymbologyFactory.SymbolLibraryPath + File.separator + folderTestName); |
|
62 |
if (f.exists()) { |
|
63 |
deleteRecursively(f); |
|
64 |
} |
|
65 |
|
|
66 |
}; |
|
67 |
|
|
68 |
@Override |
|
69 |
public void tearDown(){ |
|
70 |
// this only prepares the test, it is not the test itself |
|
71 |
File f = new File(SymbologyFactory.SymbolLibraryPath + File.separator + folderTestName); |
|
72 |
if (f.exists()) { |
|
73 |
deleteRecursively(f); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
private void deleteRecursively(File f) { |
|
78 |
if (f.isDirectory()) { |
|
79 |
for (int i = f.list().length-1; i >= 0; i--) { |
|
80 |
deleteRecursively(new File(f.getAbsolutePath()+File.separator+f.list()[i])); |
|
81 |
} |
|
82 |
} |
|
83 |
f.delete(); |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Tests the correct operation of the library |
|
88 |
*/ |
|
89 |
public void testAddFolder(){ |
|
90 |
|
|
91 |
int childs = lib.getChildCount(lib.getRoot()); |
|
92 |
|
|
93 |
//adding one folder |
|
94 |
lib.addFolder(lib.getRoot(), folderTestName); |
|
95 |
int childsExpected = lib.getChildCount(lib.getRoot()); |
|
96 |
|
|
97 |
assertEquals("Folder does not have been added to Library",childs+1,childsExpected); |
|
98 |
} |
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
public void testAddSymbol() { |
|
103 |
testAddFolder(); |
|
104 |
|
|
105 |
//add symbol to the created folder |
|
106 |
ILineSymbol lineIn = getTestLineSymbol(); |
|
107 |
lib.addElement(lineIn, test_fileName, testFolder); |
|
108 |
|
|
109 |
DefaultMutableTreeNode lineAux = (DefaultMutableTreeNode) lib.getElement( |
|
110 |
testFolder, test_fileName); |
|
111 |
|
|
112 |
File obj = (File)lineAux.getUserObject(); |
|
113 |
|
|
114 |
assertTrue("File does not exist", obj.exists()); |
|
115 |
} |
|
116 |
|
|
117 |
private ILineSymbol getTestLineSymbol() { |
|
118 |
ILineSymbol lineIn = (ILineSymbol) SymbologyFactory.createDefaultLineSymbol(); |
|
119 |
lineIn.setLineWidth(328975); // a non usual value for the test (avoid false positives) |
|
120 |
lineIn.setDescription("TestingSymbolLibrary"); |
|
121 |
return lineIn; |
|
122 |
} |
|
123 |
|
|
124 |
|
|
125 |
public void testGetSymbol() { |
|
126 |
testAddSymbol(); |
|
127 |
DefaultMutableTreeNode lineAux = (DefaultMutableTreeNode) lib.getElement(testFolder, test_fileName); |
|
128 |
File obj = (File)lineAux.getUserObject(); |
|
129 |
|
|
130 |
ILineSymbol lineIn = getTestLineSymbol(); |
|
131 |
XMLEntity xml = null; |
|
132 |
try { |
|
133 |
xml = new XMLEntity((XmlTag) XmlTag.unmarshal(XMLEncodingUtils.getReader(obj))); |
|
134 |
} catch (MarshalException e) { |
|
135 |
e.printStackTrace(); |
|
136 |
} catch (ValidationException e) { |
|
137 |
e.printStackTrace(); |
|
138 |
} catch (FileNotFoundException e) { |
|
139 |
e.printStackTrace(); |
|
140 |
} |
|
141 |
|
|
142 |
ILineSymbol lineOut = (ILineSymbol) SymbologyFactory.createSymbolFromXML(xml, obj.getName()); |
|
143 |
|
|
144 |
assertTrue("Symbol in library is different to created symbol", |
|
145 |
lineIn.getLineWidth() == lineOut.getLineWidth() && |
|
146 |
lineIn.getDescription().equals(lineIn.getDescription()) && |
|
147 |
lineIn.getClassName().equals(lineOut.getClassName())); |
|
148 |
} |
|
149 |
|
|
150 |
public void testRemoveElement() { |
|
151 |
testAddSymbol(); // <- to previously create the test symbol |
|
152 |
|
|
153 |
assertTrue("removing something that does not existr", |
|
154 |
lib.getElement(testFolder, test_fileName) != null); |
|
155 |
//delete created element |
|
156 |
lib.removeElement(test_fileName, testFolder); |
|
157 |
assertFalse("library didn't delete the symbol", |
|
158 |
lib.getElement(testFolder, test_fileName) != null); |
|
159 |
|
|
160 |
// TODO faltar?a ver si lo que se ha eliminado es lo que esperamos! |
|
161 |
} |
|
162 |
|
|
163 |
public void testRemoveFolder() { |
|
164 |
testAddSymbol(); // <- to previously create the test symbol |
|
165 |
/* |
|
166 |
* For the childs, childsExpected, lineAux and obj variables to contain |
|
167 |
* right values, it is necessary that the tests testAddFolder, testAddSymbol and testGetSymbol |
|
168 |
* do not fail before to run this one. If one of the previous test has failed, |
|
169 |
* the result of this test will not be correct. |
|
170 |
*/ |
|
171 |
int childsBefore = lib.getChildCount(lib.getRoot()); |
|
172 |
|
|
173 |
//delete folder |
|
174 |
File f = new File(SymbologyFactory.SymbolLibraryPath); |
|
175 |
lib.removeElement(folderTestName,f); |
|
176 |
int childsAfter = lib.getChildCount(lib.getRoot()); |
|
177 |
|
|
178 |
assertEquals("Folder is not deleted", childsBefore, childsAfter+1); |
|
179 |
|
|
180 |
} |
|
181 |
|
|
182 |
|
|
183 |
} |
trunk/applications/appgvSIG/src-test/com/iver/cit/gvsig/AllTests.java | ||
---|---|---|
4 | 4 |
import junit.framework.TestSuite; |
5 | 5 |
|
6 | 6 |
import com.iver.cit.gvsig.gui.filter.TestFilterExpressionFromWhereIsEmpty_Method; |
7 |
import com.iver.cit.gvsig.gui.styling.TestSymbolLibrary; |
|
7 | 8 |
import com.iver.cit.gvsig.panelGroup.Test2ExceptionsUsingTabbedPanel; |
8 | 9 |
import com.iver.cit.gvsig.panelGroup.Test2ExceptionsUsingTreePanel; |
9 | 10 |
import com.iver.cit.gvsig.panelGroup.TestPanelGroupLoaderFromExtensionPoint; |
... | ... | |
26 | 27 |
suite.addTestSuite(Test2ExceptionsUsingTabbedPanel.class); |
27 | 28 |
suite.addTestSuite(Test2ExceptionsUsingTreePanel.class); |
28 | 29 |
|
30 |
suite.addTestSuite(TestSymbolLibrary.class); |
|
29 | 31 |
//$JUnit-END$ |
30 | 32 |
return suite; |
31 | 33 |
} |
Also available in: Unified diff