Package org.geotools.styling

Examples of org.geotools.styling.TextSymbolizer2


                placement.build(), geometry);
        if (uom != null) {
            ts.setUnitOfMeasure(uom);
        }
        if (ts instanceof TextSymbolizer2 && options != null) {
            TextSymbolizer2 ts2 = (TextSymbolizer2) ts;
            ts2.getOptions().putAll(options);
        }
        reset();
        return ts;
    }
View Full Code Here


        PolygonSymbolizer ps = (PolygonSymbolizer) collector.symbolizers.get(0);
        assertEquals("#40FF40", ps.getFill().getColor().evaluate(null, String.class));
        assertEquals(Color.WHITE, ps.getStroke().getColor().evaluate(null, Color.class));
        assertEquals(2, (int) ps.getStroke().getWidth().evaluate(null, Integer.class));

        TextSymbolizer2 ts = (TextSymbolizer2) collector.symbolizers.get(1);
        assertEquals(ff.property("name"), ts.getLabel());
        assertEquals(Color.BLACK, ts.getFill().getColor().evaluate(null, Color.class));

        // font
        Font font = ts.getFont();
        assertEquals("Arial", font.getFamily().get(0).evaluate(null, String.class));
        assertEquals(11, (int) font.getSize().evaluate(null, Integer.class));
        assertEquals(Font.Style.NORMAL, font.getStyle().evaluate(null, String.class));
        assertEquals(Font.Weight.BOLD, font.getWeight().evaluate(null, String.class));

        // placement
        PointPlacement pp = (PointPlacement) ts.getLabelPlacement();
        assertEquals(0.5, pp.getAnchorPoint().getAnchorPointX().evaluate(null, Double.class), 0);
        assertEquals(0.5, pp.getAnchorPoint().getAnchorPointY().evaluate(null, Double.class), 0);

        // halo
        assertEquals(3, (int) ts.getHalo().getRadius().evaluate(null, Integer.class));
        assertEquals(Color.WHITE, ts.getHalo().getFill().getColor().evaluate(null, Color.class));

        // vendor options
        assertEquals(2, ts.getOptions().size());
        assertEquals("60", ts.getOptions().get("autoWrap"));
        assertEquals("150", ts.getOptions().get("maxDisplacement"));
    }
View Full Code Here

        if (copy.getHalo() != null) {
            copy.getHalo().setRadius(rescale(copy.getHalo().getRadius(), uom));
        }

        if (copy instanceof TextSymbolizer2) {
            TextSymbolizer2 copy2 = (TextSymbolizer2) copy;

            rescale(copy2.getGraphic(), uom);
        }

        // scale various options as well
        Map<String, String> options = copy.getOptions();
        scaleIntOption(options, TextSymbolizer.MAX_DISPLACEMENT_KEY, uom);
View Full Code Here

        copy.setLabelPlacement( copy( text.getLabelPlacement()));
        copy.setPriority( copy( text.getPriority()));
        copy.getOptions().putAll(text.getOptions());
       
        if (text instanceof TextSymbolizer2){
          TextSymbolizer2 text2 = (TextSymbolizer2) text;
          TextSymbolizer2 copy2 = (TextSymbolizer2) copy;
         
          copy2.setGraphic( copy(text2.getGraphic()));
          copy2.setSnippet(copy(text2.getSnippet()));
          copy2.setFeatureDescription(copy(text2.getFeatureDescription()));
          copy2.setOtherText(copy(text2.getOtherText()));
        }
       
        if( STRICT && !copy.equals( text )){
            throw new IllegalStateException("Was unable to duplicate provided TextSymbolizer:"+text );
        }
View Full Code Here

    /**
     * Test that {@link TextSymbolizer2} is correctly duplicated.
     * @author Stefan Tzeggai, June 29th 2010 
     */
    public void testTextSymbolizer2() {
        TextSymbolizer2 symb = (TextSymbolizer2) sf.createTextSymbolizer();
       
        // Create a Graphic with two recognizable values
        GraphicImpl gr = new GraphicImpl(ff);
        gr.setOpacity(ff.literal(0.77));
        gr.setSize(ff.literal(77));
        symb.setGraphic(gr);
        Literal snippet = ff.literal("no idea what a snipet is good for");
    symb.setSnippet(snippet);
        Literal fD = ff.literal("some description");
    symb.setFeatureDescription(fD);
        OtherTextImpl otherText = new OtherTextImpl();
        otherText.setTarget("otherTextTarget");
        otherText.setText(ff.literal("otherTextText"));
    symb.setOtherText(otherText);

    // copy it
        TextSymbolizer2 copy = (TextSymbolizer2) visitor.copy(symb);

        // compare it
        assertEquals("Graphic of TextSymbolizer2 has not been correctly duplicated", gr, copy
                .getGraphic());
        assertEquals("Graphic of TextSymbolizer2 has not been correctly duplicated", gr.getOpacity(), copy
                .getGraphic().getOpacity());
        assertEquals("Graphic of TextSymbolizer2 has not been correctly duplicated", gr.getSize(), copy
                .getGraphic().getSize());       
        assertEquals("Snippet of TextSymbolizer2 has not been correctly duplicated", snippet, copy
                .getSnippet());
        assertEquals("FeatureDescription of TextSymbolizer2 has not been correctly duplicated", fD, copy
                .getFeatureDescription());
        assertEquals("OtherText of TextSymbolizer2 has not been correctly duplicated", otherText.getTarget(), copy
                .getOtherText().getTarget());
        assertEquals("OtherText of TextSymbolizer2 has not been correctly duplicated", otherText.getText(), copy
                .getOtherText().getText());       
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.TextSymbolizer2

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.