gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.fmap / src / main / java / org / gvsig / raster / fmap / layers / DynObjectSetRasterInfo.java @ 1738
History | View | Annotate | Download (3.72 KB)
1 | 238 | nbrodin | /* 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.fmap.layers; |
||
23 | |||
24 | import org.gvsig.fmap.dal.feature.FeatureSet; |
||
25 | 349 | cordinyana | import org.gvsig.tools.ToolsLocator; |
26 | 238 | nbrodin | import org.gvsig.tools.dispose.DisposableIterator; |
27 | import org.gvsig.tools.dynobject.DynClass; |
||
28 | import org.gvsig.tools.dynobject.DynField; |
||
29 | import org.gvsig.tools.dynobject.DynObject; |
||
30 | import org.gvsig.tools.dynobject.DynObjectSet; |
||
31 | import org.gvsig.tools.dynobject.impl.DefaultDynObject; |
||
32 | import org.gvsig.tools.exception.BaseException; |
||
33 | import org.gvsig.tools.observer.Observable; |
||
34 | import org.gvsig.tools.observer.Observer; |
||
35 | import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable; |
||
36 | import org.gvsig.tools.visitor.Visitor; |
||
37 | |||
38 | /**
|
||
39 | * {@link DynObject} implementation to facade of a {@link FeatureSet} and allow
|
||
40 | * to be used as a {@link DynObjectSet}.
|
||
41 | *
|
||
42 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
43 | * @version $Id$
|
||
44 | */
|
||
45 | public class DynObjectSetRasterInfo extends BaseWeakReferencingObservable |
||
46 | implements DynObjectSet, Observer { |
||
47 | private DynObjectIteratorRasterInfo ite = null; |
||
48 | private DynClass dynClass = null; |
||
49 | |||
50 | /**
|
||
51 | * Creates a new facade over a given info, with fast dynobject
|
||
52 | * iteration.
|
||
53 | */
|
||
54 | public DynObjectSetRasterInfo() {
|
||
55 | 349 | cordinyana | dynClass = |
56 | ToolsLocator.getDynObjectManager().createDynClass( |
||
57 | "RasterInfoByPoint", "Raster", "Raster point information"); |
||
58 | 238 | nbrodin | } |
59 | |||
60 | /**
|
||
61 | * Adds a field to the DynObject
|
||
62 | * @param name
|
||
63 | * @param object
|
||
64 | * @param order
|
||
65 | */
|
||
66 | public void addField(String name, Object object, int order) { |
||
67 | DynField field = dynClass.addDynField(name); |
||
68 | field.setDefaultFieldValue(object); |
||
69 | if(order != -1) |
||
70 | field.setOrder(order); |
||
71 | DefaultDynObject dynObject = new DefaultDynObject(dynClass);
|
||
72 | ite = new DynObjectIteratorRasterInfo(dynObject);
|
||
73 | } |
||
74 | |||
75 | public void dispose() { |
||
76 | |||
77 | } |
||
78 | |||
79 | public void accept(final Visitor visitor, long firstValueIndex) throws BaseException { |
||
80 | while(ite.hasNext()) {
|
||
81 | visitor.visit(ite.next()); |
||
82 | } |
||
83 | } |
||
84 | |||
85 | public void accept(final Visitor visitor) throws BaseException { |
||
86 | while(ite.hasNext()) {
|
||
87 | visitor.visit(ite.next()); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | public long getSize() throws BaseException { |
||
92 | return ite.getSize();
|
||
93 | } |
||
94 | |||
95 | public DisposableIterator iterator(long index) throws BaseException { |
||
96 | return iterator();
|
||
97 | } |
||
98 | |||
99 | public DisposableIterator iterator() throws BaseException { |
||
100 | return ite;
|
||
101 | } |
||
102 | |||
103 | public boolean isEmpty() throws BaseException { |
||
104 | return (getSize() == 0); |
||
105 | } |
||
106 | |||
107 | public boolean isDeleteEnabled() { |
||
108 | return true; |
||
109 | } |
||
110 | |||
111 | public void delete(DynObject dynObject) throws BaseException { |
||
112 | |||
113 | } |
||
114 | |||
115 | public boolean isUpdateEnabled() { |
||
116 | return true; |
||
117 | } |
||
118 | |||
119 | public void update(DynObject dynObject) throws BaseException { |
||
120 | } |
||
121 | |||
122 | public void update(Observable observable, Object notification) { |
||
123 | } |
||
124 | } |