Revision 44831
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/pom.xml | ||
---|---|---|
76 | 76 |
<artifactId>org.gvsig.installer.lib.spi</artifactId> |
77 | 77 |
<scope>compile</scope> |
78 | 78 |
</dependency> |
79 |
<dependency> |
|
80 |
<groupId>org.apache.commons</groupId> |
|
81 |
<artifactId>commons-lang3</artifactId> |
|
82 |
<scope>compile</scope> |
|
83 |
</dependency> |
|
79 | 84 |
</dependencies> |
80 | 85 |
</project> |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/pom.xml | ||
---|---|---|
1 |
<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/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.raster.legend</artifactId> |
|
6 |
<version>2.0.272-SNAPSHOT</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.raster.legend.swing</artifactId> |
|
9 |
<packaging>pom</packaging> |
|
10 |
<modules> |
|
11 |
<module> org.gvsig.raster.legend.swing.api </module> |
|
12 |
<module> org.gvsig.raster.legend.swing.impl </module> |
|
13 |
</modules> |
|
14 |
</project> |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.swing.legend.RasterSwingLegendLibrary |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/java/org/gvsig/raster/swing/legend/RasterSwingLegendManager.java | ||
---|---|---|
1 |
package org.gvsig.raster.swing.legend; |
|
2 |
/* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2017 gvSIG Association |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
|
|
26 |
import org.gvsig.raster.swing.legend.colortable.create.CreateColorTablePanel; |
|
27 |
import org.gvsig.raster.swing.legend.colortable.editor.ColorTableEditorPanel; |
|
28 |
import org.gvsig.raster.swing.legend.colortable.selector.ColorTableSelectorPanel; |
|
29 |
import org.gvsig.tools.service.Manager; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
* @see RasterSwingLegendManager |
|
35 |
* @author gvSIG team |
|
36 |
* @version $Id$ |
|
37 |
*/ |
|
38 |
public interface RasterSwingLegendManager extends Manager{ |
|
39 |
|
|
40 |
/** |
|
41 |
* @return |
|
42 |
*/ |
|
43 |
ColorTableSelectorPanel createColorTableSelectorPanel(); |
|
44 |
|
|
45 |
/** |
|
46 |
* @return |
|
47 |
*/ |
|
48 |
ColorTableEditorPanel createColorTableEditorPanel(); |
|
49 |
|
|
50 |
/** |
|
51 |
* @return |
|
52 |
*/ |
|
53 |
CreateColorTablePanel createCreateColorTablePanel(); |
|
54 |
|
|
55 |
|
|
56 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/java/org/gvsig/raster/swing/legend/colortable/editor/ColorTableClassesTableModel.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2017 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.swing.legend.colortable.editor; |
|
24 |
|
|
25 |
import javax.swing.table.TableModel; |
|
26 |
|
|
27 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
28 |
import org.gvsig.raster.lib.legend.api.colortable.colortableclass.ColorTableClass; |
|
29 |
|
|
30 |
|
|
31 |
/** |
|
32 |
* @author fdiaz |
|
33 |
* |
|
34 |
*/ |
|
35 |
public interface ColorTableClassesTableModel extends TableModel { |
|
36 |
|
|
37 |
/** |
|
38 |
* @param colorTable |
|
39 |
*/ |
|
40 |
public void addColorTableClass(ColorTableClass colorTableClass); |
|
41 |
|
|
42 |
/** |
|
43 |
* @param index |
|
44 |
*/ |
|
45 |
public void removeColorTableClass(int index); |
|
46 |
|
|
47 |
/** |
|
48 |
* @param index |
|
49 |
* @return |
|
50 |
*/ |
|
51 |
public ColorTableClass getColorTableClass(int index); |
|
52 |
|
|
53 |
/** |
|
54 |
* |
|
55 |
*/ |
|
56 |
public void removeAllColorTableClasses(); |
|
57 |
|
|
58 |
public void setColorTable(ColorTable colorTable); |
|
59 |
|
|
60 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/java/org/gvsig/raster/swing/legend/colortable/editor/ColorTableEditorPanel.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2017 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.swing.legend.colortable.editor; |
|
24 |
|
|
25 |
import java.awt.event.ItemListener; |
|
26 |
|
|
27 |
import javax.swing.event.ChangeListener; |
|
28 |
import javax.swing.event.TableModelListener; |
|
29 |
|
|
30 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
31 |
import org.gvsig.raster.lib.legend.api.colortable.colortableclass.ColorTableClass; |
|
32 |
import org.gvsig.tools.swing.api.Component; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* @author fdiaz |
|
37 |
* |
|
38 |
*/ |
|
39 |
public interface ColorTableEditorPanel extends Component { |
|
40 |
|
|
41 |
/** |
|
42 |
* @param colorTable |
|
43 |
*/ |
|
44 |
public void set(ColorTable colorTable); |
|
45 |
|
|
46 |
public ColorTableClass getSelected(); |
|
47 |
|
|
48 |
public ColorTable getColorTable(); |
|
49 |
|
|
50 |
public boolean isModified(); |
|
51 |
|
|
52 |
void addTableModelListener(TableModelListener listener); |
|
53 |
|
|
54 |
void removeTableModelListener(TableModelListener listener); |
|
55 |
|
|
56 |
void addChkInterpolatedItemListener(ItemListener listener); |
|
57 |
|
|
58 |
|
|
59 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/java/org/gvsig/raster/swing/legend/colortable/selector/ColorTablesTableModel.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2017 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.swing.legend.colortable.selector; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import javax.swing.table.TableModel; |
|
29 |
|
|
30 |
import org.apache.commons.lang3.tuple.Pair; |
|
31 |
|
|
32 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
33 |
|
|
34 |
|
|
35 |
/** |
|
36 |
* @author fdiaz |
|
37 |
* |
|
38 |
*/ |
|
39 |
public interface ColorTablesTableModel extends TableModel { |
|
40 |
|
|
41 |
/** |
|
42 |
* @param colorTable |
|
43 |
*/ |
|
44 |
public void addColorTable(Pair<File,ColorTable> colorTable); |
|
45 |
|
|
46 |
/** |
|
47 |
* @param index |
|
48 |
*/ |
|
49 |
public void removeColorTable(int index); |
|
50 |
|
|
51 |
/** |
|
52 |
* @param index |
|
53 |
* @return |
|
54 |
*/ |
|
55 |
public Pair<File, ColorTable> getColorTable(int index); |
|
56 |
|
|
57 |
/** |
|
58 |
* @param selectedRow |
|
59 |
* @param colorTableEdited |
|
60 |
*/ |
|
61 |
public void setColorTable(int index, ColorTable colorTableEdited); |
|
62 |
|
|
63 |
List<Pair<File, ColorTable>> getColorTables(); |
|
64 |
|
|
65 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/java/org/gvsig/raster/swing/legend/colortable/selector/ColorTableSelectorPanel.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2017 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.swing.legend.colortable.selector; |
|
24 |
|
|
25 |
import java.awt.event.ActionListener; |
|
26 |
import java.io.File; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import javax.swing.event.ListSelectionListener; |
|
30 |
|
|
31 |
import org.apache.commons.lang3.tuple.Pair; |
|
32 |
|
|
33 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
34 |
import org.gvsig.tools.swing.api.Component; |
|
35 |
|
|
36 |
|
|
37 |
/** |
|
38 |
* @author fdiaz |
|
39 |
* |
|
40 |
*/ |
|
41 |
public interface ColorTableSelectorPanel extends Component { |
|
42 |
|
|
43 |
/** |
|
44 |
* @author fdiaz |
|
45 |
* |
|
46 |
*/ |
|
47 |
public enum Modification { |
|
48 |
NONE, |
|
49 |
ADDED, |
|
50 |
MODIFIED, |
|
51 |
REMOVED |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* @return |
|
56 |
*/ |
|
57 |
public ColorTable getSelected(); |
|
58 |
|
|
59 |
/** |
|
60 |
* Selects the ColorTable at position i |
|
61 |
* |
|
62 |
* @param i |
|
63 |
*/ |
|
64 |
public void select(int i); |
|
65 |
|
|
66 |
/** |
|
67 |
* @param colorTables |
|
68 |
*/ |
|
69 |
public void set(List<Pair<File,ColorTable>> colorTables); |
|
70 |
|
|
71 |
public List<Pair<File,ColorTable>> getModifiedColorTables(); |
|
72 |
|
|
73 |
public List<Pair<File,ColorTable>> getRemovedColorTables(); |
|
74 |
|
|
75 |
public List<ColorTable> getAddedColorTables(); |
|
76 |
|
|
77 |
public void setEditable(boolean editable); |
|
78 |
|
|
79 |
/** |
|
80 |
* @param listener |
|
81 |
*/ |
|
82 |
public void addListSelectionListener(ListSelectionListener listener); |
|
83 |
|
|
84 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/java/org/gvsig/raster/swing/legend/colortable/create/CreateColorTablePanel.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2017 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.swing.legend.colortable.create; |
|
24 |
|
|
25 |
import java.awt.Color; |
|
26 |
|
|
27 |
import org.gvsig.raster.lib.legend.api.colortable.MakeColorTable; |
|
28 |
import org.gvsig.tools.swing.api.Component; |
|
29 |
|
|
30 |
|
|
31 |
/** |
|
32 |
* @author fdiaz |
|
33 |
* |
|
34 |
*/ |
|
35 |
public interface CreateColorTablePanel extends Component { |
|
36 |
|
|
37 |
/** |
|
38 |
* @param colorTable |
|
39 |
*/ |
|
40 |
public void fetch(MakeColorTable makeColorTable); |
|
41 |
|
|
42 |
/** |
|
43 |
* @param name |
|
44 |
*/ |
|
45 |
public void setName(String name); |
|
46 |
|
|
47 |
/** |
|
48 |
* @param minimum |
|
49 |
*/ |
|
50 |
public void setMinimum(double minimum); |
|
51 |
|
|
52 |
/** |
|
53 |
* @param maximum |
|
54 |
*/ |
|
55 |
public void setMaximum(double maximum); |
|
56 |
|
|
57 |
/** |
|
58 |
* @param mode |
|
59 |
*/ |
|
60 |
public void setMode(int mode); |
|
61 |
|
|
62 |
/** |
|
63 |
* @param intervals |
|
64 |
*/ |
|
65 |
public void setIntervals(int intervals); |
|
66 |
|
|
67 |
/** |
|
68 |
* @param intervalSize |
|
69 |
*/ |
|
70 |
public void setIntervalSize(double intervalSize); |
|
71 |
|
|
72 |
/** |
|
73 |
* @param fromColor |
|
74 |
*/ |
|
75 |
public void setFromColor(Color fromColor); |
|
76 |
|
|
77 |
/** |
|
78 |
* @param toColor |
|
79 |
*/ |
|
80 |
public void setToColor(Color toColor); |
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/java/org/gvsig/raster/swing/legend/RasterSwingLegendLocator.java | ||
---|---|---|
1 |
package org.gvsig.raster.swing.legend; |
|
2 |
/* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2017 gvSIG Association |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
|
|
26 |
import org.gvsig.tools.locator.BaseLocator; |
|
27 |
|
|
28 |
/** |
|
29 |
* This locator is the entry point for the raster buffer swing library, |
|
30 |
* |
|
31 |
* @author gvSIG team |
|
32 |
* @version $Id$ |
|
33 |
*/ |
|
34 |
public class RasterSwingLegendLocator extends BaseLocator { |
|
35 |
|
|
36 |
/** |
|
37 |
* Chart swing manager name. |
|
38 |
*/ |
|
39 |
public static final String SWING_MANAGER_NAME = |
|
40 |
"Raster.swing.legend.manager"; |
|
41 |
|
|
42 |
/** |
|
43 |
* Chart swing manager description. |
|
44 |
*/ |
|
45 |
public static final String SWING_MANAGER_DESCRIPTION = |
|
46 |
"UIManager of Raster legend library"; |
|
47 |
|
|
48 |
private static final String LOCATOR_NAME = "Raster.swing.legend.locator"; |
|
49 |
|
|
50 |
/** |
|
51 |
* Unique instance. |
|
52 |
*/ |
|
53 |
private static final RasterSwingLegendLocator INSTANCE = |
|
54 |
new RasterSwingLegendLocator(); |
|
55 |
|
|
56 |
/** |
|
57 |
* Return the singleton instance. |
|
58 |
* |
|
59 |
* @return the singleton instance |
|
60 |
*/ |
|
61 |
public static RasterSwingLegendLocator 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 RasterSwingLegendManager> 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 RasterSwingLegendManager getSwingManager() { |
|
92 |
return (RasterSwingLegendManager) getInstance() |
|
93 |
.get(SWING_MANAGER_NAME); |
|
94 |
} |
|
95 |
|
|
96 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/src/main/java/org/gvsig/raster/swing/legend/RasterSwingLegendLibrary.java | ||
---|---|---|
1 |
package org.gvsig.raster.swing.legend; |
|
2 |
|
|
3 |
import org.gvsig.tools.library.AbstractLibrary; |
|
4 |
/* gvSIG. Desktop Geographic Information System. |
|
5 |
* |
|
6 |
* Copyright ? 2007-2017 gvSIG Association |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
* For any additional information, do not hesitate to contact us |
|
24 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
25 |
*/ |
|
26 |
import org.gvsig.tools.library.LibraryException; |
|
27 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* @author fdiaz |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class RasterSwingLegendLibrary extends AbstractLibrary{ |
|
37 |
|
|
38 |
@Override |
|
39 |
public void doRegistration() { |
|
40 |
registerAsAPI(RasterSwingLegendLibrary.class); |
|
41 |
// this.require(RasterLibrary.class); |
|
42 |
// this.require(BufferLibrary.class); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
protected void doInitialize() throws LibraryException { |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected void doPostInitialize() throws LibraryException { |
|
51 |
// Validate there is any implementation registered. |
|
52 |
RasterSwingLegendManager manager = |
|
53 |
RasterSwingLegendLocator.getSwingManager(); |
|
54 |
if (manager == null) { |
|
55 |
throw new ReferenceNotRegisteredException( |
|
56 |
RasterSwingLegendLocator.SWING_MANAGER_NAME, |
|
57 |
RasterSwingLegendLocator.getInstance()); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.api/pom.xml | ||
---|---|---|
1 |
<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/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.raster.legend.swing</artifactId> |
|
6 |
<version>2.0.272-SNAPSHOT</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.raster.legend.swing.api</artifactId> |
|
9 |
<name>${project.artifactId}</name> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
14 |
<scope>compile</scope> |
|
15 |
</dependency> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
19 |
<scope>compile</scope> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
24 |
<scope>compile</scope> |
|
25 |
</dependency> |
|
26 |
</dependencies> |
|
27 |
</project> |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.impl/pom.xml | ||
---|---|---|
1 |
<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/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.raster.legend.swing</artifactId> |
|
6 |
<version>2.0.272-SNAPSHOT</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.raster.legend.swing.impl</artifactId> |
|
9 |
<name>${project.artifactId}</name> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.raster.legend.swing.api</artifactId> |
|
14 |
</dependency> |
|
15 |
<dependency> |
|
16 |
<groupId>com.jgoodies</groupId> |
|
17 |
<artifactId>jgoodies-forms</artifactId> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>com.jeta</groupId> |
|
21 |
<artifactId>formsrt</artifactId> |
|
22 |
<scope>compile</scope> |
|
23 |
</dependency> |
|
24 |
|
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
28 |
</dependency> |
|
29 |
</dependencies> |
|
30 |
</project> |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.impl/src/main/java/org/gvsig/raster/swing/legend/impl/DefaultRasterSwingLegendLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2017 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.swing.legend.impl; |
|
24 |
|
|
25 |
import org.gvsig.raster.swing.legend.RasterSwingLegendLibrary; |
|
26 |
import org.gvsig.raster.swing.legend.RasterSwingLegendLocator; |
|
27 |
import org.gvsig.tools.library.LibraryException; |
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
/** |
|
32 |
* @author fdiaz |
|
33 |
* |
|
34 |
*/ |
|
35 |
public class DefaultRasterSwingLegendLibrary extends RasterSwingLegendLibrary{ |
|
36 |
|
|
37 |
|
|
38 |
@Override |
|
39 |
public void doRegistration() { |
|
40 |
registerAsImplementationOf(RasterSwingLegendLibrary.class); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void doInitialize() throws LibraryException { |
|
45 |
RasterSwingLegendLocator |
|
46 |
.registerSwingManager(DefaultRasterSwingLegendManager.class); |
|
47 |
} |
|
48 |
|
|
49 |
@Override |
|
50 |
protected void doPostInitialize() throws LibraryException { |
|
51 |
} |
|
52 |
|
|
53 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.impl/src/main/java/org/gvsig/raster/swing/legend/impl/colortable/selector/PreviewerColorTableCellRenderer.java | ||
---|---|---|
1 |
package org.gvsig.raster.swing.legend.impl.colortable.selector; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.Graphics2D; |
|
6 |
import java.awt.Rectangle; |
|
7 |
import java.awt.image.BufferedImage; |
|
8 |
|
|
9 |
import javax.swing.ImageIcon; |
|
10 |
import javax.swing.JComponent; |
|
11 |
import javax.swing.JLabel; |
|
12 |
import javax.swing.JPanel; |
|
13 |
import javax.swing.JTable; |
|
14 |
import javax.swing.table.TableCellRenderer; |
|
15 |
|
|
16 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
17 |
|
|
18 |
|
|
19 |
/** |
|
20 |
* @author fdiaz |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class PreviewerColorTableCellRenderer extends JLabel implements TableCellRenderer { |
|
24 |
|
|
25 |
/** |
|
26 |
* |
|
27 |
*/ |
|
28 |
private static final long serialVersionUID = 9027225839371919399L; |
|
29 |
private ColorTable colorTable; |
|
30 |
|
|
31 |
@Override |
|
32 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, |
|
33 |
int row, int column) { |
|
34 |
if (value instanceof ColorTable) { |
|
35 |
this.colorTable = (ColorTable)value; |
|
36 |
Rectangle cellRect = table.getCellRect(row, column, false); |
|
37 |
BufferedImage image = new BufferedImage((int)cellRect.getWidth(), (int)cellRect.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); |
|
38 |
this.paintImage(image, isSelected); |
|
39 |
ImageIcon icon = new ImageIcon(image, this.colorTable.getName()); |
|
40 |
this.setIcon(icon); |
|
41 |
} |
|
42 |
return this; |
|
43 |
} |
|
44 |
|
|
45 |
private void paintImage(BufferedImage image, boolean isSelected) { |
|
46 |
Graphics2D g = (Graphics2D)image.getGraphics(); |
|
47 |
|
|
48 |
Rectangle area = new Rectangle(image.getWidth(), image.getHeight()); |
|
49 |
|
|
50 |
int x1 = area.x; |
|
51 |
int x2 = area.x + area.width - 1; |
|
52 |
|
|
53 |
Color bgColor = new Color(224, 224, 224); |
|
54 |
for (int i = 0; (i * 4) <= area.width; i++) { |
|
55 |
for (int j = 0; (j * 4) <= area.height; j++) { |
|
56 |
if ((i + j) % 2 == 0) |
|
57 |
g.setColor(Color.white); |
|
58 |
else |
|
59 |
g.setColor(bgColor); |
|
60 |
g.fillRect(area.x + 1 + i * 4, area.y + 1 + j * 4, 4, 4); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
if (colorTable.getClasses().size() >= 1) { |
|
65 |
double min = colorTable.getClasses().get(0).getValue(); |
|
66 |
double max = colorTable.getClasses().get(colorTable.getClasses().size() - 1).getValue(); |
|
67 |
for (int i = area.x; i < (area.x + area.width); i++) { |
|
68 |
double pos = min + (((max - min) * (i - area.x)) / (area.width - 2)); |
|
69 |
|
|
70 |
byte[] col3 = colorTable.getRGBA(pos); |
|
71 |
g.setColor(new Color(col3[0] & 0xff, col3[1] & 0xff, col3[2] & 0xff, col3[3] & 0xff)); |
|
72 |
g.drawLine(i, area.y, i, area.y + area.height); |
|
73 |
} |
|
74 |
} else { |
|
75 |
g.setColor(new Color(224, 224, 224)); |
|
76 |
g.fillRect(x1, area.y, x2 - x1, area.height); // - 1); |
|
77 |
} |
|
78 |
if (isSelected) { //????? |
|
79 |
g.setColor(Color.black); |
|
80 |
} else { |
|
81 |
g.setColor(new Color(96, 96, 96)); |
|
82 |
} |
|
83 |
g.drawRect(x1, area.y, x2 - x1, area.height - 1); |
|
84 |
} |
|
85 |
|
|
86 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.impl/src/main/java/org/gvsig/raster/swing/legend/impl/colortable/selector/DefaultColorTablesTableModel.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2017 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.swing.legend.impl.colortable.selector; |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import javax.swing.table.AbstractTableModel; |
|
29 |
|
|
30 |
import org.apache.commons.lang3.tuple.Pair; |
|
31 |
|
|
32 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
33 |
import org.gvsig.raster.swing.legend.colortable.selector.ColorTablesTableModel; |
|
34 |
import org.gvsig.tools.ToolsLocator; |
|
35 |
import org.gvsig.tools.i18n.I18nManager; |
|
36 |
|
|
37 |
|
|
38 |
/** |
|
39 |
* @author fdiaz |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class DefaultColorTablesTableModel extends AbstractTableModel implements ColorTablesTableModel{ |
|
43 |
|
|
44 |
/** |
|
45 |
* |
|
46 |
* |
|
47 |
*/ |
|
48 |
private static final long serialVersionUID = -6739781555636046945L; |
|
49 |
private List<Pair<File,ColorTable>> colorTables; |
|
50 |
|
|
51 |
private static final int COLUMNS = 4; |
|
52 |
|
|
53 |
public static final int COLUMN_PREVIEW = 0; |
|
54 |
public static final int COLUMN_NAME = 1; |
|
55 |
public static final int COLUMN_CLASSES = 2; |
|
56 |
public static final int COLUMN_INTERPOLATED = 3; |
|
57 |
|
|
58 |
/** |
|
59 |
* @param bandsInfo |
|
60 |
*/ |
|
61 |
public DefaultColorTablesTableModel(List<Pair<File,ColorTable>> colorTables) { |
|
62 |
this.colorTables = colorTables; |
|
63 |
} |
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see javax.swing.table.TableModel#getRowCount() |
|
67 |
*/ |
|
68 |
@Override |
|
69 |
public int getRowCount() { |
|
70 |
return colorTables.size(); |
|
71 |
} |
|
72 |
|
|
73 |
/* (non-Javadoc) |
|
74 |
* @see javax.swing.table.TableModel#getColumnCount() |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public int getColumnCount() { |
|
78 |
return COLUMNS; |
|
79 |
} |
|
80 |
|
|
81 |
/* (non-Javadoc) |
|
82 |
* @see javax.swing.table.TableModel#getValueAt(int, int) |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
86 |
switch (columnIndex) { |
|
87 |
case COLUMN_PREVIEW: |
|
88 |
return colorTables.get(rowIndex).getValue(); |
|
89 |
case COLUMN_NAME: |
|
90 |
return colorTables.get(rowIndex).getValue().getName(); |
|
91 |
case COLUMN_CLASSES: |
|
92 |
return colorTables.get(rowIndex).getValue().getClasses().size(); |
|
93 |
case COLUMN_INTERPOLATED: |
|
94 |
return colorTables.get(rowIndex).getValue().isInterpolated(); |
|
95 |
} |
|
96 |
return null; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public String getColumnName(int column) { |
|
101 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
102 |
switch (column) { |
|
103 |
case COLUMN_PREVIEW: |
|
104 |
return i18nManager.getTranslation("_preview"); |
|
105 |
case COLUMN_NAME: |
|
106 |
return i18nManager.getTranslation("_name"); |
|
107 |
case COLUMN_CLASSES: |
|
108 |
return i18nManager.getTranslation("_classes"); |
|
109 |
case COLUMN_INTERPOLATED: |
|
110 |
return i18nManager.getTranslation("_interpolated"); |
|
111 |
} |
|
112 |
return null; |
|
113 |
} |
|
114 |
|
|
115 |
public boolean isCellEditable(int row, int col) { |
|
116 |
return false; |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public Class<?> getColumnClass(int col) { |
|
121 |
if (col == COLUMN_PREVIEW) { |
|
122 |
return ColorTable.class; |
|
123 |
} else if (col == COLUMN_INTERPOLATED) { |
|
124 |
return Boolean.class; |
|
125 |
} |
|
126 |
return super.getColumnClass(col); |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public void addColorTable(Pair<File,ColorTable> colorTable) { |
|
131 |
colorTables.add(colorTable); |
|
132 |
this.fireTableDataChanged(); |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public void removeColorTable(int index) { |
|
137 |
colorTables.remove(index); |
|
138 |
this.fireTableDataChanged(); |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public Pair<File, ColorTable> getColorTable(int index) { |
|
143 |
return colorTables.get(index); |
|
144 |
} |
|
145 |
|
|
146 |
@Override |
|
147 |
public void setColorTable(int index, ColorTable colorTableEdited) { |
|
148 |
colorTables.get(index).getValue().copyFrom(colorTableEdited); |
|
149 |
this.fireTableDataChanged(); |
|
150 |
} |
|
151 |
|
|
152 |
@Override |
|
153 |
public List<Pair<File, ColorTable>> getColorTables() { |
|
154 |
return colorTables; |
|
155 |
} |
|
156 |
|
|
157 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.raster.legend/org.gvsig.raster.legend.swing/org.gvsig.raster.legend.swing.impl/src/main/java/org/gvsig/raster/swing/legend/impl/colortable/selector/ColorTableSelectorPanelController.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2017 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.raster.swing.legend.impl.colortable.selector; |
|
24 |
|
|
25 |
import java.awt.Color; |
|
26 |
import java.awt.Dimension; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import java.awt.event.ComponentListener; |
|
30 |
import java.awt.event.FocusListener; |
|
31 |
import java.io.File; |
|
32 |
import java.util.ArrayList; |
|
33 |
import java.util.Iterator; |
|
34 |
import java.util.List; |
|
35 |
import java.util.Locale; |
|
36 |
|
|
37 |
import javax.swing.JComponent; |
|
38 |
import javax.swing.JFileChooser; |
|
39 |
import javax.swing.ListSelectionModel; |
|
40 |
import javax.swing.event.ListSelectionEvent; |
|
41 |
import javax.swing.event.ListSelectionListener; |
|
42 |
import javax.swing.table.DefaultTableColumnModel; |
|
43 |
import javax.swing.table.TableColumn; |
|
44 |
import javax.swing.table.TableColumnModel; |
|
45 |
|
|
46 |
import org.apache.commons.io.FilenameUtils; |
|
47 |
import org.apache.commons.lang3.tuple.MutablePair; |
|
48 |
import org.apache.commons.lang3.tuple.Pair; |
|
49 |
import org.slf4j.Logger; |
|
50 |
import org.slf4j.LoggerFactory; |
|
51 |
|
|
52 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
|
53 |
import org.gvsig.raster.lib.legend.api.RasterLegendManager; |
|
54 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTable; |
|
55 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTableIO; |
|
56 |
import org.gvsig.raster.lib.legend.api.colortable.ColorTableIOFactory; |
|
57 |
import org.gvsig.raster.lib.legend.api.colortable.MakeColorTable; |
|
58 |
import org.gvsig.raster.lib.legend.api.exceptions.ColorTableIOException; |
|
59 |
import org.gvsig.raster.swing.legend.RasterSwingLegendLocator; |
|
60 |
import org.gvsig.raster.swing.legend.RasterSwingLegendManager; |
|
61 |
import org.gvsig.raster.swing.legend.colortable.create.CreateColorTablePanel; |
|
62 |
import org.gvsig.raster.swing.legend.colortable.editor.ColorTableEditorPanel; |
|
63 |
import org.gvsig.raster.swing.legend.colortable.selector.ColorTableSelectorPanel; |
|
64 |
import org.gvsig.raster.swing.legend.colortable.selector.ColorTablesTableModel; |
|
65 |
import org.gvsig.raster.swing.legend.impl.colortable.editor.ColorTableEditorPanelController; |
|
66 |
import org.gvsig.tools.ToolsLocator; |
|
67 |
import org.gvsig.tools.i18n.I18nManager; |
|
68 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
69 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
70 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
71 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
72 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
73 |
|
|
74 |
|
|
75 |
/** |
|
76 |
* @author fdiaz |
|
77 |
* |
|
78 |
*/ |
|
79 |
public class ColorTableSelectorPanelController extends ColorTableSelectorPanelView implements ColorTableSelectorPanel { |
|
80 |
|
|
81 |
/** |
|
82 |
* |
|
83 |
*/ |
|
84 |
private static final long serialVersionUID = -2427828721121167549L; |
|
85 |
private static final Logger LOG = LoggerFactory.getLogger(ColorTableSelectorPanelController.class); |
|
86 |
|
|
87 |
private List<Pair<File,ColorTable>> colorTables; |
|
88 |
private List<ColorTable> addedColorTables; |
|
89 |
private List<Pair<File,ColorTable>> modifiedColorTables; |
|
90 |
private List<Pair<File,ColorTable>> removedColorTables; |
|
91 |
private boolean editable; |
|
92 |
|
|
93 |
public ColorTableSelectorPanelController() { |
|
94 |
translate(); |
|
95 |
this.editable = true; |
|
96 |
initializeComponents(); |
|
97 |
} |
|
98 |
|
|
99 |
/* (non-Javadoc) |
|
100 |
* @see org.gvsig.tools.swing.api.Component#asJComponent() |
|
101 |
*/ |
|
102 |
@Override |
|
103 |
public JComponent asJComponent() { |
|
104 |
return this; |
|
105 |
} |
|
106 |
|
|
107 |
private void initializeComponents() { |
|
108 |
IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
|
109 |
btnNew.setIcon(iconTheme.get("new-color-table-icon")); |
|
110 |
btnEdit.setIcon(iconTheme.get("edit-color-table-icon")); |
|
111 |
btnExport.setIcon(iconTheme.get("export-color-table-icon")); |
|
112 |
btnImport.setIcon(iconTheme.get("import-color-table-icon")); |
|
113 |
btnRemove.setIcon(iconTheme.get("remove-color-table-icon")); |
|
114 |
|
|
115 |
btnNew.addActionListener(new ActionListener() { |
|
116 |
@Override |
|
117 |
public void actionPerformed(ActionEvent e) { |
|
118 |
doNewColorTable(); |
|
119 |
} |
|
120 |
}); |
|
121 |
|
|
122 |
btnEdit.addActionListener(new ActionListener() { |
|
123 |
@Override |
|
124 |
public void actionPerformed(ActionEvent e) { |
|
125 |
doEditColorTable(); |
|
126 |
} |
|
127 |
}); |
|
128 |
|
|
129 |
btnExport.addActionListener(new ActionListener() { |
|
130 |
@Override |
|
131 |
public void actionPerformed(ActionEvent e) { |
|
132 |
doExportColorTable(); |
|
133 |
} |
|
134 |
}); |
|
135 |
|
|
136 |
btnImport.addActionListener(new ActionListener() { |
|
137 |
@Override |
|
138 |
public void actionPerformed(ActionEvent e) { |
|
139 |
doImportColorTable(); |
|
140 |
} |
|
141 |
}); |
|
142 |
|
|
143 |
btnRemove.addActionListener(new ActionListener() { |
|
144 |
@Override |
|
145 |
public void actionPerformed(ActionEvent e) { |
|
146 |
doRemoveColorTable(); |
|
147 |
} |
|
148 |
}); |
|
149 |
|
|
150 |
tblColorTables.setRowSelectionAllowed(true); |
|
151 |
tblColorTables.setColumnSelectionAllowed(false); |
|
152 |
tblColorTables.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
153 |
tblColorTables.getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
|
154 |
@Override |
|
155 |
public void valueChanged(ListSelectionEvent e) { |
|
156 |
updateComponents(); |
|
157 |
} |
|
158 |
}); |
|
159 |
|
|
160 |
updateComponents(); |
|
161 |
|
|
162 |
} |
|
163 |
protected void doEditColorTable() { |
|
164 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
165 |
|
|
166 |
int index = this.tblColorTables.getSelectedRow(); |
|
167 |
ColorTable sourceColorTable = ((ColorTablesTableModel)this.tblColorTables.getModel()).getColorTable(index).getValue(); |
|
168 |
|
|
169 |
//Le pasamos una copiamos de la tabla de color al editor para que no la modifique autom?ticamente |
|
170 |
ColorTable colorTable = RasterLegendLocator.getRasterLegendManager().createColorTable(); |
|
171 |
colorTable.copyFrom(colorTable); |
|
172 |
|
|
173 |
//FIXME: ?Al manager? |
|
174 |
final ColorTableEditorPanelController panel = new ColorTableEditorPanelController(); |
|
175 |
|
|
176 |
panel.set(colorTable); |
|
177 |
panel.asJComponent().setPreferredSize(new Dimension(600, 400)); |
|
178 |
|
|
179 |
final WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
180 |
|
|
181 |
final Dialog dialog = |
|
182 |
winManager.createDialog(panel.asJComponent(), i18nManager.getTranslation("color-table-edit"), |
|
183 |
null, WindowManager_v2.BUTTONS_APPLY_OK_CANCEL); |
|
184 |
|
|
185 |
dialog.addActionListener(new ActionListener() { |
|
186 |
|
|
187 |
@Override |
|
188 |
public void actionPerformed(ActionEvent e) { |
|
189 |
switch (dialog.getAction()) { |
|
190 |
case WindowManager_v2.BUTTON_APPLY: |
|
191 |
doApplyEditColorTable(panel); |
|
192 |
break; |
|
193 |
|
|
194 |
case WindowManager_v2.BUTTON_OK: |
|
195 |
if (doApplyEditColorTable(panel)) { |
|
196 |
panel.asJComponent().setVisible(false); |
|
197 |
} |
|
198 |
break; |
|
199 |
|
|
200 |
case WindowManager_v2.BUTTON_CANCEL: |
|
201 |
panel.asJComponent().setVisible(false); |
|
202 |
break; |
|
203 |
} |
|
204 |
|
|
205 |
} |
|
206 |
|
|
207 |
}); |
|
208 |
dialog.show(WindowManager.MODE.DIALOG); |
|
209 |
|
|
210 |
} |
|
211 |
|
|
212 |
protected boolean doApplyEditColorTable(ColorTableEditorPanel panel) { |
|
213 |
int selectedRow = tblColorTables.getSelectedRow(); |
|
214 |
ColorTable colorTableEdited = panel.getColorTable(); |
|
215 |
if(panel.isModified()){ |
|
216 |
ColorTablesTableModel colorTablesTableModel = (ColorTablesTableModel)this.tblColorTables.getModel(); |
|
217 |
colorTablesTableModel.setColorTable(selectedRow, colorTableEdited); |
|
218 |
if(!modifiedColorTables.contains(colorTablesTableModel.getColorTable(selectedRow))){ |
|
219 |
modifiedColorTables.add(colorTablesTableModel.getColorTable(selectedRow)); |
|
220 |
} |
|
221 |
|
|
222 |
tblColorTables.setRowSelectionInterval(selectedRow, selectedRow); |
|
223 |
} |
|
224 |
return true; |
|
225 |
} |
|
226 |
|
|
227 |
protected void doRemoveColorTable() { |
|
228 |
int row = tblColorTables.getSelectedRow(); |
|
229 |
ColorTablesTableModel colorTablesTableModel = (ColorTablesTableModel)tblColorTables.getModel(); |
|
230 |
Pair<File, ColorTable> pair = colorTablesTableModel.getColorTable(row); |
|
231 |
removedColorTables.add(pair); |
|
232 |
colorTablesTableModel.removeColorTable(tblColorTables.getSelectedRow()); |
|
233 |
} |
|
234 |
|
|
235 |
protected void doImportColorTable() { |
|
236 |
RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager(); |
|
237 |
JFileChooser fileChooser = new JFileChooser(); |
|
238 |
List<ColorTableIOFactory> factories = legendManager.getColorTableIOFactories(); |
|
239 |
for (Iterator iterator = factories.iterator(); iterator.hasNext();) { |
|
240 |
ColorTableIOFactory colorTableIOFactory = (ColorTableIOFactory) iterator.next(); |
|
241 |
fileChooser.addChoosableFileFilter(new MyFileFilter(colorTableIOFactory)); |
|
242 |
} |
|
243 |
|
|
244 |
fileChooser.setMultiSelectionEnabled(true); |
|
245 |
fileChooser.setAcceptAllFileFilterUsed(false); |
|
246 |
|
|
247 |
int result = fileChooser.showOpenDialog(this); |
|
248 |
|
|
249 |
if (result == JFileChooser.APPROVE_OPTION) { |
|
250 |
File[] files = fileChooser.getSelectedFiles(); |
|
251 |
for (File file : files) { |
|
252 |
for (Iterator iterator = factories.iterator(); iterator.hasNext();) { |
|
253 |
ColorTableIOFactory colorTableIOFactory = (ColorTableIOFactory) iterator.next(); |
|
254 |
if(colorTableIOFactory.accept(file)){ |
|
255 |
ColorTableIO colorTableIO = colorTableIOFactory.create(); |
|
256 |
ColorTable colorTable; |
|
257 |
try { |
|
258 |
colorTable = colorTableIO.read(file); |
|
259 |
} catch (ColorTableIOException e) { |
|
260 |
LOG.warn("Can't read color table '"+file.getName()+"'.", e); |
|
261 |
//FIXME: mostrar aviso al usuario |
|
262 |
throw new RuntimeException("Can't read color table '"+file.getName()+"'.", e); |
|
263 |
} |
|
264 |
addedColorTables.add(colorTable); |
|
265 |
((ColorTablesTableModel)tblColorTables.getModel()).addColorTable(new MutablePair<File, ColorTable>(null,colorTable)); |
|
266 |
continue; |
|
267 |
} |
|
268 |
} |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 |
protected void doExportColorTable() { |
|
274 |
ColorTable colorTable = |
|
275 |
((ColorTablesTableModel) tblColorTables.getModel()).getColorTable(tblColorTables.getSelectedRow()) |
|
276 |
.getValue(); |
|
277 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
278 |
RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager(); |
|
279 |
JFileChooser fileChooser = new JFileChooser(); |
|
280 |
List<ColorTableIOFactory> factories = legendManager.getColorTableIOFactories(); |
|
281 |
for (Iterator iterator = factories.iterator(); iterator.hasNext();) { |
|
282 |
ColorTableIOFactory colorTableIOFactory = (ColorTableIOFactory) iterator.next(); |
|
283 |
fileChooser.addChoosableFileFilter(new MyFileFilter(colorTableIOFactory)); |
|
284 |
} |
|
285 |
|
|
286 |
fileChooser.setMultiSelectionEnabled(false); |
|
287 |
fileChooser.setAcceptAllFileFilterUsed(false); |
|
288 |
|
|
289 |
int result = fileChooser.showSaveDialog(this); |
|
290 |
|
|
291 |
if (result == JFileChooser.APPROVE_OPTION) { |
|
292 |
File file = fileChooser.getSelectedFile(); |
|
293 |
MyFileFilter fileFilter = (MyFileFilter) fileChooser.getFileFilter(); |
|
294 |
File parent = file.getParentFile(); |
|
295 |
String filename = file.getName(); |
|
296 |
ColorTableIOFactory colorTableIOFactory = fileFilter.getColorTableIOFactory(); |
|
297 |
if (FilenameUtils.getExtension(filename).isEmpty()) { |
|
298 |
file = new File(parent, filename + "." + colorTableIOFactory.getDefaultExtension()); |
|
299 |
} |
|
300 |
; |
|
301 |
try { |
|
302 |
colorTableIOFactory.create().write(colorTable, file); |
|
303 |
} catch (ColorTableIOException e) { |
|
304 |
LOG.warn("Can't write color table '" + file.getName() + "'.", e); |
|
305 |
// FIXME: mostrar aviso al usuario |
|
306 |
throw new RuntimeException("Can't write color table '" + file.getName() + "'.", e); |
|
307 |
} |
|
308 |
} |
|
309 |
} |
|
310 |
|
|
311 |
protected void doNewColorTable() { |
|
312 |
RasterSwingLegendManager rasterSwingLegendManager = RasterSwingLegendLocator.getSwingManager(); |
|
313 |
final CreateColorTablePanel panel = rasterSwingLegendManager.createCreateColorTablePanel(); |
|
314 |
panel.setFromColor(new Color(0,0,0,255)); |
|
315 |
panel.setToColor(new Color(255,255,255,255)); |
|
316 |
panel.setMinimum(0); |
|
317 |
panel.setMaximum(255); |
|
318 |
panel.setIntervals(1); |
|
319 |
panel.setMode(MakeColorTable.MODE_NUMBER_OF_INTERVALS); |
|
320 |
panel.setName(""); |
|
321 |
panel.asJComponent().setPreferredSize(new Dimension(400, 300)); |
|
322 |
|
|
323 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
324 |
|
|
325 |
final WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
326 |
|
|
327 |
final Dialog dialog = |
|
328 |
winManager.createDialog(panel.asJComponent(), i18nManager.getTranslation("color-tables-library"), |
|
329 |
null, WindowManager_v2.BUTTONS_OK_CANCEL); |
|
330 |
|
|
331 |
dialog.addActionListener(new ActionListener() { |
|
332 |
|
|
333 |
@Override |
|
334 |
public void actionPerformed(ActionEvent e) { |
|
335 |
switch (dialog.getAction()) { |
|
336 |
case WindowManager_v2.BUTTON_OK: |
|
337 |
if (doMakeColorTable(panel)) { |
|
338 |
panel.asJComponent().setVisible(false); |
|
339 |
} |
|
340 |
break; |
|
341 |
|
|
342 |
case WindowManager_v2.BUTTON_CANCEL: |
|
343 |
panel.asJComponent().setVisible(false); |
|
344 |
break; |
|
345 |
} |
|
346 |
|
|
347 |
} |
|
348 |
|
|
349 |
}); |
|
350 |
dialog.show(WindowManager.MODE.WINDOW); |
|
351 |
} |
|
352 |
|
|
353 |
protected boolean doMakeColorTable(CreateColorTablePanel panel) { |
|
354 |
MakeColorTable makeColorTable = RasterLegendLocator.getRasterLegendManager().createMakeColorTable(); |
|
355 |
panel.fetch(makeColorTable); |
|
356 |
ColorTable colorTable = makeColorTable.getColorTable(); |
|
357 |
((ColorTablesTableModel)tblColorTables.getModel()).addColorTable(new MutablePair<File, ColorTable>(null, colorTable)); |
|
358 |
addedColorTables.add(colorTable); |
|
359 |
return true; |
|
360 |
} |
|
361 |
|
|
362 |
private void translate() { |
|
363 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
364 |
|
|
365 |
btnNew.setToolTipText(i18nManager.getTranslation(btnNew.getToolTipText())); |
|
366 |
btnImport.setToolTipText(i18nManager.getTranslation(btnImport.getToolTipText())); |
|
367 |
btnExport.setToolTipText(i18nManager.getTranslation(btnExport.getToolTipText())); |
|
368 |
btnRemove.setToolTipText(i18nManager.getTranslation(btnRemove.getToolTipText())); |
|
369 |
} |
|
370 |
|
|
371 |
/** |
|
372 |
* @param locale |
|
373 |
* |
|
374 |
*/ |
|
375 |
public void setLocate(Locale locale) { |
|
376 |
Locale l = super.getLocale(); |
|
377 |
if (!l.equals(locale)) { |
|
378 |
translate(); |
|
379 |
} |
|
380 |
super.setLocale(locale); |
|
381 |
} |
|
382 |
|
|
383 |
|
|
384 |
/* (non-Javadoc) |
|
385 |
* @see org.gvsig.raster.tools.swing.api.colortable.ColorTableSelector#fetch(org.gvsig.raster.lib.legend.api.ColorTable) |
|
386 |
*/ |
|
387 |
@Override |
|
388 |
public ColorTable getSelected() { |
|
389 |
int row = tblColorTables.getSelectedRow(); |
|
390 |
if(row<0){ |
|
391 |
return null; |
|
392 |
} |
|
393 |
return (ColorTable)((ColorTablesTableModel)tblColorTables.getModel()).getValueAt(row, 0); |
|
394 |
} |
|
395 |
|
|
396 |
/* (non-Javadoc) |
|
397 |
* @see org.gvsig.raster.tools.swing.api.colortable.ColorTableSelector#set(java.util.List) |
|
398 |
*/ |
|
399 |
@Override |
|
400 |
public void set(List<Pair<File,ColorTable>> colorTables) { |
|
401 |
if(colorTables!=null){ |
|
402 |
this.colorTables = colorTables; |
|
403 |
} else { |
|
404 |
this.colorTables = new ArrayList<Pair<File,ColorTable>>(); |
|
405 |
} |
|
406 |
this.modifiedColorTables = new ArrayList<Pair<File,ColorTable>>(); |
|
407 |
this.addedColorTables = new ArrayList<ColorTable>(); |
|
408 |
this.removedColorTables = new ArrayList<Pair<File,ColorTable>>(); |
|
409 |
this.init(); |
|
410 |
} |
|
411 |
|
|
412 |
private void init() { |
|
413 |
|
|
414 |
ColorTablesTableModel tableModel = new DefaultColorTablesTableModel(this.colorTables); |
|
415 |
tblColorTables.setModel(tableModel); |
|
416 |
|
|
417 |
tblColorTables.setColumnModel(new DefaultTableColumnModel()); |
|
418 |
TableColumnModel columnModel = tblColorTables.getColumnModel(); |
|
419 |
columnModel.setColumnSelectionAllowed(false); |
|
420 |
for (int i = 0; i < tableModel.getColumnCount(); i++) { |
|
421 |
TableColumn tableColumn = new TableColumn(i); |
|
422 |
tableColumn.setIdentifier(tableModel.getColumnName(i)); |
|
423 |
tableColumn.setHeaderValue(tableModel.getColumnName(i)); |
|
424 |
if(i==DefaultColorTablesTableModel.COLUMN_PREVIEW){ |
|
425 |
tableColumn.setCellRenderer(new PreviewerColorTableCellRenderer()); |
|
426 |
} |
|
427 |
columnModel.addColumn(tableColumn); |
|
428 |
} |
|
429 |
|
|
430 |
} |
|
431 |
|
|
432 |
private void updateComponents() { |
|
433 |
boolean selected = tblColorTables.getSelectedRowCount() >= 1; |
|
434 |
btnExport.setEnabled(selected); |
|
435 |
btnRemove.setEnabled(selected && this.editable); |
|
436 |
btnEdit.setEnabled(selected && this.editable); |
|
437 |
|
|
438 |
btnEdit.setVisible(this.editable); |
|
439 |
btnImport.setVisible(this.editable); |
|
440 |
btnNew.setVisible(this.editable); |
|
441 |
btnRemove.setVisible(this.editable); |
|
442 |
btnExport.setVisible(this.editable); |
|
443 |
} |
|
444 |
|
|
445 |
@Override |
|
446 |
public List<Pair<File, ColorTable>> getModifiedColorTables() { |
|
447 |
return modifiedColorTables; |
|
448 |
} |
|
449 |
|
|
450 |
@Override |
|
451 |
public List<Pair<File, ColorTable>> getRemovedColorTables() { |
|
452 |
return removedColorTables; |
|
453 |
} |
|
454 |
|
|
455 |
@Override |
|
456 |
public List<ColorTable> getAddedColorTables() { |
|
457 |
return addedColorTables; |
|
458 |
} |
|
459 |
|
|
460 |
@Override |
|
461 |
public void setEditable(boolean editable) { |
|
462 |
this.editable = editable; |
|
463 |
updateComponents(); |
|
464 |
} |
|
465 |
|
|
466 |
/** |
|
467 |
* @author fdiaz |
|
468 |
* |
|
469 |
*/ |
|
470 |
private static class MyFileFilter extends javax.swing.filechooser.FileFilter { |
Also available in: Unified diff