Revision 47476 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/styling/PictureLine.java
PictureLine.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.app.gui.styling; |
25 | 25 |
|
26 |
import java.awt.Color; |
|
27 |
import java.awt.geom.Point2D; |
|
28 |
import java.io.IOException; |
|
29 |
import java.net.URL; |
|
30 |
import static org.gvsig.expressionevaluator.ExpressionUtils.getPhrase; |
|
31 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
26 | 32 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
33 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IWarningSymbol; |
|
34 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
|
27 | 35 |
import org.gvsig.i18n.Messages; |
36 |
import org.gvsig.symbology.SymbologyLocator; |
|
37 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.IPictureLineSymbol; |
|
28 | 38 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IPictureMarkerSymbol; |
29 | 39 |
|
30 | 40 |
/** |
... | ... | |
36 | 46 |
* refreshControls and getLayer. |
37 | 47 |
* |
38 | 48 |
* |
39 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
|
49 |
* @author gvSIG Team
|
|
40 | 50 |
*/ |
41 | 51 |
public class PictureLine extends PictureMarker { |
42 | 52 |
|
... | ... | |
45 | 55 |
} |
46 | 56 |
|
47 | 57 |
@Override |
58 |
protected void initComponents() { |
|
59 |
super.initComponents(); |
|
60 |
|
|
61 |
|
|
62 |
this.colorLinePicker.setEditable(false); |
|
63 |
this.xoffsetExpPicker.setEditable(false); |
|
64 |
this.yoffsetExpPicker.setEditable(false); |
|
65 |
this.rotationExpPicker.setEditable(false); |
|
66 |
this.colorExpPicker.setEditable(false); |
|
67 |
|
|
68 |
this.view.txtColorLine.setEnabled(false); |
|
69 |
this.view.btnColorLine.setEnabled(false); |
|
70 |
this.view.txtColorLineExp.setEnabled(false); |
|
71 |
this.view.btnColorLineExpression.setEnabled(false); |
|
72 |
this.view.btnColorLineExpressionBookmarks.setEnabled(false); |
|
73 |
this.view.btnColorLineExpressionHistory.setEnabled(false); |
|
74 |
|
|
75 |
this.view.txtX.setEnabled(false); |
|
76 |
this.view.txtXOffset.setEnabled(false); |
|
77 |
this.view.btnXOffsetExpression.setEnabled(false); |
|
78 |
this.view.btnXOffsetExpressionBookmarks.setEnabled(false); |
|
79 |
this.view.btnXOffsetExpressionHistory.setEnabled(false); |
|
80 |
|
|
81 |
this.view.txtY.setEnabled(false); |
|
82 |
this.view.txtYOffset.setEnabled(false); |
|
83 |
this.view.btnYOffsetExpression.setEnabled(false); |
|
84 |
this.view.btnYOffsetExpressionBookmarks.setEnabled(false); |
|
85 |
this.view.btnYOffsetExpressionHistory.setEnabled(false); |
|
86 |
|
|
87 |
this.view.txtRotation.setEnabled(false); |
|
88 |
this.view.txtRotationExp.setEnabled(false); |
|
89 |
this.view.btnRotationExpression.setEnabled(false); |
|
90 |
this.view.btnRotationExpressionBookmarks.setEnabled(false); |
|
91 |
this.view.btnRotationExpressionHistory.setEnabled(false); |
|
92 |
|
|
93 |
this.view.chkDrawLineToOffset.setEnabled(false); |
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
@Override |
|
48 | 100 |
public String getName() { |
49 | 101 |
return Messages.getText("picture_line_symbol"); |
50 | 102 |
} |
51 | 103 |
|
52 |
// @Override |
|
53 |
// public void refreshControls(ISymbol layer) { |
|
54 |
// try { |
|
55 |
// if (layer == null) { |
|
56 |
// setValues(1d, 0d, 0d, null, null); //, sym.getOffsetXExpression(), sym.getOffsetYExpression(), sym.getLineToOffsetColor(), sym.getLineToOffsetColorExpression(), sym.getRotation(), sym.getRotationExpression()); |
|
57 |
// } else { |
|
58 |
// IPictureLineSymbol sym = (IPictureLineSymbol) layer; |
|
59 |
// setValues(sym.getLineWidth(), |
|
60 |
// sym.getXScale(), |
|
61 |
// sym.getYScale(), |
|
62 |
// sym.getSource(), |
|
63 |
// sym.getSelectedSource() //, |
|
64 |
//// sym.getOffsetXExpression(), |
|
65 |
//// sym.getOffsetYExpression(), |
|
66 |
//// sym.getLineToOffsetColor(), |
|
67 |
//// sym.getLineToOffsetColorExpression(), |
|
68 |
//// sym.getRotation(), |
|
69 |
//// sym.getRotationExpression() |
|
70 |
// ); |
|
71 |
// } |
|
72 |
// } catch (Exception ex) { |
|
73 |
// LOGGER.warn("Can't refresh picture line symbol panel.", ex); |
|
74 |
// } |
|
75 |
// |
|
76 |
// } |
|
77 |
|
|
78 |
// protected void setValues( |
|
79 |
// double size, |
|
80 |
// double xOffset, |
|
81 |
// double yOffset, |
|
82 |
// URL picture, |
|
83 |
// URL selectedPicture) { |
|
84 |
// |
|
85 |
// setSize(size); |
|
86 |
// setX(xOffset); |
|
87 |
// setY(yOffset); |
|
88 |
// |
|
89 |
// setPicture(picture); |
|
90 |
// setSelectedPicture(selectedPicture); |
|
91 |
// } |
|
104 |
@Override |
|
105 |
public void refreshControls(ISymbol layer) { |
|
106 |
try { |
|
107 |
if (layer == null) { |
|
108 |
setValues(1d, 0d, 0d, null, null, null, null, null, null, null, null, false); |
|
109 |
} else { |
|
110 |
IPictureLineSymbol sym = (IPictureLineSymbol) layer; |
|
111 |
setValues(sym.getLineWidth(), |
|
112 |
sym.getRotation(), |
|
113 |
sym.getOffset().getX(), |
|
114 |
sym.getOffset().getY(), |
|
115 |
sym.getSource(), |
|
116 |
sym.getSelectedSource(), |
|
117 |
sym.getSizeExpression(), |
|
118 |
sym.getOffsetXExpression(), |
|
119 |
sym.getOffsetYExpression(), |
|
120 |
sym.getLineToOffsetColor(), |
|
121 |
sym.getLineToOffsetColorExpression(), |
|
122 |
sym.getRotationExpression(), |
|
123 |
sym.isDrawLineToOffset() |
|
124 |
); |
|
125 |
} |
|
126 |
} catch (Exception ex) { |
|
127 |
LOGGER.warn("Can't refresh picture line symbol panel.", ex); |
|
128 |
} |
|
129 |
|
|
130 |
} |
|
92 | 131 |
|
132 |
@Override |
|
133 |
protected void setValues( |
|
134 |
double size, |
|
135 |
double rotation, |
|
136 |
double xOffset, |
|
137 |
double yOffset, |
|
138 |
URL picture, |
|
139 |
URL selectedPicture, |
|
140 |
String sizeExpression, |
|
141 |
String offsetXExpression, |
|
142 |
String offsetYExpression, |
|
143 |
Color lineToOffsetColor, |
|
144 |
String lineToOffsetColorExpression, |
|
145 |
String rotationExpression, |
|
146 |
boolean isDrawLineToOffset) { |
|
147 |
|
|
148 |
super.setValues(size, rotation, xOffset, yOffset, picture, selectedPicture, sizeExpression, offsetXExpression, offsetYExpression, lineToOffsetColor, lineToOffsetColorExpression, rotationExpression, isDrawLineToOffset); |
|
149 |
|
|
150 |
} |
|
93 | 151 |
|
94 |
// @Override |
|
95 |
// public ISymbol getLayer() { |
|
96 |
// try { |
|
97 |
// IPictureLineSymbol layer = null; |
|
98 |
// if (this.getPictureFile() != null) { |
|
99 |
// layer = SymbologyLocator.getSymbologyManager().createPictureLineSymbol( |
|
100 |
// this.getPictureURL(), |
|
101 |
// this.getSelectedPictureURL() |
|
102 |
// ); |
|
103 |
// layer.setLineWidth(this.getSize()); |
|
104 |
// layer.setXScale(this.getX()); |
|
105 |
// layer.setYScale(this.getY()); |
|
106 |
// } |
|
107 |
// return layer; |
|
108 |
// } catch (IOException e) { |
|
109 |
// IWarningSymbol warning |
|
110 |
// = (IWarningSymbol) MapContextLocator.getSymbolManager() |
|
111 |
// .getWarningSymbol( |
|
112 |
// SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
|
113 |
// Messages.getText("failed_acessing_files"), |
|
114 |
// SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS); |
|
115 |
// return warning; |
|
116 |
// |
|
117 |
// } |
|
118 |
// |
|
119 |
// } |
|
152 |
@Override |
|
153 |
public ISymbol getLayer() { |
|
154 |
try { |
|
155 |
IPictureLineSymbol layer = null; |
|
156 |
if (this.getPictureFile() != null) { |
|
157 |
layer = SymbologyLocator.getSymbologyManager().createPictureLineSymbol( |
|
158 |
this.getPictureURL(), |
|
159 |
this.getSelectedPictureURL() |
|
160 |
); |
|
161 |
layer.setFeature(this.getSampleFeature()); |
|
162 |
layer.setLineWidth(this.getSize()); |
|
163 |
layer.setSizeExpression(getPhrase(getSizeExpression())); |
|
164 |
layer.setOffset(new Point2D.Double(this.getX(), this.getY())); |
|
165 |
layer.setRotation(Math.toRadians(getRotation())); |
|
166 |
layer.setRotationExpression(getPhrase(this.getRotationExpression())); |
|
167 |
layer.setOffsetXExpression(getPhrase(this.getXOffsetExpression())); |
|
168 |
layer.setOffsetYExpression(getPhrase(this.getYOffsetExpression())); |
|
169 |
layer.setSizeExpression(getPhrase(getSizeExpression())); |
|
170 |
layer.setDrawLineToOffset(isSelectedDrawLineToOffset()); |
|
171 |
layer.setLineToOffsetColor(this.getLineToOffsetColor()); |
|
172 |
layer.setLineToOffsetColorExpression(getPhrase(getLineToOffsetColorExpression())); |
|
173 |
} |
|
174 |
return layer; |
|
175 |
} catch (IOException e) { |
|
176 |
IWarningSymbol warning |
|
177 |
= (IWarningSymbol) MapContextLocator.getSymbolManager() |
|
178 |
.getWarningSymbol( |
|
179 |
SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
|
180 |
Messages.getText("failed_acessing_files"), |
|
181 |
SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS); |
|
182 |
return warning; |
|
120 | 183 |
|
184 |
} |
|
185 |
|
|
186 |
} |
|
187 |
|
|
121 | 188 |
@Override |
122 | 189 |
public boolean canManageSymbol(ISymbol symbol) { |
123 | 190 |
return symbol instanceof IPictureMarkerSymbol; |
Also available in: Unified diff