Revision 5736

View differences:

org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.toolbox.algorithm/src/main/resources/org/gvsig/raster/tools/sextante/i18n/text.properties
1
layer_datatype=Cambiar tipo de dato
2
raster_layer=Capas r?ster
3
Input_layer=Capa de entrada
4
dst_datatype=Tipo de dato de destino
5
dec_2_int=De decimal a entero
6
big_2_small=De mayor a menor
7
file_exists=El fichero existe
8
convert_datatype=Convirtiendo el tipo de dato
0 9

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.toolbox.algorithm/src/main/resources/org/gvsig/raster/tools/sextante/i18n/text_en.properties
1
layer_datatype=Change the data type
2
raster_layer=Raster layers
3
Input_layer=Input layer
4
dst_datatype=Data type of the result
5
dec_2_int=From decimal to integer
6
big_2_small=From greater type to lesser type
7
file_exists=The file exists
8
convert_datatype=Transforming the data type
0 9

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.toolbox.algorithm/src/main/resources/help/LayerDatatypeSextanteAlgorithm.xml
1
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
2
<help>
3
	<element name="DESCRIPTION"
4
		text=""
5
		description="Descripci&#243;n" type="0">
6
		<!-- <image description="" file="">
7
		</image>-->
8
	</element>
9
	<element name="ADDITIONAL_INFO" text=""
10
		description="Informaci&#243;n adicional" type="0">
11
	</element>
12
	<element name="EXTENSION_AUTHOR" text=""
13
		description="Algoritmo creado por" type="0">
14
	</element>
15
	<element name="HELP_AUTHOR" text="" description="Ayuda creada por"
16
		type="0">
17
	</element>
18
	<element name="USER_NOTES" text="" description="Notas de usuario"
19
		type="0">
20
	</element>
21
</help>
0 22

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.toolbox.algorithm/src/main/resources/help/LayerDatatypeSextanteAlgorithm_en.xml
1
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
2
<help>
3
	<element name="DESCRIPTION"
4
		text=""
5
		description="Descripci&#243;n" type="0">
6
		<!-- <image description="" file="">
7
		</image> -->
8
	</element>
9
	<element name="ADDITIONAL_INFO" text=""
10
		description="Informaci&#243;n adicional" type="0">
11
	</element>
12
	<element name="EXTENSION_AUTHOR" text=""
13
		description="Algoritmo creado por" type="0">
14
	</element>
15
	<element name="HELP_AUTHOR" text="" description="Ayuda creada por"
16
		type="0">
17
	</element>
18
	<element name="USER_NOTES" text="" description="Notas de usuario"
19
		type="0">
20
	</element>
21
</help>
0 22

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.toolbox.algorithm/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.raster.tools.RasterToolsSextanteLibrary
0 2

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.toolbox.algorithm/src/main/java/org/gvsig/raster/tools/LayerDatatypeSextanteAlgorithm.java
1
package org.gvsig.raster.tools;
2

  
3
import java.util.HashMap;
4
import java.util.List;
5

  
6
import org.gvsig.fmap.dal.coverage.RasterLocator;
7
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
8
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
9
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
10
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
11
import org.gvsig.geoprocess.lib.sextante.dataObjects.FLyrRasterIRasterLayer;
12
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary;
13
import org.gvsig.raster.algorithm.process.DataProcess;
14
import org.gvsig.raster.algorithm.process.IProcessActions;
15
import org.gvsig.raster.algorithm.process.ProcessException;
16
import org.gvsig.raster.fmap.layers.FLyrRaster;
17

  
18
import es.unex.sextante.core.AnalysisExtent;
19
import es.unex.sextante.core.Sextante;
20
import es.unex.sextante.dataObjects.IRasterLayer;
21
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException;
22
import es.unex.sextante.exceptions.NullParameterAdditionalInfoException;
23
import es.unex.sextante.exceptions.NullParameterValueException;
24
import es.unex.sextante.exceptions.RepeatedParameterNameException;
25
import es.unex.sextante.exceptions.WrongParameterIDException;
26
import es.unex.sextante.exceptions.WrongParameterTypeException;
27

  
28
/**
29
 * Process to change a layer of data type
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 */
32
public class LayerDatatypeSextanteAlgorithm extends AbstractSextanteGeoProcess implements IProcessActions {
33
    public static final String RESULT            = "RESULT";
34
    public static final String LAYER             = "RasterStore1";
35
	public static final String DATATYPE          = "Datatype";
36
	public static final String ADJUST_DEC2INT    = "AdjustDec2Int";
37
	public static final String ADJUST_BIG2SMALL  = "AdjustBig2Small";
38

  
39
	public static String[]    DEC2INT_OPTIONS    = new String[]{"Trunk", "Round", "Ceil", "Floor"};
40
	public static String[]    BIG2SMALL_OPTIONS  = new String[]{"Trunk", "Maxvalue", "NoData"};
41
	public static String[]    DATATYPES          = new String[]{"Byte", "UShort", "Short", "Integer", "Float", "Double"};
42

  
43
    private DataProcess        task            = null;
44

  
45

  
46
    public void defineCharacteristics() {
47
        setName(getTranslation("layer_datatype"));
48
        setGroup(getTranslation("raster_layer"));
49

  
50
        try {
51
            m_Parameters.addInputRasterLayer(LAYER, getTranslation("Input_layer"), true);
52
            m_Parameters.addSelection(DATATYPE, getTranslation("dst_datatype"), DATATYPES);
53
            m_Parameters.addSelection(ADJUST_DEC2INT, getTranslation("dec_2_int"), DEC2INT_OPTIONS);
54
            m_Parameters.addSelection(ADJUST_BIG2SMALL, getTranslation("big_2_small"), BIG2SMALL_OPTIONS);
55
        } catch (RepeatedParameterNameException e) {
56
            Sextante.addErrorToLog(e);
57
        }
58
        addOutputRasterLayer(RESULT, getTranslation("principalcomponents"));
59
    }
60

  
61
    public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
62

  
63
    	if(existsOutPutFile(LayerDatatypeSextanteAlgorithm.RESULT, 0)) {
64
    		throw new GeoAlgorithmExecutionException(getTranslation("file_exists"));
65
    	}
66

  
67
    	IRasterLayer input = m_Parameters.getParameterValueAsRasterLayer(LAYER);
68

  
69
    	FLyrRaster lyrRaster = ((FLyrRaster)input.getBaseDataObject());
70
    	IRasterLayer output = null;
71

  
72
    	output = getNewRORasterLayer(
73
    			RESULT,
74
    			Sextante.getText("layerdatatype_description"),
75
    			input.getDataType(),
76
    			input.getBandsCount());
77

  
78
    	String fileName = ((FLyrRasterIRasterLayer)output).getName();
79

  
80
    	try {
81
    		setProgressText(getTranslation("convert_datatype"));
82
			task = createLayerDatatypeProcess(lyrRaster.getDataStore(), fileName);
83
			task.execute();
84
			HashMap<String, Object> params = task.getResult();
85
			fileName = (String)params.get("FileName");
86

  
87
			((FLyrRasterIRasterLayer)output).setBaseDataObject(fileName);
88
		} catch (ProcessInterruptedException e) {
89
			Sextante.addErrorToLog(e);
90
		} catch (ProcessException e) {
91
			Sextante.addErrorToLog(e);
92
		}
93

  
94
		if(getTaskMonitor().isCanceled())
95
			return false;
96

  
97
        return true;
98
    }
99

  
100
    /**
101
     * Creates a process to calculate statistics
102
     * @param inputStore
103
     * @return
104
     * @throws ProcessException
105
     * @throws NullParameterAdditionalInfoException
106
     * @throws NullParameterValueException
107
     * @throws WrongParameterIDException
108
     * @throws WrongParameterTypeException
109
     */
110
    private DataProcess createLayerDatatypeProcess(RasterDataStore inputStore, String fileName) throws ProcessException, WrongParameterTypeException, WrongParameterIDException, NullParameterValueException, NullParameterAdditionalInfoException {
111
    	DataProcess taskStats = RasterBaseAlgorithmLibrary.getManager().createRasterTask("LayerDatatypeProcess");
112
    	taskStats.setActions(this);
113
    	List<String> params = taskStats.getRasterTaskInputParameters("LayerDatatypeProcess");
114
    	for (int i = 0; i < params.size(); i++) {
115
    		String paramName = params.get(i);
116
    		Class<?> paramType = taskStats.getParameterTypeByProcess("LayerDatatypeProcess", paramName);
117
    		if(paramType == RasterDataStore.class) {
118
    			taskStats.addParam(paramName, (RasterDataStore)inputStore);
119
    		}
120

  
121
    		if(paramName.equals("Path")) {
122
    			taskStats.addParam(paramName, fileName);
123
    		}
124

  
125
    		if(paramName.equals(DATATYPE)) {
126
    			String value = m_Parameters.getParameterValueAsString(DATATYPE);
127
    			int position = 0;
128
    			for (int j = 0; j < DATATYPES.length; j++) {
129
					if(DATATYPES[j].equals(value))
130
						position = j;
131
				}
132
    			taskStats.addParam(paramName, position);
133
    		}
134

  
135
    		if(paramName.equals(ADJUST_DEC2INT)) {
136
    			String value = m_Parameters.getParameterValueAsString(ADJUST_DEC2INT);
137
    			int position = 0;
138
    			for (int j = 0; j < DEC2INT_OPTIONS.length; j++) {
139
					if(DEC2INT_OPTIONS[j].equals(value))
140
						position = j;
141
				}
142
    			taskStats.addParam(paramName, position);
143
    		}
144

  
145
    		if(paramName.equals(ADJUST_BIG2SMALL)) {
146
    			String value = m_Parameters.getParameterValueAsString(ADJUST_BIG2SMALL);
147
    			int position = 0;
148
    			for (int j = 0; j < BIG2SMALL_OPTIONS.length; j++) {
149
					if(BIG2SMALL_OPTIONS[j].equals(value))
150
						position = j;
151
				}
152
    			taskStats.addParam(paramName, position);
153
    		}
154

  
155
    		if(paramName.equals("WINDOW")) {
156
    			AnalysisExtent ext = getAnalysisExtent();
157
    			Extent bbox = RasterLocator.getManager().getDataStructFactory().createExtent(
158
    					ext.getXMin(), ext.getYMax(), ext.getXMax(), ext.getYMin());
159
    			Extent inputBbox = inputStore.getExtent();
160
    			if(bbox.getULX() != inputBbox.getULX() ||
161
    				bbox.getULY() != inputBbox.getULY() ||
162
    				bbox.getLRX() != inputBbox.getLRX() ||
163
    				bbox.getLRY() != inputBbox.getLRY()) {
164
    				taskStats.addParam(paramName, bbox);
165
    			}
166
    		}
167
    	}
168
    	return taskStats;
169
    }
170

  
171
	public void interrupted() {
172

  
173
	}
174

  
175
	public void end(Object param) {
176

  
177
	}
178

  
179
	public void updateProgress(int current, int total) {
180
		boolean cancelled = setProgress(current, total);
181

  
182
		if(!cancelled) {
183
			if(task != null)
184
				task.actionCanceled(null);
185
		}
186
	}
187

  
188
    /*
189
     * TODO: Customized panels
190
    @Override
191
    public Class<? extends GeoAlgorithmParametersPanel> getCustomParametersPanelClass() {
192
        return PrincipalComponentsParametersPanel.class;
193
    }*/
194
}
0 195

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.toolbox.algorithm/src/main/java/org/gvsig/raster/tools/RasterToolsSextanteLibrary.java
1
package org.gvsig.raster.tools;
2

  
3
import org.gvsig.geoprocess.algorithm.base.core.AlgorithmAbstractLibrary;
4
import org.gvsig.i18n.Messages;
5
import org.gvsig.tools.library.LibraryException;
6

  
7
/**
8
 * Initialization of <code>RasterToolsSextanteLibrary</code> library.
9
 */
10
public class RasterToolsSextanteLibrary extends AlgorithmAbstractLibrary {
11

  
12
    @Override
13
    protected void doInitialize() throws LibraryException {
14
        // Nothing to do
15
    }
16

  
17
    @Override
18
    protected void doPostInitialize() throws LibraryException {
19
        Messages.addResourceFamily(
20
            "org.gvsig.raster.tools.sextante.i18n.text", RasterToolsSextanteLibrary.class
21
                .getClassLoader(), RasterToolsSextanteLibrary.class.getClass().getName());
22
        
23
        registerGeoProcess(new LayerDatatypeSextanteAlgorithm());
24
    }
25

  
26
}
0 27

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.toolbox.algorithm/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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3

  
4
	<modelVersion>4.0.0</modelVersion>
5
	<artifactId>org.gvsig.raster.tools.toolbox.algorithm</artifactId>
6
	<packaging>jar</packaging>
7
	<name>org.gvsig.raster.tools.toolbox.algorithm</name>
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.raster.tools</artifactId>
11
		<version>2.2.34</version>
12
	</parent>
13
	<dependencies>
14
		<dependency>
15
		    <groupId>org.gvsig</groupId>
16
   			<artifactId>org.gvsig.raster.tools.algorithm.layerdatatype</artifactId>
17
            <scope>runtime</scope>
18
   		</dependency>
19
		<dependency>
20
		    <groupId>org.gvsig</groupId>
21
   			<artifactId>org.gvsig.raster.algorithm</artifactId>
22
            <scope>compile</scope>
23
   		</dependency>
24
		<dependency>
25
		    <groupId>org.gvsig</groupId>
26
   			<artifactId>org.gvsig.geoprocess.algorithm.base</artifactId>
27
            <scope>compile</scope>
28
   		</dependency>
29
		<dependency>
30
			<groupId>org.gvsig</groupId>
31
			<artifactId>org.gvsig.geoprocess.lib.sextante</artifactId>
32
			<scope>compile</scope>
33
		</dependency>
34
		<dependency>
35
			<groupId>org.gvsig</groupId>
36
			<artifactId>org.gvsig.tools.lib</artifactId>
37
			<scope>compile</scope>
38
		</dependency>
39
		<dependency>
40
			<groupId>org.gvsig</groupId>
41
			<artifactId>org.gvsig.ui</artifactId>
42
			<scope>compile</scope>
43
		</dependency>
44
	    <dependency>
45
			<groupId>org.gvsig</groupId>
46
			<artifactId>org.gvsig.i18n</artifactId>
47
			<scope>compile</scope>
48
		</dependency>
49
		<dependency>
50
            <groupId>org.gvsig</groupId>
51
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
52
            <scope>compile</scope>
53
        </dependency>
54
        <dependency>
55
            <groupId>org.gvsig</groupId>
56
            <artifactId>org.gvsig.fmap.mapcontext.impl</artifactId>
57
            <scope>runtime</scope>
58
        </dependency>
59
		<dependency>
60
            <groupId>org.gvsig</groupId>
61
            <artifactId>org.gvsig.projection.api</artifactId>
62
            <scope>compile</scope>
63
        </dependency>
64
        <dependency>
65
            <groupId>org.gvsig</groupId>
66
            <artifactId>org.gvsig.projection.cresques.impl</artifactId>
67
            <scope>runtime</scope>
68
        </dependency>
69
   		<dependency>
70
            <groupId>org.gvsig</groupId>
71
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
72
            <scope>compile</scope>
73
        </dependency>
74
	</dependencies>
75
</project>
0 76

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/buildNumber.properties
1
#Mon Jun 20 16:48:56 CEST 2016
2
buildNumber=85
0 3

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/src/test/java/org/gvsig/raster/app/extension/TestClipPanel.java
1
package org.gvsig.raster.app.extension;
2

  
3
import javax.swing.JFrame;
4

  
5
import org.gvsig.raster.tools.app.basic.tool.clip.ui.ClippingPanel;
6
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
7

  
8
public class TestClipPanel {
9
		private int                          w        = 510;
10
		private int                          h        = 300;
11
		private JFrame                       frame    = new JFrame();
12
		private ClippingPanel               desc     = null;
13

  
14
		public TestClipPanel() {
15
			new DefaultLibrariesInitializer().fullInitialize(true);
16
			desc = new ClippingPanel(null);
17
			frame.getContentPane().add(desc);
18
			frame.setSize(w, h);
19
			frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
20
			frame.setVisible(true);
21
		}
22

  
23
		public static void main(String[] args) {
24
			new TestClipPanel();
25
		}
26
	}
0 27

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/src/test/java/org/gvsig/raster/app/extension/TestNoDataPanel.java
1
package org.gvsig.raster.app.extension;
2

  
3
import javax.swing.JFrame;
4

  
5
import org.gvsig.raster.tools.app.basic.tool.properties.panel.NoDataPanel;
6

  
7
public class TestNoDataPanel {
8
		private int                          w        = 510;
9
		private int                          h        = 300;
10
		private JFrame                       frame    = new JFrame();
11
		private NoDataPanel               desc     = null;
12

  
13
		public TestNoDataPanel() {
14
			desc = new NoDataPanel();
15
			frame.getContentPane().add(desc);
16
			frame.setSize(w, h);
17
			frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
18
			frame.setVisible(true);
19
		}
20

  
21
		public static void main(String[] args) {
22
			new TestNoDataPanel();
23
		}
24
	}
0 25

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
0 9

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.raster">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
0 38

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25

  
26
  <dependencySets>
27
    <dependencySet>
28
      <useProjectArtifact>false</useProjectArtifact>
29
	  <useTransitiveDependencies>false</useTransitiveDependencies>
30
      <outputDirectory>lib</outputDirectory>
31
      <includes> 
32
				<include>org.gvsig:org.gvsig.raster.tools.app.basic:jar</include>
33
				<include>org.gvsig:org.gvsig.raster.tools.algorithm.layerdatatype:jar</include>
34
				<include>org.gvsig:org.gvsig.raster.tools.algorithm.saveraster:jar</include>
35
				<include>org.gvsig:org.gvsig.raster.tools.algorithm.swing.api:jar</include>
36
				<include>org.gvsig:org.gvsig.raster.tools.algorithm.swing.impl:jar</include>
37
				<include>org.gvsig:org.gvsig.raster.tools.toolbox.algorithm:jar</include>
38
	  </includes>
39
	</dependencySet>
40
  </dependencySets>
41
</assembly>
0 42

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/gui/preference/RasterPreferences.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.raster.tools.app.basic.raster.gui.preference;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27

  
28
import javax.swing.ImageIcon;
29
import javax.swing.JPanel;
30
import javax.swing.JScrollPane;
31
import javax.swing.border.EmptyBorder;
32

  
33
import org.gvsig.andami.IconThemeHelper;
34
import org.gvsig.andami.preferences.AbstractPreferencePage;
35
import org.gvsig.andami.preferences.StoreException;
36
import org.gvsig.raster.tools.app.basic.raster.gui.preference.panel.PreferenceCache;
37
import org.gvsig.raster.tools.app.basic.raster.gui.preference.panel.PreferenceGeneral;
38
import org.gvsig.raster.tools.app.basic.raster.gui.preference.panel.PreferenceLoadLayer;
39
import org.gvsig.raster.tools.app.basic.raster.gui.preference.panel.PreferenceNoData;
40
import org.gvsig.raster.tools.app.basic.raster.gui.preference.panel.PreferenceOverviews;
41
import org.gvsig.raster.tools.app.basic.raster.gui.preference.panel.PreferenceTemporal;
42

  
43
/**
44
 * RasterPreferences es un panel de preferencias situado a nivel de las
45
 * preferencias de gvSIG que engloba todas las opciones configurables de Raster
46
 *
47
 * @version 11/12/2007
48
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
49
 */
50
public class RasterPreferences extends AbstractPreferencePage {
51
	private static final long serialVersionUID = -1689657253810393874L;
52

  
53
	protected static String     id        = RasterPreferences.class.getName();
54
	private ImageIcon           icon;
55

  
56
	private PreferenceNoData    noData    = null;
57
	private PreferenceOverviews overviews = null;
58
	private PreferenceCache     cache     = null;
59
	private PreferenceTemporal  temporal  = null;
60
	private PreferenceGeneral   general   = null;
61
	private PreferenceLoadLayer loadLayer = null;
62

  
63
	/**
64
	 * Constructor de la clase RasterPreferences
65
	 */
66
	public RasterPreferences() {
67
		super();
68
		icon = IconThemeHelper.getImageIcon("pref-raster-icon");
69
		initialize();
70
	}
71

  
72
	/**
73
	 * Inicializacion del panel de preferencias.
74
	 */
75
	private void initialize() {
76
		setTitle("Frame");
77

  
78
		GridBagConstraints gridBagConstraints;
79

  
80
		JScrollPane scrollPane = new JScrollPane();
81

  
82
		scrollPane.getVerticalScrollBar().setUnitIncrement(20);
83

  
84
		JPanel panel = new JPanel();
85

  
86
		panel.setLayout(new GridBagLayout());
87

  
88
		gridBagConstraints = new GridBagConstraints();
89
		gridBagConstraints.gridx = 0;
90
		gridBagConstraints.gridy = 0;
91
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
92
		panel.add(getPreferenceGeneral(), gridBagConstraints);
93

  
94
		//gridBagConstraints = new GridBagConstraints();
95
		//gridBagConstraints.gridx = 0;
96
		gridBagConstraints.gridy = 1;
97
		//gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
98
		panel.add(getPreferenceLoadLayer(), gridBagConstraints);
99

  
100
		//gridBagConstraints = new GridBagConstraints();
101
		//gridBagConstraints.gridx = 0;
102
		//gridBagConstraints.gridy = 2;
103
		//gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
104
		//panel.add(getPreferenceNoData(), gridBagConstraints);
105

  
106
		//gridBagConstraints = new GridBagConstraints();
107
		//gridBagConstraints.gridx = 0;
108
		gridBagConstraints.gridy = 2;
109
		//gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
110
		panel.add(getPreferenceTemporal(), gridBagConstraints);
111

  
112
		//gridBagConstraints = new GridBagConstraints();
113
		//gridBagConstraints.gridx = 0;
114
		gridBagConstraints.gridy = 3;
115
		//gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
116
		panel.add(getPreferenceOverviews(), gridBagConstraints);
117

  
118
		//gridBagConstraints = new GridBagConstraints();
119
		//gridBagConstraints.gridx = 0;
120
		gridBagConstraints.gridy = 4;
121
		//gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
122
		panel.add(getPreferenceCache(), gridBagConstraints);
123

  
124
		//gridBagConstraints = new GridBagConstraints();
125
		//gridBagConstraints.gridx = 0;
126
		gridBagConstraints.gridy = 5;
127
		gridBagConstraints.weightx = 1.0;
128
		gridBagConstraints.weighty = 1.0;
129
		panel.add(new JPanel(), gridBagConstraints);
130

  
131
		panel.setBorder(new EmptyBorder(5, 5, 5, 5));
132

  
133
		scrollPane.setViewportView(panel);
134

  
135
		setLayout(new BorderLayout());
136
		add(scrollPane, BorderLayout.CENTER);
137
	}
138

  
139
	/**
140
	 * Devuelve el panel de configuracion para los valores NoData
141
	 * @return
142
	 */
143
	private PreferenceNoData getPreferenceNoData() {
144
		if (noData == null) {
145
			noData = new PreferenceNoData();
146
		}
147
		return noData;
148
	}
149
	
150
	/**
151
	 * Devuelve el panel de configuracion general de Raster. Aqui es donde se
152
	 * define si se visualiza automaticamente Raster, el numero de clases, si se
153
	 * pregunta la reproyeccion, etc...
154
	 * @return
155
	 */
156
	private PreferenceGeneral getPreferenceGeneral() {
157
		if (general == null) {
158
			general = new PreferenceGeneral();
159
		}
160
		return general;
161
	}
162

  
163
	/**
164
	 * Devuelve un panel de configuracion para las overviews de Raster.
165
	 * @return
166
	 */
167
	private PreferenceOverviews getPreferenceOverviews() {
168
		if (overviews == null) {
169
			overviews = new PreferenceOverviews();
170
		}
171
		return overviews;
172
	}
173

  
174
	/**
175
	 * Devuelve el panel de preferencias para las opciones de cache de Raster.
176
	 * Aqu? se podr?n definir todos los parametros configurables respecto a la
177
	 * cache.
178
	 * @return
179
	 */
180
	private PreferenceCache getPreferenceCache() {
181
		if (cache == null) {
182
			cache = new PreferenceCache();
183
		}
184
		return cache;
185
	}
186

  
187
	
188
	private PreferenceTemporal getPreferenceTemporal() {
189
		if (temporal == null) {
190
			temporal = new PreferenceTemporal();
191
		}
192
		return temporal;
193
	}
194

  
195
	private PreferenceLoadLayer getPreferenceLoadLayer() {
196
		if (loadLayer == null) {
197
			loadLayer = new PreferenceLoadLayer();
198
		}
199
		return loadLayer;
200
	}
201

  
202
	/*
203
	 * (non-Javadoc)
204
	 * @see com.iver.andami.preferences.IPreference#initializeValues()
205
	 */
206
	public void initializeValues() {
207
		getPreferenceNoData().initializeValues();
208
		getPreferenceOverviews().initializeValues();
209
		getPreferenceCache().initializeValues();
210
		getPreferenceTemporal().initializeValues();
211
		getPreferenceGeneral().initializeValues();
212
		getPreferenceLoadLayer().initializeValues();
213
	}
214

  
215
	/*
216
	 * (non-Javadoc)
217
	 * @see com.iver.andami.preferences.AbstractPreferencePage#storeValues()
218
	 */
219
	public void storeValues() throws StoreException {
220
		getPreferenceNoData().storeValues();
221
		getPreferenceOverviews().storeValues();
222
		getPreferenceCache().storeValues();
223
		getPreferenceTemporal().storeValues();
224
		getPreferenceGeneral().storeValues();
225
		getPreferenceLoadLayer().storeValues();
226
	}
227

  
228
	/*
229
	 * (non-Javadoc)
230
	 * @see com.iver.andami.preferences.IPreference#initializeDefaults()
231
	 */
232
	public void initializeDefaults() {
233
		getPreferenceNoData().initializeDefaults();
234
		getPreferenceOverviews().initializeDefaults();
235
		getPreferenceCache().initializeDefaults();
236
		getPreferenceTemporal().initializeDefaults();
237
		getPreferenceGeneral().initializeDefaults();
238
		getPreferenceLoadLayer().initializeDefaults();
239
	}
240

  
241
	/*
242
	 * (non-Javadoc)
243
	 * @see com.iver.andami.preferences.AbstractPreferencePage#isResizeable()
244
	 */
245
	public boolean isResizeable() {
246
		return true;
247
	}
248

  
249
	/*
250
	 * (non-Javadoc)
251
	 * @see com.iver.andami.preferences.IPreference#getID()
252
	 */
253
	public String getID() {
254
		return id;
255
	}
256

  
257
	/*
258
	 * (non-Javadoc)
259
	 * @see com.iver.andami.preferences.IPreference#getIcon()
260
	 */
261
	public ImageIcon getIcon() {
262
		return icon;
263
	}
264

  
265
	/*
266
	 * (non-Javadoc)
267
	 * @see com.iver.andami.preferences.IPreference#getPanel()
268
	 */
269
	public JPanel getPanel() {
270
		return this;
271
	}
272

  
273
	/*
274
	 * (non-Javadoc)
275
	 * @see com.iver.andami.preferences.IPreference#getTitle()
276
	 */
277
	public String getTitle() {
278
		return "Raster";
279
	}
280

  
281
	/*
282
	 * (non-Javadoc)
283
	 * @see com.iver.andami.preferences.IPreference#isValueChanged()
284
	 */
285
	public boolean isValueChanged() {
286
		return true;
287
	}
288

  
289
	public void setChangesApplied() {}
290
}
0 291

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/gui/preference/combocolortable/PreferenceColorTableIconPainter.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.raster.tools.app.basic.raster.gui.preference.combocolortable;
23

  
24
import java.awt.Color;
25
import java.awt.Graphics2D;
26
import java.awt.Rectangle;
27
import java.util.ArrayList;
28
import java.util.List;
29

  
30
import org.gvsig.fmap.dal.coverage.datastruct.ColorItem;
31
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
32
import org.gvsig.gui.beans.listview.IIconPaint;
33
/**
34
 * Clase para dibujar los iconos del ListViewComponent del panel de color. Se
35
 * puede indicar si la paleta esta seleccionada y si se dibuja con
36
 * interpolaciones.
37
 *
38
 * @version 29/06/2007
39
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
40
 */
41
public class PreferenceColorTableIconPainter implements IIconPaint {
42
	private ColorTable colorTable;
43

  
44
	/**
45
	 * Construye un ColorTablePaint con una tabla de color pasada por parametro
46
	 * @param colorTable
47
	 */
48
	public PreferenceColorTableIconPainter(ColorTable colorTable) {
49
		this.colorTable = colorTable;
50
	}
51

  
52
	/**
53
	 * Define si los valores estan interpolados o no entre si
54
	 * @param value
55
	 */
56
	public void setInterpolated(boolean value) {
57
		colorTable.setInterpolated(value);
58
	}
59

  
60
	/**
61
	 * Obtiene el array de los colores de la paleta de color
62
	 * @return
63
	 */
64
	public List<ColorItem> getColorItems() {
65
		return colorTable.getColorItems();
66
	}
67

  
68
	/**
69
	 * Obtiene el ColorTable
70
	 * @return
71
	 */
72
	public ColorTable getColorTable() {
73
		return colorTable;
74
	}
75

  
76
	/**
77
	 * Especificar los colores de la tabla de color, definiendo si estan los
78
	 * valores interpolados y si la paleta se comprimira o no.
79
	 * @param value
80
	 * @param interpolated
81
	 * @param compress
82
	 */
83
	public void setColorItems(ArrayList<ColorItem> value, boolean interpolated, boolean compress) {
84
		colorTable.createPaletteFromColorItems(value, compress);
85
		setInterpolated(interpolated);
86
	}
87

  
88
	/**
89
	 * Metodo de pintado de la tabla de color
90
	 * @param g
91
	 * @param isSelected
92
	 */
93
	public void paint(Graphics2D g, boolean isSelected) {
94
		Rectangle area = g.getClipBounds();
95

  
96
		int x1 = area.x;
97
		int x2 = area.x + area.width - 1;
98

  
99
		Color bgColor = new Color(224, 224, 224);
100
		for (int i = 0; (i * 4) <= area.width; i++) {
101
			for (int j = 0; (j * 4) <= area.height; j++) {
102
				if ((i + j) % 2 == 0)
103
					g.setColor(Color.white);
104
				else
105
					g.setColor(bgColor);
106
				g.fillRect(area.x + 1 + i * 4, area.y + 1 + j * 4, 4, 4);
107
			}
108
		}
109

  
110
		if (colorTable.getColorItems().size() >= 1) {
111
			double min = ((ColorItem) colorTable.getColorItems().get(0)).getValue();
112
			double max = ((ColorItem) colorTable.getColorItems().get(colorTable.getColorItems().size() - 1)).getValue();
113
			for (int i = area.x; i < (area.x + area.width); i++) {
114
				double pos = min + (((max - min) * (i - area.x)) / (area.width - 2));
115

  
116
				byte[] col3 = colorTable.getRGBAByBand(pos);
117
				g.setColor(new Color(col3[0] & 0xff, col3[1] & 0xff, col3[2] & 0xff, col3[3] & 0xff));
118
				g.drawLine(i, area.y, i, area.y + area.height - 2);
119
			}
120
		} else {
121
			g.setColor(new Color(224, 224, 224));
122
			g.fillRect(x1, area.y, x2 - x1, area.height - 1);
123
		}
124
		if (isSelected)
125
			g.setColor(Color.black);
126
		else
127
			g.setColor(new Color(96, 96, 96));
128
		g.drawRect(x1, area.y, x2 - x1, area.height - 1);
129
	}
130
}
0 131

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.34/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/raster/gui/preference/combocolortable/PaintItem.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.raster.tools.app.basic.raster.gui.preference.combocolortable;
23

  
24
import java.awt.Color;
25
import java.awt.Component;
26
import java.awt.Dimension;
27
import java.awt.FontMetrics;
28
import java.awt.GradientPaint;
29
import java.awt.Graphics;
30
import java.awt.Graphics2D;
31
import java.awt.Rectangle;
32
/**
33
 * Clase que se encarga de dibujar los elementos de una tabla de color dentro
34
 * de un JComboBox.
35
 *
36
 * @version 17/04/2007
37
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
38
 */
39
public class PaintItem extends Component {
40
	private static final long serialVersionUID = -6448740563809113949L;
41
	private boolean isSelected = false;
42
	private String name = "";
43
	private PreferenceColorTableIconPainter colorTablePaint = null;
44

  
45
	public PaintItem(String name, PreferenceColorTableIconPainter colorTablePaint, boolean isSelected) {
46
		this.name = name;
47
		this.colorTablePaint = colorTablePaint;
48
		this.isSelected = isSelected;
49

  
50
		setSize(getWidth(), 19);
51
		setPreferredSize(new Dimension(getWidth(), 19));
52
	}
53

  
54
	/*
55
	 * (non-Javadoc)
56
	 * @see java.awt.Component#paint(java.awt.Graphics)
57
	 */
58
	public void paint(Graphics g) {
59
		Graphics2D g2 = (Graphics2D) g;
60
		if (isSelected) {
61
			Color color1 = new Color(89, 153, 229);
62
			Color color2 = new Color(31, 92, 207);
63
			g2.setPaint(new GradientPaint(0, 1, color1, 0, getHeight() - 1, color2, false));
64
			g2.fillRect(0, 1, getWidth(), getHeight() - 1);
65
			g2.setColor(new Color(61, 123, 218));
66
			g2.drawLine(0, 0, getWidth(), 0);
67
			g2.setColor(Color.white);
68
		} else {
69
			g2.setColor(Color.white);
70
			g2.fillRect(0, 0, getWidth(), getHeight());
71
			g2.setColor(Color.black);
72
		}
73

  
74
		Rectangle bounds = getBounds();
75

  
76
		FontMetrics fm = g2.getFontMetrics();
77
		int upper = (bounds.height + fm.getHeight()) / 2 - fm.getDescent();
78

  
79
		g2.setClip(bounds.x, 0, bounds.width, bounds.height);
80
		g2.drawString(name, bounds.width - 146, upper);
81

  
82
		g2.setClip(bounds.x, 0, bounds.width - 150, bounds.height);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff