Revision 104 org.gvsig.legend.dotdensity.app.mainplugin/trunk/org.gvsig.legend.dotdensity.app.mainplugin/src/main/java/org/gvsig/symbology/gui/layerproperties/DotDensityPanel.java
DotDensityPanel.java | ||
---|---|---|
147 | 147 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
148 | 148 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
149 | 149 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
150 |
import org.gvsig.gui.beans.swing.JIncrementalNumberField;
|
|
150 |
import org.gvsig.gui.beans.swing.JNumberSpinner;
|
|
151 | 151 |
import org.gvsig.i18n.Messages; |
152 | 152 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.MultiLayerFillSymbol; |
153 | 153 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.SimpleFillSymbol; |
... | ... | |
158 | 158 |
|
159 | 159 |
/** |
160 | 160 |
* This panel lets the user choose the dot density legend settings |
161 |
* (numeric field, density of points, etc)
|
|
161 |
* (numeric field, density of points, etc) |
|
162 | 162 |
* |
163 | 163 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
164 |
* @param <JNumberSpinner> |
|
164 | 165 |
* |
165 | 166 |
*/ |
166 | 167 |
public class DotDensityPanel extends JPanel implements ILegendPanel { |
167 |
|
|
168 |
|
|
168 | 169 |
private static Logger logger = LoggerFactory.getLogger(DotDensityPanel.class); |
169 |
|
|
170 |
|
|
170 | 171 |
private static final int MAX_VALUE_COUNT = 300; |
171 | 172 |
private FLyrVect layer; |
172 | 173 |
private JPanel northPanel = null; |
... | ... | |
176 | 177 |
private JRadioButton rdBtnHigh = null; |
177 | 178 |
private JRadioButton rdBtnMedium = null; |
178 | 179 |
private JRadioButton rdBtnLow = null; |
179 |
private JIncrementalNumberField numDotSize = null;
|
|
180 |
private JNumberSpinner numDotSize = null;
|
|
180 | 181 |
|
181 |
private JIncrementalNumberField nmbrDotValue = null;
|
|
182 |
private JNumberSpinner nmbrDotValue = null;
|
|
182 | 183 |
private JLabel lblLabellingField = null; |
183 | 184 |
private DotDensityLegend legend; |
184 |
|
|
185 |
|
|
185 | 186 |
private String theFieldName; |
186 | 187 |
private int theFieldType; |
187 |
|
|
188 |
|
|
188 | 189 |
private boolean initializing; |
189 | 190 |
private double max; |
190 | 191 |
private double maxDotSize = 0; |
... | ... | |
221 | 222 |
} else { |
222 | 223 |
theFieldName = (String) cmbLegendField.getItemAt(0); |
223 | 224 |
} |
224 |
|
|
225 |
|
|
225 | 226 |
FeatureAttributeDescriptor att = |
226 | 227 |
fty.getAttributeDescriptor(theFieldName); |
227 | 228 |
theFieldType = att.getDataType().getType(); |
... | ... | |
231 | 232 |
|
232 | 233 |
double maxValue = -Double.MAX_VALUE; |
233 | 234 |
double minValue = Double.MAX_VALUE; |
234 |
|
|
235 |
|
|
235 | 236 |
DisposableIterator disp = fset.fastIterator(); |
236 | 237 |
Feature fitem = null; |
237 | 238 |
double value = 0; |
238 |
|
|
239 |
|
|
239 | 240 |
int i = 0; |
240 | 241 |
while (i < MAX_VALUE_COUNT && disp.hasNext()) { |
241 |
|
|
242 |
|
|
242 | 243 |
fitem = (Feature) disp.next(); |
243 | 244 |
value = fitem.getDouble(theFieldName); |
244 | 245 |
if (value < minValue){ |
... | ... | |
263 | 264 |
|
264 | 265 |
} catch (Exception ex) { |
265 | 266 |
logger.info("Error while computing a,b.", ex); |
266 |
|
|
267 |
|
|
267 | 268 |
ApplicationLocator.getManager().message( |
268 | 269 |
Messages.getText("error") + |
269 | 270 |
" (" + Messages.getText("dot_density") + ")\n\n" |
... | ... | |
272 | 273 |
} |
273 | 274 |
} |
274 | 275 |
} |
275 |
|
|
276 |
|
|
276 |
|
|
277 |
|
|
277 | 278 |
private ActionListener buttonsListener = new ActionListener() { |
278 | 279 |
public void actionPerformed(ActionEvent e) { |
279 | 280 |
int oldValue = getSldDensity().getValue(); |
... | ... | |
305 | 306 |
|
306 | 307 |
dotValueChanging = true; |
307 | 308 |
double d = sldValueToDotValue(getSldDensity().getValue()); |
308 |
nmbrDotValue.setDouble(d);
|
|
309 |
nmbrDotValue.setDouble(d);
|
|
309 | 310 |
dotValueChanging = false; |
310 | 311 |
} |
311 | 312 |
|
... | ... | |
326 | 327 |
dotValueChanging = false; |
327 | 328 |
} |
328 | 329 |
}; |
329 |
|
|
330 |
|
|
330 | 331 |
private ColorChooserPanel jcc; |
331 | 332 |
private ILegend oldLegend; |
332 | 333 |
private JSymbolPreviewButton btnOutline; |
... | ... | |
363 | 364 |
public void setData(FLayer lyr, ILegend legend) { |
364 | 365 |
this.layer = (FLyrVect) lyr; |
365 | 366 |
this.oldLegend = legend.cloneLegend(); |
366 |
|
|
367 |
|
|
367 | 368 |
try { |
368 | 369 |
// Para evitar los campos no pertenecientes a la fuente original de la capa. |
369 | 370 |
// SelectableDataSource sds = layer.getSource().getRecordset(); |
... | ... | |
380 | 381 |
cmbLegendField.addItem(atts[i].getName()); |
381 | 382 |
} |
382 | 383 |
} |
383 |
|
|
384 |
|
|
384 | 385 |
if (!(legend instanceof DotDensityLegend)) { |
385 | 386 |
legend = new DotDensityLegend(); |
386 | 387 |
((DotDensityLegend) legend).setClassifyingFieldNames( |
... | ... | |
437 | 438 |
|
438 | 439 |
// shapeType should be always polygon |
439 | 440 |
if (!DotDensityLegend.isPolygonal(shapeType)) { |
440 |
|
|
441 |
|
|
441 | 442 |
ApplicationLocator.getManager().message( |
442 | 443 |
Messages.getText("cannot_apply_to_a_non_polygon_layer"), |
443 | 444 |
JOptionPane.ERROR_MESSAGE); |
... | ... | |
496 | 497 |
legend.addSymbol(Messages.getText("theSymbol"), symbol); |
497 | 498 |
legend.setDefaultSymbol(symbol); |
498 | 499 |
legend.setDotValue(dotValue); |
499 |
|
|
500 |
|
|
500 | 501 |
legend.setClassifyingFieldNames(new String[] { theFieldName }); |
501 | 502 |
legend.setClassifyingFieldTypes(new int[] { theFieldType }); |
502 |
|
|
503 |
|
|
503 | 504 |
legend.setBGColor(getBackgroundColorChooserPanel().getColor()); |
504 | 505 |
legend.setDotColor(getDotColorChooserPanel().getColor()); |
505 | 506 |
|
506 | 507 |
} catch (Exception e) { |
507 |
|
|
508 |
|
|
508 | 509 |
ApplicationLocator.getManager().message( |
509 | 510 |
Messages.getText("could_not_setup_legend"), |
510 | 511 |
JOptionPane.ERROR_MESSAGE); |
... | ... | |
692 | 693 |
* |
693 | 694 |
* @return de.ios.framework.swing.JNumberField |
694 | 695 |
*/ |
695 |
private JIncrementalNumberField getNumDotSize() {
|
|
696 |
private JNumberSpinner getNumDotSize() {
|
|
696 | 697 |
if (numDotSize == null) { |
697 |
numDotSize = new JIncrementalNumberField(null, 4); |
|
698 |
numDotSize.setMinValue(0); |
|
699 |
numDotSize.setDouble(1); |
|
698 |
numDotSize = new JNumberSpinner(1.0, 4, 0.0, Double.MAX_VALUE, 1.0, 2); |
|
700 | 699 |
} |
701 | 700 |
return numDotSize; |
702 | 701 |
} |
... | ... | |
706 | 705 |
* |
707 | 706 |
* @return de.ios.framework.swing.JNumberField |
708 | 707 |
*/ |
709 |
private JIncrementalNumberField getNmbrDotValue() {
|
|
708 |
private JNumberSpinner getNmbrDotValue() {
|
|
710 | 709 |
if (nmbrDotValue == null) { |
711 |
nmbrDotValue = new JIncrementalNumberField(null, 15); |
|
712 |
nmbrDotValue.setMinValue(0.01); |
|
710 |
nmbrDotValue = new JNumberSpinner(1.0, 15, 0.01, Double.MAX_VALUE, 1.0, 2); |
|
713 | 711 |
nmbrDotValue.addActionListener(nmbrDotValueListener); |
714 | 712 |
|
715 | 713 |
} |
... | ... | |
788 | 786 |
} |
789 | 787 |
} |
790 | 788 |
} catch (Exception e) { |
791 |
|
|
789 |
|
|
792 | 790 |
ApplicationLocator.getManager().messageDialog( |
793 | 791 |
Messages.getText("error_trying_to_access_to_the_layer"), |
794 | 792 |
Messages.getText("error"), |
... | ... | |
799 | 797 |
return false; |
800 | 798 |
} |
801 | 799 |
|
802 |
} |
|
800 |
} |
Also available in: Unified diff