Examples of TextSymbolizer


Examples of org.geotools.styling.TextSymbolizer

        PolygonStyle2D ps = (PolygonStyle2D) sld.createPolygonStyle(feature, symb, range);
        assertTrue(ps.getFill() instanceof TexturePaint);
    }
   
    public void testUnknownFont() throws Exception {
      TextSymbolizer ts = sf.createTextSymbolizer();
      ts.setFill(sf.createFill(null));
      Font font = sf.createFont(ff.literal("notExistingFont"), ff.literal("italic"), ff.literal("bold"), ff.literal(20));
      ts.setFont(font);
     
      TextStyle2D tsd = (TextStyle2D) sld.createTextStyle(feature, ts, range);
      assertEquals(20, tsd.getFont().getSize());
      assertEquals(java.awt.Font.ITALIC | java.awt.Font.BOLD, tsd.getFont().getStyle());
      assertEquals("Serif", tsd.getFont().getName());
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

        assertTrue(rbe.isEstimateAccurate());
    }

    @Test
    public void testTextDisplaced() {
        TextSymbolizer ts = sb.createTextSymbolizer();
        ts.setFont(sb.createFont("Arial", 20));
        PointPlacement pp = sb.createPointPlacement(1, 1, 10, 10, 0);
        ts.setLabelPlacement(pp);
        Style style = sb.createStyle(ts);
        MetaBufferEstimator rbe = new MetaBufferEstimator();
        rbe.visit(style);
        // 20 (font) + 20 * 0.5 (anchor) + 10 (offset)
        assertEquals(40, rbe.getBuffer());
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

    // creation of the TextSymbolizer
    AnchorPoint anchorPoint = sb.createAnchorPoint(sb.attributeExpression("X"),
            sb.attributeExpression("Y"));
    PointPlacement pointPlacement = sb.createPointPlacement(anchorPoint, null,
            sb.literalExpression(0));
    TextSymbolizer textSymbolizer = sb.createTextSymbolizer(sb.createFill(Color.BLACK), new Font[] {
            sb.createFont("Lucida Sans", 10), sb.createFont("Arial", 10) }, sb.createHalo(),
            sb.attributeExpression("name"), pointPlacement, null);
   
    // creation of the Point symbolizer
    Mark circle = sb.createMark(StyleBuilder.MARK_CIRCLE, Color.RED);
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

    // "labelPoint" feature type style
    AnchorPoint anchorPoint = sb.createAnchorPoint(sb.attributeExpression("X"),
            sb.attributeExpression("Y"));
    PointPlacement pointPlacement = sb.createPointPlacement(anchorPoint, null,
            sb.literalExpression(0));
    TextSymbolizer textSymbolizer = sb.createTextSymbolizer(sb.createFill(Color.BLACK), new Font[] {
            sb.createFont("Lucida Sans", 10), sb.createFont("Arial", 10) }, sb.createHalo(),
            sb.attributeExpression("name"), pointPlacement, null);
    Mark circle = sb.createMark(StyleBuilder.MARK_CIRCLE, Color.RED);
    Graphic graph2 = sb.createGraphic(null, circle, null, 1, 4, 0);
    PointSymbolizer pointSymbolizer = sb.createPointSymbolizer(graph2);
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

    @Override
    public void visit(TextSymbolizer text) {
        this.defaultUnit = text.getUnitOfMeasure();
        try {
            super.visit(text);
            TextSymbolizer copy = (TextSymbolizer) pages.peek();

            // rescales fonts
            Font[] fonts = copy.getFonts();
            for (Font font : fonts) {
                font.setSize(rescale(font.getSize()));
            }
            copy.setFonts(fonts);

            // rescales label placement
            LabelPlacement placement = copy.getLabelPlacement();
            if (placement instanceof PointPlacement) {
                // rescales point label placement
                PointPlacement pointPlacement = (PointPlacement) placement;
                Displacement disp = pointPlacement.getDisplacement();
                if (disp != null) {
                    disp.setDisplacementX(rescale(disp.getDisplacementX()));
                    disp.setDisplacementY(rescale(disp.getDisplacementY()));
                    pointPlacement.setDisplacement(disp);
                }
            } else if (placement instanceof LinePlacement) {
                // rescales line label placement
                LinePlacement linePlacement = (LinePlacement) placement;
                linePlacement.setGap(rescale(linePlacement.getGap()));
                linePlacement.setInitialGap(rescale(linePlacement.getInitialGap()));
                linePlacement.setPerpendicularOffset(rescale(linePlacement.getPerpendicularOffset()));
            }
            copy.setLabelPlacement(placement);
           
            // rescale the halo
            if(copy.getHalo() != null) {
                copy.getHalo().setRadius(rescale(copy.getHalo().getRadius()));
            }
           
            // deal with the format options specified in pixels
            Map<String, String> options = copy.getOptions();
            rescaleOption(options, SPACE_AROUND_KEY, DEFAULT_SPACE_AROUND);
            rescaleOption(options, MAX_DISPLACEMENT_KEY, DEFAULT_MAX_DISPLACEMENT);
            rescaleOption(options, MIN_GROUP_DISTANCE_KEY, DEFAULT_MIN_GROUP_DISTANCE);
            rescaleOption(options, LABEL_REPEAT_KEY, DEFAULT_LABEL_REPEAT);
            rescaleOption(options, AUTO_WRAP_KEY, DEFAULT_AUTO_WRAP);
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

    @SuppressWarnings("deprecation")
    @Override
    public void visit(TextSymbolizer text) {
        super.visit(text);
        TextSymbolizer copy = (TextSymbolizer) pages.peek();

        Unit<Length> uom = copy.getUnitOfMeasure();
        // rescales fonts
        Font[] fonts = copy.getFonts();
        for (Font font : fonts)
            font.setSize(rescale(font.getSize(), uom));
        copy.setFonts(fonts);

        // rescales label placement
        LabelPlacement placement = copy.getLabelPlacement();
        if (placement instanceof PointPlacement) {
            // rescales point label placement
            PointPlacement pointPlacement = (PointPlacement) placement;
            Displacement disp = pointPlacement.getDisplacement();
            if (disp != null) {
                disp.setDisplacementX(rescale(disp.getDisplacementX(), uom));
                disp.setDisplacementY(rescale(disp.getDisplacementY(), uom));
                pointPlacement.setDisplacement(disp);
            }
        } else if (placement instanceof LinePlacement) {
            // rescales line label placement
            LinePlacement linePlacement = (LinePlacement) placement;
            linePlacement.setGap(rescale(linePlacement.getGap(), uom));
            linePlacement.setInitialGap(rescale(linePlacement.getInitialGap(), uom));
            linePlacement.setPerpendicularOffset(rescale(linePlacement.getPerpendicularOffset(),
                    uom));
        }
        copy.setLabelPlacement(placement);

        // rescale the halo
        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);
        scaleIntOption(options, TextSymbolizer.SPACE_AROUND_KEY, uom);
        scaleIntOption(options, TextSymbolizer.MIN_GROUP_DISTANCE_KEY, uom);
        scaleIntOption(options, TextSymbolizer.LABEL_REPEAT_KEY, uom);
        scaleIntOption(options, TextSymbolizer.AUTO_WRAP_KEY, uom);
        scaleIntArrayOption(options, TextSymbolizer.GRAPHIC_MARGIN_KEY, uom);

        copy.setUnitOfMeasure(NonSI.PIXEL);
    }
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

        }
        pages.push(copy);
    }

    public void visit(TextSymbolizer text) {
        TextSymbolizer copy = sf.createTextSymbolizer();
       
        copy.setFill( copy( text.getFill()));
        copy.setFont( copy( text.getFont()));
       
        copy.setGeometry(copy(text.getGeometry()));
       
        copy.setUnitOfMeasure(text.getUnitOfMeasure());
        copy.setHalo( copy( text.getHalo() ));
        copy.setLabel( copy( text.getLabel()));
        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 );
        }
        pages.push(copy);
    }
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

    @Override
    public void visit(TextSymbolizer text) {
        this.defaultUnit = text.getUnitOfMeasure();
        try {
            super.visit(text);
            TextSymbolizer copy = (TextSymbolizer) pages.peek();

            // rescales fonts
            Font[] fonts = copy.getFonts();
            for (Font font : fonts) {
                font.setSize(rescale(font.getSize()));
            }
            copy.setFonts(fonts);

            // rescales label placement
            LabelPlacement placement = copy.getLabelPlacement();
            if (placement instanceof PointPlacement) {
                // rescales point label placement
                PointPlacement pointPlacement = (PointPlacement) placement;
                Displacement disp = pointPlacement.getDisplacement();
                if (disp != null) {
                    disp.setDisplacementX(rescale(disp.getDisplacementX()));
                    disp.setDisplacementY(rescale(disp.getDisplacementY()));
                    pointPlacement.setDisplacement(disp);
                }
            } else if (placement instanceof LinePlacement) {
                // rescales line label placement
                LinePlacement linePlacement = (LinePlacement) placement;
                linePlacement.setGap(rescale(linePlacement.getGap()));
                linePlacement.setInitialGap(rescale(linePlacement.getInitialGap()));
                linePlacement.setPerpendicularOffset(rescale(linePlacement.getPerpendicularOffset()));
            }
            copy.setLabelPlacement(placement);
           
            // rescale the halo
            if(copy.getHalo() != null) {
                copy.getHalo().setRadius(rescale(copy.getHalo().getRadius()));
            }
           
            // deal with the format options specified in pixels
            Map<String, String> options = copy.getOptions();
            rescaleOption(options, SPACE_AROUND_KEY, DEFAULT_SPACE_AROUND);
            rescaleOption(options, MAX_DISPLACEMENT_KEY, DEFAULT_MAX_DISPLACEMENT);
            rescaleOption(options, MIN_GROUP_DISTANCE_KEY, DEFAULT_MIN_GROUP_DISTANCE);
            rescaleOption(options, LABEL_REPEAT_KEY, DEFAULT_LABEL_REPEAT);
            rescaleOption(options, AUTO_WRAP_KEY, DEFAULT_AUTO_WRAP);
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

            textSymb.addToOptions(TextSymbolizer.GRAPHIC_MARGIN_KEY, maxDisplacement + " " + maxDisplacement * 2);

            visitor = new UomRescaleStyleVisitor(scaleMetersToPixel);

            textSymb.accept(visitor);
            TextSymbolizer rescaledTextSymb = (TextSymbolizer) visitor.getCopy();
           
            double rescaledFontSize = rescaledTextSymb.getFont().getSize().evaluate(null, Double.class);
            PointPlacement rescaledPlacement = (PointPlacement) rescaledTextSymb.getLabelPlacement();
            double rescaledDisplacementXSize = rescaledPlacement.getDisplacement().getDisplacementX().evaluate(null, Double.class);
            double rescaledDisplacementYSize = rescaledPlacement.getDisplacement().getDisplacementY().evaluate(null, Double.class);
           
            assertEquals(Math.round(expectedRescaledFontSize), Math.round(rescaledFontSize));
            assertEquals(Math.round(expectedRescaledDisplacementXSize), Math.round(rescaledDisplacementXSize));
            assertEquals(Math.round(expectedRescaledDisplacementYSize), Math.round(rescaledDisplacementYSize));
            assertNotSame(rescaledTextSymb, textSymb);
           
            Map<String, String> options = rescaledTextSymb.getOptions();
            int rescaledMaxDisplacement = Converters.convert(options.get("maxDisplacement"), Integer.class).intValue();
            assertEquals(rescaledMaxDisplacement, expectedMaxDisplacement);
           
            String[] splitted = options.get(TextSymbolizer.GRAPHIC_MARGIN_KEY).split("\\s+");
            int rescaledGraphicMargin1 = Converters.convert(splitted[0], Integer.class).intValue();
View Full Code Here

Examples of org.geotools.styling.TextSymbolizer

            textSymb.setLabelPlacement(placement);
           
            visitor = new UomRescaleStyleVisitor(scaleMetersToPixel);

            textSymb.accept(visitor);
            TextSymbolizer rescaledTextSymb = (TextSymbolizer) visitor.getCopy();
           
            double rescaledFontSize = rescaledTextSymb.getFont().getSize().evaluate(null, Double.class);
            LinePlacement rescaledPlacement = (LinePlacement) rescaledTextSymb.getLabelPlacement();
            double rescaledPerpOffset = rescaledPlacement.getPerpendicularOffset().evaluate(null, Double.class);
            double rescaledGap = rescaledPlacement.getGap().evaluate(null, Double.class);
            double rescaledInitialGap = rescaledPlacement.getInitialGap().evaluate(null, Double.class);
           
            assertEquals(Math.round(expectedRescaledFontSize), Math.round(rescaledFontSize));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.