Revision 5457 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/ThemeToAnnotationExtension.java

View differences:

ThemeToAnnotationExtension.java
40 40
 */
41 41
package com.iver.cit.gvsig;
42 42

  
43
import javax.swing.ImageIcon;
44

  
45
import jwizardcomponent.FinishAction;
46
import jwizardcomponent.JWizardComponents;
47

  
43 48
import com.hardcode.gdbms.engine.data.driver.DriverException;
44 49
import com.iver.andami.PluginServices;
45 50
import com.iver.andami.plugins.Extension;
......
48 53
import com.iver.cit.gvsig.fmap.layers.FLayer;
49 54
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation;
50 55
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
56
import com.iver.cit.gvsig.fmap.layers.MappingAnnotation;
51 57
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
52
import com.iver.cit.gvsig.gui.Panels.MappingFieldsToAnotation;
58
import com.iver.cit.gvsig.gui.Panels.annotation.ConfigureLabel;
59
import com.iver.cit.gvsig.gui.Panels.annotation.SelectAnnotationLayerNameAndField;
60
import com.iver.cit.gvsig.gui.simpleWizard.SimpleWizard;
53 61
import com.iver.cit.gvsig.project.ProjectView;
54 62

  
55 63

  
......
69 77
    /**
70 78
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
71 79
     */
80
    
81
    public class MyFinishAction extends FinishAction {
82
    	private JWizardComponents myWizardComponents;
83
    	private FMap map;
84
    	private FLyrVect layerVectorial;
85
    	private FLyrAnnotation layerAnnotation;
86

  
87
		public MyFinishAction(JWizardComponents wizardComponents, FMap map,FLyrVect layerVectorial, FLyrAnnotation layerAnnotation ) {
88
			super(wizardComponents);
89
			this.map = map;
90
			this.layerVectorial = layerVectorial;
91
			this.layerAnnotation = layerAnnotation;
92
			myWizardComponents = wizardComponents;
93
		}
94

  
95
		public void performAction() {
96
			
97
			SelectAnnotationLayerNameAndField panel1 = (SelectAnnotationLayerNameAndField) myWizardComponents.getWizardPanel(0);
98
			ConfigureLabel panel2 = (ConfigureLabel) myWizardComponents.getWizardPanel(1);
99
			
100
			SelectableDataSource source;
101
			MappingAnnotation mapping=new MappingAnnotation();
102
			
103
			try {
104
				source = this.layerAnnotation.getRecordset();
105

  
106
				
107
				
108
				mapping.setColumnText(source.getFieldIndexByName(panel1.getField()));
109
				
110
				if (!panel2.getAngleFieldName().equals("")) {
111
					mapping.setColumnRotate(source.getFieldIndexByName(panel2.getAngleFieldName()));
112
				}
113
				
114
				if (!panel2.getColorFieldName().equals("")) {
115
					mapping.setColumnColor(source.getFieldIndexByName(panel2.getColorFieldName()));
116
				}
117
				
118
				if (!panel2.getSizeFieldName().equals("")) {
119
					mapping.setColumnHeight(source.getFieldIndexByName(panel2.getSizeFieldName()));
120
					this.layerAnnotation.setInPixels(panel2.sizeUnitsInPixels());
121
				}
122
				
123
				if (!panel2.getFontFieldName().equals("")) {
124
					mapping.setColumnTypeFont(source.getFieldIndexByName(panel2.getFontFieldName()));
125
				}
126
			} catch (com.iver.cit.gvsig.fmap.DriverException e) {
127
				// TODO Que hacemos aqui
128
				e.printStackTrace();
129
				return;
130
			} catch (DriverException e) {
131
				// TODO Auto-generated catch block
132
				e.printStackTrace();
133
			}
134

  
135
			
136
			this.layerAnnotation.setName(panel1.getNewLayerName());
137
			this.layerAnnotation.setMapping(mapping);
138
			
139
			
140
        	this.map.getLayers().addLayer(this.layerAnnotation);
141
        	this.map.getLayers().removeLayer(this.layerVectorial);
142
			
143
		}
144
    	
145
    }
72 146
    public void execute(String actionCommand) {
73 147
        if ("LAYERTOANNOTATION".equals(actionCommand)) {
148
        	ImageIcon Logo = new javax.swing.ImageIcon(this.getClass().getClassLoader()
149
					.getResource("images/package_graphics.png"));
150

  
151
        	SimpleWizard wizard = new SimpleWizard(Logo);
152
        	
74 153
            FLyrVect lv=(FLyrVect)map.getLayers().getActives()[0];
75 154
            FLyrAnnotation la=new FLyrAnnotation();
76 155
            la.setSource(lv.getSource());
77 156

  
157
        	
158
        	SelectAnnotationLayerNameAndField panel1 = new SelectAnnotationLayerNameAndField(wizard.getWizardComponents(),la);
159
        	ConfigureLabel panel2 = new ConfigureLabel(wizard.getWizardComponents(),la);
160

  
161

  
162
        	
163
        	wizard.getWizardComponents().addWizardPanel(panel1);
164
        	wizard.getWizardComponents().addWizardPanel(panel2);
165
        	
166
			wizard.getWizardComponents().setFinishAction(
167
					new MyFinishAction(wizard.getWizardComponents(),
168
							map,lv, la));
169
			
170
			wizard.getViewInfo().setWidth(540);
171
			wizard.getViewInfo().setHeight(380);
172
			wizard.getViewInfo().setTitle(PluginServices.getText(this,"to_annotation"));
173
			
174
			PluginServices.getMDIManager().addView(wizard);
175
			
176
			
177
			
178
        	/*
179
            FLyrVect lv=(FLyrVect)map.getLayers().getActives()[0];
180
            FLyrAnnotation la=new FLyrAnnotation();
181
            la.setSource(lv.getSource());
182

  
78 183
			MappingFieldsToAnotation mfta=new MappingFieldsToAnotation(la);
79 184
            PluginServices.getMDIManager().addView(mfta);
80 185

  
......
82 187
            	map.getLayers().addLayer(la);
83 188
            	map.getLayers().removeLayer(lv);
84 189
            }
190
            */
191
        	
85 192
        }
86 193
    }
87 194

  
......
130 237
            return false;
131 238
        }
132 239
    }
240
    
241

  
133 242
}

Also available in: Unified diff