Revision 41254
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.impl/src/main/java/org/gvsig/annotation/impl/DefaultAnnotationCreationService.java | ||
---|---|---|
285 | 285 |
out.close(); |
286 | 286 |
} |
287 | 287 |
|
288 |
private void checkAttribute(int index, int type) throws DataException{ |
|
288 |
private void checkAttribute(int index, int[] type) throws DataException{
|
|
289 | 289 |
if (index >= sourceStore.getDefaultFeatureType().size()){ |
290 | 290 |
throw new IllegalArgumentException("Attribute not found"); |
291 | 291 |
} |
292 |
if (sourceStore.getDefaultFeatureType().getAttributeDescriptor(index).getDataType().getType() != type){ |
|
292 |
int datatype = sourceStore.getDefaultFeatureType().getAttributeDescriptor(index).getDataType().getType(); |
|
293 |
|
|
294 |
boolean validType = false; |
|
295 |
if(type != null) { |
|
296 |
for (int i = 0; i < type.length; i++) { |
|
297 |
if(datatype == type[i]) { |
|
298 |
validType = true; |
|
299 |
} |
|
300 |
} |
|
301 |
} |
|
302 |
|
|
303 |
if (!validType) { |
|
293 | 304 |
throw new IllegalArgumentException("The Attribute has not have the fine type"); |
294 | 305 |
} |
295 | 306 |
} |
296 | 307 |
|
297 | 308 |
|
298 |
public void setFontTypetAttribute(int index) throws DataException {
|
|
299 |
checkAttribute(index, AnnotationDataTypes.FONTTYPE);
|
|
309 |
public void setFontTypeAttribute(int index) throws DataException { |
|
310 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTTYPE});
|
|
300 | 311 |
this.sourceFontTypeAttribute = index; |
301 | 312 |
} |
302 | 313 |
|
303 | 314 |
public void setFontStyleAttribute(int index) throws DataException { |
304 |
checkAttribute(index, AnnotationDataTypes.FONTSTYLE);
|
|
315 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTSTYLE});
|
|
305 | 316 |
this.sourceFontStyleAttribute = index; |
306 | 317 |
} |
307 | 318 |
|
308 | 319 |
public void setFontColorAttribute(int index) throws DataException { |
309 |
checkAttribute(index, AnnotationDataTypes.FONTCOLOR);
|
|
320 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTCOLOR});
|
|
310 | 321 |
this.sourceFontColorAttribute = index; |
311 | 322 |
} |
312 | 323 |
|
313 | 324 |
public void setFontHeigthAttribute(int index) throws DataException { |
314 |
checkAttribute(index, AnnotationDataTypes.FONTHEIGHT);
|
|
325 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTHEIGHT, DataTypes.INT, DataTypes.LONG, DataTypes.FLOAT});
|
|
315 | 326 |
this.sourceHeigthAttribute = index; |
316 | 327 |
} |
317 | 328 |
|
318 | 329 |
public void setFontRotationAttribute(int index) throws DataException { |
319 |
checkAttribute(index, AnnotationDataTypes.FONTROTATION);
|
|
330 |
checkAttribute(index, new int[]{AnnotationDataTypes.FONTROTATION});
|
|
320 | 331 |
this.sourceRotationAttribute = index; |
321 | 332 |
} |
322 | 333 |
|
... | ... | |
349 | 360 |
setFontStyleAttribute(getIndex(attributeName)); |
350 | 361 |
} |
351 | 362 |
|
352 |
public void setFontTypetAttribute(String attributeName) throws DataException {
|
|
353 |
setFontTypetAttribute(getIndex(attributeName));
|
|
363 |
public void setFontTypeAttribute(String attributeName) throws DataException { |
|
364 |
setFontTypeAttribute(getIndex(attributeName)); |
|
354 | 365 |
} |
355 | 366 |
|
356 | 367 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.lib/org.gvsig.annotation.lib.api/src/main/java/org/gvsig/annotation/AnnotationCreationService.java | ||
---|---|---|
97 | 97 |
*/ |
98 | 98 |
public void setAnnotationPositionCalculator(AnnotationPositionCalculator annotationPositionCalculator); |
99 | 99 |
|
100 |
public void setFontTypetAttribute(int index) throws DataException;
|
|
100 |
public void setFontTypeAttribute(int index) throws DataException; |
|
101 | 101 |
|
102 | 102 |
public void setFontStyleAttribute(int index) throws DataException; |
103 | 103 |
|
... | ... | |
107 | 107 |
|
108 | 108 |
public void setFontRotationAttribute(int index) throws DataException; |
109 | 109 |
|
110 |
public void setFontTypetAttribute(String attributeName) throws DataException;
|
|
110 |
public void setFontTypeAttribute(String attributeName) throws DataException; |
|
111 | 111 |
|
112 | 112 |
public void setFontStyleAttribute(String attributeName) throws DataException; |
113 | 113 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.annotation/org.gvsig.annotation.swing/org.gvsig.annotation.swing.impl/src/main/java/org/gvsig/annotation/swing/impl/DefaultJAnnotationCreationServicePanel.java | ||
---|---|---|
24 | 24 |
package org.gvsig.annotation.swing.impl; |
25 | 25 |
|
26 | 26 |
import java.awt.BorderLayout; |
27 |
import java.net.URL; |
|
28 | 27 |
|
29 |
import javax.swing.ImageIcon; |
|
30 | 28 |
import javax.swing.JOptionPane; |
31 | 29 |
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
|
|
35 | 30 |
import org.gvsig.annotation.AnnotationCreationException; |
36 | 31 |
import org.gvsig.annotation.AnnotationCreationService; |
37 | 32 |
import org.gvsig.annotation.AnnotationCreationServiceException; |
... | ... | |
50 | 45 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
51 | 46 |
import org.gvsig.tools.swing.icontheme.IconThemeManager; |
52 | 47 |
import org.gvsig.tools.task.TaskStatus; |
48 |
import org.slf4j.Logger; |
|
49 |
import org.slf4j.LoggerFactory; |
|
53 | 50 |
|
54 | 51 |
/** |
55 | 52 |
* Default implementation for the {@link JAnnotationCreationServicePanel}. |
... | ... | |
134 | 131 |
public String getTextValueAttribute(){ |
135 | 132 |
return mainOptionsWizard.getTextValueAttribute(); |
136 | 133 |
} |
134 |
|
|
135 |
public String getTextRotationAttribute() { |
|
136 |
return optionalOptionsWizard.getRotationAttribute(); |
|
137 |
} |
|
138 |
|
|
139 |
public String getTextColorAttribute() { |
|
140 |
return optionalOptionsWizard.getColorAttribute(); |
|
141 |
} |
|
142 |
|
|
143 |
public String getTextHeightAttribute() { |
|
144 |
return optionalOptionsWizard.getHeightAttribute(); |
|
145 |
} |
|
146 |
|
|
147 |
public String getTextTypeAttribute(){ |
|
148 |
return optionalOptionsWizard.getFontAttribute(); |
|
149 |
} |
|
137 | 150 |
|
138 | 151 |
public WizardPanelActionListener getWizardPanelActionListener() { |
139 | 152 |
if ((wizardListenerAdapter == null && (getAnnotationServicePanelActionListener() != null))){ |
... | ... | |
172 | 185 |
public void createAnnotation() { |
173 | 186 |
this.lastWizard(); |
174 | 187 |
|
175 |
Annotation annotation = new Annotation(getDestinationShapeFile(), getTextValueAttribute()); |
|
188 |
Annotation annotation = new Annotation( |
|
189 |
getDestinationShapeFile(), |
|
190 |
getTextValueAttribute(), |
|
191 |
getTextRotationAttribute(), |
|
192 |
getTextColorAttribute(), |
|
193 |
getTextHeightAttribute(), |
|
194 |
getTextTypeAttribute()); |
|
176 | 195 |
annotation.start(); |
177 | 196 |
} |
178 | 197 |
|
... | ... | |
183 | 202 |
private class Annotation extends Thread{ |
184 | 203 |
private String file; |
185 | 204 |
private String textValueAttributeName; |
205 |
private String attrRotation; |
|
206 |
private String attrColor; |
|
207 |
private String attrHeight; |
|
208 |
private String attrType; |
|
186 | 209 |
|
187 |
public Annotation(String file, String textValueAttributeName) { |
|
210 |
/*public Annotation(String file, String textValueAttributeName) {
|
|
188 | 211 |
super(); |
189 | 212 |
this.file = file; |
190 | 213 |
this.textValueAttributeName = textValueAttributeName; |
214 |
}*/ |
|
215 |
|
|
216 |
public Annotation(String file, |
|
217 |
String textValueAttributeName, |
|
218 |
String attrRotation, |
|
219 |
String attrColor, |
|
220 |
String attrHeight, |
|
221 |
String attrType) { |
|
222 |
super(); |
|
223 |
this.file = file; |
|
224 |
this.textValueAttributeName = textValueAttributeName; |
|
225 |
this.attrColor = attrColor; |
|
226 |
this.attrHeight = attrHeight; |
|
227 |
this.attrRotation = attrRotation; |
|
228 |
this.attrType = attrType; |
|
191 | 229 |
} |
192 | 230 |
|
193 | 231 |
public synchronized void run() { |
194 | 232 |
AnnotationCreationService annotationCreationService = getAnnotationCreationService(); |
195 | 233 |
annotationProgressWizard.bind(annotationCreationService.getTaskStatus()); |
196 | 234 |
try { |
197 |
annotationCreationService.createAnnotationStore(file, textValueAttributeName); |
|
235 |
if(attrRotation != null) |
|
236 |
annotationCreationService.setFontRotationAttribute(attrRotation); |
|
237 |
if(attrColor != null) |
|
238 |
annotationCreationService.setFontColorAttribute(attrColor); |
|
239 |
if(attrHeight != null) |
|
240 |
annotationCreationService.setFontHeigthAttribute(attrHeight); |
|
241 |
if(attrType != null) |
|
242 |
annotationCreationService.setFontTypeAttribute(attrType); |
|
243 |
annotationCreationService.createAnnotationStore(file, textValueAttributeName); |
|
198 | 244 |
} catch (AnnotationCreationException e) { |
199 | 245 |
LOG.error("Error creating the annotation", e); |
200 | 246 |
showError(e, annotationCreationService.getTaskStatus()); |
201 |
} |
|
247 |
} catch (DataException e) { |
|
248 |
LOG.error("Error assigning properties to the annotation layer", e); |
|
249 |
} |
|
202 | 250 |
} |
203 | 251 |
} |
204 | 252 |
|
Also available in: Unified diff