Revision 1732

View differences:

tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/package.html
1
<html>
2
	<body>User Interface: Clases para interface de usuario.
3
</body>
4
</html>
0 5

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/RasterPropsDialogPanel.java
1
/*
2
 * Creado el 20-feb-2005
3
 */
4
package org.cresques.ui.raster;
5

  
6
import javax.swing.JPanel;
7

  
8
import org.cresques.io.GeoRasterFile;
9
import org.cresques.ui.DefaultDialogPanel;
10

  
11
/**
12
 * Dialogo para configurar las propiedades del raster.
13
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
14
 */
15
public class RasterPropsDialogPanel extends DefaultDialogPanel {
16
	//private BandSetupPanel bandSetupPanel = null;
17
	
18
	public RasterPropsDialogPanel() {
19
		super();
20
		initialize();
21
	}
22

  
23
	/**
24
	 * This method initializes this
25
	 * 
26
	 * @return void
27
	 */
28
	private void initialize() {
29
        this.setBounds(0,0,355,230);
30
	}
31
	
32
	protected BandSetupPanel getBandSetupPanel() {
33
		return (BandSetupPanel) getContentPanel();
34
	}
35
	
36
	protected JPanel getContentPanel() {
37
		if (contentPane == null) {
38
			contentPane = new BandSetupPanel();
39
			contentPane.setBounds(14, 12, 345, 174);
40
		}
41
		return contentPane;
42
	}
43
	/**
44
	 * @param files
45
	 */
46
	public void addFiles(GeoRasterFile[] files) {
47
		getBandSetupPanel().addFiles(files);
48
		getBandSetupPanel().repaint();
49
		this.repaint();
50
	}
51
	/**
52
	 * @param nBand
53
	 * @param flag
54
	 */
55
	public void assignBand(int nBand, int flag) {
56
		getBandSetupPanel().assignBand(nBand, flag);
57
	}
58
	
59
	public int getAssignedBand(int flag) {
60
		return getBandSetupPanel().getAssignedBand(flag);
61
	}
62
}
63

  
0 64

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/BandSetupPanel.java
1
/*
2
 * Created on 18-feb-2005
3
 */
4
package org.cresques.ui.raster;
5

  
6
import java.awt.Component;
7
import java.awt.Dimension;
8
import java.awt.event.ActionEvent;
9
import java.awt.event.ActionListener;
10
import java.io.File;
11
import java.util.Vector;
12

  
13
import javax.swing.AbstractCellEditor;
14
import javax.swing.JPanel;
15
import javax.swing.JRadioButton;
16
import javax.swing.JScrollPane;
17
import javax.swing.JTable;
18
import javax.swing.SwingConstants;
19
import javax.swing.SwingUtilities;
20
import javax.swing.event.TableModelEvent;
21
import javax.swing.event.TableModelListener;
22
import javax.swing.table.DefaultTableModel;
23
import javax.swing.table.TableCellEditor;
24
import javax.swing.table.TableCellRenderer;
25
import javax.swing.table.TableColumn;
26

  
27
import org.cresques.io.GeoRasterFile;
28

  
29
/**
30
 * Selecciona las bandas visibles en un raster
31
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
32
 */
33
public class BandSetupPanel extends JPanel implements TableModelListener {
34
	public static final int RED_BAND	= GeoRasterFile.RED_BAND;
35
	public static final int GREEN_BAND	= GeoRasterFile.GREEN_BAND;
36
	public static final int BLUE_BAND	= GeoRasterFile.BLUE_BAND;
37
	private FileList fileList = null;
38
	private JTable rgbTable = null;
39
	private JScrollPane rgbBandAssignPane = null;
40
	RGBBandAsignTableModel tableModel = null;
41
	/**
42
	 * This method initializes 
43
	 * 
44
	 */
45
	public BandSetupPanel() {
46
		super();
47
		initialize();
48
	}
49
	/**
50
	 * This method initializes this
51
	 * 
52
	 * @return void
53
	 */
54
	void initialize() {
55
        this.setPreferredSize(new Dimension(345,174));
56
        this.setBounds(0, 0, 345, 174);
57
        this.setLayout(null);
58
        this.add(getFileList(), null);
59
        this.add(getRGBBandAssignPane(), null);
60
	}
61
	
62
	public void addFiles(GeoRasterFile [] files) {
63
		System.out.println("BSP addFiles");
64
		for (int i=0; i<files.length; i++) {
65
			String fName = files[i].getName();
66
			getFileList().addFName(fName);
67
			//((DefaultListModel)fileList.getJList().getModel()).addElement(fName);
68
			String bandName = new File(fName).getName();
69
			String bandType = "8U";
70
			if (files[i].getBandCount() > 1) {
71
				for (int b=0; b<files[i].getBandCount(); b++)
72
					addBand((b+1)+" ["+bandType+"] "+bandName);
73
			} else
74
				addBand("1 ["+bandType+"] "+bandName);
75
		}
76
	}
77
	
78
	private FileList getFileList() {
79
		if (fileList == null) {
80
			fileList = new FileList();
81
			fileList.setBounds(9, 9, 328, 75);
82
/*			listManagerDemoSkin.getListManager().setListener(new ListManagerListener() {
83
				public Object[] addObjects() {
84
                    fileChooser = new JFileChooser(lastPath);
85
                    fileChooser.setMultiSelectionEnabled(true);
86
                    fileChooser.setAcceptAllFileFilterUsed(false);
87

  
88
                    try {
89
						String[] driverNames = LayerFactory.getDM().getDriverNames();
90
						FileFilter defaultFileFilter = null, auxF;
91
						for (int i = 0; i < driverNames.length; i++) {
92
							System.err.println("DRIVER "+i+" : "+driverNames[i]);
93
							boolean is = false;
94
							for (int j = 0; j < driverClasses.length; j++) {
95
								if (i == 0) System.err.println("DRIVER CLASS "+j+" : "+driverClasses[j].toString());
96
								if (LayerFactory.getDM().isA(driverNames[i], driverClasses[j]))
97
									is = true;
98
							}
99
							if (is){
100
							    auxF = new DriverFileFilter(driverNames[i]);
101
								fileChooser.addChoosableFileFilter(auxF);
102
								if (driverNames[i].indexOf("shp") != -1)
103
								{
104
								    defaultFileFilter = auxF;
105
								}
106
							}
107
						}
108
						if (defaultFileFilter != null)
109
						    if (lastFileFilter == null)
110
						        fileChooser.setFileFilter(defaultFileFilter);
111
						    else
112
						        fileChooser.setFileFilter(lastFileFilter);
113
					} catch (DriverLoadException e1) {
114
						NotificationManager.addError("No se pudo acceder a los drivers", e1);
115
					}
116

  
117
					int result = fileChooser.showOpenDialog(FileOpenDialog.this);
118
					
119
                    File[] newFiles = null;
120
                    MyFile[] toAdd;
121
                    if (result == JFileChooser.APPROVE_OPTION) {
122
                        lastFileFilter = fileChooser.getFileFilter();
123
                        lastPath = fileChooser.getCurrentDirectory().getAbsolutePath();
124
                		newFiles = fileChooser.getSelectedFiles();
125
                		toAdd = new MyFile[newFiles.length];
126
                		for (int ind=0; ind < newFiles.length; ind++)
127
                		{
128
                		    String driverName = ((DriverFileFilter) fileChooser.getFileFilter()).getDescription();
129
                		    toAdd[ind] = new MyFile(newFiles[ind], driverName);
130
                		}
131
                			
132
                		
133
                		return toAdd;
134
                    }
135
                    else
136
                    	return new Object[0];
137

  
138
                    // DefaultListModel lstModel = new DefaultListModel();
139

  
140
                }
141

  
142
				public Object getProperties(Object selected) {
143
					return null;
144
				}
145
			});*/
146
		}
147
		return fileList;
148
	}
149

  
150
	private final static String[] columnNames = {"R","G","B","Band"};
151
/*	private Object[][] data = {
152
		{new Boolean(true),new Boolean(true),new Boolean(true),""},
153
		{new Boolean(false),new Boolean(false),new Boolean(false),""},
154
//		{new Boolean(false),new Boolean(false),new Boolean(false),""}
155
	};*/
156
	 
157
	class RadioColumnEditor extends AbstractCellEditor implements TableCellEditor {
158
		private JRadioButton theRadioButton;
159
 
160
		public RadioColumnEditor() {
161
			super();
162
			theRadioButton = new JRadioButton();
163
			theRadioButton.addActionListener(new ActionListener() {
164
				public void actionPerformed(ActionEvent event) {
165
					fireEditingStopped();
166
				}
167
			});
168
		}
169
 
170
		public Component getTableCellEditorComponent(JTable table, Object obj, boolean isSelected, int row, int col) {
171
			theRadioButton.setHorizontalAlignment(SwingUtilities.CENTER);
172
			Boolean lValueAsBoolean = (Boolean)obj;
173
			theRadioButton.setSelected(lValueAsBoolean.booleanValue());
174
			return theRadioButton;
175
		}
176
 
177
		public Object getCellEditorValue() {
178
			return new Boolean(theRadioButton.isSelected());
179
		}
180
	}
181
 
182
	class RadioColumnRenderer extends JRadioButton implements TableCellRenderer {
183
		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
184
			if (value == null) {
185
				this.setSelected(false);
186
			}
187
			Boolean ValueAsBoolean = (Boolean)value;
188
			this.setSelected(ValueAsBoolean.booleanValue());
189
			this.setHorizontalAlignment(SwingConstants.CENTER);
190
			return this;
191
		}
192
	}
193
 
194
	class RGBBandAsignTableModel extends DefaultTableModel {
195
		public RGBBandAsignTableModel() {
196
			super(new Object[0][4], columnNames);
197
		}
198
	 
199
		public Class getColumnClass(int c) {
200
			if (c <3) return Boolean.class;
201
			return String.class;
202
		}
203
	 
204
		public void setValueAt(Object value, int row, int col) {
205
			if (col < 3 && ((Boolean)value).booleanValue()) {
206
				for (int i = 0; i < getRowCount(); i++) {
207
					if (i != row) {
208
						setValueAt(new Boolean(false), i, col);
209
					}
210
				}
211
			}
212
			super.setValueAt(value, row, col);
213
		}
214
	 
215
		public void addNew() {
216
			super.addRow(new Object[]{new Boolean(false),new Boolean(false),new Boolean(false),""});
217
		}
218
	}
219

  
220
	/**
221
	 * This method initializes jTable	
222
	 * 	
223
	 * @return javax.swing.JTable
224
	 */
225
	private JScrollPane getRGBBandAssignPane() {
226
		if (rgbBandAssignPane == null) {
227
			rgbBandAssignPane = new JScrollPane(getRGBTable());
228
			rgbBandAssignPane.setBounds(9, 95, 328, 72);
229
			TableColumn column = null;
230
			for (int i=0; i<3; i++) {
231
				column = rgbTable.getColumnModel().getColumn(i);
232
				column.setCellRenderer(new RadioColumnRenderer());
233
				column.setCellEditor(new RadioColumnEditor());
234
				column.setMaxWidth(22);
235
				column.setMinWidth(22);
236
			}
237
//			frame.setContentPane(scrollPane);
238
		}
239
		return rgbBandAssignPane;
240
	}
241
	
242
	private JTable getRGBTable() {
243
		if (rgbTable == null) {
244
			tableModel =  new RGBBandAsignTableModel();
245
			tableModel.addTableModelListener(this);
246
			rgbTable = new JTable(tableModel);
247
			rgbTable.setPreferredScrollableViewportSize(new Dimension(328, 72));
248
		}
249
		return rgbTable;
250
	}
251
	
252
	private void addBand(String bandName) {
253
		Vector v = new Vector();
254
		v.add(new Boolean(false));
255
		v.add(new Boolean(false));
256
		v.add(new Boolean(false));
257
		v.add(bandName);
258
		((DefaultTableModel) rgbTable.getModel()).addRow(v);
259
	}
260

  
261
	public void assignBand(int nBand, int flag) {
262
		Boolean t = new Boolean(true);
263
		if ((flag & RED_BAND) == RED_BAND)
264
			((DefaultTableModel) rgbTable.getModel()).setValueAt(t, nBand, 0);
265
		if ((flag & GREEN_BAND) == GREEN_BAND)
266
			((DefaultTableModel) rgbTable.getModel()).setValueAt(t, nBand, 1);
267
		if ((flag & BLUE_BAND) == BLUE_BAND)
268
			((DefaultTableModel) rgbTable.getModel()).setValueAt(t, nBand, 2);
269
	}
270

  
271
	public int getAssignedBand(int flag) {
272
		if ((flag & RED_BAND) == RED_BAND)
273
			for (int nBand=0; nBand<rgbTable.getRowCount(); nBand++)
274
				if (((Boolean)((DefaultTableModel) rgbTable.getModel()).getValueAt(nBand, 0)).booleanValue())
275
					return nBand;
276
		if ((flag & GREEN_BAND) == GREEN_BAND)
277
			for (int nBand=0; nBand<rgbTable.getRowCount(); nBand++)
278
				if (((Boolean)((DefaultTableModel) rgbTable.getModel()).getValueAt(nBand, 1)).booleanValue())
279
					return nBand;
280
		if ((flag & BLUE_BAND) == BLUE_BAND)
281
			for (int nBand=0; nBand<rgbTable.getRowCount(); nBand++)
282
				if (((Boolean)((DefaultTableModel) rgbTable.getModel()).getValueAt(nBand, 2)).booleanValue())
283
					return nBand;
284
		return -1;
285
	}
286
	
287
	/* (non-Javadoc)
288
	 * @see javax.swing.event.TableModelListener#tableChanged(javax.swing.event.TableModelEvent)
289
	 */
290
	public void tableChanged(TableModelEvent e) {
291
		rgbTable.revalidate();
292
		rgbBandAssignPane.revalidate();
293
		revalidate();
294
		System.err.println("TableChanged.");
295
	}
296
 }  //  @jve:decl-index=0:visual-constraint="10,10"
0 297

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/FileList.java
1

  
2
package org.cresques.ui.raster;
3

  
4
import java.awt.BorderLayout;
5
import java.awt.FlowLayout;
6
import java.util.Vector;
7

  
8
import javax.swing.JButton;
9
import javax.swing.JList;
10
import javax.swing.JPanel;
11
import javax.swing.JScrollPane;
12
public class FileList extends JPanel {
13

  
14
	private JScrollPane jScrollPane = null;
15
	private JPanel jPanel = null;
16
	private JButton jButton2 = null;
17
	private JButton jButton3 = null;
18

  
19
	private Vector fileNames = null;
20
	private JList jList = null;
21
	private JPanel jPanel1 = null;
22
	/**
23
	 * This method initializes jScrollPane	
24
	 * 	
25
	 * @return javax.swing.JScrollPane	
26
	 */    
27
	private JScrollPane getJScrollPane() {
28
		if (jScrollPane == null) {
29
			jScrollPane = new JScrollPane();
30
			jScrollPane.setViewportView(getJList());
31
		}
32
		return jScrollPane;
33
	}
34
	/**
35
	 * This method initializes jPanel	
36
	 * 	
37
	 * @return javax.swing.JPanel	
38
	 */    
39
	private JPanel getJPanel() {
40
		if (jPanel == null) {
41
			FlowLayout flowLayout2 = new FlowLayout();
42
			jPanel = new JPanel();
43
			jPanel.setLayout(flowLayout2);
44
			flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
45
			jPanel.add(getJPanel1(), null);
46
		}
47
		return jPanel;
48
	}
49
	/**
50
	 * This method initializes jButton2	
51
	 * 	
52
	 * @return javax.swing.JButton	
53
	 */    
54
	private JButton getJButton2() {
55
		if (jButton2 == null) {
56
			jButton2 = new JButton("A?adir");
57
			//jButton2.setText(PluginServices.getText(this, "Anadir"));
58
			jButton2.setPreferredSize(new java.awt.Dimension(72,25));
59
		}
60
		return jButton2;
61
	}
62
	/**
63
	 * This method initializes jButton3	
64
	 * 	
65
	 * @return javax.swing.JButton	
66
	 */    
67
	private JButton getJButton3() {
68
		if (jButton3 == null) {
69
			jButton3 = new JButton("Eliminar");
70
			//jButton3.setText(PluginServices.getText(this, "Eliminar"));
71
			jButton3.setPreferredSize(new java.awt.Dimension(72,25));
72
		}
73
		return jButton3;
74
	}
75
	/**
76
	 * This method initializes jList	
77
	 * 	
78
	 * @return javax.swing.JList	
79
	 */    
80
	public JList getJList() {
81
		if (jList == null) {
82
			fileNames = new Vector();
83
			jList = new JList(fileNames);
84
		}
85
		return jList;
86
	}
87
         	/**
88
	 * This is the default constructor
89
	 */
90
	public FileList() {
91
		super();
92
		initialize();
93
	}
94
	/**
95
	 * This method initializes this
96
	 * 
97
	 * @return void
98
	 */
99
	private  void initialize() {
100
		this.setLayout(new BorderLayout());
101
		this.setSize(300, 248);
102
		this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
103
		this.add(getJPanel(), java.awt.BorderLayout.EAST);
104
	}
105
	/**
106
	 * This method initializes jPanel1	
107
	 * 	
108
	 * @return javax.swing.JPanel	
109
	 */    
110
	private JPanel getJPanel1() {
111
		if (jPanel1 == null) {
112
			jPanel1 = new JPanel();
113
			jPanel1.setPreferredSize(new java.awt.Dimension(86,180));
114
			jPanel1.add(getJButton2(), null);
115
			jPanel1.add(getJButton3(), null);
116
		}
117
		return jPanel1;
118
	}
119
	
120
	public void addFName(String fName) {
121
		fileNames.add(fName);
122
	}
123
}  //  @jve:decl-index=0:visual-constraint="10,10"
0 124

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/ImageInfoPanel.java
1
/*
2
 * Created on 21-feb-2005
3
 */
4
package org.cresques.ui.raster;
5

  
6
/**
7
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
8
 */
9
public class ImageInfoPanel {
10

  
11
	/**
12
	 * 
13
	 */
14
	public ImageInfoPanel() {
15
		super();
16
		// TODO Auto-generated constructor stub
17
	}
18

  
19
}
0 20

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/CQCursor.java
1
/*
2
 * Creado el 24-ago-2004
3
 */
4
package org.cresques.ui;
5

  
6
import java.awt.Cursor;
7
import java.awt.Point;
8
import java.awt.Toolkit;
9

  
10
/**
11
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
12
 */
13
public class CQCursor {
14
	public static int ZOOMIN_CURSOR	= 0x100;
15
	public static int ZOOMOUT_CURSOR	= 0x101;
16
	public static int PAN_CURSOR		= 0x102;
17
	public static int SELECT_CURSOR	= 0x103;
18
	public static int INFO_CURSOR		= 0x104;
19
	private static int MAXCURSORNR	= 15;
20
	private static Cursor [] cursores = null;
21
	
22
	static {
23
		ClassLoader loader = CQCursor.class.getClassLoader();
24
		//ImageIcon folderIcon = new ImageIcon(loader.getResource("images/"+"folderXP.gif"));
25
		cursores = new Cursor[MAXCURSORNR];
26
		cursores[ZOOMIN_CURSOR - 0x100] = Toolkit.getDefaultToolkit().createCustomCursor(
27
			Toolkit.getDefaultToolkit().getImage(loader.getResource("images/zi_cur.gif")),
28
			new Point(6,5), "ZoomMas");
29
		cursores[ZOOMOUT_CURSOR - 0x100] = Toolkit.getDefaultToolkit().createCustomCursor(
30
			Toolkit.getDefaultToolkit().getImage(loader.getResource("images/zo_cur.gif")),
31
			new Point(6,5), "ZoomMenos");
32
		cursores[PAN_CURSOR - 0x100] = Toolkit.getDefaultToolkit().createCustomCursor(
33
			Toolkit.getDefaultToolkit().getImage(loader.getResource("images/pan_cur.gif")),
34
			new Point(3,3), "Pan");
35
		cursores[SELECT_CURSOR - 0x100] = Toolkit.getDefaultToolkit().createCustomCursor(
36
				Toolkit.getDefaultToolkit().getImage(loader.getResource("images/select_cur.gif")),
37
				new Point(6,1), "Select");
38
		cursores[INFO_CURSOR - 0x100] = Toolkit.getDefaultToolkit().createCustomCursor(
39
				Toolkit.getDefaultToolkit().getImage(loader.getResource("images/info_cur.gif")),
40
				new Point(5, 26), "Info");
41
	}
42
	
43
	public static Cursor getCursor(int type) {
44
		Cursor cursor = null;
45
		if (type < 0x100)
46
			cursor = new Cursor(type);
47
		else if (type >= 0x100)
48
			cursor = cursores[type - 0x100];
49
		return cursor;
50
		
51
	}
52
}
0 53

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/CmdPan.java
1
package org.cresques.ui.cmd;
2

  
3
import java.awt.geom.Point2D;
4

  
5
import org.cresques.ui.CQCursor;
6
import org.cresques.ui.CQMapCanvas;
7

  
8
/**
9
 * Comando pan.
10
 * A?ade al canvas la capacidad de desplazar la vista.
11
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
12
 */
13
public class CmdPan extends Cmd {
14
	private Point2D ptIni = null;
15
	
16
	/**
17
	 * Construye un nuevo CmdPan para el Canvas.
18
	 * @param canvas
19
	 */
20
	public CmdPan(CQMapCanvas canvas) {
21
		super(canvas);
22
		eventsWanted = LEFT | PRESS | RELEASE;
23
		cursor = CQCursor.getCursor(CQCursor.PAN_CURSOR);
24
	}
25

  
26
	/**
27
	 * Recibe los eventos del rat?n.
28
	 */
29
	public void cmd(Point2D pt, int btn, int mouseEvent) {
30
		if (mouseEvent == Cmd.RELEASE) {
31
			pan(ptIni, pt);
32
		} else if (mouseEvent == Cmd.PRESS) {
33
			ptIni = pt;
34
		}
35
	}
36
	
37
	/**
38
	 * Realiza un desplazamiento de la vista.
39
	 * @param ptIni Punto inicial.
40
	 * @param ptFin Punto final.
41
	 */void pan(Point2D ptIni, Point2D ptFin) {
42
		canvas.getVPData().pan(ptIni, ptFin);
43
		canvas.viewPortChanged();
44
		canvas.repaint();
45
	}
46
}
0 47

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/Cmd.java
1
package org.cresques.ui.cmd;
2

  
3
import java.awt.Cursor;
4
import java.awt.geom.Point2D;
5
import java.util.TreeMap;
6

  
7
import org.cresques.ui.CQMapCanvas;
8

  
9
/**
10
 * Clase Cmd, ancestro de todos los comandos del canvas.
11
 * Permite a?adir al canvas funcionalidades que responden a eventos de
12
 * rat?n y producen canvios en el estado del canvas.
13
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
14
 */
15
public abstract class Cmd {
16
	public static final int LEFT		= 0x0001;
17
	public static final int RIGHT		= 0x0002;
18
	public static final int MIDDLE	= 0x0004;
19
	public static final int PRESS		= 0x0008;
20
	public static final int RELEASE	= 0x0010;
21
	public static final int DRAG		= 0x0020;
22

  
23
	public static final int type=0;
24
	CQMapCanvas canvas = null;
25
	int eventsWanted = 0;
26
	protected Cursor cursor = null;
27
	private static TreeMap cmdPool = null;;
28
	
29
	/**
30
	 * Inicializaci?n de la pool de comandos. 
31
	 */
32
	static {
33
		cmdPool = new TreeMap();
34
	}
35
	
36
	public static void register(String cmdStr, Cmd command) {
37
		Cmd.cmdPool.put(cmdStr, command);
38
	}
39
	
40
	public static Cmd get(String cmdStr) {
41
		 return (Cmd) Cmd.cmdPool.get(cmdStr);
42
	}
43
	
44
	/**
45
	 * Construye un nuevo Cmd para el Canvas
46
	 * @param canvas
47
	 */
48
	public Cmd(CQMapCanvas canvas) {
49
		this.canvas = canvas;
50
	}
51
	
52
	/**
53
	 * Recibe los eventos del rat?n.
54
	 */
55
	abstract public void cmd(Point2D pt, int bt, int mouseEvent);
56
	
57
	/**
58
	 * Devuelve un Bitset con los eventos de raton que requiere.
59
	 * @return eventsWanted (BitSet)
60
	 */
61
	public int getEventsWanted() {
62
		return eventsWanted;
63
	}
64
	
65
	public Cursor getCursor() {
66
		return cursor;
67
	}
68
}
0 69

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/CmdSelect.java
1
package org.cresques.ui.cmd;
2

  
3
import java.awt.geom.Point2D;
4

  
5
import org.cresques.ui.CQCursor;
6
import org.cresques.ui.CQMapCanvas;
7

  
8
/**
9
 * Comando select.
10
 * A?ade al canvas la capacidad de seleccionar datos de una cobertura
11
 * 	usando una malla poligonal.
12
 * @see org.cresques.geo.cover.Coverage
13
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
14
 */
15
public class CmdSelect extends Cmd {
16
	
17
	/**
18
	 * Construye un nuevo CmdSelect para el Canvas
19
	 * @param canvas
20
	 */
21
	public CmdSelect(CQMapCanvas canvas) {
22
		super(canvas);
23
		eventsWanted = LEFT | RIGHT | PRESS;
24
		cursor = CQCursor.getCursor(CQCursor.SELECT_CURSOR);
25
	}
26

  
27
	/**
28
	 * Recibe los eventos del rat?n.
29
	 */
30
	public void cmd(Point2D pt, int btn, int mouseEvent) {
31
		canvas.getApp().selectHoja(pt);
32
		canvas.repaint();
33
	}
34
}
0 35

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/CmdMeasure.java
1
package org.cresques.ui.cmd;
2

  
3
import java.awt.Cursor;
4
import java.awt.geom.Point2D;
5

  
6
import org.cresques.ui.CQCursor;
7
import org.cresques.ui.CQMapCanvas;
8

  
9
/**
10
 * Comando measure.
11
 * A?ade al canvas la capacidad de medir distancias.
12
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
13
 */
14
public class CmdMeasure extends Cmd {
15
	private Point2D ptIni = null;
16
	
17
	/**
18
	 * Construye un nuevo CmdMeasure para el Canvas.
19
	 * @param canvas
20
	 */
21
	public CmdMeasure(CQMapCanvas canvas) {
22
		super(canvas);
23
		eventsWanted = LEFT | PRESS | RELEASE;
24
		cursor = CQCursor.getCursor(Cursor.CROSSHAIR_CURSOR);
25
	}
26

  
27
	/**
28
	 * Recibe los eventos del rat?n.
29
	 */
30
	public void cmd(Point2D pt, int btn, int mouseEvent) {
31
		if (mouseEvent == Cmd.RELEASE) {
32
			measure(ptIni, pt);
33
		} else if (mouseEvent == Cmd.PRESS) {
34
			ptIni = pt;
35
		}
36
	}
37
	
38
	/**
39
	 * Mide la distancia entre dos puntos.
40
	 * @param ptIni Punto inicial.
41
	 * @param ptFin Punto final.
42
	 */void measure(Point2D ptIni, Point2D ptFin) {
43
		//canvas.getVPData().pan(ptIni, ptFin);
44
		//canvas.viewPortChanged();
45
		//canvas.repaint();
46
	}
47
}
0 48

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/CmdZoom.java
1
package org.cresques.ui.cmd;
2

  
3
import java.awt.geom.Point2D;
4

  
5
import java.awt.event.MouseEvent;
6

  
7
import org.cresques.px.Extent;
8
import org.cresques.ui.CQCursor;
9
import org.cresques.ui.CQMapCanvas;
10

  
11
/**
12
 * Comando zoom.
13
 * A?ade al canvas la capacidad de aumentar y disminuir la vista.
14
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
15
 */
16
public class CmdZoom extends Cmd {
17
	public double aumenta = 2.0;
18
	public double reduce = .5;
19
	private Point2D ptIni = null;
20
	
21
	/**
22
	 * Construye un nuevo CmdZoom para el Canvas
23
	 * @param canvas
24
	 */
25
	public CmdZoom(CQMapCanvas canvas) {
26
		super(canvas);
27
		eventsWanted = (LEFT | RIGHT | PRESS | RELEASE | DRAG);
28
		cursor = CQCursor.getCursor(CQCursor.ZOOMIN_CURSOR);
29

  
30
	}
31
	
32
	/**
33
	 * Recibe los eventos del rat?n.
34
	 */
35
	public void cmd(Point2D pt, int bt, int mouseEvent) {
36
		//System.out.println("Zoom: Evento = "+ mouseEvent);
37
		if (mouseEvent == PRESS) {
38
			ptIni = pt;
39
		} else if (mouseEvent == RELEASE) {
40
			if (pt.getX() != ptIni.getX()) {
41
				zoomBox(new Extent(ptIni, pt));
42
			} else if (bt == MouseEvent.BUTTON1) {
43
				zoomMas(pt);
44
			} else if (bt == MouseEvent.BUTTON3) {
45
				zoomMenos(pt);
46
			}
47
		} 
48
	}
49
	
50
	/**
51
	 * Realiza un zoom de aumento, centrado en el Point2D;
52
	 * @param pt
53
	 */
54
	public void zoomMas(Point2D pt) {
55
		canvas.getVPData().zoom(aumenta, pt);
56
		canvas.viewPortChanged();
57
		canvas.repaint();
58
	}
59
	
60
	/**
61
	 * Realiza un zoom de disminuci?n, centrado en el Point2D;
62
	 * @param pt
63
	 */
64
	public void zoomMenos(Point2D pt) {
65
		canvas.getVPData().zoom(reduce, pt);
66
		canvas.viewPortChanged();
67
		canvas.repaint();
68
	}
69
	
70
	/**
71
	 * Realiza un zoom que abarque el Extent;
72
	 * @param box
73
	 */
74
	public void zoomBox(Extent box) {
75
		canvas.getVPData().zoom(box);
76
		canvas.viewPortChanged();
77
		canvas.repaint();
78
	}
79
}
0 80

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/CmdPLine.java
1
/*
2
 * 20-sep-2004
3
 */
4
package org.cresques.ui.cmd;
5

  
6
import java.awt.event.MouseEvent;
7
import java.awt.geom.Point2D;
8
import java.util.Vector;
9

  
10
import org.cresques.px.PxLine;
11
import org.cresques.px.dxf.DxfPolyline;
12
import org.cresques.px.gml.Feature;
13
import org.cresques.px.gml.LineString;
14
import org.cresques.ui.CQCursor;
15
import org.cresques.ui.CQMapCanvas;
16

  
17
/**
18
 * Comando pline.
19
 * A?ade al canvas la capacidad de crear polilineas.
20
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
21
 */
22
public class CmdPLine extends Cmd {
23
	private Point2D ptIni = null;
24
	private Vector pts = new Vector();
25
	private Feature pLine = null;
26
	
27
	/**
28
	 * Construye un nuevo CmdPan para el Canvas.
29
	 * @param canvas
30
	 */
31
	public CmdPLine(CQMapCanvas canvas) {
32
		super(canvas);
33
		eventsWanted = LEFT | RIGHT | PRESS | RELEASE;
34
		cursor = CQCursor.getCursor(CQCursor.SELECT_CURSOR);
35
	}
36

  
37
	/**
38
	 * Recibe los eventos del rat?n.
39
	 */
40
	public void cmd(Point2D pt, int bt, int mouseEvent) {
41
		if (mouseEvent == Cmd.RELEASE) 
42
			if (bt == MouseEvent.BUTTON1) {
43
				pts.add(pt);
44
				pline();
45
			} else {
46
				pts = new Vector();
47
			}
48
	}
49
	
50
	/**
51
	 * Realiza un desplazamiento de la vista.
52
	 * @param ptIni Punto inicial.
53
	 * @param ptFin Punto final.
54
	 */
55
	private void pline() {
56
		if (pts.size() > 2) {
57
			pLine.getGeometry().add((Point2D) pts.lastElement());
58
		} else if (pts.size() == 2) {
59
			pLine = new Feature();
60
			pLine.setGeometry(new LineString());
61
			pLine.getGeometry().add((Point2D) pts.get(0));
62
			pLine.getGeometry().add((Point2D) pts.get(1));
63
			canvas.getApp().getCurrentLayer().add(pLine);
64
		} 
65
		canvas.repaint();
66
	}
67
}
0 68

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/package.html
1
<html>
2
	<body>cmd: Comandos que actuan sobre el canvas.
3
</body>
4
</html>
0 5

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cmd/CmdInfo.java
1
package org.cresques.ui.cmd;
2

  
3
import java.awt.geom.Point2D;
4

  
5
import org.cresques.ui.CQCursor;
6
import org.cresques.ui.CQMapCanvas;
7

  
8
/**
9
 * Comando info.
10
 * A?ade al canvas la capacidad de obtener informaci?n de un elemento
11
 * debajo del cursor.
12
 * @see org.cresques.geo.cover.Coverage
13
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
14
 */
15
public class CmdInfo extends Cmd {
16
	
17
	/**
18
	 * Construye un nuevo CmdInfo para el Canvas
19
	 * @param canvas
20
	 */
21
	public CmdInfo(CQMapCanvas canvas) {
22
		super(canvas);
23
		eventsWanted = LEFT | RIGHT | PRESS;
24
		cursor = CQCursor.getCursor(CQCursor.INFO_CURSOR);
25
	}
26

  
27
	/**
28
	 * Recibe los eventos del rat?n.
29
	 */
30
	public void cmd(Point2D pt, int btn, int mouseEvent) {
31
		canvas.getApp().selectHoja(pt);
32
		canvas.repaint();
33
	}
34
}
0 35

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/CQApp.java
1
/*
2
 * Created on 11-may-2004
3
 */
4
package org.cresques.ui;
5

  
6
import java.awt.geom.Point2D;
7

  
8
import org.cresques.cts.IProjection;
9
import org.cresques.px.PxLayer;
10

  
11
/**
12
 * Define los m?todos de comunicaci?n entre la librer?a y la aplicaci?n
13
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
14
 */
15

  
16
public interface CQApp {
17
	
18
	public CQMapCanvas getCanvas();
19
	
20
	public IProjection getCurrentProjection();
21
	public void setCurrentProjection(IProjection proj);
22

  
23
	public PxLayer getLayerByName(String lName);
24
	public void setCurrentLayer(PxLayer layer);
25
	public PxLayer getCurrentLayer();
26
	public PxLayer createLayer(String name, IProjection proj);
27

  
28
	public void loadFile(String fName, IProjection proj);
29
	public void loadFile(String [] fNames, IProjection proj);
30
	public void setCurrentMinuteo(PxLayer layerMin);
31

  
32
	public void selectHoja(Point2D pt);
33

  
34
}
0 35

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/DefaultDialogPanel.java
1
/*
2
 * Created on 20-feb-2005
3
 */
4
package org.cresques.ui;
5

  
6
import java.awt.FlowLayout;
7
import java.awt.event.ComponentEvent;
8
import java.awt.event.ComponentListener;
9

  
10
import javax.swing.JButton;
11
import javax.swing.JLabel;
12
import javax.swing.JPanel;
13
import javax.swing.event.AncestorEvent;
14
import javax.swing.event.AncestorListener;
15

  
16
/**
17
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
18
 */
19
public class DefaultDialogPanel extends JPanel {
20
	protected JPanel contentPane = null;
21
	private JPanel tabPane = null;
22
	private JPanel buttonPane = null;
23
	private JButton acceptButton = null;
24
	private JButton cancelButton = null;
25
	private JButton applyButton = null;
26

  
27
	/**
28
	 * 
29
	 */
30
	public DefaultDialogPanel() {
31
		super();
32
		initialize();
33
	}
34

  
35
	/**
36
	 * This method initializes this
37
	 * 
38
	 * @return void
39
	 */
40
	private void initialize() {
41
		//setBounds(0,0,321,230);
42
		//javax.swing.BoxLayout(jContentPane, javax.swing.BoxLayout.Y_AXIS);
43
		//jContentPane.setLayout(new java.awt.GridLayout(2,1));
44
		setLayout(new FlowLayout());
45
		setBorder(javax.swing.BorderFactory.createEmptyBorder(5,5,5,5));
46
		//jContentPane.setSize(30, 24);
47
		this.setPreferredSize(new java.awt.Dimension(320,165));
48
		add(getTabPanel(), null);
49
		add(getButtonPanel(), null);
50
	}
51
	
52
	protected JPanel getContentPanel(){
53
		if (contentPane == null) {
54
			contentPane = new JPanel();
55
			contentPane.setBounds(6, 200, 309, 125);
56
			contentPane.setPreferredSize(new java.awt.Dimension(310,100));
57
		}
58
		return contentPane;
59
	}
60
	
61
	private JPanel getTabPanel() {
62
		if (tabPane == null){
63
			tabPane = new JPanel();
64
			setLayout(new FlowLayout());
65
			//tabPane.setBounds(6, 7, 309, 189);
66
			tabPane.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.SoftBevelBorder.RAISED));
67
			tabPane.add(getContentPanel(), null);
68
		}
69
		return tabPane;
70
	}
71
	
72
	protected JPanel getButtonPanel() {
73
		if (buttonPane == null) {
74
			java.awt.FlowLayout flowLayout2 = new FlowLayout();
75
			buttonPane = new JPanel();
76
			buttonPane.setLayout(flowLayout2);
77
			buttonPane.setSize(309, 25);
78
			buttonPane.setBounds(6, 200, 309, 25);
79
			flowLayout2.setHgap(0);
80
			flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
81
			flowLayout2.setVgap(1);
82
			buttonPane.add(getAcceptButton(), null);
83
			JLabel lbl1 = new JLabel();
84
			lbl1.setPreferredSize(new java.awt.Dimension(18,23));
85
			buttonPane.add(lbl1);
86
			buttonPane.add(getCancelButton(), null);
87
			JLabel lbl2 = new JLabel();
88
			lbl2.setPreferredSize(new java.awt.Dimension(18,23));
89
			buttonPane.add(lbl2);
90
			buttonPane.add(getApplyButton(), null);
91
		}
92
		return buttonPane;
93
	}
94
	/**
95
	 * This method initializes jButton	
96
	 * 	
97
	 * @return javax.swing.JButton	
98
	 */    
99
	public JButton getAcceptButton() {
100
		if (acceptButton == null) {
101
			acceptButton = new JButton("Aceptar");
102
			acceptButton.setText("Aceptar");
103
		}
104
		return acceptButton;
105
	}
106
	/**
107
	 * This method initializes jButton	
108
	 * 	
109
	 * @return javax.swing.JButton	
110
	 */    
111
	public JButton getCancelButton() {
112
		if (cancelButton == null) {
113
			cancelButton = new JButton("Cancelar");
114
			cancelButton.setText("Cancelar");
115
		}
116
		return cancelButton;
117
	}
118
	/**
119
	 * This method initializes jButton	
120
	 * 	
121
	 * @return javax.swing.JButton	
122
	 */    
123
	public JButton getApplyButton() {
124
		if (applyButton == null) {
125
			applyButton = new JButton("Aplicar");
126
		}
127
		return applyButton;
128
	}
129
}
0 130

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cts/CSSelectionDialogPanel.java
1
/*
2
 * Creado el 31-ago-2004
3
 */
4
package org.cresques.ui.cts;
5

  
6
import javax.swing.JPanel;
7

  
8
import org.cresques.cts.ProjectionPool;
9
import org.cresques.ui.DefaultDialogPanel;
10
import org.cresques.ui.cts.CSSelectionPanel;
11

  
12
/**
13
 * Dialogo para abrir fichero.
14
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
15
 */
16
public class CSSelectionDialogPanel extends DefaultDialogPanel {
17
	public CSSelectionDialogPanel() {
18
		super();
19
		initialize();
20
	}
21

  
22
	/**
23
	 * This method initializes this
24
	 * 
25
	 * @return void
26
	 */
27
	private void initialize() {
28
        this.setBounds(0,0,321,230);
29
			
30
	}
31
	public CSSelectionPanel getProjPanel() {
32
		return (CSSelectionPanel) getContentPanel();
33
	}
34
	
35
	protected JPanel getContentPanel() {
36
		if (contentPane == null) {
37
			contentPane = new CSSelectionPanel("Sistema de referencia");
38
			contentPane.setBounds(14, 12, 280, 163);
39
			
40
			((CSSelectionPanel)contentPane).setProjection(ProjectionPool.get("EPSG:32619"));
41
		}
42
		return contentPane;
43
	}
44
}
45

  
0 46

  
tags/Root_CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/cts/CSSelectionPanel.java
1
/*
2
 * Creado el 31-ago-2004
3
 */
4
package org.cresques.ui.cts;
5

  
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8

  
9
import javax.swing.JComboBox;
10
import javax.swing.JLabel;
11
import javax.swing.JPanel;
12

  
13
import org.cresques.cts.IProjection;
14
import org.cresques.ui.LoadableComboBox;
15

  
16
//import es.gva.cit.geoexplorer.ui.LoadableComboBox;
17

  
18
/**
19
 * Panel de edici?n de Sistemas de referencia	
20
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
21
 */
22
public class CSSelectionPanel extends JPanel {
23
	private LoadableComboBox datumComboBox = null;
24
	private LoadableComboBox projComboBox = null;
25
	private LoadableComboBox huseComboBox = null;
26
	private JLabel jLabel = null;
27
	private JLabel jLabel1 = null;
28
	private JLabel jLabel2 = null;
29
	private int wDisplay = 335;
30
	private int wCombo = 250;
31
	private int h=23, x=14;
32
	private String tit;
33
	private CSSelectionModel model;
34

  
35
	/**
36
	 * Constructor de la clase.
37
	 */
38
	public CSSelectionPanel(String tit) {
39
		super();
40
		if (tit == null) tit = "Sistema de referencia";
41
		this.tit = tit;
42
		setModel(new CSSelectionModel());
43
		initialize();
44
	}
45
	/**
46
	 * Inicializa el panel.
47
	 * @return javax.swing.JPanel	
48
	 */    
49
	private void initialize() {
50
		setPreferredSize(new java.awt.Dimension(280, 155));
51
        setLayout(null);
52
		/*javax.swing.border.Border border = javax.swing.BorderFactory.createCompoundBorder(
53
        	javax.swing. BorderFactory.createTitledBorder("Sistema de coordenadas"),
54
        	javax.swing.BorderFactory.createEmptyBorder(5,5,5,5)); */
55
        setBorder(javax.swing.BorderFactory.createCompoundBorder(
56
        	null, javax.swing.BorderFactory.createTitledBorder(
57
        	null, "Sistema de Referencia", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)));
58
        
59
        jLabel = new JLabel();
60
        jLabel.setBounds(15, 15, 77, 23);
61
        jLabel.setText("Datum :");
62
        add(jLabel, null);
63
        add(getDatumComboBox(), null);
64

  
65
        jLabel1 = new JLabel();
66
        jLabel1.setBounds(15, 60, 77, 23);
67
        jLabel1.setText("Proyecci?n :");
68
        add(jLabel1, null);
69
        add(getProjComboBox(), null);
70

  
71
        jLabel2 = new JLabel();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff