Revision 45240

View differences:

tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/test/java/org/gvsig/fmap/mapcontrol/tools/AreaListenerTest.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontrol.tools;
25

  
26
import java.awt.geom.Point2D;
27

  
28
import org.cresques.cts.IProjection;
29
import org.gvsig.fmap.crs.CRSFactory;
30
import org.gvsig.fmap.mapcontext.MapContext;
31
import org.gvsig.fmap.mapcontext.ViewPort;
32
import org.gvsig.fmap.mapcontrol.MapControl;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34

  
35

  
36
public class AreaListenerTest extends AbstractLibraryAutoInitTestCase {
37
	private IProjection projectionUTM = CRSFactory.getCRS("EPSG:23030");
38
	private IProjection projectionGeo = CRSFactory.getCRS("EPSG:4230");
39
		
40
	@Override
41
	protected void doSetUp() throws Exception {
42
		// Nothing to do	
43
	}
44

  
45
	public void test1() {
46
		AreaListenerImpl areaListenerUTM=new AreaListenerImpl(newMapControlUTM());
47
		AreaListenerImpl areaListenerGeo=new AreaListenerImpl(newMapControlGeo());
48
		Double[] xsUTM=new Double[] {new Double(731292),new Double(731901),new Double(730138)};
49
		Double[] ysUTM=new Double[] {new Double(4351223),new Double(4350768),new Double(4349232)};
50
		double areaUTM=areaListenerUTM.returnCoordsArea(xsUTM,ysUTM,new Point2D.Double(730138,4349232));
51
		Double[] xsGeo=new Double[] {new Double(-0.31888183),new Double(-0.31173131),new Double(-0.33268401)};
52
		Double[] ysGeo=new Double[] {new Double(39.27871741),new Double(39.27464327),new Double(39.26117368)};
53
		double areaGeo=areaListenerGeo.returnGeoCArea(xsGeo,ysGeo,new Point2D.Double(-0.33268401,39.26117368));
54
		assertTrue("Area UTM igual a Geo",areaUTM<(areaGeo+1000)&& areaUTM>(areaGeo-1000));
55
	}
56
	private MapControl newMapControlUTM() {
57
		ViewPort vp = new ViewPort(projectionUTM);
58
		MapControl mc=new MapControl();
59
		mc.setMapContext(new MapContext(vp));
60
		return mc;
61
	}
62
	private MapControl newMapControlGeo() {
63
		ViewPort vp = new ViewPort(projectionGeo);
64
		MapControl mc=new MapControl();
65
		mc.setMapContext(new MapContext(vp));
66
		return mc;
67
	}
68
}
0 69

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/app/gui/JComboBoxUnits.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.gui;
25

  
26
import org.gvsig.fmap.mapcontext.MapContext;
27
import org.gvsig.i18n.Messages;
28
import org.gvsig.utils.swing.JComboBox;
29

  
30

  
31
/**
32
 * <p>Class representing a JComboBox with the measure units handled by the application.
33
 * It takes values from Attributes.NAMES and Attributes.CHANGE static fields. So, to
34
 * add more measure units, you must edit Attributes class and change will be automatically
35
 * reflected in the combo box.</p>
36
 *
37
 * <p>The internatiolanization of the field is automatically handled by the system</p>
38
 * @author jaume dominguez faus - jaume.dominguez@iver.es
39
 */
40
public class JComboBoxUnits extends JComboBox {
41
	private static final long serialVersionUID = 8015263853737441433L;
42

  
43
	/**
44
	 * Creates a new instance of JUnitComboBox including "pixel" units and
45
	 * setting them as automatically pre-selected.
46
	 */
47
	public JComboBoxUnits() {
48
		this(true);
49
	}
50

  
51
	/**
52
	 *
53
	 * Creates a new instance of JUnitComboBox. If includePixel is true
54
	 * then pixel units are included in the list and they are automatically
55
	 * pre-selected. Otherwise, meters are preselected.
56
	 *
57
	 */
58
	public JComboBoxUnits(boolean includePixel) {
59
		super();
60
		String[] names=MapContext.getDistanceNames();
61

  
62
		for (int i = 0; i < names.length; i++) {
63
			super.addItem(Messages.getText(names[i]));
64
		}
65
		if (includePixel) {
66
			super.addItem(Messages.getText("_Pixels"));
67
			setSelectedItem(Messages.getText("_Pixels"));
68
		} else {
69
			setSelectedIndex(1);
70
		}
71
		setMaximumRowCount(10);
72
	}
73

  
74

  
75
	/**
76
	 * Returns the conversion factor from the <b>unit selected in the combo box</b>
77
	 * to <b>meters</b> or <b>0</b> if pixels have been selected as the size unit.
78
	 * @return
79
	 */
80
	public double getUnitConversionFactor() {
81
			double unitFactor;
82
			try {
83
				unitFactor = MapContext.getDistanceTrans2Meter()[getSelectedIndex()];
84
			} catch (ArrayIndexOutOfBoundsException aioobEx) { //jijiji
85
				unitFactor = 0; // which represents size in pixel
86
			}
87
			return unitFactor;
88

  
89
	}
90

  
91
	/**
92
	 * the use of this method is not allowed in this combo box.
93
	 * @deprecated
94
	 */
95
	public void addItem(Object anObject) {
96
		throw new Error("Operation not allowed");
97
	}
98

  
99
	/**
100
	 * the use of this method is not allowed for this combo box.
101
	 * @deprecated
102
	 */
103
	public void removeAllItems() {
104
		throw new Error("Operation not allowed");
105
	}
106

  
107
	public int getSelectedUnitIndex() {
108
		int i = getSelectedIndex();
109
		if (i>MapContext.getDistanceNames().length-1)
110
			return -1;
111
		else return i;
112
	}
113

  
114
	public void setSelectedUnitIndex(int unitIndex) {
115
		if (unitIndex == -1) {
116
			setSelectedIndex(getItemCount()-1);
117
		} else {
118
			setSelectedIndex(unitIndex);
119
		}
120
	}
121

  
122

  
123

  
124
}
0 125

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* gvSIG. Geographic Information System of the Valencian Government
25
*
26
* Copyright (C) 2007-2008 Infrastructures and Transports Department
27
* of the Valencian Government (CIT)
28
* 
29
* This program is free software; you can redistribute it and/or
30
* modify it under the terms of the GNU General Public License
31
* as published by the Free Software Foundation; either version 2
32
* of the License, or (at your option) any later version.
33
* 
34
* This program is distributed in the hope that it will be useful,
35
* but WITHOUT ANY WARRANTY; without even the implied warranty of
36
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
* GNU General Public License for more details.
38
* 
39
* You should have received a copy of the GNU General Public License
40
* along with this program; if not, write to the Free Software
41
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
42
* MA  02110-1301, USA.
43
* 
44
*/
45

  
46
/*
47
* AUTHORS (In addition to CIT):
48
* 2009 {Iver T.I.}   {Task}
49
*/
50
 
51
package org.gvsig.fmap.mapcontrol;
52

  
53
import org.gvsig.tools.exception.BaseException;
54

  
55
/**
56
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
57
 */
58
public class MapControlException extends BaseException {
59
	private static final long serialVersionUID = 981894833703125550L;
60

  
61
	/**
62
     * @see BaseException#BaseException(String, String, long)
63
     */
64
    public MapControlException(String message, String key, long code) {
65
        super(message, key, code);
66
    }
67

  
68
    /**
69
     * @see BaseException#BaseException(String, Throwable, String, long)
70
     */
71
    public MapControlException(String message, Throwable cause, String key,
72
            long code) {
73
        super(message, cause, key, code);
74
    }
75
}
76

  
77

  
0 78

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/LayersTreeModel.java
1
package org.gvsig.fmap.mapcontrol;
2

  
3
import java.util.ArrayList;
4
import java.util.Arrays;
5
import java.util.Iterator;
6
import java.util.List;
7
import javax.swing.event.TreeModelEvent;
8
import javax.swing.event.TreeModelListener;
9
import javax.swing.tree.TreeModel;
10
import javax.swing.tree.TreePath;
11
import org.apache.commons.lang3.BooleanUtils;
12
import org.gvsig.fmap.mapcontext.layers.FLayer;
13
import org.gvsig.fmap.mapcontext.layers.FLayers;
14
import org.gvsig.tools.evaluator.Evaluator;
15
import org.gvsig.tools.evaluator.EvaluatorData;
16

  
17
public class LayersTreeModel implements TreeModel {
18

  
19
    private final List<TreeModelListener> listeners = new ArrayList();
20
    protected FLayers layers;
21
    private Evaluator filter;
22
    private MyEvaluatorData datafilter;
23

  
24
    private static class MyEvaluatorData implements EvaluatorData {
25

  
26
        public FLayer layer = null;
27

  
28
        @Override
29
        public Object getDataValue(String name) {
30
            if (name.equalsIgnoreCase("layer")) {
31
                return layer;
32
            }
33
            return null;
34
        }
35

  
36
        @Override
37
        public Object getContextValue(String name) {
38
            if (name.equalsIgnoreCase("layer")) {
39
                return layer;
40
            }
41
            return null;
42
        }
43

  
44
        @Override
45
        public Iterator getDataValues() {
46
            return Arrays.asList(new FLayer[]{this.layer}).iterator();
47
        }
48

  
49
        @Override
50
        public Iterator getDataNames() {
51
            return Arrays.asList(new String[]{"layer"}).iterator();
52
        }
53

  
54
        @Override
55
        public boolean hasDataValue(String name) {
56
            if (name.equalsIgnoreCase("layer")) {
57
                return true;
58
            }
59
            return false;
60
        }
61

  
62
        @Override
63
        public boolean hasContextValue(String name) {
64
            if (name.equalsIgnoreCase("layer")) {
65
                return true;
66
            }
67
            return false;
68
        }
69

  
70
    }
71

  
72
    public LayersTreeModel(FLayers layers) {
73
        this.layers = layers;
74
    }
75

  
76
    public void setFilter(Evaluator filter) {
77
        this.filter = filter;
78
        this.datafilter = new MyEvaluatorData();
79
    }
80

  
81
    @Override
82
    public Object getRoot() {
83
        return layers;
84
    }
85

  
86
    @Override
87
    public Object getChild(Object parent, int index) {
88
        if (!(parent instanceof FLayers)) {
89
            return null;
90
        }
91
        return ((FLayers) parent).getLayer(index);
92
    }
93

  
94
    @Override
95
    public int getChildCount(Object parent) {
96
        if (!(parent instanceof FLayers)) {
97
            return 0;
98
        }
99
        if (this.filter == null) {
100
            return ((FLayers) parent).getLayersCount();
101
        }
102
        int count = 0;
103
        for (int i = 0; i < ((FLayers) parent).getLayersCount(); i++) {
104
            FLayer layer = ((FLayers) parent).getLayer(i);
105
            try {
106
                if (!(layer instanceof FLayers)) {
107
                    this.datafilter.layer = layer;
108
                    if (BooleanUtils.isTrue((Boolean) this.filter.evaluate(this.datafilter))) {
109
                        count++;
110
                    }
111
                }
112
            } catch (Exception ex) {
113
                // Do nothing, skyp this layer on error.
114
            }
115
        }
116
        return count;
117

  
118
    }
119

  
120
    @Override
121
    public boolean isLeaf(Object node) {
122
        return !(node instanceof FLayers);
123
    }
124

  
125
    @Override
126
    public int getIndexOfChild(Object parent, Object child) {
127
        if (this.filter == null) {
128
            for (int i = 0; i < ((FLayers) parent).getLayersCount(); i++) {
129
                FLayer layer = ((FLayers) parent).getLayer(i);
130
                if (child == layer) {
131
                    return i;
132
                }
133
            }
134
            return -1;
135
        }
136
        int count = 0;
137
        for (int i = 0; i < ((FLayers) parent).getLayersCount(); i++) {
138
            FLayer layer = ((FLayers) parent).getLayer(i);
139
            try {
140
                if (!(layer instanceof FLayers)) {
141
                    this.datafilter.layer = layer;
142
                    if (BooleanUtils.isTrue((Boolean) this.filter.evaluate(this.datafilter))) {
143
                        if (child == layer) {
144
                            return count;
145
                        }
146
                        count++;
147
                    }
148
                }
149
            } catch (Exception ex) {
150
                // Do nothing, skyp this layer on error.
151
            }
152
        }
153
        return -1;
154

  
155
    }
156

  
157
    @Override
158
    public void valueForPathChanged(TreePath path, Object value) {
159
    }
160

  
161
    @Override
162
    public void addTreeModelListener(TreeModelListener listener) {
163
        listeners.add(listener);
164
    }
165

  
166
    @Override
167
    public void removeTreeModelListener(TreeModelListener listener) {
168
        listeners.remove(listener);
169
    }
170

  
171
    public void reload() {
172
        TreeModelEvent event = new TreeModelEvent(this, new TreePath(this.layers));
173
        Iterator<TreeModelListener> iterator = listeners.iterator();
174
        TreeModelListener listener;
175
        while (iterator.hasNext()) {
176
            listener = iterator.next();
177
            listener.treeStructureChanged(event);
178
        }
179
    }
180

  
181
}
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/PrimitivesDrawer.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* gvSIG. Geographic Information System of the Valencian Government
25
*
26
* Copyright (C) 2007-2008 Infrastructures and Transports Department
27
* of the Valencian Government (CIT)
28
* 
29
* This program is free software; you can redistribute it and/or
30
* modify it under the terms of the GNU General Public License
31
* as published by the Free Software Foundation; either version 2
32
* of the License, or (at your option) any later version.
33
* 
34
* This program is distributed in the hope that it will be useful,
35
* but WITHOUT ANY WARRANTY; without even the implied warranty of
36
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
* GNU General Public License for more details.
38
* 
39
* You should have received a copy of the GNU General Public License
40
* along with this program; if not, write to the Free Software
41
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
42
* MA  02110-1301, USA.
43
* 
44
*/
45

  
46
/*
47
* AUTHORS (In addition to CIT):
48
* 2009 {Iver T.I.}   {Task}
49
*/
50
 
51
package org.gvsig.fmap.mapcontrol;
52

  
53
import java.awt.Color;
54
import java.awt.Graphics;
55

  
56
/**
57
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
58
 */
59
public interface PrimitivesDrawer {
60
	
61
	/**
62
	 * This method is used to start a drawing process that needs to 
63
	 * be synchronized.
64
	 * @param obj
65
	 * The object that locks the resource.
66
	 * @throws InterruptedException
67
	 */
68
	public void startDrawing(Object obj) throws InterruptedException;
69
	
70
	/**
71
	 * This method is used to finish a drawing process that needs to 
72
	 * be synchronized. 
73
	 * @param obj
74
	 * The object that has locked the resource.
75
	 */
76
	public void stopDrawing(Object obj);
77
	
78
	/**
79
	 * This method sets the <code>Graphics</code> where the 
80
	 * <code>Drawer</code> has to draw all the objects. 
81
	 * @param graphics
82
	 * The component where the new objects has to be drawn. 
83
	 */
84
	public void setGraphics(Graphics graphics);
85
	
86
	/**
87
	 * Sets the color that is used to draw the objects that don't 
88
	 * have a symbol.
89
	 * @param color
90
	 * The color to use on the drawing operations.
91
	 */
92
	public void setColor(Color color);
93
		
94
	/**
95
	 * It draws a rectangle on the map using the color 
96
	 * specified using the {@link #setColor(Color)} method. 
97
	 * @param x
98
	 * The minimum X coordinate.
99
	 * @param y
100
	 * The minimum Y coordinate.
101
	 * @param width
102
	 * The rectangle width.
103
	 * @param height
104
	 * The rectangle height.
105
	 */
106
	public void drawRect(int x, int y, int width, int height);
107
		
108
	/**
109
	 * It fills a rectangle on the map using the color 
110
	 * specified using the {@link #setColor(Color)} method. 
111
	 * @param x
112
	 * The minimum X coordinate.
113
	 * @param y
114
	 * The minimum Y coordinate.
115
	 * @param width
116
	 * The rectangle width.
117
	 * @param height
118
	 * The rectangle height.
119
	 */
120
	public void fillRect(int x, int y, int width, int height);
121
	
122
	public void drawOval(int i, int j, int sizePixels, int sizePixels2);
123

  
124
	public void drawLine(int x1, int y1, int x3, int y12);
125
}
0 126

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlLocator.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
 
25
package org.gvsig.fmap.mapcontrol;
26

  
27
import org.gvsig.propertypage.PropertiesPageManager;
28
import org.gvsig.tools.locator.AbstractLocator;
29
import org.gvsig.tools.locator.Locator;
30
import org.gvsig.tools.locator.LocatorException;
31
import org.gvsig.tools.util.ToolsUtilLocator;
32

  
33
/**
34
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
35
 */
36
public class MapControlLocator extends AbstractLocator {
37
	private static final String LOCATOR_NAME = "MapContolLocator";
38
	
39
	/**
40
	 * MapControlManager name used by the locator to access the instance
41
	 */
42
	public static final String MAPCONTROL_MANAGER_NAME = "MapControlManager";
43
	private static final String MAPCONTROL_MANAGER_DESCRIPTION = "MapControlManager of gvSIG";
44

  
45
	public static final String EDITING_NOTIFICATION_MANAGER_NAME = "EditingNotificationManager";
46
	private static final String EDITING_NOTIFICATION_MANAGER_DESCRIPTION = "EditingNotificationManager of gvSIG";
47

  
48
	public static final String PROPERTIES_PAGE_MANAGER_NAME = "PropertiesPageManager";
49
	private static final String PROPERTIES_PAGE_MANAGER_DESCRIPTION = "PropertiesPage manager of gvSIG";
50

  
51
        /**
52
	 * Unique instance.
53
	 */
54
	private static final MapControlLocator instance = new MapControlLocator();
55
	
56
	/* (non-Javadoc)
57
	 * @see org.gvsig.tools.locator.Locator#getLocatorName()
58
	 */
59
	public String getLocatorName() {
60
		return LOCATOR_NAME;
61
	}
62
	
63
	/**
64
	 * Return a reference to {@link MapControlManager}.
65
	 *
66
	 * @return a reference to MapControlManager
67
	 * @throws LocatorException
68
	 *             if there is no access to the class or the class cannot be
69
	 *             instantiated
70
	 * @see Locator#get(String)
71
	 */
72
	public static MapControlManager getMapControlManager() throws LocatorException {
73
		return (MapControlManager) getInstance().get(MAPCONTROL_MANAGER_NAME);
74
	}
75
	
76
	/**
77
	 * Return the singleton instance.
78
	 *
79
	 * @return the singleton instance
80
	 */
81
	public static MapControlLocator getInstance() {
82
		return instance;
83
	}
84
	
85
	/**
86
	 * Registers the Class implementing the {@link MapControlManager} interface.
87
	 *
88
	 * @param clazz
89
	 *            implementing the MapControlManager interface
90
	 */
91
	public static void registerMapControlManager(Class clazz) {
92
		getInstance().register(MAPCONTROL_MANAGER_NAME, 
93
				MAPCONTROL_MANAGER_DESCRIPTION,
94
				clazz);
95
	}
96
        
97
        public static PropertiesPageManager getPropertiesPageManager() {
98
            return ToolsUtilLocator.getPropertiesPageManager();
99
        }
100

  
101
}
102

  
103

  
0 104

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/MapControlLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2009 {DiSiD Technologies}  {Create Library class to initialize the MapControls library}
27
 */
28
package org.gvsig.fmap.mapcontrol;
29

  
30

  
31
import org.gvsig.fmap.IconThemeHelper;
32
import org.gvsig.fmap.mapcontext.MapContextLibrary;
33
import org.gvsig.fmap.mapcontrol.swing.pickercontroller.impl.EnvelopePickerControllerImpl;
34
import org.gvsig.fmap.mapcontrol.swing.pickercontroller.impl.ScalePickerControllerImpl;
35
import org.gvsig.tools.ToolsLocator;
36
import org.gvsig.tools.i18n.I18nManager;
37
import org.gvsig.tools.library.AbstractLibrary;
38
import org.gvsig.tools.library.LibraryException;
39

  
40
/**
41
 * Initialization of the MapControls library.
42
 * 
43
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
44
 */
45
public class MapControlLibrary extends AbstractLibrary {
46

  
47
    @Override
48
    public void doRegistration() {
49
        registerAsAPI(MapControlLibrary.class);
50
        require(MapContextLibrary.class);
51
    }
52

  
53
	@Override
54
	protected void doInitialize() throws LibraryException {
55
		I18nManager i18nManager = ToolsLocator.getI18nManager();
56
		i18nManager.addResourceFamily(
57
				"org.gvsig.fmap.mapcontrol.i18n.text",
58
				MapControlLibrary.class.getClassLoader(),
59
				MapControlLibrary.class.getClass().getName()
60
                );
61
	}
62
	
63
	@Override
64
	protected void doPostInitialize() throws LibraryException {
65
	   	IconThemeHelper.registerIcon("cursor", "cursor-crux", this);
66
	   	IconThemeHelper.registerIcon("cursor", "cursor-info-by-point",this);
67
	   	IconThemeHelper.registerIcon("cursor", "cursor-pan", this);
68
	   	IconThemeHelper.registerIcon("cursor", "cursor-query-area", this);
69
	   	IconThemeHelper.registerIcon("cursor", "cursor-select-by-point", this);
70
	   	IconThemeHelper.registerIcon("cursor", "cursor-select-by-polygon", this);
71
	   	IconThemeHelper.registerIcon("cursor", "cursor-zoom-in", this);
72
	   	IconThemeHelper.registerIcon("cursor", "cursor-zoom-out", this);
73

  
74
	   	IconThemeHelper.registerIcon("layer", "layer-icon", this);
75
	   	IconThemeHelper.registerIcon("layer", "layer-icon-group", this);
76
	   	IconThemeHelper.registerIcon("layer", "layer-icon-vectorial", this);
77
                
78
                EnvelopePickerControllerImpl.selfRegister();
79
                ScalePickerControllerImpl.selfRegister();
80
	   	
81
	}
82
}
0 83

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/CompoundLayersTreeModel.java
1
package org.gvsig.fmap.mapcontrol;
2

  
3
import org.gvsig.fmap.mapcontext.layers.FLayers;
4

  
5

  
6
public class CompoundLayersTreeModel extends LayersTreeModel {
7

  
8
        public CompoundLayersTreeModel() {
9
            super(new FLayers());
10
        }
11
        
12
        public void addLayers(FLayers layers) {
13
            this.layers.add(layers);
14
        }
15
}
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/LayersDynObjectSetComponent.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontrol.swing.dynobject;
25

  
26
import org.gvsig.fmap.mapcontext.MapContext;
27
import org.gvsig.tools.dispose.Disposable;
28
import org.gvsig.tools.swing.api.Component;
29

  
30
/**
31
 * Interface for components to show information of a list of layers.
32
 * 
33
 * @author gvSIG Team
34
 * @version $Id$
35
 */
36
public interface LayersDynObjectSetComponent extends Component, Disposable {
37

  
38
	public void setMapContext(MapContext mapContext);
39
}
0 40

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/DefaultLayersDynObjectSetComponent.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10
 *
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.mapcontrol.swing.dynobject.impl;
24

  
25
import java.awt.BorderLayout;
26
import java.awt.Dimension;
27
import java.awt.event.ActionEvent;
28
import java.util.Iterator;
29
import java.util.Map;
30

  
31
import javax.swing.AbstractAction;
32
import javax.swing.Action;
33
import javax.swing.JComponent;
34
import javax.swing.JOptionPane;
35
import javax.swing.JPanel;
36
import javax.swing.JScrollPane;
37
import javax.swing.JSplitPane;
38
import javax.swing.JTree;
39
import javax.swing.event.TreeSelectionEvent;
40
import javax.swing.event.TreeSelectionListener;
41
import javax.swing.tree.DefaultMutableTreeNode;
42
import javax.swing.tree.DefaultTreeModel;
43
import javax.swing.tree.MutableTreeNode;
44
import javax.swing.tree.TreeNode;
45
import javax.swing.tree.TreePath;
46
import javax.swing.tree.TreeSelectionModel;
47

  
48
import org.gvsig.fmap.geom.DataTypes;
49
import org.gvsig.fmap.geom.Geometry;
50
import org.gvsig.fmap.mapcontext.MapContext;
51
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
52
import org.gvsig.tools.ToolsLocator;
53
import org.gvsig.tools.dataTypes.DataTypesManager;
54
import org.gvsig.tools.dynform.AbortActionException;
55
import org.gvsig.tools.dynform.DynFormLocator;
56
import org.gvsig.tools.dynform.DynFormManager;
57
import org.gvsig.tools.dynform.JDynFormField;
58
import org.gvsig.tools.dynform.JDynFormSet;
59
import org.gvsig.tools.dynform.JDynFormSet.JDynFormSetListener;
60
import org.gvsig.tools.dynobject.DynObject;
61
import org.gvsig.tools.dynobject.DynObjectSet;
62
import org.gvsig.tools.exception.BaseException;
63
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
65

  
66
/**
67
 * @author gvSIG Team
68
 * @version $Id$
69
 *
70
 */
71
public class DefaultLayersDynObjectSetComponent extends JPanel implements
72
        LayersDynObjectSetComponent, TreeSelectionListener, JDynFormSetListener {
73

  
74
    private static final long serialVersionUID = 5864674721657215264L;
75

  
76
    private static final Logger LOG = LoggerFactory
77
            .getLogger(DefaultLayersDynObjectSetComponent.class);
78

  
79
    private final LayersDynObjectSetComponentModel model;
80

  
81
    private JDynFormSet component;
82

  
83
    private JTree layersTree;
84
    private JPanel contentPanel;
85

  
86
    private final boolean writable;
87

  
88
    private DefaultMutableTreeNode topNode;
89
    private MutableTreeNode previousSelection = null;
90

  
91
    private MapContext mapContext = null;
92

  
93
    /**
94
     * Creates a new {@link DefaultLayersDynObjectSetComponent} with the given
95
     * information for a list of layers.
96
     */
97
    public DefaultLayersDynObjectSetComponent(
98
            Map<String, DynObjectSet> layerName2InfoByPoint) {
99
        this(layerName2InfoByPoint, true);
100
    }
101

  
102
    /**
103
     * @param isDoubleBuffered
104
     */
105
    public DefaultLayersDynObjectSetComponent(
106
            Map<String, DynObjectSet> layerName2InfoByPoint,
107
            boolean writable) {
108
        super(new BorderLayout());
109
        this.writable = writable;
110
        model = new LayersDynObjectSetComponentModel(layerName2InfoByPoint);
111
        initializeUI();
112
    }
113

  
114
    private void initializeUI() {
115
        addLayerTree();
116
    }
117

  
118
    private void addLayerTree() {
119
        topNode = new DefaultMutableTreeNode("");
120
        layersTree = new JTree(topNode);
121
        layersTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
122

  
123
        //layersTree.setShowsRootHandles(true);
124
        layersTree.addTreeSelectionListener(this);
125
        createTreeModel();
126

  
127
        JScrollPane scroll = new JScrollPane(layersTree);
128
        scroll.setPreferredSize(new Dimension(200, 200));
129

  
130
        contentPanel = new JPanel();
131
        contentPanel.setLayout(new BorderLayout());
132

  
133
        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
134
                scroll, contentPanel);
135
        splitPane.setOneTouchExpandable(true);
136
        splitPane.setDividerLocation(170);
137

  
138
        //Provide minimum sizes for the two components in the split pane
139
        Dimension minimumSize = new Dimension(100, 150);
140
        scroll.setMinimumSize(minimumSize);
141

  
142
        add(splitPane, BorderLayout.CENTER);
143

  
144
        for (int i = 0; i < layersTree.getRowCount(); i++) {
145
            layersTree.expandRow(i);
146
        }
147
        layersTree.setRootVisible(false);
148

  
149
        if (topNode.getChildCount() > 0 && topNode.getFirstChild().getChildCount() > 0) {
150
            layersTree.setSelectionPath(new TreePath(((DefaultTreeModel) layersTree.getModel()).getPathToRoot(topNode.getFirstChild().getChildAt(0))));
151
        }
152
    }
153

  
154
    private void createTreeModel() {
155
        for (int i = 0; i < model.getSize(); i++) {
156
            MutableTreeNode newLayer = new DefaultMutableTreeNode(
157
                    model.getElementAt(i),
158
                    true);
159

  
160
            DynObjectSet dynObjects = model.getLayerInfoByPoint((String) model.getElementAt(i));
161
            Iterator it;
162
            try {
163
                it = dynObjects.iterator();
164
                int j = 0;
165
                while (it.hasNext()) {
166
                    DynObject dynObject = (DynObject) it.next();
167
                    MutableTreeNode newDynObject = new DefaultMutableTreeNode(
168
                            concatString(dynObject.toString(), 20),
169
                            false);
170
                    newLayer.insert(newDynObject, j);
171
                    j++;
172
                }
173
            } catch (BaseException e) {
174
                LOG.error("Error getting the DynObjects of "
175
                        + "the DynObjectSet: " + dynObjects, e);
176
            }
177
            topNode.add(newLayer);
178

  
179
        }
180
    }
181

  
182
    private String concatString(String cadena, int i) {
183
        if (cadena.length() > i && i > 3) {
184
            String newCadena = cadena.substring(0, i - 3);
185
            cadena = newCadena + "...";
186
        }
187
        return cadena;
188
    }
189

  
190
    private void setCurrentLayerInfoByPoint(String layerName) {
191
        JDynFormSet newComponent = null;
192
        try {
193
            DynFormManager dynFormManager = DynFormLocator.getDynFormManager();
194

  
195
            DynObjectSet dynObjectSet = model.getLayerInfoByPoint(layerName);
196

  
197
            if (dynObjectSet != null && dynObjectSet.getSize() > 0) {
198
                newComponent = dynFormManager.createJDynFormSet(null, dynObjectSet);
199
                newComponent.setReadOnly(!this.writable);
200
                newComponent.setAllowDelete(false);
201
                newComponent.setAllowNew(false);
202
                newComponent.setAllowSearch(false);
203
                newComponent.setAllowUpdate(false);
204
                if (this.mapContext != null) {
205
                    DataTypesManager dataManager = ToolsLocator.getDataTypesManager();
206
                    newComponent.addActionToPopupMenu(
207
                            dataManager.get(DataTypes.GEOMETRY),
208
                            "Center in current view",
209
                            new CenterGeometryInMapContext(this.mapContext)
210
                    );
211
                }
212
                removeCurrentDynObjectSetComponent();
213
                component = newComponent;
214
                component.addListener(this);
215
                JComponent comp = component.asJComponent();
216
                contentPanel.add(comp, BorderLayout.CENTER);
217
            }
218
            revalidate();
219
            repaint();
220
        } catch(Exception ex) {
221
            LOG.warn("Can't show information.", ex);
222
        }
223
    }
224

  
225
    public JComponent asJComponent() {
226
        return this;
227
    }
228

  
229
    public void dispose() {
230
        removeCurrentDynObjectSetComponent();
231
        model.dispose();
232
    }
233

  
234
    private void removeCurrentDynObjectSetComponent() {
235
        if (component != null) {
236
            remove(component.asJComponent());
237
            //  component.dispose();
238
            contentPanel.removeAll();
239
            contentPanel.repaint();
240
        }
241
    }
242

  
243
    public void valueChanged(TreeSelectionEvent e) {
244
        TreePath newPath = e.getNewLeadSelectionPath();
245
        TreePath oldPath = e.getOldLeadSelectionPath();
246

  
247
        if (!newPath.equals(oldPath)) {
248
            DefaultMutableTreeNode aux
249
                    = (DefaultMutableTreeNode) layersTree.getLastSelectedPathComponent();
250

  
251
            if (layersTree.getSelectionPath() != null) {
252
                if (aux.isLeaf()) { // A Feature node is selected
253
                    String layerName = "";
254
                    if (previousSelection == null
255
                            || !aux.getParent().equals(previousSelection.getParent())) {
256
                        layerName = aux.getParent().toString();
257
                        setCurrentLayerInfoByPoint(layerName);
258
                    }
259
                    int childIndex = aux.getParent().getIndex(aux);
260
                    if (childIndex != -1 && component!=null) {
261
                            component.setCurrentIndex(childIndex);
262
                    }
263
                    previousSelection = aux;
264
                }
265
            }
266
        }
267
    }
268

  
269
    public void message(String arg0) {
270
        // Do nothing
271
    }
272

  
273
    public void formClose() {
274
        this.setVisible(false);
275
    }
276

  
277
    public void formMessage(String arg0) {
278
        // Do nothing
279
    }
280

  
281
    public void formMovedTo(int arg0) {
282
        DefaultMutableTreeNode aux
283
                = (DefaultMutableTreeNode) layersTree.getLastSelectedPathComponent();
284
        TreeNode parent = aux.getParent();
285
        TreeNode selectNode = parent.getChildAt(arg0);
286

  
287
        TreePath path = new TreePath(((DefaultTreeModel) layersTree.getModel()).getPathToRoot(selectNode));
288
        layersTree.setSelectionPath(path);
289
    }
290

  
291
    public void setMapContext(MapContext mapContext) {
292
        this.mapContext = mapContext;
293
    }
294

  
295
    public void formBeforeSave(JDynFormSet jdfs) throws AbortActionException {
296
    }
297

  
298
    public void formBeforeNew(JDynFormSet jdfs) throws AbortActionException {
299
    }
300

  
301
    public void formBeforeDelete(JDynFormSet jdfs) throws AbortActionException {
302
    }
303

  
304
    public void formBeforeSearch(JDynFormSet jdfs) throws AbortActionException {
305
    }
306

  
307
    public void formAfterSave(JDynFormSet jdfs) {
308
    }
309

  
310
    public void formAfterNew(JDynFormSet jdfs) {
311
    }
312

  
313
    public void formAfterDelete(JDynFormSet jdfs) {
314
    }
315

  
316
    public void formAfterSearch(JDynFormSet jdfs) {
317
    }
318

  
319
    @Override
320
    public void formBeforeCancelNew(JDynFormSet dynformSet) throws AbortActionException {
321
    }
322

  
323
    @Override
324
    public void formAfterCancelNew(JDynFormSet dynformSet) throws AbortActionException {
325
    }
326

  
327
    public class CenterGeometryInMapContext extends AbstractAction implements Action {
328

  
329
        private MapContext mapContext;
330

  
331
        public CenterGeometryInMapContext(MapContext mapContext) {
332
            super("Center in the current view");
333
            this.mapContext = mapContext;
334
            this.putValue(Action.SHORT_DESCRIPTION, "Center geometry in the current view");
335
            this.putValue(Action.LONG_DESCRIPTION, "Center geometry in the current view");
336
        }
337

  
338
        public void actionPerformed(ActionEvent arg0) {
339
            if (mapContext == null) {
340
                return;
341
            }
342
            Object source = null;
343
            try {
344
                source = arg0.getSource();
345
                JDynFormField field = (JDynFormField) source;
346
                Geometry geom = (Geometry) field.getValue();
347
                if (geom == null) {
348
                    JOptionPane.showMessageDialog(component.asJComponent(), "The geometri is not valid. Can't center the view in it.", "Warning", JOptionPane.INFORMATION_MESSAGE);
349
                    return;
350
                }
351
                mapContext.getViewPort().setEnvelope(geom.getEnvelope());
352
                mapContext.invalidate();
353
            } catch (Exception ex) {
354
                LOG.warn("Can't center view in the geometry (source=" + source.toString() + ").", ex);
355
            }
356
        }
357

  
358
    }
359

  
360
}
0 361

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/impl/LayersDynObjectSetComponentModel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontrol.swing.dynobject.impl;
25

  
26
import java.util.Iterator;
27
import java.util.Map;
28
import java.util.Set;
29

  
30
import javax.swing.AbstractListModel;
31

  
32
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent;
33
import org.gvsig.tools.dispose.Disposable;
34
import org.gvsig.tools.dynobject.DynObjectSet;
35

  
36
/**
37
 * Model for a {@link LayersDynObjectSetComponent}.
38
 * 
39
 * @author gvSIG Team
40
 * @version $Id$
41
 */
42
public class LayersDynObjectSetComponentModel extends AbstractListModel
43
    implements Disposable {
44

  
45
    private static final long serialVersionUID = -7978388308830573063L;
46

  
47
    private final Map<String, DynObjectSet> layerName2InfoByPoint;
48
    private final String[] layerNames;
49

  
50
    public LayersDynObjectSetComponentModel(
51
        Map<String, DynObjectSet> layerName2InfoByPoint) {
52
        this.layerName2InfoByPoint = layerName2InfoByPoint;
53
        Set<String> keyset = layerName2InfoByPoint.keySet();
54
        layerNames = keyset.toArray(new String[keyset.size()]);
55
    }
56

  
57
    public String[] getLayerNames() {
58
        Set<String> keyset = layerName2InfoByPoint.keySet();
59
        return keyset.toArray(new String[keyset.size()]);
60
    }
61

  
62
    public DynObjectSet getLayerInfoByPoint(String layerName) {
63
        return layerName2InfoByPoint.get(layerName);
64
    }
65

  
66
    public int getSize() {
67
        return layerName2InfoByPoint.size();
68
    }
69

  
70
    public Object getElementAt(int index) {
71
        return layerNames[index];
72
    }
73

  
74
    public void dispose() {
75
        for (Iterator<DynObjectSet> iterator =
76
            layerName2InfoByPoint.values().iterator(); iterator.hasNext();) {
77
            iterator.next().dispose();
78
        }
79
        layerName2InfoByPoint.clear();
80
    }
81
}
0 82

  
tags/org.gvsig.desktop-2.0.290/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/swing/dynobject/DynObjectViewer.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
* AUTHORS (In addition to CIT):
26
* 2009 IVER T.I. S.A.   {{Task}}
27
*/
28

  
29
package org.gvsig.fmap.mapcontrol.swing.dynobject;
30

  
31
import java.awt.Color;
32
import java.awt.GridBagConstraints;
33
import java.awt.GridBagLayout;
34

  
35
import javax.swing.JLabel;
36
import javax.swing.JPanel;
37
import javax.swing.JTextField;
38

  
39
import org.cresques.cts.IProjection;
40
import org.gvsig.i18n.Messages;
41
import org.gvsig.tools.dynobject.DynClass;
42
import org.gvsig.tools.dynobject.DynField;
43
import org.gvsig.tools.dynobject.DynObject;
44

  
45

  
46
/**
47
 * @deprecated use JDynForm
48
 * @author jjdelcerro
49
 */
50
public class DynObjectViewer extends JPanel {
51

  
52
	/**
53
	 *
54
	 */
55
	private static final long serialVersionUID = -5277036770491043233L;
56
	private GridBagConstraints paramsListLabelConstraint;
57
	private GridBagConstraints paramsListValueConstraint;
58
	private GridBagConstraints paramsListFillConstraint;
59

  
60
	public DynObjectViewer() {
61
		super();
62
		this.intialize();
63
	}
64

  
65
	private void intialize() {
66
		this.setLayout(new GridBagLayout());
67

  
68
		paramsListLabelConstraint = new GridBagConstraints();
69
		paramsListValueConstraint = new GridBagConstraints();
70
		paramsListFillConstraint = new GridBagConstraints();
71

  
72
		paramsListLabelConstraint.ipadx = 3;
73
		paramsListLabelConstraint.ipady = 3;
74
		paramsListLabelConstraint.anchor = GridBagConstraints.FIRST_LINE_START;
75
		paramsListLabelConstraint.gridwidth = GridBagConstraints.RELATIVE;
76
		paramsListLabelConstraint.fill = GridBagConstraints.HORIZONTAL;
77
		paramsListLabelConstraint.weightx = 0.5;
78

  
79
		paramsListValueConstraint.ipadx = 3;
80
		paramsListValueConstraint.ipady = 3;
81
		paramsListValueConstraint.anchor = GridBagConstraints.FIRST_LINE_END;
82
		paramsListValueConstraint.gridwidth = GridBagConstraints.REMAINDER;
83
		paramsListValueConstraint.fill = GridBagConstraints.HORIZONTAL;
84
		paramsListValueConstraint.weightx = 0.5;
85

  
86
		paramsListFillConstraint.ipadx = 3;
87
		paramsListFillConstraint.ipady = 3;
88
		paramsListFillConstraint.anchor = GridBagConstraints.FIRST_LINE_END;
89
		paramsListFillConstraint.gridwidth = GridBagConstraints.REMAINDER;
90
		paramsListFillConstraint.fill = GridBagConstraints.BOTH;
91
		paramsListFillConstraint.weightx = 1;
92
		paramsListFillConstraint.weighty = 1;
93
	}
94

  
95
	private String getLocalizedText(String txt) {
96
		try {
97
			return Messages.getText(txt);
98
		} catch (Exception e) {
99
			return txt;
100
		}
101
	}
102

  
103
	public void load(DynObject dynObj) {
104
		this.removeAll();
105

  
106
		if (dynObj == null) {
107
			this.doLayout();
108
			return;
109
		}
110
		DynClass dynClass = dynObj.getDynClass();
111

  
112
		JTextField label;
113
		JTextField text;
114
		Object value;
115
		String strValue;
116

  
117
		//		label = new JLabel();
118
		//		label.setText(getLocalizedText("parameter"));
119
		//		label.setBackground(Color.LIGHT_GRAY);
120
		//		this.add(label, paramsListLabelConstraint);
121

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff