* Initialize the panel with pre-existing values.
*
* @param ruleWrapper the {@link RuleWrapper}.
*/
public void init( RuleWrapper ruleWrapper ) {
PolygonSymbolizerWrapper polygonSymbolizerWrapper = ruleWrapper.getGeometrySymbolizersWrapper().adapt(
PolygonSymbolizerWrapper.class);
mainComposite = new Composite(parent, SWT.NONE);
mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
mainComposite.setLayout(new GridLayout(3, true));
boolean widgetEnabled = polygonSymbolizerWrapper.hasFill();
fillEnableButton = new Button(mainComposite, SWT.CHECK);
GridData fillEnableButtonGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
fillEnableButtonGD.horizontalSpan = 3;
fillEnableButton.setLayoutData(fillEnableButtonGD);
fillEnableButton.setText(Messages.PolygonFillParametersComposite_0);
fillEnableButton.setSelection(widgetEnabled);
fillEnableButton.addSelectionListener(this);
/*
* radio panel for fill choice
*/
// fill color
Label colorLabel = new Label(mainComposite, SWT.RADIO);
colorLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
colorLabel.setText(Messages.PolygonFillParametersComposite_1);
String color = polygonSymbolizerWrapper.getFillColor();
Color tmpColor = null;
try {
tmpColor = Color.decode(color);
} catch (Exception e) {
tmpColor = Color.gray;
}
fillColorEditor = new StolenColorEditor(mainComposite, this);
fillColorEditor.setColor(tmpColor);
fillColorButton = fillColorEditor.getButton();
GridData fillColorButtonGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
fillColorButton.setLayoutData(fillColorButtonGD);
fillColorAttributecombo = new Combo(mainComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
fillColorAttributecombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fillColorAttributecombo.setItems(stringAttributesArrays);
fillColorAttributecombo.addSelectionListener(this);
fillColorAttributecombo.select(0);
if (tmpColor == null) {
int index = getAttributeIndex(color, stringAttributesArrays);
if (index != -1) {
fillColorAttributecombo.select(index);
}
}
// graphics fill
Label graphicsFillLabel = new Label(mainComposite, SWT.RADIO);
graphicsFillLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
graphicsFillLabel.setText(Messages.PolygonFillParametersComposite_2);
Composite pathComposite = new Composite(mainComposite, SWT.NONE);
GridData pathCompositeGD = new GridData(SWT.FILL, SWT.FILL, true, false);
pathCompositeGD.horizontalSpan = 2;
pathComposite.setLayoutData(pathCompositeGD);
GridLayout pathLayout = new GridLayout(2, false);
pathLayout.marginWidth = 0;
pathLayout.marginHeight = 0;
pathComposite.setLayout(pathLayout);
graphicsPathText = new Text(pathComposite, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
graphicsPathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
try {
graphicsPathText.setText(polygonSymbolizerWrapper.getFillExternalGraphicFillPath());
} catch (Exception e) {
graphicsPathText.setText(""); //$NON-NLS-1$
}
graphicsPathText.addModifyListener(this);
Button pathButton = new Button(pathComposite, SWT.PUSH);
pathButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
pathButton.setText("..."); //$NON-NLS-1$
pathButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter(){
public void widgetSelected( org.eclipse.swt.events.SelectionEvent e ) {
FileDialog fileDialog = new FileDialog(graphicsPathText.getShell(), SWT.OPEN);
String path = fileDialog.open();
if (path == null || path.length() < 1) {
graphicsPathText.setText(""); //$NON-NLS-1$
} else {
graphicsPathText.setText(path);
}
}
});
// well known marks
Label wkmLabel = new Label(mainComposite, SWT.RADIO);
wkmLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
wkmLabel.setText(Messages.PolygonFillParametersComposite_3);
wkmarkNameCombo = new Combo(mainComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData wkmarkNameComboGD = new GridData(SWT.FILL, SWT.FILL, false, false);
wkmarkNameComboGD.horizontalSpan = 2;
wkmarkNameCombo.setLayoutData(wkmarkNameComboGD);
wkmarkNameCombo.setItems(Utilities.getAllMarksArray());
wkmarkNameCombo.addSelectionListener(this);
String wkMarkNameFill = polygonSymbolizerWrapper.getWkMarkNameFill();
int attributeIndex = getAttributeIndex(wkMarkNameFill, Utilities.getAllMarksArray());
if (attributeIndex != -1) {
wkmarkNameCombo.select(attributeIndex);
}
new Label(mainComposite, SWT.NONE);
Composite wkmarkComposite = new Composite(mainComposite, SWT.NONE);
GridData wkmarkCompositeGD = new GridData(SWT.FILL, SWT.FILL, true, false);
wkmarkCompositeGD.horizontalSpan = 2;
wkmarkComposite.setLayoutData(wkmarkCompositeGD);
GridLayout wkmarkCompositeLayout = new GridLayout(3, false);
wkmarkCompositeLayout.marginWidth = 0;
wkmarkCompositeLayout.marginHeight = 0;
wkmarkComposite.setLayout(wkmarkCompositeLayout);
// mark width
wkmWidthSpinner = new Spinner(wkmarkComposite, SWT.BORDER);
wkmWidthSpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
wkmWidthSpinner.setMaximum(200);
wkmWidthSpinner.setMinimum(0);
wkmWidthSpinner.setIncrement(1);
wkmWidthSpinner.setToolTipText(Messages.PolygonFillParametersComposite_4);
String wkMarkWidth = polygonSymbolizerWrapper.getWkMarkWidthFill();
Double tmpWidth = isDouble(wkMarkWidth);
int tmpWidthInt = 1;
if (tmpWidth != null) {
tmpWidthInt = tmpWidth.intValue();
}
wkmWidthSpinner.setSelection(tmpWidthInt * 10);
wkmWidthSpinner.setDigits(1);
wkmWidthSpinner.addSelectionListener(this);
// mark size
wkmSizeSpinner = new Spinner(wkmarkComposite, SWT.BORDER);
wkmSizeSpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
wkmSizeSpinner.setMaximum(1000);
wkmSizeSpinner.setMinimum(0);
wkmSizeSpinner.setIncrement(1);
wkmSizeSpinner.setToolTipText(Messages.PolygonFillParametersComposite_5);
String wkMarkSize = polygonSymbolizerWrapper.getWkMarkSizeFill();
Double tmpSize = isDouble(wkMarkSize);
int tmpSizeInt = 5;
if (tmpSize != null) {
tmpSizeInt = tmpSize.intValue();
}
wkmSizeSpinner.setSelection(tmpSizeInt * 10);
wkmSizeSpinner.setDigits(1);
wkmSizeSpinner.addSelectionListener(this);
// mark color
String wkMarkColor = polygonSymbolizerWrapper.getWkMarkColorFill();
Color tmpWkmColor;
try {
tmpWkmColor = Color.decode(wkMarkColor);
} catch (Exception e) {
tmpWkmColor = Color.gray;
}
wkmColorEditor = new StolenColorEditor(wkmarkComposite, this);
wkmColorEditor.setColor(tmpWkmColor);
wkmColorButton = wkmColorEditor.getButton();
GridData wkmColorButtonGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
wkmColorButton.setLayoutData(wkmColorButtonGD);
// header
new Label(mainComposite, SWT.NONE);
Label valueLabel = new Label(mainComposite, SWT.NONE);
valueLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
valueLabel.setText(Messages.PolygonFillParametersComposite_6);
Label fieldsLabel = new Label(mainComposite, SWT.NONE);
fieldsLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
fieldsLabel.setText(Messages.PolygonFillParametersComposite_7);
// border alpha
Label fillOpactityLabel = new Label(mainComposite, SWT.NONE);
fillOpactityLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fillOpactityLabel.setText(Messages.PolygonFillParametersComposite_8);
fillOpacitySpinner = new Spinner(mainComposite, SWT.BORDER);
fillOpacitySpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fillOpacitySpinner.setMaximum(100);
fillOpacitySpinner.setMinimum(0);
fillOpacitySpinner.setIncrement(10);
String opacity = polygonSymbolizerWrapper.getFillOpacity();
Double tmpOpacity = isDouble(opacity);
int tmp = 100;
if (tmpOpacity != null) {
tmp = (int) (tmpOpacity.doubleValue() * 100);
}