Revision 2441

View differences:

org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/infobypoint/MainInfoByPointPanel.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.swing.infobypoint;
23

  
24
import java.awt.event.ActionListener;
25
import java.util.Observer;
26

  
27
import org.gvsig.raster.swing.pixelinspector.PixelInspector;
28

  
29

  
30
/**
31
 * Main panel for the information by point
32
 * @author Nacho Brodin (nachobrodin@gmail.com)
33
 *
34
 */
35
public interface MainInfoByPointPanel extends Observer {
36
	/**
37
	 * Gets the data model
38
	 * @return
39
	 */
40
	public InfoByPointDataModel getInfoByPointDataModel();
41
	
42
	/**
43
	 * Gets the pixel inspector panel
44
	 * @return
45
	 */
46
	public PixelInspector getPixelInspectorPanel();
47
	
48
	/**
49
	 * Adds a listener to the extended button
50
	 * @param listener
51
	 */
52
	public void addListenerExtendedButton(ActionListener listener);
53
}
0 54

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/infobypoint/InfoByPointDataModel.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.swing.infobypoint;
23

  
24
import java.util.List;
25

  
26
/**
27
 * Data model for the information by point
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 *
30
 */
31
public interface InfoByPointDataModel {
32
	public void setBandValues(double[] list);
33
	
34
	public void setNumberOfBands(int n);
35
	
36
	public void setLayerList(List<String> list);
37
	
38
	public void setARGB(int r, int g, int b);
39
	
40
	public void setCMYK(double[] cmyk);
41
	
42
	public void setHSL(double h, double s, double l);
43
	
44
	public void setPixelPoint(double x, double y);
45
	
46
	public void setWorldPoint(double x, double y);
47
	
48
	public void setViewPoint(double x, double y);
49
	
50
	public String getFormatedLayerName(int i);
51
	
52
	public void notifyObservers();
53
}
0 54

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/buttonbar/ButtonBar.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.swing.buttonbar;
23

  
24
import javax.swing.JButton;
25

  
26

  
27
/**
28
 * Bar of buttons of 16x16 pixels
29
 * @author Nacho Brodin (nachobrodin@gmail.com)
30
 */
31
public interface ButtonBar {
32
	/**
33
	 * A?ade un boton al ArrayList de los botones.
34
	 *
35
	 * @param iconName: nombre del icono asignado al boton. La imagen tendr?a que
36
	 * 					estar dentro de la carpeta "images/"
37
	 * @param tip: tip del boton;
38
	 * @param order: orden que ocupar? el boton dentro del control
39
	 */
40
	public void addButton(String iconName, String tip, int order);
41

  
42
	/**
43
	 * Elimina el bot?n correspondiente al indice que le pasamos.
44
	 * @param index
45
	 */
46
	public void delButton(int index);
47

  
48
	/**
49
	 * A?ade en el panel los botones que tenemos en el ArrayList.
50
	 *
51
	 */
52
	public void addList();
53

  
54

  
55
	/**
56
	 * Esta funci?n deshabilita todos los controles y guarda sus valores
57
	 * de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
58
	 * se vuelvan a quedar como estaba
59
	 */
60
	public void disableAllControls();
61

  
62
	/**
63
	 * Esta funci?n deja los controles como estaban al ejecutar la funci?n
64
	 * disableAllControls
65
	 */
66
	public void restoreControlsValue();
67

  
68
	/**
69
	 * M?todo para acceder a los botones del control;
70
	 * @param index
71
	 * @return
72
	 */
73
	public JButton getButton(int index);
74

  
75
	/**
76
	 * M?todo para establecer la posici?n de los botones dentro del control.
77
	 * @param align: "left" o "right"
78
	 */
79
	public void setButtonAlignment(String align);
80

  
81
	public void setComponentBorder(boolean br);
82
}
0 83

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/openfile/OpenFileContainer.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.swing.openfile;
23

  
24
import java.io.File;
25

  
26
/**
27
 * Panel to choose a file from disk
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public interface OpenFileContainer {
31
	/**
32
	 * Gets the selected file
33
	 * @return
34
	 */
35
	public File getFile();
36
	
37
	/**
38
	 * Sets a path in the field of text
39
	 * @param path
40
	 */
41
	public void setPath(String path);
42
	
43
	public void setEnabled(boolean enabled);
44
}
0 45

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/openfile/FileFilter.java
1
package org.gvsig.raster.swing.openfile;
2

  
3

  
4
public abstract class FileFilter extends javax.swing.filechooser.FileFilter {
5

  
6
	/**
7
	 * <p>Gets the default file extension, which will be
8
	 * added to the selected file if its extension is not
9
	 * valid.</p>
10
	 * 
11
	 * @return
12
	 */
13
	public abstract String getDefaultExtension();
14
}
0 15

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/RasterWindowManager.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.swing;
23

  
24
import javax.swing.JPanel;
25

  
26
/**
27
 * Responsible of the window management to show the panels of the
28
 * Validation swing library.
29
 * 
30
 * @see RasterSwingManager
31
 * @see JValidationServicePanel
32
 * @author gvSIG Team
33
 * @version $Id$
34
 */
35
public interface RasterWindowManager {
36

  
37
    public static final int MODE_DIALOG = 1;
38
    public static final int MODE_WINDOW = 2;
39
    public static final int MODE_TOOL = 3;
40

  
41
    /**
42
     * Inserts a Panel in a window with a characteristic properties.
43
     * 
44
     * @param panel
45
     *            JPanel with the content of the window
46
     * @param title
47
     *            String with the title of the window
48
     * @param mode
49
     *            int that defines the type of window
50
     */
51
    public void showWindow(JPanel panel, String title, int mode);
52
}
0 53

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/pixelinspector/PixelInspector.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.swing.pixelinspector;
23

  
24
import java.awt.image.BufferedImage;
25

  
26
/**
27
 * @author Nacho Brodin (nachobrodin@gmail.com)
28
 */
29
public interface PixelInspector {
30

  
31
	public void setClear(boolean clear);
32
	
33
	/**
34
	 * Gets the with of the control
35
	 * @return
36
	 */
37
	public int getWidth();
38
	
39
	/**
40
	 * Gets the height of the control
41
	 * @return
42
	 */
43
	public int getHeight();
44
	
45
	/**
46
	 * Gets the scale factor
47
	 * @return
48
	 */
49
	public int getScale();
50
	
51
	/**
52
	 * Assigns view coordinates 
53
	 * @param pixX
54
	 * @param pixY
55
	 */
56
	public void setViewCoordinates(int pixX, int pixY);
57
	
58
	public void setDataBuffer(BufferedImage view);
59
	
60
	public BufferedImage getDataBuffer();
61
	
62
	/**
63
	 * Sets the X position of the control where the painted starts
64
	 * 
65
	 * @param posX 
66
	 */
67
	public void setPosX(int posX);
68

  
69
	/**
70
	 * Sets the Y position of the control where the painted starts
71
	 * 
72
	 * @param posY 
73
	 */
74
	public void setPosY(int posY);
75
	
76
	/**
77
	 * Repaints the control
78
	 */
79
	public void repaint();
80
}
0 81

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/BasePanel.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.swing;
23

  
24
import java.awt.Component;
25
import java.awt.event.ActionListener;
26
import java.awt.event.KeyListener;
27
import java.awt.event.MouseListener;
28
import java.util.ArrayList;
29

  
30
import javax.swing.AbstractButton;
31
import javax.swing.JPanel;
32

  
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

  
36
/**
37
 * Clase base para los paneles gr?ficos. 
38
 * 
39
 * 17/07/2008
40
 * @author Nacho Brodin nachobrodin@gmail.com
41
 */
42
public abstract class BasePanel extends JPanel {
43
	private static final long    serialVersionUID         = -8877600252349334979L;
44
	private boolean	             enableValueChangedEvent  = true;
45
	
46
	public static final int      KEYLISTENER              = 0;
47
	public static final int      ACTIONLISTENER           = 1;
48
	public static final int      MOUSELISTENER            = 2;
49
	private static final Logger  logger                   = LoggerFactory.getLogger(BasePanel.class);
50
	
51
	/**
52
	 * Obtiene la traducci?n de la cadena de texto
53
	 * @param parent Ventana padre
54
	 * @param text Cadena a traducir
55
	 * @return Cadena de texto traducida
56
	 */
57
	public String getText(Object parent, String key) {
58
		 if (key == null)
59
	            return null;
60
	        String translation = org.gvsig.i18n.Messages.getText(key, false);
61
	        if (translation != null)
62
	            return translation;
63
	        else {
64
	            logger.debug("Can't find translation for ''{1}''.", key);
65
	            return key;
66
	        }
67
	}
68
	
69
	/**
70
	 * Obtiene la traducci?n de la cadena de texto
71
	 * @param text Cadena a traducir
72
	 * @return Cadena de texto traducida
73
	 */
74
	public String getText(String text) {
75
		return getText(this, text);
76
	}
77
	
78
	/**
79
	 * Asigna el valor para la activaci?n y desactivaci?n del evento de cambio de valor en
80
	 * las cajas de texto.
81
	 * @param enableValueChangedEvent
82
	 */
83
	public void setEnableValueChangedEvent(boolean enableValueChangedEvent) {
84
		this.enableValueChangedEvent = enableValueChangedEvent;
85
	}
86
	
87
	/**
88
	 * Obtiene el valor para la activaci?n y desactivaci?n del evento de cambio de valor en
89
	 * las cajas de texto.
90
	 * @param enableValueChangedEvent
91
	 */
92
	public boolean isEnableValueChangedEvent() {
93
		return this.enableValueChangedEvent;
94
	}
95
	
96
	/**
97
	 * Obtiene la lista de componentes del panel. Si dentro tiene alg?n BasePanel
98
	 * consulta la lista de componentes de este y la devuelve.
99
	 * @return
100
	 */
101
	@SuppressWarnings("unchecked")
102
	public ArrayList getComponentList() {
103
		ArrayList listComp = new ArrayList();
104
		for (int i = 0; i < this.getComponentCount(); i++) {
105
			if(getComponent(i) instanceof BasePanel) {
106
				ArrayList list = ((BasePanel)getComponent(i)).getComponentList();
107
				for (int j = 0; j < list.size(); j++) 
108
					listComp.add(list.get(j));
109
			} else
110
				listComp.add(getComponent(i));
111
		}
112
		return listComp;
113
	}
114
	
115
	/**
116
	 * Registra un listener en todos los componentes contenidos en este panel.
117
	 * @param type Tipo de listener definido por las variables est?ticas en esta clase
118
	 * @param listener Objeto listener del tipo correcto
119
	 */
120
	@SuppressWarnings("unchecked")
121
	public void registerListener(int type, Object listener) {
122
		ArrayList listComp = getComponentList();
123
		if(type == KEYLISTENER) {
124
			if(listener instanceof KeyListener) {
125
				for (int i = 0; i < listComp.size(); i++)
126
					if(listComp.get(i) instanceof Component)
127
						((Component)listComp.get(i)).addKeyListener((KeyListener)listener);
128
			}
129
		}
130
		if(type == ACTIONLISTENER) {
131
			if(listener instanceof ActionListener) {
132
				for (int i = 0; i < listComp.size(); i++)
133
					if(listComp.get(i) instanceof AbstractButton)
134
						((AbstractButton)listComp.get(i)).addActionListener((ActionListener)listener);
135
			}
136
		}
137
		if(type == MOUSELISTENER) {
138
			if(listener instanceof MouseListener) {
139
				for (int i = 0; i < listComp.size(); i++)
140
					if(listComp.get(i) instanceof Component)
141
						((Component)listComp.get(i)).addMouseListener((MouseListener)listener);
142
			}
143
		}
144
	}
145
	
146
	/**
147
	 * Traducci?n centralizada de los componentes de una panel
148
	 */
149
	protected abstract void translate();
150
	
151
	/**
152
	 * Acciones de inicializaci?n
153
	 */
154
	protected abstract void init();
155
}
0 156

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/RasterSwingLocator.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.swing;
23

  
24
import org.gvsig.tools.locator.BaseLocator;
25

  
26
/**
27
 * This locator is the entry point for the Validation swing library,
28
 * providing access to all Validation swing services through the
29
 * {@link RasterSwingManager} .
30
 * 
31
 * @author gvSIG team
32
 * @version $Id$
33
 */
34
public class RasterSwingLocator extends BaseLocator {
35

  
36
    /**
37
     * Validation swing manager name.
38
     */
39
    public static final String SWING_MANAGER_NAME =
40
        "Raster.swing.manager";
41

  
42
    /**
43
     * Validation swing manager description.
44
     */
45
    public static final String SWING_MANAGER_DESCRIPTION =
46
        "Raster UIManager";
47

  
48
    private static final String LOCATOR_NAME = "Raster.swing.locator";
49

  
50
    /**
51
     * Unique instance.
52
     */
53
    private static final RasterSwingLocator INSTANCE =
54
        new RasterSwingLocator();
55

  
56
    /**
57
     * Return the singleton instance.
58
     * 
59
     * @return the singleton instance
60
     */
61
    public static RasterSwingLocator 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 RasterSwingManager> 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 RasterSwingManager getSwingManager() {
92
        return (RasterSwingManager) getInstance()
93
            .get(SWING_MANAGER_NAME);
94
    }
95

  
96
}
0 97

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/RasterSwingLibrary.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.swing;
23

  
24
import java.awt.Component;
25
import java.util.List;
26

  
27
import javax.swing.JOptionPane;
28

  
29
import org.gvsig.i18n.Messages;
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.LibraryException;
32
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
33
import org.slf4j.LoggerFactory;
34

  
35
/**
36
 * Library for Swing API initialization and configuration.
37
 * 
38
 * @author gvSIG team
39
 * @version $Id$
40
 */
41
public class RasterSwingLibrary extends AbstractLibrary {
42

  
43
    @Override
44
    protected void doInitialize() throws LibraryException {
45
        // Do nothing
46
    }
47

  
48
    @Override
49
    protected void doPostInitialize() throws LibraryException {
50
        // Validate there is any implementation registered.
51
        RasterSwingManager manager =
52
            RasterSwingLocator.getSwingManager();
53
        if (manager == null) {
54
            throw new ReferenceNotRegisteredException(
55
                RasterSwingLocator.SWING_MANAGER_NAME,
56
                RasterSwingLocator.getInstance());
57
        }
58
    }
59
    
60
    public static boolean messageBoxYesOrNot(String msg, Object parentWindow){
61
		String string1 = Messages.getText("yes");
62
		String string2 = Messages.getText("no");
63
		Object[] options = {string1, string2};
64
		Component parent = null;
65
		if(parentWindow instanceof Component)
66
			parent = (Component)parentWindow;
67
		int n = JOptionPane.showOptionDialog(parent,
68
					"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>",
69
					Messages.getText("confirmacion"),
70
					JOptionPane.YES_NO_OPTION,
71
					JOptionPane.QUESTION_MESSAGE,
72
					null,
73
					options,
74
					string1);
75
		if (n == JOptionPane.YES_OPTION)
76
			return true;
77
		else
78
			return false;
79
	}
80

  
81
	public static void messageBoxError(String msg, Object parentWindow) {
82
		String string = Messages.getText("accept");
83
		Object[] options = {string};
84
		Component parent = null;
85
		if(parentWindow instanceof Component)
86
			parent = (Component)parentWindow;
87
		JOptionPane.showOptionDialog(parent,
88
					"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>",
89
					Messages.getText("confirmacion"),
90
					JOptionPane.OK_OPTION,
91
					JOptionPane.ERROR_MESSAGE,
92
					null,
93
					options,
94
					string);
95
	}
96

  
97
	public static void messageBoxInfo(String msg, Object parentWindow) {
98
		String string = Messages.getText("accept");
99
		Object[] options = {string};
100
		Component parent = null;
101
		if(parentWindow instanceof Component)
102
			parent = (Component)parentWindow;
103
		JOptionPane.showOptionDialog(parent,
104
					"<html>" + Messages.getText(msg).replaceAll("\n", "<br>") + "</html>",
105
					Messages.getText("confirmacion"),
106
					JOptionPane.OK_OPTION,
107
					JOptionPane.INFORMATION_MESSAGE,
108
					null,
109
					options,
110
					string);
111
	}
112

  
113
	public static void debug(String msg, Object parent, Exception exception) {
114
		if(parent != null)
115
		    LoggerFactory
116
            .getLogger(parent.getClass()).debug(Messages.getText(msg), exception);
117
	}
118

  
119
	public static void messageBoxError(String msg, Object parentWindow, Exception exception) {
120
		debug(msg, parentWindow, exception);
121
		messageBoxError(msg, parentWindow);
122
	}
123
	
124
	public static void messageBoxError(String msg, Object parentWindow, List<Exception> exception) {
125
		for (int i = 0; i < exception.size(); i++) 
126
			debug(msg, parentWindow, exception.get(i));
127
		messageBoxError(msg, parentWindow);
128
	}
129

  
130
	public static void messageBoxInfo(String msg, Object parentWindow, Exception exception) {
131
		debug(msg, parentWindow, exception);
132
		messageBoxInfo(msg, parentWindow);
133
	}
134

  
135
	public static boolean messageBoxYesOrNot(String msg, Object parentWindow, Exception exception) {
136
		debug(msg, parentWindow, exception);
137
		return messageBoxYesOrNot(msg, parentWindow);
138
	}
139

  
140
}
0 141

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/preview/PreviewRenderProcess.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.swing.preview;
23

  
24
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException;
25

  
26
/**
27
 * Interfaz para el procesado del rendering antes de dibujar la preview.
28
 * El cliente puede obtener la lista de filtros del rendering de la imagen 
29
 * que va a dibujarse como preview y modificarla para visulizar la preview 
30
 * modificada. En caso de no modificar la preview se ver? la imagen sin variaciones
31
 * con respecto a la original.
32
 * 
33
 * 19/02/2008
34
 * @author Nacho Brodin nachobrodin@gmail.com
35
 */
36
public interface PreviewRenderProcess {
37
	
38
	/**
39
	 * Procesado del rendering
40
	 * @param rendering
41
	 * @throws ImageUnavailable Cuando se ha producido un error y hay que mostrar un mensaje en la 
42
	 * previsualizaci?n porque no se puede mostrar la imagen
43
	 */
44
	public void process(DataSourcePreview lyr) throws ImageUnavailableException;
45
	
46
	/**
47
	 * Obtiene el flag que informa de si se est? mostrando la previsualizaci?n o no.
48
	 * En caso de no mostrarse deber?a lanzarse una excepci?n ImageUnavailableExcepcion al
49
	 * hacer un process.
50
	 * @return
51
	 */
52
	public boolean isShowPreview();
53
	
54
	/**
55
	 * Asigna el flag para mostrar u ocultar la preview. En caso de no mostrarse deber?a lanzarse una 
56
	 * excepci?n ImageUnavailableExcepcion cuando se hace un process.
57
	 * @param showPreview
58
	 */
59
	public void setShowPreview(boolean showPreview);
60
}
0 61

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/preview/PreviewPanel.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.swing.preview;
23

  
24
import java.awt.Dimension;
25

  
26
import javax.swing.JTabbedPane;
27

  
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
29
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
30
import org.gvsig.gui.beans.imagenavigator.ImageNavigator;
31

  
32
/**
33
 * Base interface for panels with preview
34
 * 
35
 * @author Nacho Brodin nachobrodin@gmail.com
36
 */
37
public interface PreviewPanel {
38
	
39
	/**
40
	 * Gets the data source of the preview
41
	 * @return
42
	 */
43
	public DataSourcePreview getDataSourcePreview();
44
	
45
	/**
46
	 * Obtiene el componente con los tabs donde se a?aden las pesta?as del usuario.
47
	 * @return JTabbedPane
48
	 */
49
	public JTabbedPane getTabbedPane();
50
	
51
	/**
52
	 * Obtener el objeto <code>ButtonsPanel</code> del <code>DialogPanel</code>.
53
	 * En caso de no estar creado, lo crear?.
54
	 *
55
	 * @return El componente bp
56
	 */
57
	public ButtonsPanel getButtonsPanel();
58
	
59
	/**
60
	 * Devuelve el componente para la vista previa
61
	 * @return
62
	 */
63
	public ImageNavigator getImageNavigator();
64
	
65
	/**
66
	 * Preview refresh
67
	 */
68
	public void refreshPreview();
69
	
70
	public void addButtonPressedListener(ButtonsPanelListener listener);
71
	
72
	/**
73
	 * Sets the size of the preview
74
	 * @param dimension
75
	 */
76
	public void setPreviewSize(Dimension dimension);
77
	
78
	/**
79
	 * Sets the data source for the preview. 
80
	 * 
81
	 * @param layer
82
	 */
83
	public void setLayer(DataSourcePreview fLayer);
84
	
85
	/**
86
	 * Initializes the preview size and coordinates. This function should
87
	 * be called after the window has been opened because this call
88
	 * assigns the size of the preview panel.
89
	 * 
90
	 * @param layer
91
	 */
92
	public void previewInitializeSizes();
93
	
94
	/**
95
	 * Cierra la capa abierta para previsualizaci?n
96
	 */
97
	public void closePreviewLayer();
98
}
0 99

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/preview/PreviewBasePanelTab.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.swing.preview;
23

  
24
import javax.swing.JPanel;
25

  
26

  
27
/**
28
 * Interfaz que implementan los paneles que se incorporan al PreviewBasePanel
29
 * 
30
 * 19/02/2008
31
 * @author Nacho Brodin nachobrodin@gmail.com
32
 */
33
public interface PreviewBasePanelTab {
34
	/**
35
	 * Obtiene el t?tulo del panel. Esta ser? la etiqueta que se ponga en 
36
	 * la pesta?a del tab.
37
	 * @return Cadena con el t?tulo.
38
	 */
39
	public String getTitle();
40
	
41
	/**
42
	 * Obtiene el panel que se a?ade en el tab
43
	 * @return JPanel
44
	 */
45
	public JPanel getPanel();
46
}
0 47

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/preview/DataSourcePreview.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.swing.preview;
23

  
24
import java.awt.Graphics2D;
25
import java.awt.geom.Rectangle2D;
26
import java.awt.image.BufferedImage;
27

  
28
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException;
29
import org.gvsig.tools.task.Cancellable;
30

  
31
/**
32
 * Data source for the raster preview
33
 * @author Nacho Brodin nachobrodin@gmail.com
34
 */
35
@SuppressWarnings("deprecation")
36
public interface DataSourcePreview {
37

  
38
	public void draw(BufferedImage image, Graphics2D g, double[] coords, int w, int h, Cancellable cancel, double scale) throws ImageUnavailableException;
39
	
40
	public Rectangle2D getBBoxRectangle();
41
	
42
	public double getCellSize();
43
	
44
	public void closePreviewLayer();
45
	
46
	public void pushStatus();
47
	
48
	public void popStatus();
49
	
50
	public DataSourcePreview cloneDataSourcePreview();
51
	
52
	public Object getSource();
53
}
0 54

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/slider/SliderEvent.java
1
package org.gvsig.raster.swing.slider;
2

  
3
import java.util.EventObject;
4

  
5
public class SliderEvent extends EventObject {
6
	private static final long serialVersionUID = -128111523373280522L;
7

  
8
	/**
9
	 * Construye un SliderEvent
10
	 * @param source
11
	 */
12
	public SliderEvent(Object source) {
13
		super(source);
14
	}
15
}
0 16

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/slider/SliderText.java
1
package org.gvsig.raster.swing.slider;
2

  
3
import javax.swing.JComponent;
4

  
5
import org.gvsig.gui.beans.slidertext.listeners.SliderListener;
6

  
7
public interface SliderText {
8
	
9
	/**
10
	 * Adds a listener to receive changes in this component
11
	 * @param listener
12
	 */
13
	public void addValueChangedListener(SliderListener listener);
14
	
15
	/**
16
	 * Obtiene el valor del control.
17
	 * @return Valor del control en formato double.
18
	 */
19
	public double getValue();
20

  
21
	/**
22
	 * Asigna el valor del control.
23
	 * @return Valor del control en formato double.
24
	 */
25
	public void setValue(double value);
26

  
27
	/**
28
	 * Activa o desactiva el control del panel
29
	 * @param active
30
	 */
31
	public void setControlEnabled(boolean active);
32

  
33
	/**
34
	 * Asigna el flag que dice si el valor del campo de texto ser?
35
	 * decimal o entero
36
	 * @param dec true si se admiten valores decimales y false si no se admiten
37
	 */
38
	public void setDecimal (boolean dec);
39

  
40
	/**
41
	 * Obtiene el flag que dice si el valor del campo de texto es
42
	 * decimal o entero
43
	 * @return true si se admiten valores decimales y false si no se admiten
44
	 */
45
	public boolean getDecimal ();
46

  
47
	/**
48
	 * Obtiene el valor m?ximo del slider
49
	 * @return Entero con el valor m?ximo
50
	 */
51
	public int getMax();
52

  
53
	/**
54
	 * Asigna el valor m?ximo del slider
55
	 * @param Entero con el valor m?ximo
56
	 */
57
	public void setMaximum(int max);
58

  
59
	/**
60
	 * Obtiene el valor m?nimo del slider
61
	 * @return Entero con el valor m?nimo
62
	 */
63
	public int getMin();
64

  
65
	/**
66
	 * Asigna el valor m?nimo del slider
67
	 * @param Entero con el valor m?nimo
68
	 */
69
	public void setMinimum(int min);
70

  
71
	/**
72
	 * Definir un intervalo para el slider
73
	 * @param value
74
	 */
75
	public void setInterval(double value);
76

  
77
	/**
78
	 * Obtener el intervalo definido para el slider
79
	 * @return
80
	 */
81
	public double getInterval();
82
	
83
	/**
84
	 * Asigna un borde al componente con el texto pasado como
85
	 * par?metro
86
	 * @param name
87
	 */
88
	public void setBorder(String name);
89
	
90
	public JComponent getComponent();
91
}
0 92

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/slider/SliderListener.java
1
package org.gvsig.raster.swing.slider;
2

  
3
import java.util.EventListener;
4

  
5
public interface SliderListener extends EventListener {
6
	/**
7
	 * Evento que se dispara cuando cambia el valor del componente. Nunca
8
	 * se dispara mientras se hace un dragged con el rat?n.
9
	 * @param e
10
	 */
11
	public void actionValueChanged(SliderEvent e);
12

  
13
	/**
14
	 * Evento que se dispara cuando cambia el valor del componente mientras se
15
	 * hace un dragged con el rat?n.
16
	 * @param e
17
	 */
18
	public void actionValueDragged(SliderEvent e);
19
}
0 20

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/gcanvas/IGCanvasListener.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.swing.gcanvas;
23

  
24
import java.util.EventListener;
25
/**
26
 * Listener que deben implementar las clases que quieran recibir cambios
27
 * del GCanvas.
28
 * 
29
 * @version 28/02/2008
30
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
31
 */
32
public interface IGCanvasListener extends EventListener {
33
	/**
34
	 * Evento que se dispara cuando el GCanvas cambia el valor de alg?n elemento
35
	 * @param e
36
	 */
37
	public void actionDataChanged(GCanvasEvent e);
38
	
39
	/**
40
	 * Evento que se dispara mientras se esta produciendo la acci?n
41
	 * @param e
42
	 */
43
	public void actionDataDragged(GCanvasEvent e);
44
}
0 45

  
org.gvsig.raster/trunk/org.gvsig.raster_old/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/gcanvas/GCanvas.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.swing.gcanvas;
23

  
24
import java.awt.Color;
25
import java.awt.Graphics;
26
import java.awt.event.MouseListener;
27
import java.awt.event.MouseMotionListener;
28
import java.util.ArrayList;
29

  
30
/**
31
 * Canvas where graphic elements are painted
32
 * @author Nacho Brodin (nachobrodin@gmail.com)
33
 */
34
@SuppressWarnings("unchecked")
35
public interface GCanvas extends MouseListener, MouseMotionListener {
36
	/**
37
     * Creates a border layer to the graphic canvas
38
     * @param color
39
     * @return
40
     */
41
    public DrawableElement createBorderLayerForGCanvas(Color color);
42
    
43
    /**
44
     * Creates a information layer for the graphic canvas
45
     * @param colorLayer
46
     * @return
47
     */
48
    public InfoLayer createInfoLayerForGCanvas(Color colorLayer);
49
    
50
    /**
51
     * Creates a histogram for the graphic canvas
52
     * @param data
53
     * @param color
54
     * @return
55
     */
56
    public GraphicHistogram createHistogramForGCanvas(double[] data, Color color);
57
    
58
    /**
59
     * Creates a minmax layer for the graphic canvas
60
     * @param color
61
     * @return
62
     */
63
    public MinMaxLines createMinMaxLinesForGCanvas(Color color);
64
    
65
    /**
66
     * Creates a straight line layer for the graphic canvas
67
     * @param color
68
     * @return
69
     */
70
    public StraightLine createStraightLineForGCanvas(Color color);
71
    
72
    /**
73
     * Creates a logaritmic or exponential function layer for the graphic canvas
74
     * @param color
75
     * @return
76
     */
77
    public LogaritmicExponentialLine createLogaritmicExponentialLineForGCanvas(Color color, double point);
78
    
79
    /**
80
     * Creates a square root or pow line function for the graphic canvas
81
     * @param color
82
     * @return
83
     */
84
    public SquareRootPowLine createSquareRootPowLineForGCanvas(Color color, double point);
85
    
86
    /**
87
     * Creates a density slice function for the graphic canvas
88
     * @param color
89
     * @return
90
     */
91
    public DensitySlicingLine createDensitySliceForGCanvas(Color color, int levels);
92
	
93
	
94
	public void addBorder(int x1, int y1, int x2, int y2);
95
	
96
	/**
97
	 * A?adir un listener a la lista de eventos
98
	 * @param listener
99
	 */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff