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

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


                Style namedStyle = Utilities.sf.createStyle();
                namedStyle.featureTypeStyles().add(featureTypeStyle);
                namedStyle.setName(selectedRule.getName());

                try {
                    lineStyleManager.addStyle(new StyleWrapper(namedStyle));
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });

        final Button saveAllButton = new Button(rulesGroup, SWT.PUSH);
        saveAllButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        saveAllButton.setImage(saveAllImg);
        saveAllButton.setToolTipText(Messages.LinePropertiesEditor_17);
        saveAllButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                String newStyleName = Messages.LinePropertiesEditor_18;
                InputDialog iDialog = new InputDialog(saveAllButton.getShell(), Messages.LinePropertiesEditor_19,
                        Messages.LinePropertiesEditor_20, newStyleName, null);
                iDialog.setBlockOnOpen(true);
                int open = iDialog.open();
                if (open == SWT.CANCEL) {
                    return;
                }
                String name = iDialog.getValue();
                if (name == null || name.length() == 0) {
                    name = newStyleName;
                }
                styleWrapper.setName(name);
                try {
                    lineStyleManager.addStyle(styleWrapper);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }

        });

        Button deleteButton = new Button(rulesGroup, SWT.PUSH);
        deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        deleteButton.setImage(delImg);
        deleteButton.setToolTipText(Messages.LinePropertiesEditor_21);
        deleteButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                StyleWrapper styleWrapper = lineStyleManager.getCurrentSelectedStyle();
                if (styleWrapper == null) {
                    return;
                }
                try {
                    lineStyleManager.removeStyle(styleWrapper);
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        });

        Button loadButton = new Button(rulesGroup, SWT.PUSH);
        loadButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        loadButton.setImage(loadImg);
        loadButton.setToolTipText(Messages.LinePropertiesEditor_22);
        loadButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                StyleWrapper styleWrapperToLoad = lineStyleManager.getCurrentSelectedStyle();
                if (styleWrapperToLoad == null) {
                    return;
                }

                List<FeatureTypeStyleWrapper> featureTypeStylesWrapperList = styleWrapperToLoad.getFeatureTypeStylesWrapperList();
                for( FeatureTypeStyleWrapper featureTypeStyleWrapper : featureTypeStylesWrapperList ) {
                    styleWrapper.addFeatureTypeStyle(featureTypeStyleWrapper.getFeatureTypeStyle());
                }

                reloadGroupsAndRules();
View Full Code Here


                break;
            default:
                throw new IllegalArgumentException();
            }
        }
        styleWrapper = new StyleWrapper(style);

        createGui(parent);
    }
View Full Code Here

    public void updateStyle( Style style ) {
        if (style == null) {
            style = Utilities.createDefaultPointStyle();
        }

        styleWrapper = new StyleWrapper(style);

        groupRulesTreeViewer.setInput(styleWrapper.getFeatureTypeStylesWrapperList());
        RuleWrapper ruleWrapper = styleWrapper.getFirstRule();
        if (ruleWrapper != null) {
            setRuleToSelected(ruleWrapper);
View Full Code Here

    @Override
    public boolean select( Viewer viewer, Object parentElement, Object element ) {
        if (searchString == null || searchString.length() == 0) {
            return true;
        }
        StyleWrapper p = (StyleWrapper) element;
        if (p.getName().matches(searchString)) {
            return true;
        }
        return false;
    }
View Full Code Here

                StyledLayerDescriptor sld = readStyle(file);
                Style style = SLDs.getDefaultStyle(sld);
                String name = FilenameUtils.removeExtension(file.getName());
                style.setName(name);

                StyleWrapper styleWrapper = new StyleWrapper(style);
                newStylesList.add(styleWrapper);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
View Full Code Here

     */
    public static String checkSameNameStyle( List<StyleWrapper> styles, String styleName ) {
        int index = 1;
        String name = styleName.trim();
        for( int i = 0; i < styles.size(); i++ ) {
            StyleWrapper styleWrapper = styles.get(i);
            String tmpName = styleWrapper.getName();
            if (tmpName == null) {
                continue;
            }

            tmpName = tmpName.trim();
View Full Code Here

        } else if (name.toLowerCase().endsWith(".svg")) {
            exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/svg+xml");
        } else if (name.toLowerCase().endsWith(".sld")) {
            StyledLayerDescriptor sld = readStyle(graphicsPath);
            Style style = SLDs.getDefaultStyle(sld);
            return new StyleWrapper(style);
        }

        if (exGraphic == null) {
            throw new IOException("Style could not be created!");
        }

        Graphic gr = sf.createDefaultGraphic();
        gr.graphicalSymbols().clear();
        gr.graphicalSymbols().add(exGraphic);
        Expression size = ff.literal(20);
        gr.setSize(size);

        Rule rule = sf.createRule();
        PointSymbolizer pointSymbolizer = sf.createPointSymbolizer(gr, null);
        rule.symbolizers().add(pointSymbolizer);

        FeatureTypeStyle featureTypeStyle = sf.createFeatureTypeStyle();
        featureTypeStyle.rules().add(rule);

        Style namedStyle = sf.createStyle();
        namedStyle.featureTypeStyles().add(featureTypeStyle);
        namedStyle.setName(FilenameUtils.removeExtension(name));

        return new StyleWrapper(namedStyle);
    }
View Full Code Here

        });

        stylesViewer.setLabelProvider(new LabelProvider(){
            public Image getImage( Object element ) {
                if (element instanceof StyleWrapper) {
                    StyleWrapper styleWrapper = (StyleWrapper) element;
                    List<FeatureTypeStyleWrapper> featureTypeStylesWrapperList = styleWrapper.getFeatureTypeStylesWrapperList();
                    int iconSize = 48;
                    BufferedImage image = new BufferedImage(iconSize, iconSize, BufferedImage.TYPE_INT_ARGB);
                    Graphics2D g2d = image.createGraphics();
                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                    for( FeatureTypeStyleWrapper featureTypeStyle : featureTypeStylesWrapperList ) {
                        List<RuleWrapper> rulesWrapperList = featureTypeStyle.getRulesWrapperList();
                        BufferedImage tmpImage = Utilities.lineRulesWrapperToImage(rulesWrapperList, iconSize, iconSize);
                        g2d.drawImage(tmpImage, 0, 0, null);
                    }
                    g2d.dispose();
                    Image convertToSWTImage = AWTSWTImageUtils.convertToSWTImage(image);
                    return convertToSWTImage;
                }
                return null;
            }

            public String getText( Object element ) {
                if (element instanceof StyleWrapper) {
                    StyleWrapper styleWrapper = (StyleWrapper) element;
                    String styleName = styleWrapper.getName();
                    if (styleName == null || styleName.length() == 0) {
                        styleName = Utilities.DEFAULT_STYLENAME;
                        styleName = Utilities.checkSameNameStyle(getStyles(), styleName);
                        styleWrapper.setName(styleName);
                    }
                    return styleName;
                }
                return ""; //$NON-NLS-1$
            }
View Full Code Here

                Style namedStyle = Utilities.sf.createStyle();
                namedStyle.featureTypeStyles().add(featureTypeStyle);
                namedStyle.setName(selectedRule.getName());

                try {
                    pointStyleManager.addStyle(new StyleWrapper(namedStyle));
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });

        final Button saveAllButton = new Button(rulesGroup, SWT.PUSH);
        saveAllButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        saveAllButton.setImage(saveAllImg);
        saveAllButton.setToolTipText(Messages.PointPropertiesEditor_17);
        saveAllButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                String newStyleName = Messages.PointPropertiesEditor_18;
                InputDialog iDialog = new InputDialog(saveAllButton.getShell(), Messages.PointPropertiesEditor_19,
                        Messages.PointPropertiesEditor_20, newStyleName, null);
                iDialog.setBlockOnOpen(true);
                int open = iDialog.open();
                if (open == SWT.CANCEL) {
                    return;
                }
                String name = iDialog.getValue();
                if (name == null || name.length() == 0) {
                    name = newStyleName;
                }
                styleWrapper.setName(name);
                try {
                    pointStyleManager.addStyle(styleWrapper);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }

        });

        Button deleteButton = new Button(rulesGroup, SWT.PUSH);
        deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        deleteButton.setImage(delImg);
        deleteButton.setToolTipText(Messages.PointPropertiesEditor_21);
        deleteButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                StyleWrapper styleWrapper = pointStyleManager.getCurrentSelectedStyle();
                if (styleWrapper == null) {
                    return;
                }
                try {
                    pointStyleManager.removeStyle(styleWrapper);
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        });

        Button loadButton = new Button(rulesGroup, SWT.PUSH);
        loadButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        loadButton.setImage(loadImg);
        loadButton.setToolTipText(Messages.PointPropertiesEditor_22);
        loadButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                StyleWrapper styleWrapperToLoad = pointStyleManager.getCurrentSelectedStyle();
                if (styleWrapperToLoad == null) {
                    return;
                }

                List<FeatureTypeStyleWrapper> featureTypeStylesWrapperList = styleWrapperToLoad.getFeatureTypeStylesWrapperList();
                for( FeatureTypeStyleWrapper featureTypeStyleWrapper : featureTypeStylesWrapperList ) {
                    styleWrapper.addFeatureTypeStyle(featureTypeStyleWrapper.getFeatureTypeStyle());
                }

                reloadGroupsAndRules();
View Full Code Here

                Style namedStyle = Utilities.sf.createStyle();
                namedStyle.featureTypeStyles().add(featureTypeStyle);
                namedStyle.setName(selectedRule.getName());

                try {
                    polygonStyleManager.addStyle(new StyleWrapper(namedStyle));
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });

        final Button saveAllButton = new Button(rulesGroup, SWT.PUSH);
        saveAllButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        saveAllButton.setImage(saveAllImg);
        saveAllButton.setToolTipText(Messages.PolygonPropertiesEditor_17);
        saveAllButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                String newStyleName = Messages.PolygonPropertiesEditor_18;
                InputDialog iDialog = new InputDialog(saveAllButton.getShell(), Messages.PolygonPropertiesEditor_19,
                        Messages.PolygonPropertiesEditor_20, newStyleName, null);
                iDialog.setBlockOnOpen(true);
                int open = iDialog.open();
                if (open == SWT.CANCEL) {
                    return;
                }
                String name = iDialog.getValue();
                if (name == null || name.length() == 0) {
                    name = newStyleName;
                }
                styleWrapper.setName(name);
                try {
                    polygonStyleManager.addStyle(styleWrapper);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }

        });

        Button deleteButton = new Button(rulesGroup, SWT.PUSH);
        deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        deleteButton.setImage(delImg);
        deleteButton.setToolTipText(Messages.PolygonPropertiesEditor_21);
        deleteButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                StyleWrapper styleWrapper = polygonStyleManager.getCurrentSelectedStyle();
                if (styleWrapper == null) {
                    return;
                }
                try {
                    polygonStyleManager.removeStyle(styleWrapper);
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        });

        Button loadButton = new Button(rulesGroup, SWT.PUSH);
        loadButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        loadButton.setImage(loadImg);
        loadButton.setToolTipText(Messages.PolygonPropertiesEditor_22);
        loadButton.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                StyleWrapper styleWrapperToLoad = polygonStyleManager.getCurrentSelectedStyle();
                if (styleWrapperToLoad == null) {
                    return;
                }

                List<FeatureTypeStyleWrapper> featureTypeStylesWrapperList = styleWrapperToLoad.getFeatureTypeStylesWrapperList();
                for( FeatureTypeStyleWrapper featureTypeStyleWrapper : featureTypeStylesWrapperList ) {
                    styleWrapper.addFeatureTypeStyle(featureTypeStyleWrapper.getFeatureTypeStyle());
                }

                reloadGroupsAndRules();
View Full Code Here

TOP

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

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.