* Initialize the panel with pre-existing values.
*
* @param ruleWrapper the {@link RuleWrapper}.
*/
public void init( RuleWrapper ruleWrapper ) {
LineSymbolizerWrapper lineSymbolizerWrapper = ruleWrapper.getGeometrySymbolizersWrapper().adapt(
LineSymbolizerWrapper.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 = lineSymbolizerWrapper.hasStroke();
borderEnableButton = new Button(mainComposite, SWT.CHECK);
GridData borderEnableButtonGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
borderEnableButtonGD.horizontalSpan = 3;
borderEnableButton.setLayoutData(borderEnableButtonGD);
borderEnableButton.setText(Messages.BoderParametersComposite_0);
borderEnableButton.setSelection(widgetEnabled);
borderEnableButton.addSelectionListener(this);
// 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.BoderParametersComposite_1);
Label fieldsLabel = new Label(mainComposite, SWT.NONE);
fieldsLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
fieldsLabel.setText(Messages.BoderParametersComposite_2);
// border width
Label borderWidthLabel = new Label(mainComposite, SWT.NONE);
borderWidthLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
borderWidthLabel.setText(Messages.BoderParametersComposite_3);
borderWidthSpinner = new Spinner(mainComposite, SWT.BORDER);
borderWidthSpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
borderWidthSpinner.setMaximum(500);
borderWidthSpinner.setMinimum(0);
borderWidthSpinner.setIncrement(10);
String width = lineSymbolizerWrapper.getStrokeWidth();
Double tmpWidth = isDouble(width);
int tmp = 3;
if (tmpWidth != null) {
tmp = tmpWidth.intValue();
}
borderWidthSpinner.setSelection(tmp * 10);
borderWidthSpinner.setDigits(1);
borderWidthSpinner.addSelectionListener(this);
borderWidthAttributecombo = new Combo(mainComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
borderWidthAttributecombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
borderWidthAttributecombo.setItems(numericAttributesArrays);
borderWidthAttributecombo.addSelectionListener(this);
borderWidthAttributecombo.select(0);
if (tmpWidth == null) {
int index = getAttributeIndex(width, numericAttributesArrays);
if (index != -1) {
borderWidthAttributecombo.select(index);
}
}
// border alpha
Label borderOpactityLabel = new Label(mainComposite, SWT.NONE);
borderOpactityLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
borderOpactityLabel.setText(Messages.BoderParametersComposite_4);
borderOpacitySpinner = new Spinner(mainComposite, SWT.BORDER);
borderOpacitySpinner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
borderOpacitySpinner.setMaximum(100);
borderOpacitySpinner.setMinimum(0);
borderOpacitySpinner.setIncrement(10);
String opacity = lineSymbolizerWrapper.getStrokeOpacity();
Double tmpOpacity = isDouble(opacity);
tmp = 100;
if (tmpOpacity != null) {
tmp = (int) (tmpOpacity.doubleValue() * 100);
}
borderOpacitySpinner.setSelection(tmp);
borderOpacitySpinner.addSelectionListener(this);
borderOpacityAttributecombo = new Combo(mainComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
borderOpacityAttributecombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
borderOpacityAttributecombo.setItems(numericAttributesArrays);
borderOpacityAttributecombo.addSelectionListener(this);
borderOpacityAttributecombo.select(0);
if (tmpOpacity == null) {
int index = getAttributeIndex(opacity, numericAttributesArrays);
if (index != -1) {
borderOpacityAttributecombo.select(index);
}
}
// border color
Label borderColorLabel = new Label(mainComposite, SWT.NONE);
borderColorLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
borderColorLabel.setText(Messages.BoderParametersComposite_5);
String color = lineSymbolizerWrapper.getStrokeColor();
Color tmpColor;
try {
tmpColor = Color.decode(color);
} catch (Exception e) {
tmpColor = Color.gray;
}
borderColorEditor = new StolenColorEditor(mainComposite, this);
borderColorEditor.setColor(tmpColor);
borderColorButton = borderColorEditor.getButton();
GridData borderColorButtonSIMPLEGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
borderColorButton.setLayoutData(borderColorButtonSIMPLEGD);
borderColorAttributecombo = new Combo(mainComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
borderColorAttributecombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
borderColorAttributecombo.setItems(stringAttributesArrays);
borderColorAttributecombo.addSelectionListener(this);
borderColorAttributecombo.select(0);
if (tmpColor == null) {
int index = getAttributeIndex(color, stringAttributesArrays);
if (index != -1) {
borderColorAttributecombo.select(index);
}
}
// graphics fill
Label graphicsFillLabel = new Label(mainComposite, SWT.RADIO);
graphicsFillLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
graphicsFillLabel.setText(Messages.BoderParametersComposite_6);
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(lineSymbolizerWrapper.getStrokeExternalGraphicStrokePath());
} catch (MalformedURLException e1) {
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);
}
}
});
// line properties
// dash
Label dashLabel = new Label(mainComposite, SWT.NONE);
GridData dashLabelGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
dashLabel.setLayoutData(dashLabelGD);
dashLabel.setText(Messages.BoderParametersComposite_8);
dashText = new Text(mainComposite, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
GridData dashGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
dashGD.horizontalSpan = 2;
dashText.setLayoutData(dashGD);
String dash = lineSymbolizerWrapper.getDash();
float[] dashArray = Utilities.getDash(dash);
if (dashArray != null) {
dashText.setText(dash);
} else {
dashText.setText(""); //$NON-NLS-1$
}
dashText.addModifyListener(this);
// dashoffset
Label dashOffsetLabel = new Label(mainComposite, SWT.NONE);
GridData dashOffsetLabelGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
dashOffsetLabel.setLayoutData(dashOffsetLabelGD);
dashOffsetLabel.setText(Messages.BoderParametersComposite_9);
dashOffsetText = new Text(mainComposite, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
GridData dashOffsetGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
dashOffsetGD.horizontalSpan = 2;
dashOffsetText.setLayoutData(dashOffsetGD);
String dashOffset = lineSymbolizerWrapper.getDashOffset();
Double dashOffsetFloat = isDouble(dashOffset);
if (dashOffsetFloat != null) {
dashOffsetText.setText(dashOffset);
} else {
dashOffsetText.setText(""); //$NON-NLS-1$
}
dashOffsetText.addModifyListener(this);
// line cap
Label linCapLabel = new Label(mainComposite, SWT.NONE);
linCapLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
linCapLabel.setText(Messages.BoderParametersComposite_10);
lineCapCombo = new Combo(mainComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData lineCapGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
lineCapGD.horizontalSpan = 2;
lineCapCombo.setLayoutData(lineCapGD);
lineCapCombo.setItems(Utilities.lineCapNames);
lineCapCombo.addSelectionListener(this);
String lineCap = lineSymbolizerWrapper.getLineCap();
if (lineCap != null) {
int index = getAttributeIndex(lineCap, Utilities.lineCapNames);
if (index != -1) {
lineCapCombo.select(index);
}
}
// line join
Label linJoinLabel = new Label(mainComposite, SWT.NONE);
linJoinLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
linJoinLabel.setText(Messages.BoderParametersComposite_11);
lineJoinCombo = new Combo(mainComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData lineJoinGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
lineJoinGD.horizontalSpan = 2;
lineJoinCombo.setLayoutData(lineJoinGD);
lineJoinCombo.setItems(Utilities.lineJoinNames);
lineJoinCombo.addSelectionListener(this);
String lineJoin = lineSymbolizerWrapper.getLineJoin();
if (lineJoin != null) {
int index = getAttributeIndex(lineJoin, Utilities.lineJoinNames);
if (index != -1) {
lineJoinCombo.select(index);
}