Package org.locationtech.udig.style.advanced.common.styleattributeclasses

Examples of org.locationtech.udig.style.advanced.common.styleattributeclasses.LineSymbolizerWrapper


     * 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);
            }
View Full Code Here


     * Update the panel.
     *
     * @param ruleWrapper the {@link RuleWrapper}.
     */
    public void update( RuleWrapper ruleWrapper ) {
        LineSymbolizerWrapper lineSymbolizerWrapper = ruleWrapper.getGeometrySymbolizersWrapper().adapt(
                LineSymbolizerWrapper.class);

        boolean widgetEnabled = lineSymbolizerWrapper.hasStroke();
        // border
        borderEnableButton.setSelection(widgetEnabled);

        String width = lineSymbolizerWrapper.getStrokeWidth();
        Double tmpWidth = isDouble(width);
        int tmp = 3;
        if (tmpWidth != null) {
            tmp = tmpWidth.intValue();
        }
        borderWidthSpinner.setSelection(tmp * 10);
        if (tmpWidth == null) {
            int index = getAttributeIndex(width, numericAttributesArrays);
            if (index != -1) {
                borderWidthAttributecombo.select(index);
            }
        }

        // border color
        String color = lineSymbolizerWrapper.getStrokeColor();
        Color tmpColor = null;
        try {
            tmpColor = Color.decode(color);
        } catch (Exception e) {
            // ignore and try for field
        }
        if (tmpColor != null) {
            borderColorEditor.setColor(tmpColor);
        } else {
            int index = getAttributeIndex(color, stringAttributesArrays);
            if (index != -1) {
                borderColorAttributecombo.select(index);
            }
        }

        // graphics path
        try {
            graphicsPathText.setText(lineSymbolizerWrapper.getStrokeExternalGraphicStrokePath());
        } catch (MalformedURLException e) {
            graphicsPathText.setText(""); //$NON-NLS-1$
        }

        // border alpha
        String opacity = lineSymbolizerWrapper.getStrokeOpacity();
        Double tmpOpacity = isDouble(opacity);
        tmp = 100;
        if (tmpOpacity != null) {
            tmp = (int) (tmpOpacity.doubleValue() * 100);
        }
        borderOpacitySpinner.setSelection(tmp);
        if (tmpOpacity == null) {
            int index = getAttributeIndex(opacity, numericAttributesArrays);
            if (index != -1) {
                borderOpacityAttributecombo.select(index);
            }
        }

        // dash
        String dash = lineSymbolizerWrapper.getDash();
        float[] dashArray = Utilities.getDash(dash);
        if (dashArray != null) {
            dashText.setText(dash);
        } else {
            dashText.setText(""); //$NON-NLS-1$
        }
        // dash offset
        String dashOffset = lineSymbolizerWrapper.getDashOffset();
        Double dashOffsetDouble = isDouble(dashOffset);
        if (dashOffsetDouble != null) {
            dashOffsetText.setText(dashOffset);
        } else {
            dashOffsetText.setText(""); //$NON-NLS-1$
        }

        // line cap
        String lineCap = lineSymbolizerWrapper.getLineCap();
        if (lineCap != null) {
            int index = getAttributeIndex(lineCap, Utilities.lineCapNames);
            if (index != -1) {
                lineCapCombo.select(index);
            }
        }

        // line join
        String lineJoin = lineSymbolizerWrapper.getLineJoin();
        if (lineJoin != null) {
            int index = getAttributeIndex(lineJoin, Utilities.lineJoinNames);
            if (index != -1) {
                lineJoinCombo.select(index);
            }
View Full Code Here

    }

    public void onStyleChanged( Object source, String[] values, boolean fromField, STYLEEVENTTYPE styleEventType ) {
        String value = values[0];

        LineSymbolizerWrapper lineSymbolizerWrapper = ruleWrapper.getGeometrySymbolizersWrapper().adapt(
                LineSymbolizerWrapper.class);

        TextSymbolizerWrapper textSymbolizerWrapper = ruleWrapper.getTextSymbolizersWrapper();

        switch( styleEventType ) {
        // GENERAL PARAMETERS
        case NAME:
            ruleWrapper.setName(value);
            break;
        case OFFSET:
            lineSymbolizerWrapper.setOffset(value);
            break;
        case MAXSCALE:
            ruleWrapper.setMaxScale(value);
            break;
        case MINSCALE:
            ruleWrapper.setMinScale(value);
            break;
        // BORDER PARAMETERS
        case BORDERENABLE: {
            boolean enabled = Boolean.parseBoolean(value);
            lineSymbolizerWrapper.setHasStroke(enabled);
            break;
        }
        case BORDERWIDTH: {
            lineSymbolizerWrapper.setStrokeWidth(value, fromField);
            break;
        }
        case BORDERCOLOR: {
            lineSymbolizerWrapper.setStrokeColor(value, fromField);
            break;
        }
        case BORDEROPACITY: {
            lineSymbolizerWrapper.setStrokeOpacity(value, fromField);
            break;
        }
        case GRAPHICSPATHBORDER: {
            String url = values[0];
            String width = values[1];
            String size = values[2];

            try {
                lineSymbolizerWrapper.setStrokeExternalGraphicStrokePath(url);
                Graphic graphicStroke = lineSymbolizerWrapper.getStrokeGraphicStroke();
                graphicStroke.setSize(Utilities.ff.literal(size));
                graphicStroke.setGap(Utilities.ff.literal(width));
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
            break;
        }
        case DASH: {
            lineSymbolizerWrapper.setDash(value);
            break;
        }
        case DASHOFFSET: {
            lineSymbolizerWrapper.setDashOffset(value);
            break;
        }
        case LINECAP: {
            lineSymbolizerWrapper.setLineCap(value);
            break;
        }
        case LINEJOIN: {
            lineSymbolizerWrapper.setLineJoin(value);
            break;
        }
            // LABEL PARAMETERS
        case LABELENABLE: {
            boolean doEnable = Boolean.parseBoolean(value);
View Full Code Here

TOP

Related Classes of org.locationtech.udig.style.advanced.common.styleattributeclasses.LineSymbolizerWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.