Statistics
| Revision:

root / trunk / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / gazetteer / loaders / FeatureLoader.java @ 3464

History | View | Annotate | Download (3.88 KB)

1 2966 jorpiell
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2004 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 Ib??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
package es.gva.cit.gvsig.gazetteer.loaders;
42
43 3031 jorpiell
44 3464 jorpiell
import java.awt.Color;
45
import java.awt.Font;
46 3018 jorpiell
import java.awt.geom.Rectangle2D;
47
48
import com.iver.andami.PluginServices;
49 3464 jorpiell
import com.iver.cit.gvsig.fmap.core.FMultiPoint2D;
50
import com.iver.cit.gvsig.fmap.core.IGeometry;
51
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
52
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
53
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
54
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
55
import com.iver.cit.gvsig.fmap.layers.FLyrText;
56
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
57
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
58
import com.iver.cit.gvsig.fmap.rendering.FGraphic;
59
60 2966 jorpiell
import es.gva.cit.gazetteer.querys.Feature;
61
import es.gva.cit.gvsig.catalogClient.loaders.AbstractLoader;
62
63
64
/**
65
 * This class is used to load a new feature like a layer in gvSIG
66
 *
67
 * @author Jorge Piera Llodra (piera_jor@gva.es)
68
 */
69
public class FeatureLoader extends AbstractLoader{
70
71
    /**
72 3464 jorpiell
     * It make a zoom in gvSIG
73 3031 jorpiell
     * @param
74
     * feature
75 2966 jorpiell
     * @return
76 3031 jorpiell
     * true or false if fail
77 2966 jorpiell
     */
78
    public boolean load(Feature feature) {
79 3031 jorpiell
        com.iver.cit.gvsig.gui.View activeView =
80
                        (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
81 3161 jorpiell
82 3070 jorpiell
        if ((feature.getCoordinates().getX() + feature.getCoordinates().getY()/2) < 100){
83
            activeView.getMapControl().getViewPort().setExtent(new Rectangle2D.Double(feature.getCoordinates().getX() - 0.05,
84 3018 jorpiell
                feature.getCoordinates().getY() - 0.05,
85
                0.1,
86 3070 jorpiell
                0.1));
87 3161 jorpiell
        }else{
88 3070 jorpiell
            activeView.getMapControl().getViewPort().setExtent(new Rectangle2D.Double(feature.getCoordinates().getX() - 5000,
89 3069 jorpiell
                feature.getCoordinates().getY() - 5000,
90
                10000,
91
                10000));
92 3070 jorpiell
        }
93 3464 jorpiell
94
        addFLyr(feature);
95 3031 jorpiell
                return true;
96 3464 jorpiell
        }
97 3031 jorpiell
98 3464 jorpiell
    /**
99
     * It adds a new Layer to the current view
100
     * @param feature
101
     * To obtain the coordinates
102
     */
103
    public void addFLyr(Feature feature){
104
        GraphicLayer glayer = new GraphicLayer();
105
106
        FSymbol theSymbol = new FSymbol(FConstant.SYMBOL_TYPE_TEXT);
107
        theSymbol.setColor(Color.RED);
108
        theSymbol.setDescription(feature.getName());
109
        int idSymbol = glayer.addSymbol(theSymbol);
110
111
        IGeometry geom = ShapeFactory.createPoint2D(feature.getCoordinates().getX(),
112
                feature.getCoordinates().getY());
113
        FGraphic theGraphic = new FGraphic(geom, idSymbol);
114
115
        glayer.addGraphic(theGraphic);
116
        glayer.setName(feature.getName());
117
118
        addLayerToView(glayer);
119
120
        FLyrText tlayer = new FLyrText();
121
122
    }
123 2966 jorpiell
}