Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / extPublish / src / org / gvsig / publish / infoproject / ProjectInfo.java @ 19900

History | View | Annotate | Download (4.21 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004-2006 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
 * For more information, contact:
20
 *
21
 *   Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Iba?ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
/**
42
 * This class implements IProjectInfo in order to give information about the gvSIG project
43
 * 
44
 * @author Jos? Vicente Hig?n (josevicente.higon@iver.es)
45
 */
46
package org.gvsig.publish.infoproject;
47

    
48
import java.util.ArrayList;
49
import java.util.Iterator;
50

    
51
import org.gvsig.publish.PublishLogger;
52

    
53
import com.iver.cit.gvsig.project.Project;
54
import com.iver.cit.gvsig.project.documents.view.ProjectView;
55
import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory;
56

    
57
/**
58
 * This class represents a gvSIG project information. 
59
 * 
60
 * @author Jos? Vicente Hig?n (josevicente.higon@iver.es)
61
 *
62
 */
63
public class ProjectInfo implements IProjectInfo {
64
        private Project gvProject = null;
65
        private FilterProjectInfo filter;
66
        /**
67
         * Constructor
68
         * 
69
         * @param prj gvSIG Project
70
         * 
71
         */
72
        public ProjectInfo(Project gvProj){
73
                this.gvProject = gvProj;                                
74
        }
75
        
76
        /**
77
         * @see IProjectInf.getName()
78
         */
79
        public String getName() {
80
                return this.gvProject.getName();
81
        }
82
        /**
83
         * @see IProjectInf.getOwner()
84
         */
85
        public String getOwner() {
86
                return this.gvProject.getOwner();
87
        }
88
        /*
89
         * @see IProjectInf.getActiveViewInfo()
90
         *
91
        public IViewInfo getActiveViewInfo() {
92
                //get the ProjectView
93
                ProjectView prjView = (ProjectView) activeView.getModel(); 
94
                IViewInfo viewInfo = new ViewInfo(prjView);;
95
                return viewInfo;
96
        }*/
97
        /**
98
         * Gets the information about the views 
99
         * 
100
         * @return IViewInfo[] array with information about the views of the project
101
         * 
102
         */
103
        public IViewInfo[] getViewsInfo() {
104
                //To use this method you must create a ProjectDocument and set its factory!
105
                ArrayList aux = gvProject.getDocumentsByType(ProjectViewFactory.registerName);
106
                IViewInfo[] arrayViewInfo = new IViewInfo[aux.size()];
107
                int i = 0;                
108
                for (Iterator it = aux.iterator(); it.hasNext(); i++){
109
                        ProjectView v = (ProjectView) it.next();
110
                        arrayViewInfo[i] = new ViewInfo(v,this, filter);
111
                }
112
                return arrayViewInfo;
113
        }
114
        /**
115
         * @see IProjectInfo#toString()
116
         */
117
        public String toString(){
118
                return getName();
119
        }
120
        /**
121
         * I am supposing the layer name is unique !!!
122
         * 
123
         * @return ILayerInfo with name layerName. Null if doesn't exist
124
         */
125
        public ILayerInfo findLayer(String layerName) {
126
                IViewInfo[] iview = getViewsInfo();
127
                for (int i = 0; i < iview.length; i++ ){
128
                        ILayerInfo ilayer = iview[i].findLayer(layerName);
129
                        if (ilayer != null){
130
                                return ilayer;
131
                        }
132
                }
133
                return null;
134
        }
135
        /*
136
         * (non-Javadoc)
137
         * @see org.gvsig.publish.infoproject.IProjectInfo#setFilter(org.gvsig.publish.infoproject.FilterProjectInfo)
138
         */
139
        public void setFilter(FilterProjectInfo filter) {
140
                this.filter = filter;                
141
        }
142
        /*
143
         * (non-Javadoc)
144
         * @see org.gvsig.publish.infoproject.IProjectInfo#getFilterProjectInfo()
145
         */
146
        public FilterProjectInfo getFilterProjectInfo() {
147
                return this.filter;
148
        }
149
        /**
150
         * Clones object
151
         */
152
        public Object clone(){        
153
                Object obj=null;
154
        try{
155
            obj=super.clone();
156
        }catch(CloneNotSupportedException ex){
157
                PublishLogger.getLog().error("ERROR " + getClass().getName() + ":I can't clone projectinfo", ex);
158
        }
159
        return obj;
160
        }
161
}