Revision 11417

View differences:

org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/test/java/org/gvsig/wcs/app/extension/gui/panel/TestFormatsPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.wcs.app.extension.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.FormatPanel;
24

  
25
public class TestFormatsPanel {
26
	private int               w        = 510;
27
	private int               h        = 610;
28
	private JFrame            frame    = new JFrame();
29
	private FormatPanel       desc     = null;
30

  
31
	public TestFormatsPanel() {
32
		desc = new FormatPanel();
33
		frame.getContentPane().add(desc);
34
		frame.setSize(w, h);
35
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
36
		frame.setVisible(true);
37
	}
38

  
39
	public static void main(String[] args) {
40
		new TestFormatsPanel();
41
	}
42
}
0 43

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/test/java/org/gvsig/wcs/app/extension/gui/panel/TestInfoPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.wcs.app.extension.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.InfoPanel;
24

  
25
public class TestInfoPanel {
26
	private int               w        = 510;
27
	private int               h        = 610;
28
	private JFrame            frame    = new JFrame();
29
	private InfoPanel         desc     = null;
30

  
31
	public TestInfoPanel() {
32
		desc = new InfoPanel();
33
		frame.getContentPane().add(desc);
34
		frame.setSize(w, h);
35
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
36
		frame.setVisible(true);
37
	}
38

  
39
	public static void main(String[] args) {
40
		new TestInfoPanel();
41
	}
42
}
0 43

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/test/java/org/gvsig/wcs/app/extension/gui/panel/TestLayerPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.wcs.app.extension.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.LayerPanel;
24

  
25
public class TestLayerPanel {
26
	private int               w        = 510;
27
	private int               h        = 610;
28
	private JFrame            frame    = new JFrame();
29
	private LayerPanel        desc     = null;
30

  
31
	public TestLayerPanel() {
32
		desc = new LayerPanel();
33
		frame.getContentPane().add(desc);
34
		frame.setSize(w, h);
35
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
36
		frame.setVisible(true);
37
	}
38

  
39
	public static void main(String[] args) {
40
		new TestLayerPanel();
41
	}
42
}
0 43

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/test/java/org/gvsig/wcs/app/extension/gui/panel/TestParameterPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.wcs.app.extension.gui.panel;
20

  
21
import javax.swing.JFrame;
22

  
23
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.ParameterPanel;
24

  
25
public class TestParameterPanel {
26
	private int               w        = 510;
27
	private int               h        = 610;
28
	private JFrame            frame    = new JFrame();
29
	private ParameterPanel    desc     = null;
30

  
31
	public TestParameterPanel() {
32
		desc = new ParameterPanel();
33
		frame.getContentPane().add(desc);
34
		frame.setSize(w, h);
35
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
36
		frame.setVisible(true);
37
	}
38

  
39
	public static void main(String[] args) {
40
		new TestParameterPanel();
41
	}
42
}
0 43

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/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.wcs.io:jar</include>
33
                <include>org.gvsig:org.gvsig.raster.wcs.remoteclient:jar</include>
34
            </includes>
35
        </dependencySet>
36
    </dependencySets>
37
</assembly>
0 38

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/toc/WCSZoomPixelCursorListener.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.wcs.app.wcsclient.gui.toc;
23

  
24
import java.awt.Cursor;
25
import java.awt.Image;
26
import java.awt.Point;
27
import java.awt.Toolkit;
28
import java.awt.geom.Point2D;
29

  
30
import org.gvsig.andami.IconThemeHelper;
31
import org.gvsig.fmap.dal.exception.ReadException;
32
import org.gvsig.fmap.geom.GeometryLocator;
33
import org.gvsig.fmap.geom.GeometryManager;
34
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
35
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
36
import org.gvsig.fmap.geom.primitive.Envelope;
37
import org.gvsig.fmap.mapcontext.ViewPort;
38
import org.gvsig.fmap.mapcontext.layers.FLayer;
39
import org.gvsig.fmap.mapcontrol.MapControl;
40
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
41
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
42
import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener;
43
import org.gvsig.raster.wcs.app.wcsclient.layer.FLyrWCS;
44

  
45

  
46
/**
47
 * <p>Listener that executes a <i>zoom in</i> operation in the associated <code>MapControl</code>,
48
 *  having as center the point selected.</p>
49
 * 
50
 * <p>Listens a single click of any mouse's button.</p>
51
 * 
52
 * <p>The <i>zoom in</i> factor will depend on the maximum resolution of the <i>WCS</i> layers in
53
 *  the <code>MapControl</code>.</p>
54
 *
55
 * @author Nacho Brodin (brodin_ign@gva.es)
56
 */
57
public class WCSZoomPixelCursorListener implements PointListener {
58
	private static final GeometryManager 	geomManager 				= GeometryLocator.getGeometryManager();
59
	/**
60
	 * Object used to log messages for this listener.
61
	 */
62
	//private static Logger 	logger = Logger.getLogger(WCSZoomPixelCursorListener.class.getName());
63

  
64
	/**
65
	 * The image to display when the cursor is active.
66
	 */	
67
	private final Image img = IconThemeHelper.getImageIcon("view-previsualize-area").getImage();
68

  
69
	/**
70
	 * The cursor used to work with this tool listener.
71
	 * 
72
	 * @see #getCursor()
73
	 */ 
74
	private Cursor 			cur = Toolkit.getDefaultToolkit().createCustomCursor(	img,
75

  
76
	/**
77
	 * Reference to the <code>MapControl</code> object that uses.
78
	 */																					new Point(16, 16), "");
79
	private MapControl 		mapCtrl;
80

  
81
	/**
82
	 * <p>Creates a new <code>WCSZoomPixelCursorListener</code> object.</p>
83
	 * 
84
	 * @param mc the <code>MapControl</code> where be applied the changes
85
	 */
86
	public WCSZoomPixelCursorListener(MapControl mc) {
87
		this.mapCtrl = mc;
88
	}
89
	
90
	/*
91
	 * (non-Javadoc)
92
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
93
	 */
94
	public void point(PointEvent event) throws BehaviorException {
95
		Point2D pReal = mapCtrl.getMapContext().getViewPort().toMapPoint(event.getPoint());
96
		//Point imagePoint = new Point((int) event.getPoint().getX(), (int) event.getPoint().getY());
97
		ViewPort v = mapCtrl.getMapContext().getViewPort();
98

  
99
		FLayer[] actives = mapCtrl.getMapContext().getLayers().getActives();
100
		Envelope ext = null;
101

  
102
		try {
103
			ext = actives[0].getFullEnvelope();
104
		} catch (ReadException e) {
105
			throw new BehaviorException(e.getMessage());
106
		}
107

  
108
  		if(	ext != null ){
109

  
110
  	    	double w2 = v.getImageWidth()/2D;
111
  	    	double h2 = v.getImageHeight()/2D;
112
  	    	double wcOriginX = pReal.getX();
113
  	    	double wcOriginY = pReal.getY();
114

  
115
  	    	Point2D maxRes = ((FLyrWCS)actives[0]).getMaxResolution();
116
  	    	double wcDstMinX = wcOriginX-w2*maxRes.getX();
117
  	    	double wcDstMinY = wcOriginY-h2*maxRes.getY();
118
  	    	double wcDstWidth = w2*maxRes.getX()*2D;
119
  	    	double wcDstHeight = h2*maxRes.getY()*2D;
120

  
121
  	    	Envelope rect;
122
			try {
123
				rect = geomManager.createEnvelope(
124
						wcDstMinX, wcDstMinY, wcDstMinX + wcDstWidth, wcDstMinY - wcDstHeight, SUBTYPES.GEOM2D);
125
			} catch (CreateEnvelopeException e) {
126
				throw new BehaviorException(e.getMessage());
127
			}
128
  	       	mapCtrl.getMapContext().getViewPort().setEnvelope(rect);
129
  		}
130

  
131
	}
132

  
133
	/*
134
	 * (non-Javadoc)
135
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
136
	 */
137
	public Cursor getCursor() {
138
		return cur;
139
	}
140

  
141
	/*
142
	 * (non-Javadoc)
143
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
144
	 */
145
	public boolean cancelDrawing() {
146
		return false;
147
	}
148

  
149
	/*
150
	 * (non-Javadoc)
151
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
152
	 */
153
	public void pointDoubleClick(PointEvent event) throws BehaviorException {
154
	}
155

  
156
	/*
157
	 * (non-Javadoc)
158
	 * @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getImageCursor()
159
	 */
160
	public Image getImageCursor() {
161
		return img;
162
	}
163
}
0 164

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/toc/WCSPropsTocMenuEntry.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.wcs.app.wcsclient.gui.toc;
23

  
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
26
import org.gvsig.app.project.documents.view.toc.ITocItem;
27
import org.gvsig.fmap.mapcontext.layers.FLayer;
28
import org.gvsig.raster.wcs.app.wcsclient.gui.dialog.WCSPropsDialog;
29
import org.gvsig.raster.wcs.app.wcsclient.layer.FLyrWCS;
30

  
31

  
32
/**
33
 * Changes the connection properties.
34
 *
35
 * Cambia las propiedades de la conexi?n al servidor WCS.
36
 *
37
 * @author jaume - jaume.dominguez@iver.es
38
 */
39
public class WCSPropsTocMenuEntry extends AbstractTocContextMenuAction {
40

  
41
	public void execute(ITocItem item, FLayer[] selectedItems) {
42
       	WCSPropsDialog dialog = new WCSPropsDialog((FLyrWCS) selectedItems[0]);
43
       	PluginServices.getMDIManager().addWindow(dialog);
44
	}
45

  
46
	public String getText() {
47
		return PluginServices.getText(this, "wcs_properties");
48
	}
49

  
50
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
51
		return selectedItems.length == 1 && selectedItems[0].isAvailable();
52
	}
53

  
54
	public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
55
		if (selectedItems.length != 1) {
56
			return false;
57
		}
58
		return selectedItems[0] instanceof FLyrWCS;
59

  
60
	}
61

  
62
}
0 63

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/toc/WCSZoomPixelCursorTocMenuEntry.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.wcs.app.wcsclient.gui.toc;
23

  
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
26
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
27
import org.gvsig.app.project.documents.view.toc.ITocItem;
28
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener;
29
import org.gvsig.fmap.mapcontext.layers.FLayer;
30
import org.gvsig.fmap.mapcontrol.MapControl;
31
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
32
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior;
33
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior;
34
import org.gvsig.raster.wcs.app.wcsclient.layer.FLyrWCS;
35

  
36

  
37
/**
38
 * @author Nacho Brodin <nachobrodin@gmail.com>
39
 *
40
 * Entrada de men? para la activaci?n de la funcionalidad de zoom a un
41
 * pixel centrado en el cursor.
42
 */
43
public class WCSZoomPixelCursorTocMenuEntry extends
44
		AbstractTocContextMenuAction {
45

  
46
	public void execute(ITocItem item, FLayer[] selectedItems) {
47

  
48
		AbstractViewPanel vista = (AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
49
		MapControl mapCtrl = vista.getMapControl();
50

  
51
		if (!mapCtrl.hasTool("zoom_pixel_cursor")) {
52
			StatusBarListener sbl = new StatusBarListener(mapCtrl);
53

  
54
			WCSZoomPixelCursorListener zp = new WCSZoomPixelCursorListener(
55
					mapCtrl);
56
			mapCtrl.addBehavior("zoom_pixel_cursor", new Behavior[] {
57
					new PointBehavior(zp), new MouseMovementBehavior(sbl) });
58

  
59
		}
60

  
61
		mapCtrl.setTool("zoom_pixel_cursor");
62
	}
63

  
64
	public String getText() {
65
		return PluginServices.getText(this, "Zoom_pixel");
66
	}
67

  
68
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
69
		return selectedItems.length == 1 && selectedItems[0].isAvailable();
70
	}
71

  
72
	public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
73
		if (selectedItems.length != 1) {
74
			return false;
75
		}
76
		return selectedItems[0] instanceof FLyrWCS;
77

  
78
	}
79

  
80
}
0 81

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/toc/WCSZoomToPixelTocMenuEntry.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
package org.gvsig.raster.wcs.app.wcsclient.gui.toc;
24

  
25
import java.awt.event.ActionEvent;
26
import java.awt.geom.Point2D;
27

  
28
import javax.swing.JMenuItem;
29

  
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.app.project.documents.view.toc.TocMenuEntry;
32
import org.gvsig.app.project.documents.view.toc.gui.FPopupMenu;
33
import org.gvsig.fmap.geom.GeometryLocator;
34
import org.gvsig.fmap.geom.GeometryManager;
35
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
36
import org.gvsig.fmap.geom.primitive.Envelope;
37
import org.gvsig.fmap.mapcontext.ViewPort;
38
import org.gvsig.fmap.mapcontext.layers.FLayer;
39
import org.gvsig.raster.wcs.app.wcsclient.layer.FLyrWCS;
40

  
41

  
42
/**
43
 * This class implements the TOC meny entry to do a zoom to pixel. Zooming to a
44
 * pixel causes to change the view's zoom to fit in the coverage's native
45
 * resolution.
46
 *
47
 * Entrada de men? para la activaci?n de la funcionalidad de zoom a un pixel.
48
 *
49
 * @author Jaume - jaume.dominguez@iver.es
50
 *
51
 * @deprecated not used
52
 */
53
public class WCSZoomToPixelTocMenuEntry extends TocMenuEntry {
54
	public static final int ZOOM_TO_VIEW_CENTER = 0x2;
55
	private JMenuItem properties;
56
	FLayer lyr = null;
57
	public int zoomType = ZOOM_TO_VIEW_CENTER;
58

  
59
	public void initialize(FPopupMenu m) {
60
		super.initialize(m);
61

  
62
		if (isTocItemBranch()) {
63
			lyr = getNodeLayer();
64
    		// Opciones para capas raster
65
    		if ((lyr instanceof FLyrWCS)) {
66
    			properties = new JMenuItem(PluginServices.getText(this, "Zoom_pixel"));
67
    			getMenu().add( properties );
68
    			//properties.setFont(FPopupMenu.theFont);
69
    			getMenu().setEnabled(true);
70
    			properties.addActionListener(this);
71
     		}
72
		}
73
	}
74
	/**
75
	 * Calculates the zoom that fits the coverage native resolution.
76
	 *
77
	 * TODO fix the little loss of accuracy caused by a floating point issue
78
	 */
79
	public void actionPerformed(ActionEvent e) {
80
		//System.out.println("Zoom a un pixel");
81

  
82
    	ViewPort v = getMapContext().getViewPort();
83

  
84
    	double w2 = v.getImageWidth()/2D;
85
    	double h2 = v.getImageHeight()/2D;
86
    	double wcOriginCenterX = v.getExtent().getMinX()+((v.getExtent().getMaxX()-v.getExtent().getMinX())/2D);
87
    	double wcOriginCenterY = v.getExtent().getMinY()+((v.getExtent().getMaxY()-v.getExtent().getMinY())/2D);
88

  
89
    	Point2D maxRes = ((FLyrWCS) lyr).getMaxResolution();
90
    	//double wcDstMinX = wcOriginCenterX-w2*maxRes;
91
    	double wcDstMinX = wcOriginCenterX-w2*maxRes.getX();
92
    	//double wcDstMinY = wcOriginCenterY+h2*maxRes;
93
    	double wcDstMinY = wcOriginCenterY+h2*maxRes.getY();
94
    	//double wcDstWidth = w2*maxRes*2D;
95
    	double wcDstWidth = w2*maxRes.getX()*2D;
96
       	//double wcDstHeight = h2*maxRes*2D;
97
    	double wcDstHeight = h2*maxRes.getY()*2D;
98

  
99

  
100
    	GeometryManager geoMan = GeometryLocator.getGeometryManager();
101
		Envelope rAux = null;
102
		try {
103
			rAux = geoMan.createEnvelope(wcDstMinX, wcDstMinY, wcDstMinX
104
					+ wcDstWidth, wcDstMinY + wcDstHeight, SUBTYPES.GEOM2D);
105

  
106
    	} catch (Exception e1) {
107
			e1.printStackTrace();
108
		}
109
		getMapContext().getViewPort().setEnvelope(rAux);
110

  
111
	}
112
}
113

  
0 114

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/dialog/WCSPropsDialog.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.wcs.app.wcsclient.gui.dialog;
24

  
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27
import java.util.HashMap;
28

  
29
import javax.swing.JButton;
30
import javax.swing.JDialog;
31
import javax.swing.JOptionPane;
32
import javax.swing.JPanel;
33

  
34
import org.gvsig.andami.PluginServices;
35
import org.gvsig.andami.ui.mdiManager.IWindow;
36
import org.gvsig.andami.ui.mdiManager.WindowInfo;
37
import org.gvsig.app.gui.wizards.WizardListener;
38
import org.gvsig.app.gui.wizards.WizardListenerSupport;
39
import org.gvsig.fmap.dal.coverage.exception.ConnectException;
40
import org.gvsig.fmap.dal.exception.InitializeException;
41
import org.gvsig.fmap.mapcontext.MapContext;
42
import org.gvsig.fmap.mapcontext.exceptions.ConnectionErrorLayerException;
43
import org.gvsig.fmap.mapcontext.exceptions.DriverLayerException;
44
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException;
45
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
46
import org.gvsig.fmap.mapcontext.exceptions.NameLayerException;
47
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException;
48
import org.gvsig.fmap.mapcontext.exceptions.TypeLayerException;
49
import org.gvsig.fmap.mapcontext.exceptions.URLLayerException;
50
import org.gvsig.fmap.mapcontext.exceptions.UnsupportedVersionLayerException;
51
import org.gvsig.fmap.mapcontext.layers.FLayer;
52
import org.gvsig.fmap.mapcontext.layers.FLayers;
53
import org.gvsig.fmap.mapcontrol.MapControl;
54
import org.gvsig.raster.fmap.layers.FLyrRaster;
55
import org.gvsig.raster.swing.RasterSwingLibrary;
56
import org.gvsig.raster.util.CancelTaskImpl;
57
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.WCSParamsPanel;
58
import org.gvsig.raster.wcs.app.wcsclient.layer.FLyrWCS;
59
import org.gvsig.raster.wcs.io.WCSServerExplorer;
60
import org.slf4j.Logger;
61
import org.slf4j.LoggerFactory;
62

  
63

  
64
/**
65
 * The TOC WCS properties panel container.
66
 *
67
 * @author jaume - jaume.dominguez@iver.es
68
 *
69
 */
70
public class WCSPropsDialog extends JPanel implements IWindow {
71

  
72
	private static final long         serialVersionUID    = 1L;
73
	JDialog                           dlg                 = null;  
74
	private JPanel                    buttonsPanel        = null;
75
	private FLyrRaster                fLayer              = null;
76
	boolean                           applied             = false;;
77
	private WindowInfo                m_ViewInfo          = null;
78

  
79
	private JButton                   btnApply            = null;
80
	private JButton                   btnOk               = null;
81
	private JButton                   btnCancel           = null;
82
	private WCSParamsPanel            wcsParamsTabbedPane;
83
    private CommandListener           m_actionListener;
84
    private WCSServerExplorer         explorer            = null;
85
    private Logger                    logger              = LoggerFactory.getLogger(WCSPropsDialog.class);
86

  
87
    public WCSPropsDialog(FLayer layer) {
88
		super();
89
		if(layer instanceof FLyrRaster)
90
			initialize((FLyrRaster)layer);
91
	}
92

  
93

  
94
	private void initialize(FLyrRaster layer) {
95
		setLayout(null);
96

  
97
        setFLayer(layer);
98
        wcsParamsTabbedPane = getParamsPanel(((FLyrWCS) layer).getProperties());
99
        wcsParamsTabbedPane.addWizardListener(new WizardListener() {
100
			public void wizardStateChanged(boolean finishable) {
101
				getBtnOk().setEnabled(finishable);
102
				getBtnApply().setEnabled(finishable);
103
			}
104

  
105
			public void error(Exception e) {
106
			}
107

  
108
        })  ;
109
        this.add(wcsParamsTabbedPane);
110
        this.add(getButtonsPanel(), null);
111

  
112
	}
113

  
114

  
115
	public void setFLayer(FLyrRaster f) {
116
		fLayer = f;
117
	}
118

  
119
	/**
120
	 * With getParamsPanel we have access to the map config TabbedPane.
121
	 * If this panel doesn't exist yet (which can occur when an existing project is
122
	 * recovered) it is been automatically constructed by connecting to the server,
123
	 * reloading the necessary data, filling up the content and setting the selected
124
	 * values that were selected when the projet was saved.
125
	 *
126
	 *
127
	 * Since a connection to the server is needed when rebuiliding the panel, this
128
	 * causes a delay for the panel's showing up or a nullPointer error if there is
129
	 * no path to the server.
130
	 *
131
	 *
132
	 * Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n
133
	 * del mapa. Si este panel todav?a no existe (como puede ser cuando
134
	 * recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando
135
	 * al servidor, recuperando los datos necesarios, rellenando el contenido y
136
	 * dejando seleccionados los valores que estaban seleccionados cuando se
137
	 * guarda el proyecto.
138
	 *
139
	 *
140
	 * Como para reconstruirse requiere una conexi?n con el servidor esto causa
141
	 * un retardo en la aparici?n en el toc o un error de nullPointer si no
142
	 * hay conexi?n hasta el servidor.
143
	 *
144
	 *
145
	 * @return WCSParamsPanel
146
	 */
147
	public WCSParamsPanel getParamsPanel(HashMap info) {
148
	    if (info != null) {
149
	    	try {
150
	    		if(explorer == null) {
151
					explorer = ((FLyrWCS)fLayer).getExplorer();
152
					
153
					try {
154
			    		explorer.connect(new CancelTaskImpl());
155
					} catch (ConnectException e) {
156
						RasterSwingLibrary.messageBoxError("The connection cannot be established", this, e);
157
						return null;
158
					} 
159
	    		}
160
	    	} catch (Exception e) {
161
	    		explorer = null;
162
	    		JOptionPane.showMessageDialog(null, "error_comunicacion_servidor", "Error", JOptionPane.ERROR_MESSAGE);
163
	    	}
164
	    	try {
165

  
166
				WCSParamsPanel toc = new WCSParamsPanel();
167
				toc.setVisible(true);
168
				toc.setListenerSupport(new WizardListenerSupport());
169
				toc.setWizardData(explorer);
170

  
171
				toc.getLayerPanel().getLstCoverages().setListData(explorer.getCoverageList());
172

  
173
				String coverageName = (String) info.get("name");
174
				int index = toc.getLayerPanel().getCoverageIndex( coverageName );
175
				if (index != -1) {
176
					toc.getLayerPanel().getLstCoverages().setSelectedIndex(index);
177
				}
178

  
179
				toc.refreshData(((FLyrWCS)fLayer).getParameters());
180

  
181
				index = toc.getFormatsPanel().getSRSIndex((String) info.get("crs") );
182
				if (index != -1) {
183
					toc.getFormatsPanel().getLstCRSs().setSelectedIndex(index);
184
				}
185
				index = toc.getFormatsPanel().getFormatIndex((String) info.get("format"));
186
				if (index != -1) {
187
					toc.getFormatsPanel().getLstFormats().setSelectedIndex(index);
188
				}
189
				String time = (String) info.get("time");
190
				if (time != null && !time.equals("")) {
191
					toc.getTimePanel().getLstSelectedTimes().setListData(time.split(","));
192
				}
193
				String parameter = (String) info.get("parameter");
194
				if (parameter != null && !parameter.equals("")){
195
					String[] s = parameter.split("=");
196
					String pName = s[0];
197

  
198
					String regexDouble = "-?[0-9]+(\\.[0-9]+)?";
199
					String regexInterval = regexDouble+"/"+regexDouble;
200
					String regexIntervalList = regexInterval+"(,"+regexInterval+")*";
201
					if (s[1].matches(regexInterval)){
202
						// Single Interval
203
						toc.getParameterPanel().getJScrollPane5().setVisible(false);
204
						toc.getParameterPanel().getSingleParamValuesList().setEnabled(false);
205

  
206

  
207
					} else if (s[1].matches(regexIntervalList)){
208
						// Multiple Interval
209

  
210
					} else {
211
						// Single values
212
						toc.getParameterPanel().getJScrollPane5().setVisible(true);
213
						toc.getParameterPanel().getSingleParamValuesList().setEnabled(true);
214

  
215
						String[] pVals = s[1].split(",");
216
						index = toc.getParameterPanel().getParamIndex(pName);
217
						toc.getParameterPanel().getCmbParam().setSelectedIndex(index);
218
						//toc.refreshParamValues( coverageName );
219
						int[] indexes = new int[pVals.length];
220
						for (int i = 0; i < pVals.length; i++) {
221
							indexes[i] = toc.getParameterPanel().getValueIndex(pVals[i]);
222
						}
223

  
224
						toc.getParameterPanel().getSingleParamValuesList().setSelectedIndices(indexes);
225
					}
226
				}
227
				toc.refreshInfo();
228
				return toc;
229
			} catch (Exception e) {
230
				JOptionPane.showMessageDialog(null, "servidor_wcs_no_responde", "Error", JOptionPane.ERROR_MESSAGE);
231
				e.printStackTrace();
232
			}
233
	    }
234
	    return null;
235
	}
236

  
237
	public JPanel getButtonsPanel() {
238
		if (buttonsPanel == null) {
239
			m_actionListener = new CommandListener(this);
240
			buttonsPanel = new JPanel();
241
	        buttonsPanel.setBounds(5, wcsParamsTabbedPane.getHeight(), 471, 40);
242
			buttonsPanel.setLayout(null);
243
			buttonsPanel.setName("buttonPanel");
244

  
245
	        buttonsPanel.add(getBtnOk(), null);
246
	        buttonsPanel.add(getBtnApply(), null);
247
	        buttonsPanel.add(getBtnCancel(), null);
248
		}
249
		return buttonsPanel;
250
	}
251

  
252
	public JButton getBtnOk() {
253
		if (btnOk == null) {
254
	        btnOk = new JButton("ok");
255
	        btnOk.setText(PluginServices.getText(this,"ok"));
256
	        btnOk.setActionCommand("OK");
257
	        btnOk.addActionListener(m_actionListener);
258
	        btnOk.setBounds(367, 9, 90, 25);
259
		}
260
		return btnOk;
261
	}
262

  
263
	public JButton getBtnApply() {
264
		if (btnApply == null) {
265
	        btnApply = new JButton("apply");
266
	        btnApply.setText(PluginServices.getText(this,"apply"));
267
	        btnApply.setEnabled(false);
268
	        btnApply.setActionCommand("APPLY");
269
	        btnApply.addActionListener(m_actionListener);
270
	        btnApply.setBounds(267, 9, 90, 25);
271
		}
272
		return btnApply;
273
	}
274

  
275
	public JButton getBtnCancel() {
276
		if (btnCancel == null) {
277
	        btnCancel = new JButton("cancel");
278
	        btnCancel.setText(PluginServices.getText(this,"cancel"));
279
	        btnCancel.setActionCommand("CANCEL");
280
	        btnCancel.addActionListener(m_actionListener);
281
	        btnCancel.setBounds(137, 9, 90, 25);
282
		}
283
		return btnCancel;
284
	}
285

  
286
	private class CommandListener implements ActionListener {
287

  
288
		/**
289
		 * Creates a new ComandosListener object.
290
		 *
291
		 * @param lg DOCUMENT ME!
292
		 */
293
		public CommandListener(WCSPropsDialog tp) {
294
			//m_tp = tp;
295
		}
296

  
297
		/* (non-Javadoc)
298
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
299
		 */
300
		public void actionPerformed(ActionEvent e) {
301
			if (e.getActionCommand() == "CANCEL") {
302
				close();
303
			} else {
304
				((FLyrWCS) fLayer).getParameters().setFormat(wcsParamsTabbedPane.getFormat());
305
				try {
306
					((FLyrWCS) fLayer).getParameters().setSRS(wcsParamsTabbedPane.getSRS());
307
					((FLyrWCS) fLayer).getParameters().setCoverageName(wcsParamsTabbedPane.getLayerPanel().getSelectedCoverageName());
308

  
309
					//fLayer = wcsParamsTabbedPane.getLayer();
310
					FLayers parent = ((FLayer)fLayer).getParentLayer();
311

  
312
					MapControl mapCtrl = null;
313

  
314
					IWindow[] w = PluginServices.getMDIManager().getAllWindows();
315
					for (int i = 0; i < w.length; i++) {
316
						if (w[i] instanceof org.gvsig.app.project.documents.view.gui.AbstractViewPanel) {
317
							MapContext mapContext = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl().getMapContext();
318
							if(mapContext == fLayer.getMapContext())
319
								mapCtrl = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl();
320
						}
321
					} 
322

  
323
					if (parent != null) {
324
						FLayer layer = wcsParamsTabbedPane.getLayer();
325
						if(layer == null)
326
							return;
327
						mapCtrl.getMapContext().getLayers().
328
						replaceLayer(fLayer.getName(), layer);
329
					} else {
330
						mapCtrl.getMapContext().getLayers().replaceLayer(fLayer.getName(), wcsParamsTabbedPane.getLayer());
331
					}
332
					//mapCtrl.getMapContext().getLayers().addLayer( fLayer );
333
					mapCtrl.getMapContext().invalidate();
334
					applied = true;
335
					getBtnApply().setEnabled(!applied);
336
					
337
					if (e.getActionCommand() == "OK") {
338
						close();
339
					}
340
				} catch (ConnectionErrorLayerException e1) {
341
					logger.info("", e1);
342
				} catch (DriverLayerException e1) {
343
					logger.info("", e1);
344
				} catch (LegendLayerException e1) {
345
					logger.info("", e1);
346
				} catch (NameLayerException e1) {
347
					logger.info("", e1);
348
				} catch (ProjectionLayerException e1) {
349
					logger.info("", e1);
350
				} catch (TypeLayerException e1) {
351
					logger.info("", e1);
352
				} catch (UnsupportedVersionLayerException e1) {
353
					logger.info("", e1);
354
				} catch (URLLayerException e1) {
355
					logger.info("", e1);
356
				} catch (LoadLayerException e1) {
357
					logger.info("", e1);
358
				} catch (InitializeException e1) {
359
					logger.info("", e1);
360
				}
361
			}
362
		}
363
	}
364
    /**
365
     * Merge two FLayers in one
366
     * @param group1
367
     * @param group2
368
     * @return
369
     */
370
    @SuppressWarnings("unused")
371
	private FLayers mergeFLayers(FLayers group1, FLayers group2) {
372
    	//FLayers agrupation = new FLayers(group1.getFMap(), group1.getParentLayer());
373
    	FLayer layer;
374
    	for(int i = 0; i < group2.getLayersCount(); i++) {
375
    		layer = group2.getLayer( i );
376
    		if(group1.getLayer( layer.getName()) == null ) {
377
    			group1.addLayer( layer );
378
    		}
379
    	}
380

  
381
    	return group1;
382
    }
383

  
384

  
385

  
386
	public WindowInfo getWindowInfo() {
387
		if (m_ViewInfo==null){
388
			m_ViewInfo=new WindowInfo(WindowInfo.MODALDIALOG);
389
			m_ViewInfo.setTitle(PluginServices.getText(this,"fit_WCS_layer"));
390
	        m_ViewInfo.setWidth(wcsParamsTabbedPane.getWidth()+10);
391
	        m_ViewInfo.setHeight(wcsParamsTabbedPane.getHeight()+40);
392

  
393
		}
394
		return m_ViewInfo;
395
	}
396

  
397
	public void close() {
398
		PluginServices.getMDIManager().closeWindow(this);
399
	}
400

  
401

  
402
	public Object getWindowProfile() {
403
		return WindowInfo.DIALOG_PROFILE;
404
	}
405

  
406
}  //  @jve:decl-index=0:visual-constraint="10,10"
0 407

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/panel/FormatPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.wcs.app.wcsclient.gui.panel;
24

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

  
29
import javax.swing.JCheckBox;
30
import javax.swing.JComboBox;
31
import javax.swing.JList;
32
import javax.swing.JPanel;
33
import javax.swing.JScrollPane;
34

  
35
import org.gvsig.andami.PluginServices;
36

  
37

  
38
/**
39
 * Format Panel
40
 * @author Nacho Brodin (nachobrodin@gmail.com)
41
 */
42
public class FormatPanel extends JPanel {
43
	private static final long serialVersionUID            = 1L;
44
	private JPanel            jPanel2                     = null;
45
	private JPanel            jPanel3                     = null;
46
	private JPanel            jPanel4                     = null;
47
	private JScrollPane       jScrollPane1                = null;
48
	private JScrollPane       jScrollPane2                = null;
49
	private JList             lstCRSs                     = null;
50
	private JList             lstFormats                  = null;
51
	private JComboBox         cmbInterpolationMethods     = null;
52
	private JCheckBox         chkUseInterpolationMethod   = null;
53
	private WCSParamsPanel    parent                      = null;
54
	
55
	public FormatPanel() {
56
		init();
57
	}
58
	
59
	/**
60
	 * Sets the parent panel
61
	 * @param parent
62
	 */
63
	public void setWCSParamsPanel(WCSParamsPanel parent) {
64
		this.parent = parent;
65
	}
66
	
67
	public void init() {
68
		setLayout(new GridBagLayout());
69
		
70
		GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
71
		gridBagConstraints1.fill = GridBagConstraints.BOTH;
72
		gridBagConstraints1.anchor = GridBagConstraints.CENTER;
73
		gridBagConstraints1.weightx = 1.0;
74
		gridBagConstraints1.weighty = 1.0;
75
		gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2);
76
		gridBagConstraints1.gridy = 1;
77
		add(getJPanel2(), gridBagConstraints1);
78
		
79
		gridBagConstraints1.gridy = 0;
80
		add(getJPanel3(), gridBagConstraints1);
81
	}
82
	
83
	/**
84
	 * This method initializes jScrollPane2
85
	 *
86
	 * @return javax.swing.JScrollPane
87
	 */
88
	private JScrollPane getJScrollPane2() {
89
		if (jScrollPane2 == null) {
90
			jScrollPane2 = new JScrollPane();
91
			jScrollPane2.setViewportView(getLstCRSs());
92
		}
93
		return jScrollPane2;
94
	}
95
	
96
	/**
97
	 * This method initializes lstCRSs
98
	 *
99
	 * @return javax.swing.JList
100
	 */
101
	public JList getLstCRSs() {
102
		if (lstCRSs == null) {
103
			lstCRSs = new JList();
104
			lstCRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
105
			lstCRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
106
				public void valueChanged(javax.swing.event.ListSelectionEvent e) {
107
					parent.fireWizardComplete(parent.isCorrectlyConfigured());
108
				}
109
			});
110
		}
111
		return lstCRSs;
112
	}
113
	
114
	/**
115
	 * This method initializes jPanel2
116
	 *
117
	 * @return javax.swing.JPanel
118
	 */
119
	private JPanel getJPanel2() {
120
		if (jPanel2 == null) {
121
			jPanel2 = new JPanel(new BorderLayout());
122
			jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(
123
					null, PluginServices.getText(this, "seleccionar_CRS"),
124
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
125
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
126
			jPanel2.add(getJScrollPane2(), BorderLayout.CENTER);
127
		}
128
		return jPanel2;
129
	}
130
	
131
	/**
132
	 * This method initializes jScrollPane1
133
	 *
134
	 * @return javax.swing.JScrollPane
135
	 */
136
	private JScrollPane getJScrollPane1() {
137
		if (jScrollPane1 == null) {
138
			jScrollPane1 = new JScrollPane();
139
			jScrollPane1.setViewportView(getLstFormats());
140
		}
141
		return jScrollPane1;
142
	}
143
	
144
	/**
145
	 * This method initializes lstFormats
146
	 *
147
	 * @return javax.swing.JList
148
	 */
149
	public JList getLstFormats() {
150
		if (lstFormats == null) {
151
			lstFormats = new JList();
152
			lstFormats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
153
			lstFormats.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
154
				public void valueChanged(javax.swing.event.ListSelectionEvent e) {
155
					parent.fireWizardComplete(parent.isCorrectlyConfigured());
156
				}
157
			});
158
		}
159
		return lstFormats;
160
	}
161
	
162
	/**
163
	 * This method initializes jPanel3
164
	 *
165
	 * @return javax.swing.JPanel
166
	 */
167
	private JPanel getJPanel3() {
168
		if (jPanel3 == null) {
169

  
170
			jPanel3 = new JPanel(new GridBagLayout());
171
			
172
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
173
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
174
			gridBagConstraints1.anchor = GridBagConstraints.CENTER;
175
			gridBagConstraints1.weightx = 1.0;
176
			gridBagConstraints1.weighty = 1.0;
177
			gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2);
178
			
179
			jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
180
					null, PluginServices.getText(this, "seleccionar_formato"),
181
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
182
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
183
			jPanel3.add(getJScrollPane1(), gridBagConstraints1);
184

  
185
			gridBagConstraints1.gridx = 1;
186
			jPanel3.add(getJPanel4(), gridBagConstraints1);
187
		}
188
		return jPanel3;
189
	}
190
	
191
	/**
192
	 * This method initializes jPanel3
193
	 *
194
	 * @return javax.swing.JPanel
195
	 */
196
	private JPanel getJPanel4() {
197
		if (jPanel4 == null) {
198
			jPanel4 = new JPanel(new GridBagLayout());
199
			
200
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
201
			gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
202
			gridBagConstraints1.weightx = 1.0;
203
			gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2);
204

  
205
			jPanel4.add(getCmbInterpolationMethods(), gridBagConstraints1);
206
			gridBagConstraints1.gridy = 1;
207
			jPanel4.add(getChkUseInterpolationMethod(), gridBagConstraints1);
208
			
209
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
210
			gridBagConstraints1.weighty = 1.0;
211
			gridBagConstraints1.gridy = 2;
212
			jPanel4.add(new JPanel(), gridBagConstraints1);
213
		}
214
		return jPanel4;
215
	}
216
	
217
	/**
218
	 * This method initializes jComboBox
219
	 *
220
	 * @return javax.swing.JComboBox
221
	 */
222
	public JComboBox getCmbInterpolationMethods() {
223
		if (cmbInterpolationMethods == null) {
224
			cmbInterpolationMethods = new JComboBox();
225
			cmbInterpolationMethods.setEnabled(false);
226
			cmbInterpolationMethods.setEditable(false);
227
		}
228
		return cmbInterpolationMethods;
229
	}
230
	
231
	/**
232
	 * This method initializes jCheckBox
233
	 *
234
	 * @return javax.swing.JCheckBox
235
	 */
236
	public JCheckBox getChkUseInterpolationMethod() {
237
		if (chkUseInterpolationMethod == null) {
238
			chkUseInterpolationMethod = new JCheckBox();
239
			chkUseInterpolationMethod.setText(PluginServices.getText(this, "use_interpolation_method"));
240
			chkUseInterpolationMethod.setSelected(false);
241
			chkUseInterpolationMethod.setEnabled(false);
242
			chkUseInterpolationMethod.addItemListener(new java.awt.event.ItemListener() {
243
				public void itemStateChanged(java.awt.event.ItemEvent e) {
244
					cmbInterpolationMethods.setEnabled(chkUseInterpolationMethod.isSelected());
245
				}
246
			});
247
		}
248
		return chkUseInterpolationMethod;
249
	}
250
	
251
	/**
252
	 * Returns the index of the CRS within the CRS list.
253
	 * @param crs
254
	 * @return The CRS's index if it exists, -1 if it not exists.
255
	 */
256
	public int getSRSIndex(String crs) {
257
		for (int i = 0; i < getLstCRSs().getModel().getSize(); i++){
258
			if (crs.equals(getLstCRSs().getModel().getElementAt(i))) {
259
				return i;
260
			}
261
		}
262
		return -1;
263
	}
264
	
265
	/**
266
	 * Returns the index of the format within the formats list.
267
	 * @return The format's index if it exists, -1 if it not exists.
268
	 */
269
	public int getFormatIndex(String format) {
270
		for (int i = 0; i < getLstFormats().getModel().getSize(); i++){
271
			if (format.equals(getLstFormats().getModel().getElementAt(i))) {
272
				return i;
273
			}
274
		}
275
		return -1;
276
	}
277
}
278

  
0 279

  
org.gvsig.raster.wcs/tags/org.gvsig.raster.wcs-2.2.102/org.gvsig.raster.wcs.app.wcsclient/src/main/java/org/gvsig/raster/wcs/app/wcsclient/gui/panel/LayerList.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.wcs.app.wcsclient.gui.panel;
24

  
25
import java.awt.Component;
26
import java.awt.Dimension;
27

  
28
import javax.swing.DefaultListCellRenderer;
29
import javax.swing.JList;
30

  
31
import org.gvsig.gui.beans.controls.dnd.JDnDList;
32
import org.gvsig.raster.wcs.io.WCSLayerNode;
33

  
34

  
35
/**
36
 * Class implementing a JList component adapted to the WCSLayerNode
37
 * needs (use it as a JList with drag'n'drop capabilities).
38
 * 
39
 * @author jaume dominguez faus - jaume.dominguez@iver.es
40
 *
41
 */
42
public class LayerList extends JDnDList {
43
	private static final long serialVersionUID = 1L;
44
	public boolean showLayerNames = false;
45
	private int count = 0; 
46
	
47
	public LayerList() {
48
		super();
49
		setCellRenderer(new MyRenderer());
50
	}
51
	
52
	private class MyRenderer extends DefaultListCellRenderer {
53
		private static final long serialVersionUID = 1L;
54

  
55
		public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
56
			super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
57
			if (value instanceof WCSLayerNode){
58
				WCSLayerNode layer = (WCSLayerNode) value;
59
                
60
                if (!showLayerNames) {
61
                	if (layer.getName() != null || layer.getName() == "") {
62
                		String text = layer.toString();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff