org.geotools.styling.Mark Java Examples

The following examples show how to use org.geotools.styling.Mark. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StyleConverterServiceImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
private GraphicalSymbol createSymbol(FeatureStyleInfo featureStyle) throws LayerException {
	SymbolInfo info = featureStyle.getSymbol();
	if (info.getImage() != null) {

		return styleBuilder.createExternalGraphic(getUrl(info.getImage().getHref()), getFormat(info.getImage()
				.getHref()));
	} else {
		Mark mark;
		if (info.getRect() != null) {
			// TODO: do rectangles by adding custom factory ?
			mark = styleBuilder.createMark(MARK_SQUARE);
		} else if (info.getCircle() != null) {
			mark = styleBuilder.createMark(MARK_CIRCLE);
		} else {
			throw new IllegalArgumentException(
					"Feature style should have either an image, a circle or a rectangle defined. Style name: " +
							featureStyle.getName() + ", index: " + featureStyle.getIndex());
		}
		mark.setFill(createFill(featureStyle));
		mark.setStroke(createStroke(featureStyle));
		return mark;
	}
}
 
Example #2
Source File: FieldConfigArrowTest.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.vendor.geoserver.marker.arrow.FieldConfigArrow#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigArrow field =
            new FieldConfigArrow(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    null,
                    null,
                    null);

    assertFalse(field.accept(null));

    StyleBuilder styleBuilder = new StyleBuilder();

    Mark marker1 = styleBuilder.createMark("star");
    assertFalse(field.accept(marker1));

    Mark marker2 = styleBuilder.createMark("extshape://arrow?hr=1.2&t=0.34&ab=0.56");
    assertTrue(field.accept(marker2));
}
 
Example #3
Source File: FieldConfigTTFTest.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigTTF field =
            new FieldConfigTTF(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    null,
                    null,
                    null);

    assertFalse(field.accept(null));

    StyleBuilder styleBuilder = new StyleBuilder();
    ExternalGraphicImpl externalGraphic =
            (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
    assertFalse(field.accept(externalGraphic));

    Mark marker1 = styleBuilder.createMark("triangle");
    assertFalse(field.accept(marker1));

    Mark marker2 = styleBuilder.createMark("ttf://Arial");
    assertTrue(field.accept(marker2));
}
 
Example #4
Source File: FieldConfigWindBarbsTest.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigWindBarbs field =
            new FieldConfigWindBarbs(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    null,
                    null,
                    null);

    assertFalse(field.accept(null));

    StyleBuilder styleBuilder = new StyleBuilder();
    ExternalGraphicImpl externalGraphic =
            (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
    assertFalse(field.accept(externalGraphic));

    Mark marker1 = styleBuilder.createMark("triangle");
    assertFalse(field.accept(marker1));

    Mark marker2 = styleBuilder.createMark("windbarbs://default(15)[kts]");
    assertTrue(field.accept(marker2));
}
 
Example #5
Source File: FieldConfigFilenameTest.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigFilename field =
            new FieldConfigFilename(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    null,
                    null,
                    null);

    assertFalse(field.accept(null));

    StyleBuilder styleBuilder = new StyleBuilder();
    ExternalGraphicImpl externalGraphic =
            (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
    assertTrue(field.accept(externalGraphic));

    Mark marker = styleBuilder.createMark("triangle");
    assertFalse(field.accept(marker));
}
 
Example #6
Source File: SLDTreeLeafPoint.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void createFill(Symbolizer symbolizer) {
    if (symbolizer instanceof PointSymbolizer) {
        PointSymbolizer point = (PointSymbolizer) symbolizer;

        Graphic graphic = point.getGraphic();
        if (graphic == null) {
            graphic = styleFactory.createDefaultGraphic();
            point.setGraphic(graphic);
        }

        if ((graphic != null) && graphic.graphicalSymbols().isEmpty()) {
            Mark mark = styleFactory.getDefaultMark();

            graphic.graphicalSymbols().add(mark);
        }
    }
}
 
Example #7
Source File: FieldConfigWindBarbs.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the value.
 *
 * @param symbolizerType the symbolizer type
 * @param fieldConfigManager the field config manager
 * @param multiOptionPanel the multi option panel
 * @param graphic the graphic
 * @param symbol the symbol
 */
@Override
public void setValue(
        Class<?> symbolizerType,
        GraphicPanelFieldManager fieldConfigManager,
        FieldConfigSymbolType multiOptionPanel,
        Graphic graphic,
        GraphicalSymbol symbol) {
    if (symbol != null) {
        if (symbol instanceof Mark) {
            MarkImpl markerSymbol = (MarkImpl) symbol;

            if (getConfigField() != null) {
                getConfigField().populate(markerSymbol.getWellKnownName());
            }

            if (multiOptionPanel != null) {
                multiOptionPanel.setSelectedItem(WINDBARB_SYMBOL_KEY);
            }
        }
    }
}
 
Example #8
Source File: GraphicViewer.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private void setMark(final Mark mark, final Mode mode) {
	listen(false);
	try {
		this.enabled = mode == Mode.POINT && mark != null;
		this.type = SLD.wellKnownName(mark);

		// Stroke is used in line, point and polygon
		this.on.setEnabled(mode == Mode.POINT || mode == Mode.ALL);

		if (this.type != null) {
			this.name.setText(this.type);
			this.name.select(this.name.indexOf(this.type));
		}

		this.on.setSelection(this.enabled);
		this.size.setEnabled(this.enabled);
		this.name.setEnabled(this.enabled);
	} finally {
		listen(true); // listen to user now
	}
}
 
Example #9
Source File: Utils.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Create a default point style.
 *
 * @return the created style.
 */
public static Style createPointStyle() {
	final Graphic gr = styleFactory.createDefaultGraphic();
	final Mark mark = styleFactory.getCircleMark();
	mark.setStroke(styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1)));
	mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN)));
	gr.graphicalSymbols().clear();
	gr.graphicalSymbols().add(mark);
	gr.setSize(filterFactory.literal(5));
	/*
	 * Setting the geometryPropertyName arg to null signals that we want to draw the default geomettry of features
	 */
	final PointSymbolizer sym = styleFactory.createPointSymbolizer(gr, null);

	final Rule rule = styleFactory.createRule();
	rule.symbolizers().add(sym);
	final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[] { rule });
	final Style style = styleFactory.createStyle();
	style.featureTypeStyles().add(fts);

	return style;
}
 
Example #10
Source File: LineSymbolizerWrapper.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private void initEndPointSymbolizers() {
    for( Symbolizer x : super.getParent().getRule().getSymbolizers() ) {
        if (x instanceof PointSymbolizer) {
            PointSymbolizer pnt = (PointSymbolizer) x;
            Expression ex = pnt.getGeometry();
            boolean endpnt = ex instanceof FilterFunction_endPoint;
            boolean startpnt = ex instanceof FilterFunction_startPoint;
            if (endpnt || startpnt) {
                GraphicalSymbol gs = pnt.getGraphic().graphicalSymbols().get(0);
                if (gs instanceof Mark) {
                    String name = ((Mark) gs).getWellKnownName().evaluate(null, String.class);
                    if (StyleUtilities.lineEndStyles.values().contains(name)) {
                        if (endpnt) {
                            endPointStyle = new PointSymbolizerWrapper(pnt, super.getParent());
                        } else if (startpnt) {
                            startPointStyle = new PointSymbolizerWrapper(pnt, super.getParent());
                        }
                    }
                }
            }
        }
    }
}
 
Example #11
Source File: StyleUtilities.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a default {@link Rule} for a point.
 * 
 * @return the default rule.
 */
public static Rule createDefaultPointRule() {
    Graphic graphic = sf.createDefaultGraphic();
    Mark circleMark = sf.getCircleMark();
    circleMark.setFill(sf.createFill(ff.literal("#" + Integer.toHexString(Color.RED.getRGB() & 0xffffff))));
    circleMark.setStroke(sf.createStroke(ff.literal("#" + Integer.toHexString(Color.BLACK.getRGB() & 0xffffff)),
            ff.literal(DEFAULT_WIDTH)));
    graphic.graphicalSymbols().clear();
    graphic.graphicalSymbols().add(circleMark);
    graphic.setSize(ff.literal(DEFAULT_SIZE));

    PointSymbolizer pointSymbolizer = sf.createPointSymbolizer();
    Rule rule = sf.createRule();
    rule.setName("New rule");
    rule.symbolizers().add(pointSymbolizer);

    pointSymbolizer.setGraphic(graphic);
    return rule;
}
 
Example #12
Source File: FieldConfigArrow.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the value.
 *
 * @param symbolizerType the symbolizer type
 * @param fieldConfigManager the field config manager
 * @param multiOptionPanel the multi option panel
 * @param graphic the graphic
 * @param symbol the symbol
 */
@Override
public void setValue(
        Class<?> symbolizerType,
        GraphicPanelFieldManager fieldConfigManager,
        FieldConfigSymbolType multiOptionPanel,
        Graphic graphic,
        GraphicalSymbol symbol) {
    if ((symbol instanceof Mark) && (fieldConfigManager != null)) {
        MarkImpl markerSymbol = (MarkImpl) symbol;

        FillImpl fill = markerSymbol.getFill();

        if (fill != null) {
            Expression expFillColour = fill.getColor();
            Expression expFillColourOpacity = fill.getOpacity();

            FieldConfigBase field = fieldConfigManager.get(FieldIdEnum.FILL_COLOUR);
            if (field != null) {
                field.populate(expFillColour);
            }
            field = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY);
            if (field != null) {
                field.populate(expFillColourOpacity);
            }
        }

        if (arrowPanel != null) {
            arrowPanel.populateExpression(markerSymbol.getWellKnownName().toString());
        }

        if (multiOptionPanel != null) {
            multiOptionPanel.setSelectedItem(ARROW_SYMBOL_KEY);
        }
    }
}
 
Example #13
Source File: GraphicViewer.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * TODO summary sentence for setGraphic ...
 *
 * @param graphic
 * @param mode
 * @param enabled
 */
public void setGraphic(final Graphic g, final Mode mode, final Color defaultColor) {
	Graphic graphic = g;
	boolean enabled = true;
	if (graphic == null) {
		final StyleBuilder builder = new StyleBuilder();
		graphic = builder.createGraphic(null, builder.createMark(StyleBuilder.MARK_SQUARE, defaultColor), null);
		enabled = true;
	}
	this.width = SLDs.size(graphic);
	final String text = MessageFormat.format("{0,number,#0}", this.width); //$NON-NLS-1$
	if (text != null) {
		this.size.setText(text);
		this.size.select(this.size.indexOf(text));
	}

	boolean marked = false;
	if (graphic != null && graphic.graphicalSymbols() != null && !graphic.graphicalSymbols().isEmpty()) {

		for (final GraphicalSymbol symbol : graphic.graphicalSymbols()) {
			if (symbol instanceof Mark) {
				final Mark mark = (Mark) symbol;
				setMark(mark, mode);
				marked = true;
				break;
			}
		}
	}
	if (!marked) {
		setMark(null, mode);
	}
	this.enabled = this.enabled && enabled;
}
 
Example #14
Source File: FieldConfigWindBarbs.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the value.
 *
 * @param fieldConfigManager the field config manager
 * @param symbolType the symbol type
 * @param fillEnabled the fill enabled
 * @param strokeEnabled the stroke enabled
 * @return the value
 */
@Override
public List<GraphicalSymbol> getValue(
        GraphicPanelFieldManager fieldConfigManager,
        Expression symbolType,
        boolean fillEnabled,
        boolean strokeEnabled) {
    List<GraphicalSymbol> symbolList = new ArrayList<>();

    Expression wellKnownName = null;
    if ((getConfigField() != null) && (fieldConfigManager != null)) {
        wellKnownName = getConfigField().getExpression();
        if (wellKnownName != null) {
            Expression expFillColour = null;
            Expression expFillColourOpacity = null;

            FieldConfigBase field = fieldConfigManager.get(FieldIdEnum.FILL_COLOUR);
            if (field != null) {
                FieldConfigColour colourField = (FieldConfigColour) field;

                expFillColour = colourField.getColourExpression();
            }

            Stroke stroke = null;
            Fill fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
            Expression size = null;
            Expression rotation = null;
            Mark mark =
                    getStyleFactory().createMark(wellKnownName, stroke, fill, size, rotation);

            symbolList.add(mark);
        }
    }
    return symbolList;
}
 
Example #15
Source File: FieldConfigMarker.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the fill.
 *
 * @param graphicFill the graphic fill
 * @param fieldConfigManager the field config manager
 * @return the fill
 */
@Override
public Fill getFill(GraphicFill graphicFill, GraphicPanelFieldManager fieldConfigManager) {
    if (fieldConfigManager == null) {
        return null;
    }
    Expression fillColour = null;
    FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
    if ((field instanceof FieldConfigColour) && field.isEnabled()) {
        fillColour = ((FieldConfigColour) field).getColourExpression();
    }

    Expression fillColourOpacity = null;
    field = fieldConfigManager.get(fillFieldConfig.getOpacity());
    if (field != null) {
        fillColourOpacity = field.getExpression();
    }

    GraphicFill localGraphicFill = null;
    Expression localFillColour = fillColour;
    Expression localFillColourOpacity = fillColourOpacity;
    if (graphicFill != null) {
        List<GraphicalSymbol> symbolList = graphicFill.graphicalSymbols();

        if ((symbolList != null) && (!symbolList.isEmpty())) {
            GraphicalSymbol symbol = symbolList.get(0);
            Mark mark = (Mark) symbol;
            if (mark.getWellKnownName() != null) {
                localGraphicFill = graphicFill;
                localFillColour = null;
                localFillColourOpacity = null;
            }
        }
    }
    return getStyleFactory().fill(localGraphicFill, localFillColour, localFillColourOpacity);
}
 
Example #16
Source File: StyleGenerator.java    From constellation with Apache License 2.0 5 votes vote down vote up
private static Style createPointStyle() {
    final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
    org.opengis.filter.FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory();

    final Mark mark = styleFactory.getCircleMark();
    mark.setStroke(styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1)));
    mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN)));

    final Graphic gr = styleFactory.getDefaultGraphic();
    gr.graphicalSymbols().clear();
    gr.graphicalSymbols().add(mark);
    gr.setSize(filterFactory.literal(5));

    // setting the geometryPropertyName arg to null signals that we want to draw the default geometry of features
    final PointSymbolizer sym = styleFactory.createPointSymbolizer(gr, null);

    // make rule
    final Rule rule = styleFactory.createRule();
    rule.symbolizers().add(sym);

    final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[]{rule});
    final Style style = styleFactory.createStyle();
    style.getDescription().setTitle("Point Style");
    style.featureTypeStyles().add(fts);

    return style;
}
 
Example #17
Source File: StyleConverterServiceImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
private Symbolizer createGeometrySymbolizer(FeatureStyleInfo featureStyle) throws LayerException {
	Symbolizer symbolizer;
	switch (featureStyle.getLayerType()) {
		case MULTIPOLYGON:
		case POLYGON:
			symbolizer = styleBuilder.createPolygonSymbolizer(createStroke(featureStyle), createFill(featureStyle));
			break;
		case MULTILINESTRING:
		case LINESTRING:
			symbolizer = styleBuilder.createLineSymbolizer(createStroke(featureStyle));
			break;
		case POINT:
		case MULTIPOINT:
			PointSymbolizer ps = styleBuilder.createPointSymbolizer();
			GraphicalSymbol symbol = createSymbol(featureStyle);
			Expression size = null;
			if (symbol instanceof Mark) {
				SymbolInfo info = featureStyle.getSymbol();
				if (info.getRect() != null) {
					size = styleBuilder.literalExpression((int) info.getRect().getW());
				} else if (info.getCircle() != null) {
					size = styleBuilder.literalExpression(2 * (int) info.getCircle().getR());
				} // else {} already handled by createSymbol()
			} else {
				size = styleBuilder.literalExpression(featureStyle.getSymbol().getImage().getHeight());
			}
			ps.getGraphic().setSize(size);
			ps.getGraphic().graphicalSymbols().clear();
			ps.getGraphic().graphicalSymbols().add(createSymbol(featureStyle));
			symbolizer = ps;
			break;
		default:
			throw new IllegalArgumentException("Unsupported geometry type " + featureStyle.getLayerType());
	}
	return symbolizer;
}
 
Example #18
Source File: FieldConfigWKTTest.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.FieldConfigWKT#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigWKT field =
            new FieldConfigWKT(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    null,
                    null,
                    null);

    assertFalse(field.accept(null));

    StyleBuilder styleBuilder = new StyleBuilder();
    ExternalGraphicImpl externalGraphic =
            (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
    assertFalse(field.accept(externalGraphic));

    Mark marker1 = styleBuilder.createMark("star");
    assertFalse(field.accept(marker1));

    // CHECKSTYLE:OFF
    Mark marker2 =
            styleBuilder.createMark(
                    "wkt://MULTILINESTRING((-0.25 -0.25, -0.125 -0.25), (0.125 -0.25, 0.25 -0.25), (-0.25 0.25, -0.125 0.25), (0.125 0.25, 0.25 0.25))");
    // CHECKSTYLE:ON
    assertTrue(field.accept(marker2));
}
 
Example #19
Source File: OmsMapsViewer.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
private void addFeatureCollections( MapContent map ) throws Exception {
    if (inVectors == null) {
        return;
    }
    for( String path : inVectors ) {
        SimpleFeatureCollection fc = OmsVectorReader.readVector(path);
        GeometryDescriptor geometryDescriptor = fc.getSchema().getGeometryDescriptor();
        EGeometryType type = EGeometryType.forGeometryDescriptor(geometryDescriptor);

        File file = new File(path);
        Style style = SldUtilities.getStyleFromFile(file);

        switch( type ) {
        case MULTIPOLYGON:
        case POLYGON:
            if (style == null) {
                Stroke polygonStroke = sf.createStroke(ff.literal(Color.BLUE), ff.literal(2));
                Fill polygonFill = sf.createFill(ff.literal(Color.BLUE), ff.literal(0.0));

                Rule polygonRule = sf.createRule();
                PolygonSymbolizer polygonSymbolizer = sf.createPolygonSymbolizer(polygonStroke, polygonFill, null);
                polygonRule.symbolizers().add(polygonSymbolizer);

                FeatureTypeStyle polygonFeatureTypeStyle = sf.createFeatureTypeStyle();
                polygonFeatureTypeStyle.rules().add(polygonRule);

                style = sf.createStyle();
                style.featureTypeStyles().add(polygonFeatureTypeStyle);
                style.setName("polygons");
            }
            break;
        case MULTIPOINT:
        case POINT:
            if (style == null) {
                Mark circleMark = sf.getCircleMark();
                Fill fill = sf.createFill(ff.literal(Color.RED));
                circleMark.setFill(fill);
                // circleMark.setStroke(null);

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

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

                FeatureTypeStyle pointsFeatureTypeStyle = sf.createFeatureTypeStyle();
                pointsFeatureTypeStyle.rules().add(pointRule);

                style = sf.createStyle();
                style.featureTypeStyles().add(pointsFeatureTypeStyle);
                style.setName("points");
            }
            break;
        case MULTILINESTRING:
        case LINESTRING:
            if (style == null) {
                Stroke lineStroke = sf.createStroke(ff.literal(Color.RED), ff.literal(2));

                Rule lineRule = sf.createRule();
                LineSymbolizer lineSymbolizer = sf.createLineSymbolizer(lineStroke, null);
                lineRule.symbolizers().add(lineSymbolizer);

                FeatureTypeStyle lineFeatureTypeStyle = sf.createFeatureTypeStyle();
                lineFeatureTypeStyle.rules().add(lineRule);

                style = sf.createStyle();
                style.featureTypeStyles().add(lineFeatureTypeStyle);
                style.setName("lines");
            }
            break;

        default:
            break;
        }

        FeatureLayer layer = new FeatureLayer(fc, style);
        map.addLayer(layer);

    }

}
 
Example #20
Source File: FieldConfigWindBarbsTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager,
 * org.opengis.filter.expression.Expression, boolean, boolean)}.
 */
@Test
public void testGetValue() {
    // Test it with null values
    boolean valueOnly = true;
    FieldConfigWindBarbs field =
            new FieldConfigWindBarbs(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    null,
                    null,
                    null);
    field.createUI();
    assertNull(field.getStringValue());

    GraphicPanelFieldManager fieldConfigManager = null;
    Expression symbolType = null;
    List<GraphicalSymbol> actualValue =
            field.getValue(fieldConfigManager, symbolType, false, false);

    assertTrue(actualValue.isEmpty());

    Class<?> panelId = PointFillDetails.class;
    fieldConfigManager = new GraphicPanelFieldManager(panelId);
    String actualMarkerSymbol = "solid";
    StyleBuilder styleBuilder = new StyleBuilder();
    symbolType = styleBuilder.literalExpression(actualMarkerSymbol);

    FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
    FieldConfigColour colourField =
            new FieldConfigColour(
                    new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(null, expectedColourValue);
    double expectedOpacityValue = 0.72;
    FieldConfigSlider opacityField =
            new FieldConfigSlider(
                    new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    opacityField.createUI();
    opacityField.populateField(expectedOpacityValue);
    FieldConfigBase symbolSelectionField =
            new FieldConfigSymbolType(
                    new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    symbolSelectionField.createUI();

    fieldConfigManager.add(colourFieldId, colourField);
    FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
    fieldConfigManager.add(opacityFieldId, opacityField);
    FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
    fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);

    // Try without setting any fields
    actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
    assertNotNull(actualValue);
    assertEquals(1, actualValue.size());
    Mark actualSymbol = (Mark) actualValue.get(0);
    assertTrue(
            actualSymbol.getWellKnownName().toString().compareTo("windbarbs://default(0)[m/s]")
                    == 0);
}
 
Example #21
Source File: FieldConfigMarkerTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigMarker field =
            new FieldConfigMarker(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    null,
                    null,
                    null);

    assertFalse(field.accept(null));

    StyleBuilder styleBuilder = new StyleBuilder();
    ExternalGraphicImpl externalGraphic =
            (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
    assertFalse(field.accept(externalGraphic));

    Mark marker = styleBuilder.createMark("triangle");
    assertFalse(field.accept(marker));

    List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();

    dataList.add(new ValueComboBoxData("star", "Star", this.getClass()));
    dataList.add(new ValueComboBoxData("square", "Square", this.getClass()));
    dataList.add(new ValueComboBoxData("triangle", "Triangle", this.getClass()));

    List<ValueComboBoxDataGroup> groupList = new ArrayList<ValueComboBoxDataGroup>();
    groupList.add(new ValueComboBoxDataGroup(dataList));

    field.populateSymbolList(String.class, groupList);
    field.populateSymbolList(PointFillDetails.class, groupList);
    assertTrue(field.accept(marker));
    field.populateSymbolList(PointFillDetails.class, groupList);
    assertTrue(field.accept(marker));

    // Try some invalid values
    StyleFactory sf = CommonFactoryFinder.getStyleFactory();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    marker = sf.createMark();
    marker.setWellKnownName(ff.property("testproperty"));
    assertFalse(field.accept(marker));

    marker = sf.createMark();
    marker.setWellKnownName(ff.literal(12));
    assertFalse(field.accept(marker));
}
 
Example #22
Source File: FieldConfigTTFTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF#setValue(com.sldeditor.ui.detail.GraphicPanelFieldManager,
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType, org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testSetValue() {

    GraphicPanelFieldManager fieldConfigManager = null;

    Class<?> panelId = PointFillDetails.class;
    fieldConfigManager = new GraphicPanelFieldManager(panelId);
    FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
    FieldConfigColour colourField =
            new FieldConfigColour(
                    new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(null, expectedColourValue);
    fieldConfigManager.add(colourFieldId, colourField);

    ColourFieldConfig fillConfig =
            new ColourFieldConfig(
                    GroupIdEnum.FILL,
                    FieldIdEnum.FILL_COLOUR,
                    FieldIdEnum.OVERALL_OPACITY,
                    FieldIdEnum.STROKE_WIDTH);
    ColourFieldConfig strokeConfig =
            new ColourFieldConfig(
                    GroupIdEnum.STROKE,
                    FieldIdEnum.STROKE_STROKE_COLOUR,
                    FieldIdEnum.OVERALL_OPACITY,
                    FieldIdEnum.STROKE_FILL_WIDTH);
    boolean valueOnly = true;
    FieldConfigTTF field =
            new FieldConfigTTF(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    fillConfig,
                    strokeConfig,
                    null);

    field.setValue(null, null, null, null, null);
    field.setValue(null, fieldConfigManager, null, null, null);

    field.createUI();
    StyleBuilder styleBuilder = new StyleBuilder();
    Mark marker = styleBuilder.createMark("star", Color.green, Color.black, 2.0);

    field.setValue(null, null, null, null, marker);
    field.setValue(null, fieldConfigManager, null, null, marker);
}
 
Example #23
Source File: FieldConfigMarkerTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#setValue(com.sldeditor.ui.detail.GraphicPanelFieldManager,
 * com.sldeditor.ui.detail.config.FieldConfigSymbolType, org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testSetValue() {

    GraphicPanelFieldManager fieldConfigManager = null;

    Class<?> panelId = PointSymbolizer.class;
    fieldConfigManager = new GraphicPanelFieldManager(panelId);

    // Test it with non null values
    FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
    FieldConfigColour colourField =
            new FieldConfigColour(
                    new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(null, expectedColourValue);
    double expectedOpacityValue = 0.72;
    FieldConfigSlider opacityField =
            new FieldConfigSlider(
                    new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    opacityField.createUI();
    opacityField.populateField(expectedOpacityValue);
    FieldConfigBase symbolSelectionField =
            new FieldConfigSymbolType(
                    new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    symbolSelectionField.createUI();

    fieldConfigManager.add(colourFieldId, colourField);
    FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
    fieldConfigManager.add(opacityFieldId, opacityField);
    FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
    fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);

    boolean valueOnly = true;

    ColourFieldConfig fillConfig =
            new ColourFieldConfig(
                    GroupIdEnum.FILL,
                    FieldIdEnum.FILL_COLOUR,
                    FieldIdEnum.OVERALL_OPACITY,
                    FieldIdEnum.STROKE_WIDTH);
    ColourFieldConfig strokeConfig =
            new ColourFieldConfig(
                    GroupIdEnum.STROKE,
                    FieldIdEnum.STROKE_STROKE_COLOUR,
                    FieldIdEnum.OVERALL_OPACITY,
                    FieldIdEnum.STROKE_FILL_WIDTH);

    FieldConfigMarker field2 =
            new FieldConfigMarker(
                    new FieldConfigCommonData(
                            PointSymbolizer.class,
                            FieldIdEnum.NAME,
                            "test label",
                            valueOnly,
                            false),
                    fillConfig,
                    strokeConfig,
                    null);

    field2.setValue(null, null, null, null, null);
    field2.setValue(null, fieldConfigManager, null, null, null);

    StyleBuilder styleBuilder = new StyleBuilder();
    Mark marker = styleBuilder.createMark("shape://plus");
    field2.setValue(null, null, null, null, marker);
    field2.setValue(PointSymbolizer.class, fieldConfigManager, null, null, marker);

    GroupConfig strokeGroup = new GroupConfig();
    strokeGroup.setId(strokeConfig.getGroup());
    fieldConfigManager.addGroup(strokeGroup);

    GroupConfig fillGroup = new GroupConfig();
    fillGroup.setId(fillConfig.getGroup());
    fieldConfigManager.addGroup(fillGroup);

    field2.setValue(PointSymbolizer.class, fieldConfigManager, null, null, marker);
}
 
Example #24
Source File: FieldConfigArrow.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Gets the value.
 *
 * @param fieldConfigManager the field config manager
 * @param symbolType the symbol type
 * @param fillEnabled the fill enabled
 * @param strokeEnabled the stroke enabled
 * @return the value
 */
@Override
public List<GraphicalSymbol> getValue(
        GraphicPanelFieldManager fieldConfigManager,
        Expression symbolType,
        boolean fillEnabled,
        boolean strokeEnabled) {
    List<GraphicalSymbol> symbolList = new ArrayList<>();

    if (fieldConfigManager != null) {
        Expression wellKnownName = null;
        if (getConfigField() != null) {
            wellKnownName = getConfigField().getExpression();
            if (wellKnownName != null) {
                // Stroke colour
                FieldConfigBase field = null;
                Stroke stroke = getStrokeValue(fieldConfigManager, strokeEnabled);

                // Fill colour
                Fill fill = getFillValue(fieldConfigManager, fillEnabled);

                field = fieldConfigManager.get(FieldIdEnum.STROKE_WIDTH);
                if (field != null) {
                    Expression strokeWidth = field.getExpression();
                    if (stroke != null) {
                        stroke.setWidth(strokeWidth);
                    }
                }

                Expression symbolSize = getSizeValue(fieldConfigManager);
                Expression rotation = null;
                Mark mark =
                        getStyleFactory()
                                .createMark(wellKnownName, stroke, fill, symbolSize, rotation);

                symbolList.add(mark);
            }
        }
    }
    return symbolList;
}
 
Example #25
Source File: FieldConfigWKT.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Gets the value.
 *
 * @param fieldConfigManager the field config manager
 * @param symbolType the symbol type
 * @param fillEnabled the fill enabled
 * @param strokeEnabled the stroke enabled
 * @return the value
 */
@Override
public List<GraphicalSymbol> getValue(
        GraphicPanelFieldManager fieldConfigManager,
        Expression symbolType,
        boolean fillEnabled,
        boolean strokeEnabled) {
    List<GraphicalSymbol> symbolList = new ArrayList<>();

    if (fieldConfigManager != null) {
        Expression wellKnownName = null;
        if (getConfigField() != null) {
            wellKnownName = getConfigField().getExpression();
            if (wellKnownName != null) {
                Stroke stroke = null;
                Fill fill = null;

                // Stroke colour
                if (strokeEnabled) {
                    stroke = getStrokeValue(fieldConfigManager);
                }

                // Fill colour
                if (fillEnabled) {
                    fill = getFillValue(fieldConfigManager);
                }

                Expression symbolSize = null;
                symbolSize = getSizeValue(fieldConfigManager, symbolSize);

                Expression rotation = null;
                Mark mark =
                        getStyleFactory()
                                .createMark(wellKnownName, stroke, fill, symbolSize, rotation);

                symbolList.add(mark);
            }
        }
    }
    return symbolList;
}
 
Example #26
Source File: FieldConfigWKT.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Sets the value.
 *
 * @param symbolizerType the symbolizer type
 * @param fieldConfigManager the field config manager
 * @param multiOptionPanel the multi option panel
 * @param graphic the graphic
 * @param symbol the symbol
 */
@Override
public void setValue(
        Class<?> symbolizerType,
        GraphicPanelFieldManager fieldConfigManager,
        FieldConfigSymbolType multiOptionPanel,
        Graphic graphic,
        GraphicalSymbol symbol) {
    if ((symbol instanceof Mark) && (fieldConfigManager != null)) {
        MarkImpl markerSymbol = (MarkImpl) symbol;

        // Fill
        FillImpl fill = markerSymbol.getFill();

        if (fill != null) {
            populateColour(
                    fieldConfigManager, fillFieldConfig, fill.getColor(), fill.getOpacity());
        }

        GroupConfigInterface fillGroup =
                fieldConfigManager.getGroup(
                        fieldConfigManager.getComponentId(), fillFieldConfig.getGroup());
        if (fillGroup != null) {
            fillGroup.enable(fill != null);
        }

        // Stroke
        StrokeImpl stroke = markerSymbol.getStroke();

        if (stroke != null) {
            populateColour(
                    fieldConfigManager,
                    strokeFieldConfig,
                    stroke.getColor(),
                    stroke.getOpacity());
        }
        GroupConfigInterface strokeGroup =
                fieldConfigManager.getGroup(
                        fieldConfigManager.getComponentId(), strokeFieldConfig.getGroup());
        if (strokeGroup != null) {
            strokeGroup.enable(stroke != null);
        }

        if (wktPanel != null) {
            wktPanel.populateExpression(markerSymbol.getWellKnownName().toString());
        }

        if (multiOptionPanel != null) {
            multiOptionPanel.setSelectedItem(WKT_SYMBOL_KEY);
        }
    }
}
 
Example #27
Source File: FieldConfigTTF.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Gets the value.
 *
 * @param fieldConfigManager the field config manager
 * @param symbolType the symbol type
 * @param fillEnabled the fill enabled
 * @param strokeEnabled the stroke enabled
 * @return the value
 */
@Override
public List<GraphicalSymbol> getValue(
        GraphicPanelFieldManager fieldConfigManager,
        Expression symbolType,
        boolean fillEnabled,
        boolean strokeEnabled) {
    List<GraphicalSymbol> symbolList = new ArrayList<>();

    Expression wellKnownName = null;
    if ((getConfigField() != null) && (fieldConfigManager != null)) {
        wellKnownName = getConfigField().getExpression();
        if (wellKnownName != null) {
            Stroke stroke = null;
            Fill fill = null;

            if (fillEnabled) {
                Expression expFillColour = null;
                Expression expFillColourOpacity = null;

                FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
                if (field != null) {
                    FieldConfigColour colourField = (FieldConfigColour) field;

                    expFillColour = colourField.getColourExpression();
                }

                field = fieldConfigManager.get(fillFieldConfig.getOpacity());
                if (field != null) {
                    expFillColourOpacity = field.getExpression();
                }
                fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
            }

            // Size
            Expression expSize = null;

            // Rotation
            Expression expRotation = null;

            Mark mark =
                    getStyleFactory()
                            .createMark(wellKnownName, stroke, fill, expSize, expRotation);

            symbolList.add(mark);
        }
    }
    return symbolList;
}
 
Example #28
Source File: FieldConfigMarker.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Gets the value.
 *
 * @param fieldConfigManager the field config manager
 * @param symbolType the symbol type
 * @param fillEnabled the fill enabled
 * @param strokeEnabled the stroke enabled
 * @return the value
 */
@Override
public List<GraphicalSymbol> getValue(
        GraphicPanelFieldManager fieldConfigManager,
        Expression symbolType,
        boolean fillEnabled,
        boolean strokeEnabled) {
    if ((symbolType == null) || (fieldConfigManager == null)) {
        return null;
    }

    Expression symbolTypeExpression = null;

    String symbolTypeName = symbolType.toString();
    if (symbolTypeName.compareTo(SOLID_SYMBOL_KEY) != 0) {
        symbolTypeExpression = symbolType;
    }

    Fill fill = null;
    Stroke stroke = null;

    if (symbolTypeName.startsWith(GEOSERVER_MARKER_PREFIX)) {
        stroke = getGeoServerStrokeValue(fieldConfigManager);
    } else {
        Expression fillColour = null;

        FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
        if (field != null) {
            fillColour = ((FieldConfigColour) field).getColourExpression();
        }

        Expression fillColourOpacity = null;
        field = fieldConfigManager.get(fillFieldConfig.getOpacity());
        if (field != null) {
            fillColourOpacity = field.getExpression();
        }

        if (fillEnabled) {
            fill = getStyleFactory().fill(null, fillColour, fillColourOpacity);
        }

        if (strokeEnabled) {
            Expression strokeColour = null;
            field = fieldConfigManager.get(strokeFieldConfig.getColour());
            if (field != null) {
                strokeColour = ((FieldConfigColour) field).getColourExpression();
            }

            Expression strokeColourOpacity = null;
            field = fieldConfigManager.get(strokeFieldConfig.getOpacity());
            if (field != null) {
                strokeColourOpacity = field.getExpression();
            }

            Expression strokeWidth = null;
            field = fieldConfigManager.get(strokeFieldConfig.getWidth());
            if (field != null) {
                strokeWidth = field.getExpression();
            }

            stroke =
                    getStyleFactory()
                            .createStroke(strokeColour, strokeWidth, strokeColourOpacity);
        }
    }

    Mark markerSymbol = getStyleFactory().mark(symbolTypeExpression, fill, stroke);

    return SelectedSymbol.getInstance().getSymbolList(markerSymbol);
}
 
Example #29
Source File: LineFillSymbol.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Convert to fill.
 *
 * @param layerName the layer name
 * @param element the element
 * @param transparency the transparency
 * @return the list
 */
/* (non-Javadoc)
 * @see com.sldeditor.convert.esri.symbols.EsriFillSymbolInterface#convertToFill(java.lang.String, com.google.gson.JsonElement, int)
 */
@Override
public List<Symbolizer> convertToFill(String layerName, JsonElement element, int transparency) {

    if (layerName == null)
    {
        return null;
    }

    if (element == null)
    {
        return null;
    }

    List<Symbolizer> symbolizerList = new ArrayList<Symbolizer>();

    JsonObject obj = element.getAsJsonObject();

    Expression size = ff.literal(getDouble(obj, LineFillSymbolKeys.SEPARATION));
    Expression opacity = null;
    double lineAngle = normaliseAngle(getDouble(obj, CommonSymbolKeys.ANGLE));

    Expression rotation = null;
    AnchorPoint anchorPoint = null;
    Displacement displacement = null;

    Expression fillColour = getColour(obj.get(LineFillSymbolKeys.FILL_COLOUR));
    Expression fillColourOpacity = null;

    Expression join = null;
    Expression cap = null;
    float[] dashes = null;
    Expression offset = null;

    Expression width = ff.literal(1.0);

    Stroke outlineStroke = null;
    
    List<Stroke> strokeList = SymbolManager.getInstance().getStrokeList(obj.get(LineFillSymbolKeys.OUTLINE));
    // TODO
    if((strokeList != null) && (strokeList.size() == 1))
    {
        outlineStroke = strokeList.get(0);

        width = outlineStroke.getWidth();
    }

    Expression wellKnownName = null;

    if(isDoubleEqual(lineAngle, 0.0) || isDoubleEqual(lineAngle, 180.0))
    {
        wellKnownName = ff.literal("shape://horline"); 
    }
    else if(isDoubleEqual(lineAngle, 90.0) || isDoubleEqual(lineAngle, 270.0))
    {
        wellKnownName = ff.literal("shape://vertline");
    }
    else if(isDoubleEqual(lineAngle, 45.0) || isDoubleEqual(lineAngle, 225.0))
    {
        wellKnownName = ff.literal("shape://slash");
    }
    else if(isDoubleEqual(lineAngle, 135.0) || isDoubleEqual(lineAngle, 315.0))
    {
        wellKnownName = ff.literal("shape://backslash");
    }
    else
    {
        wellKnownName = ff.literal("shape://vertline");
        rotation = ff.literal(lineAngle);
    }

    Fill fill = null;
    Stroke markStroke = styleFactory.stroke(fillColour, fillColourOpacity, width, join, cap, dashes, offset);
    Mark mark = styleFactory.createMark(wellKnownName, markStroke, fill, size, rotation);

    List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();

    symbolList.add(mark);

    GraphicFill graphicFill = styleFactory.graphicFill(symbolList, opacity, size, rotation, anchorPoint, displacement);

    Fill completeFill = styleFactory.fill(graphicFill, null, null);

    PolygonSymbolizer polygonSymbolizer = styleFactory.createPolygonSymbolizer();
    polygonSymbolizer.setFill(completeFill);
    polygonSymbolizer.setStroke(outlineStroke);

    symbolizerList.add(polygonSymbolizer);

    return symbolizerList;
}
 
Example #30
Source File: CharacterMarkerSymbol.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Convert.
 *
 * @param element the element
 * @return the marker graphic
 */
@Override
public List<Graphic> convert(JsonElement element) {

    if(element == null) return null;

    JsonObject obj = element.getAsJsonObject();

    List<Graphic> markerList = new ArrayList<Graphic>();

    double angle = getDouble(obj, CommonSymbolKeys.ANGLE);
    double symbolSize = getDouble(obj, CommonSymbolKeys.SIZE);
    double xOffset = getDouble(obj, CommonSymbolKeys.X_OFFSET);
    double yOffset = getDouble(obj, CommonSymbolKeys.Y_OFFSET);

    JsonElement fontElement = obj.get(CharacterMarkerSymbolKeys.FONT);

    if(fontElement != null)
    {
        JsonObject fontObj = fontElement.getAsJsonObject();

        String fontName = getString(fontObj, FontSymbolKeys.FONT_NAME);
        int code = getInt(obj, CharacterMarkerSymbolKeys.CHARACTER_INDEX);

        Expression wellKnownName = ff.literal(String.format("ttf://%s#%s", fontName, code));

        // Create colour
        Expression colour = getColour(obj.get(CommonSymbolKeys.COLOUR));

        Fill fill = styleFactory.createFill(colour);
        Stroke stroke = null;

        Mark mark = styleFactory.mark(wellKnownName, fill, stroke);

        ExternalGraphic [] externalGraphics = null;
        Mark[] marks = new Mark[1];
        marks[0] = mark;

        Symbol[] symbols = null;
        Expression opacity = null;
        Expression rotation = ff.literal(angle);
        Expression size = ff.literal(symbolSize);

        Graphic graphic = styleFactory.createGraphic(externalGraphics, marks, symbols, opacity, size, rotation);

        // Displacement (offsets)
        if((xOffset > 0.0) && (yOffset > 0.0))
        {
            Expression expressionX = ff.literal(xOffset);
            Expression expressionY = ff.literal(yOffset);
            Displacement displacement = styleFactory.createDisplacement(expressionX, expressionY);

            graphic.setDisplacement(displacement);
        }
        markerList.add(graphic);
    }
    return markerList;
}