@VisibleForTesting
    protected TextSymbolizer createTextSymbolizer(final PJsonObject styleJson) {
        final TextSymbolizer textSymbolizer = this.styleBuilder.createTextSymbolizer();

        // make sure that labels are also rendered if a part of the text would be outside
        // the view context, see http://docs.geoserver.org/stable/en/user/styling/sld-reference/labeling
        // .html#partials
        textSymbolizer.getOptions().put("partials", "true");

        if (styleJson.has(JSON_LABEL)) {
            final Expression label =
                    parseExpression(null, styleJson, JSON_LABEL,
                                    (final String labelValue) -> labelValue.replace("${", "")
                                            .replace("}", ""));

            textSymbolizer.setLabel(label);
        } else {
            return null;
        }

        textSymbolizer.setFont(createFont(textSymbolizer.getFont(), styleJson));

        if (styleJson.has(JSON_LABEL_ANCHOR_POINT_X) ||
                styleJson.has(JSON_LABEL_ANCHOR_POINT_Y) ||
                styleJson.has(JSON_LABEL_ALIGN) ||
                styleJson.has(JSON_LABEL_X_OFFSET) ||
                styleJson.has(JSON_LABEL_Y_OFFSET) ||
                styleJson.has(JSON_LABEL_ROTATION) ||
                styleJson.has(JSON_LABEL_PERPENDICULAR_OFFSET)) {
            textSymbolizer.setLabelPlacement(createLabelPlacement(styleJson));
        }

        if (!StringUtils.isEmpty(styleJson.optString(JSON_HALO_RADIUS)) ||
                !StringUtils.isEmpty(styleJson.optString(JSON_HALO_COLOR)) ||
                !StringUtils.isEmpty(styleJson.optString(JSON_HALO_OPACITY)) ||
                !StringUtils.isEmpty(styleJson.optString(JSON_LABEL_OUTLINE_WIDTH)) ||
                !StringUtils.isEmpty(styleJson.optString(JSON_LABEL_OUTLINE_COLOR))) {
            textSymbolizer.setHalo(createHalo(styleJson));
        }

        if (!StringUtils.isEmpty(styleJson.optString(JSON_FONT_COLOR)) ||
                !StringUtils.isEmpty(styleJson.optString(JSON_FONT_OPACITY))) {
            textSymbolizer.setFill(addFill(
                    styleJson.optString(JSON_FONT_COLOR, "black"),
                    styleJson.optString(JSON_FONT_OPACITY, "1.0")));
        }

        this.addVendorOptions(JSON_LABEL_ALLOW_OVERRUNS, styleJson, textSymbolizer);
        this.addVendorOptions(JSON_LABEL_AUTO_WRAP, styleJson, textSymbolizer);
        this.addVendorOptions(JSON_LABEL_CONFLICT_RESOLUTION, styleJson, textSymbolizer);
        this.addVendorOptions(JSON_LABEL_FOLLOW_LINE, styleJson, textSymbolizer);
        this.addVendorOptions(JSON_LABEL_GOODNESS_OF_FIT, styleJson, textSymbolizer);
        this.addVendorOptions(JSON_LABEL_GROUP, styleJson, textSymbolizer);
        this.addVendorOptions(JSON_LABEL_MAX_DISPLACEMENT, styleJson, textSymbolizer);
        this.addVendorOptions(JSON_LABEL_SPACE_AROUND, styleJson, textSymbolizer);

        return textSymbolizer;
    }
@ VisibleForTesting protected TextSymbolizer createTextSymbolizer ( final PJsonObject styleJson ) { final TextSymbolizer textSymbolizer = this . styleBuilder . createTextSymbolizer ( ) ; textSymbolizer . getOptions ( ) . put ( "partials" , "true" ) ; if ( styleJson . has ( JSON_LABEL ) ) { final Expression label = parseExpression ( null , styleJson , JSON_LABEL , ( final String labelValue ) -> labelValue . replace ( "${" , "" ) . replace ( "}" , "" ) ) ; textSymbolizer . setLabel ( label ) ; } else { return null ; } textSymbolizer . setFont ( createFont ( textSymbolizer . getFont ( ) , styleJson ) ) ; if ( styleJson . has ( JSON_LABEL_ANCHOR_POINT_X ) || styleJson . has ( JSON_LABEL_ANCHOR_POINT_Y ) || styleJson . has ( JSON_LABEL_ALIGN ) || styleJson . has ( JSON_LABEL_X_OFFSET ) || styleJson . has ( JSON_LABEL_Y_OFFSET ) || styleJson . has ( JSON_LABEL_ROTATION ) || styleJson . has ( JSON_LABEL_PERPENDICULAR_OFFSET ) ) { textSymbolizer . setLabelPlacement ( createLabelPlacement ( styleJson ) ) ; } if ( ! StringUtils . isEmpty ( styleJson . optString ( JSON_HALO_RADIUS ) ) || ! StringUtils . isEmpty ( styleJson . optString ( JSON_HALO_COLOR ) ) || ! StringUtils . isEmpty ( styleJson . optString ( JSON_HALO_OPACITY ) ) || ! StringUtils . isEmpty ( styleJson . optString ( JSON_LABEL_OUTLINE_WIDTH ) ) || ! StringUtils . isEmpty ( styleJson . optString ( JSON_LABEL_OUTLINE_COLOR ) ) ) { textSymbolizer . setHalo ( createHalo ( styleJson ) ) ; } if ( ! StringUtils . isEmpty ( styleJson . optString ( JSON_FONT_COLOR ) ) || ! StringUtils . isEmpty ( styleJson . optString ( JSON_FONT_OPACITY ) ) ) { textSymbolizer . setFill ( addFill ( styleJson . optString ( JSON_FONT_COLOR , "black" ) , styleJson . optString ( JSON_FONT_OPACITY , "1.0" ) ) ) ; } this . addVendorOptions ( JSON_LABEL_ALLOW_OVERRUNS , styleJson , textSymbolizer ) ; this . addVendorOptions ( JSON_LABEL_AUTO_WRAP , styleJson , textSymbolizer ) ; this . addVendorOptions ( JSON_LABEL_CONFLICT_RESOLUTION , styleJson , textSymbolizer ) ; this . addVendorOptions ( JSON_LABEL_FOLLOW_LINE , styleJson , textSymbolizer ) ; this . addVendorOptions ( JSON_LABEL_GOODNESS_OF_FIT , styleJson , textSymbolizer ) ; this . addVendorOptions ( JSON_LABEL_GROUP , styleJson , textSymbolizer ) ; this . addVendorOptions ( JSON_LABEL_MAX_DISPLACEMENT , styleJson , textSymbolizer ) ; this . addVendorOptions ( JSON_LABEL_SPACE_AROUND , styleJson , textSymbolizer ) ; return textSymbolizer ; }
Add a text symbolizer definition to the rule.

@param styleJson The old style.