root / branches / v2_0_0_prep / libraries / libFMap_controls / src / org / gvsig / fmap / mapcontrol / swing / dynobject / impl / LayersDynObjectSetComponentModel.java @ 38564
History | View | Annotate | Download (2.57 KB)
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.fmap.mapcontrol.swing.dynobject.impl; |
23 |
|
24 |
import java.util.Iterator; |
25 |
import java.util.Map; |
26 |
import java.util.Set; |
27 |
|
28 |
import javax.swing.AbstractListModel; |
29 |
|
30 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.LayersDynObjectSetComponent; |
31 |
import org.gvsig.tools.dispose.Disposable; |
32 |
import org.gvsig.tools.dynobject.DynObjectSet; |
33 |
|
34 |
/**
|
35 |
* Model for a {@link LayersDynObjectSetComponent}.
|
36 |
*
|
37 |
* @author gvSIG Team
|
38 |
* @version $Id$
|
39 |
*/
|
40 |
public class LayersDynObjectSetComponentModel extends AbstractListModel |
41 |
implements Disposable {
|
42 |
|
43 |
private static final long serialVersionUID = -7978388308830573063L; |
44 |
|
45 |
private final Map<String, DynObjectSet> layerName2InfoByPoint; |
46 |
private final String[] layerNames; |
47 |
|
48 |
public LayersDynObjectSetComponentModel(
|
49 |
Map<String, DynObjectSet> layerName2InfoByPoint) { |
50 |
this.layerName2InfoByPoint = layerName2InfoByPoint;
|
51 |
Set<String> keyset = layerName2InfoByPoint.keySet(); |
52 |
layerNames = keyset.toArray(new String[keyset.size()]); |
53 |
} |
54 |
|
55 |
public String[] getLayerNames() { |
56 |
Set<String> keyset = layerName2InfoByPoint.keySet(); |
57 |
return keyset.toArray(new String[keyset.size()]); |
58 |
} |
59 |
|
60 |
public DynObjectSet getLayerInfoByPoint(String layerName) { |
61 |
return layerName2InfoByPoint.get(layerName);
|
62 |
} |
63 |
|
64 |
public int getSize() { |
65 |
return layerName2InfoByPoint.size();
|
66 |
} |
67 |
|
68 |
public Object getElementAt(int index) { |
69 |
return layerNames[index];
|
70 |
} |
71 |
|
72 |
public void dispose() { |
73 |
for (Iterator<DynObjectSet> iterator = |
74 |
layerName2InfoByPoint.values().iterator(); iterator.hasNext();) { |
75 |
iterator.next().dispose(); |
76 |
} |
77 |
layerName2InfoByPoint.clear(); |
78 |
} |
79 |
} |