svn-gvsig-desktop / tags / v1_0_2_Build_905 / libraries / libCq CMS for java.old / src / org / cresques / px / PxLayerList.java @ 10767
History | View | Annotate | Download (2.14 KB)
1 | 2809 | nacho | /*
|
---|---|---|---|
2 | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
||
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | */
|
||
24 | 2 | luisw | package org.cresques.px; |
25 | |||
26 | import java.util.Iterator; |
||
27 | |||
28 | 2809 | nacho | |
29 | 2 | luisw | public class PxLayerList extends PxObjList { |
30 | 2809 | nacho | PxLayer current = null;
|
31 | |||
32 | public PxLayerList() {
|
||
33 | super();
|
||
34 | } |
||
35 | |||
36 | public void add(PxLayer layer) { |
||
37 | extent.add(layer.extent); |
||
38 | super.add(layer);
|
||
39 | current = layer; |
||
40 | } |
||
41 | |||
42 | public PxLayer getByName(String lName) { |
||
43 | Iterator iter = iterator();
|
||
44 | PxLayer layer; |
||
45 | |||
46 | while (iter.hasNext()) {
|
||
47 | layer = (PxLayer) iter.next(); |
||
48 | |||
49 | if (layer.getName().compareTo(lName) == 0) { |
||
50 | return layer;
|
||
51 | } |
||
52 | } |
||
53 | |||
54 | return null; |
||
55 | } |
||
56 | |||
57 | public boolean isCurrent(PxLayer layer) { |
||
58 | return current.getId() == layer.getId();
|
||
59 | } |
||
60 | |||
61 | public PxLayer getCurrent() {
|
||
62 | return current;
|
||
63 | } |
||
64 | |||
65 | public void setCurrent(PxLayer layer) { |
||
66 | current = layer; |
||
67 | |||
68 | if (!current.isVisible()) {
|
||
69 | current.setVisible(true);
|
||
70 | } |
||
71 | } |
||
72 | |||
73 | public Extent getExtent() {
|
||
74 | Extent ext = new Extent();
|
||
75 | PxLayer layer; |
||
76 | Iterator iter = iterator();
|
||
77 | |||
78 | while (iter.hasNext()) {
|
||
79 | layer = (PxLayer) iter.next(); |
||
80 | |||
81 | if (layer.isVisible()) {
|
||
82 | ext.add(layer.extent); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | return ext;
|
||
87 | } |
||
88 | } |