Revision 3480 trunk/extensions/extCatalogYNomenclator/src/es/gva/cit/gvsig/gazetteer/loaders/FeatureLoader.java

View differences:

FeatureLoader.java
62 62
 * 
63 63
 * @author Jorge Piera Llodra (piera_jor@gva.es)
64 64
 */
65
public class FeatureLoader extends AbstractLoader{
66
     
65
public class FeatureLoader extends AbstractLoader{     
67 66
    /**
68 67
     * It makes a zoom in gvSIG
69 68
     * @param
......
76 75
     * @return
77 76
     * true or false if fail
78 77
     */
79
    public boolean load(Feature feature,boolean focus,boolean removeOld) {
80
        if (removeOld){
81
            removeOldSearches();
82
        }
78
    public boolean load(Feature feature,boolean isGotoClicked,boolean isRemoveOldClicked) {
83 79
        
84
        addAndDrawLabel(feature);
80
        addAndDrawLabel(feature,isRemoveOldClicked);
85 81
        
86
        if (focus){
82
        if (isGotoClicked){
87 83
            focusCenter(feature);
88 84
        }        
89 85
       
......
110 106
                10000,
111 107
                10000));
112 108
        }          
113
    }
109
    } 
114 110
    
115 111
    /**
116
     * This method removes all the old searches
117
     *
118
     */
119
    private void removeOldSearches(){
120
        com.iver.cit.gvsig.gui.View activeView = 
121
			(com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
122
        
123
        GraphicLayer lyr = activeView.getMapControl().getMapContext().getGraphicsLayer();
124
        lyr.clearAllGraphics();
125
        activeView.getMapControl().drawGraphics();
126
    }
127
    
128
    /**
129 112
     * It adds a new Label to the current view
130 113
     * @param feature
131 114
     * To obtain the coordinates and the toponim name
115
     * @param isRemoveOldClicked
116
     * To remove or keep the old searches
132 117
     */
133
    private void addAndDrawLabel(Feature feature){
118
    private void addAndDrawLabel(Feature feature,boolean isRemoveOldClicked){
134 119
        com.iver.cit.gvsig.gui.View activeView = 
135 120
			(com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
136 121
        
137 122
        GraphicLayer lyr = activeView.getMapControl().getMapContext().getGraphicsLayer();
138
                
139
        FSymbol theSymbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT); 
123
        if (isRemoveOldClicked){
124
            lyr.clearAllGraphics();
125
        }
126
        
127
        FSymbol theSymbol = new FSymbol(FConstant.SYMBOL_TYPE_TEXT); 
140 128
        theSymbol.setColor(Color.RED);
129
        theSymbol.setStyle(FConstant.SYMBOL_STYLE_MARKER_CIRCLE);
130
        theSymbol.setFontColor(Color.BLACK);
131
                   
141 132
        int idSymbol = lyr.addSymbol(theSymbol);
142 133
        
143
        IGeometry geom = ShapeFactory.createPoint2D(new FPoint2D(feature.getCoordinates().getX(),
144
		        feature.getCoordinates().getY()));
134
        IGeometry geom = ShapeFactory.createPoint2D(new FPoint2D(feature.getCoordinates()));
145 135
              
146 136
        FGraphicLabel theLabel = new FGraphicLabel(geom, idSymbol, feature.getName());
147 137
        lyr.addGraphic(theLabel);
148 138
       
149 139
        activeView.getMapControl().drawGraphics();
150
              
140
        
141
        //This line could look stupid, but is necessary because grawGraphics does't
142
        //remove the old Graphics searched
143
        activeView.getMapControl().getViewPort().setExtent(activeView.getMapControl().getViewPort().getExtent());
151 144
    }
152 145
}

Also available in: Unified diff