Package org.geotools.styling

Examples of org.geotools.styling.TextSymbolizer


        PointSymbolizer notEq = sf.getDefaultPointSymbolizer();
        assertEqualsContract(clone, notEq, pointSymb);
    }

    public void testTextSymbolizer() {
        TextSymbolizer textSymb = sf.createTextSymbolizer();
        Expression offset = ff.literal(10);
        textSymb.setLabelPlacement(sf.createLinePlacement(offset));

        textSymb.accept(visitor);
        TextSymbolizer clone = (TextSymbolizer) visitor.getCopy();
        assertCopy(textSymb, clone);
        assertEqualsContract(textSymb, clone);
       
        TextSymbolizer notEq = sf.getDefaultTextSymbolizer();
        Expression ancX = ff.literal(10);
        Expression ancY = ff.literal(10);
        AnchorPoint ancPoint = sf.createAnchorPoint(ancX, ancY);
        LabelPlacement placement = sf.createPointPlacement(ancPoint,
                null, null);
        notEq.setLabelPlacement(placement);
        assertEqualsContract(clone, notEq, textSymb);
    }
View Full Code Here


        notEq.setLabelPlacement(placement);
        assertEqualsContract(clone, notEq, textSymb);
    }
   
    public void testTextSymbolizerVendorParams() {
        TextSymbolizer textSymb = sf.createTextSymbolizer();
        textSymb.getOptions().put("autoWrap", "100");
       
        textSymb.accept(visitor);
        TextSymbolizer clone = (TextSymbolizer) visitor.getCopy();
        assertCopy(textSymb, clone);
        assertEqualsContract(textSymb, clone);
       
        assertEquals(1, clone.getOptions().size());
        assertEquals("100", clone.getOptions().get("autoWrap"));
    }
View Full Code Here

        assertEquals(1, clone.getOptions().size());
        assertEquals("100", clone.getOptions().get("autoWrap"));
    }
   
    public void testTextSymbolizerVendorOptions() {
        TextSymbolizer textSymb = sf.createTextSymbolizer();
        textSymb.getOptions().put("autoWrap", "100");

        textSymb.accept(visitor);
        TextSymbolizer clone = (TextSymbolizer) visitor.getCopy();
        assertCopy(textSymb, clone);
        assertEqualsContract(textSymb, clone);
    }
View Full Code Here

        assertCopy(textSymb, clone);
        assertEqualsContract(textSymb, clone);
    }

    public void testTextSymbolizerWithUOM() {
        TextSymbolizer textSymb = sf.createTextSymbolizer();
        textSymb.setUnitOfMeasure(UomOgcMapping.METRE.getUnit());
        Expression offset = ff.literal(10);
        textSymb.setLabelPlacement(sf.createLinePlacement(offset));

        textSymb.accept(visitor);
        TextSymbolizer clone = (TextSymbolizer) visitor.getCopy();
        assertCopy(textSymb, clone);
        assertEqualsContract(textSymb, clone);

        TextSymbolizer notEq = sf.getDefaultTextSymbolizer();
        Expression ancX = ff.literal(10);
        Expression ancY = ff.literal(10);
        AnchorPoint ancPoint = sf.createAnchorPoint(ancX, ancY);
        LabelPlacement placement = sf.createPointPlacement(ancPoint,
                null, null);
        notEq.setLabelPlacement(placement);
        assertEqualsContract(clone, notEq, textSymb);
    }
View Full Code Here

        assertEquals("Any Expression set as Geometry must be correctly replicated", geomFunc, copy
                .getGeometry());
    }

    public void testTextSymbolizerWithGeometryFunction() {
        TextSymbolizer symb = sf.createTextSymbolizer();

        // Set a function as geometry
        Function geomFunc = ff.function("centroid", ff.property("the_geom"));
        symb.setGeometry(geomFunc);

        TextSymbolizer copy = (TextSymbolizer) visitor.copy(symb);

        // compare it
        assertEquals("Any Expression set as Geometry must be correctly replicated", geomFunc, copy
                .getGeometry());
    }
View Full Code Here

         * @param hints
         * @throws OperationNotSupportedException
         */
        public Object getValue( Element element, ElementValue[] value, Attributes attrs1, Map hints )
                throws OperationNotSupportedException {
            TextSymbolizer symbol = StyleFactoryFinder.createStyleFactory().createTextSymbolizer();
            symbol.setFill(null);
           
            ArrayList fonts = new ArrayList();
           
            for (int i = 0; i < value.length; i++) {
                if ((value[i] == null) || value[i].getElement() == null) {
                    continue;
                }
                Element e = value[i].getElement();
                if(elems[GEOMETRY].getName().equals(e.getName()))
                    symbol.setGeometryPropertyName((String)value[i].getValue());
   
                if(elems[FILL].getName().equals(e.getName()))
                    symbol.setFill((Fill)value[i].getValue());
   
                if(elems[LABEL].getName().equals(e.getName()))
                    symbol.setLabel((Expression)value[i].getValue());
   
                if(elems[FONT].getName().equals(e.getName()))
                    fonts.add(value[i].getValue());
   
                if(elems[LABELPLACEMENT].getName().equals(e.getName()))
                    symbol.setFill((Fill)value[i].getValue());
   
                if(elems[LABELPLACEMENT].getName().equals(e.getName()))
                    symbol.setLabelPlacement((LabelPlacement)value[i].getValue());
   
                if(elems[HALO].getName().equals(e.getName()))
                    symbol.setHalo((Halo)value[i].getValue());
            }
           
            symbol.setFonts((Font[]) fonts.toArray(new Font[0]));
           
            return symbol;
        }
View Full Code Here

     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        Color color = (Color) value;

        TextSymbolizer textSymbolizer = sb.createTextSymbolizer();
        textSymbolizer.setFill(sb.createFill(color));

        return textSymbolizer;
    }
View Full Code Here

        for (int m = 0; m < length; m++) {
            LOGGER.finer(new StringBuffer("applying symbolizer ").append(
                    symbolizers[m]).toString());

            if (symbolizers[m] instanceof TextSymbolizer) {
                TextSymbolizer ts = (TextSymbolizer) symbolizers[m];
                Expression ex = ts.getLabel();
                featureLabel.append((String) ex.evaluate(feature, String.class)); // attach
                // the lable title

                Style2D style = styleFactory.createStyle(feature,
                        symbolizers[m], scaleRange);
View Full Code Here

            } else if (vectorResult) {
                // TODO: come back and sort out crs transformation
                // CoordinateReferenceSystem crs = findGeometryCS(feature,
                // symbolizers[m]);
                if (symbolizers[m] instanceof TextSymbolizer) {
                    TextSymbolizer ts = (TextSymbolizer) symbolizers[m];
                    Expression ex = ts.getLabel();
                    String value = (String) ex.evaluate(feature, String.class);
                    title.append(value);

                    Style2D style = styleFactory.createStyle(feature,
                            symbolizers[m], scaleRange);
View Full Code Here

            write(styleString.toString());
        } else if (style instanceof TextStyle2D
                && sym instanceof TextSymbolizer) {
            final StringBuffer styleString = new StringBuffer();
            TextSymbolizer textSym = (TextSymbolizer) sym;

            styleString.append("<LabelStyle><color>");

            if (textSym.getFill() != null) {
                int opacity = 255;

                if (textSym.getFill().getOpacity() != null) {
                    float op = getOpacity(textSym.getFill().getOpacity());
                    opacity = (new Float(255 * op)).intValue();
                }

                Paint p = ((TextStyle2D) style).getFill();

View Full Code Here

TOP

Related Classes of org.geotools.styling.TextSymbolizer

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.