use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class FieldConfigTTF method getValue.
/**
* 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<GraphicalSymbol>();
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;
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class FieldConfigWindBarbs method getValue.
/**
* 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<GraphicalSymbol>();
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;
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class FieldConfigArrow method getValue.
/**
* 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<GraphicalSymbol>();
if (fieldConfigManager != null) {
Expression wellKnownName = null;
if (getConfigField() != null) {
wellKnownName = getConfigField().getExpression();
if (wellKnownName != null) {
// Stroke colour
FieldConfigBase field = null;
Stroke stroke = null;
if (strokeEnabled && (strokeFieldConfig != null)) {
Expression expStrokeColour = null;
Expression expStrokeColourOpacity = null;
field = fieldConfigManager.get(strokeFieldConfig.getColour());
if (field != null) {
if (field instanceof FieldConfigColour) {
FieldConfigColour colourField = (FieldConfigColour) field;
expStrokeColour = colourField.getColourExpression();
}
}
field = fieldConfigManager.get(strokeFieldConfig.getOpacity());
if (field != null) {
expStrokeColourOpacity = field.getExpression();
}
stroke = getStyleFactory().createStroke(expStrokeColour, expStrokeColourOpacity);
}
// Fill colour
Fill fill = null;
if (fillEnabled && (fillFieldConfig != null)) {
Expression expFillColour = null;
Expression expFillColourOpacity = null;
field = fieldConfigManager.get(fillFieldConfig.getColour());
if (field != null) {
if (field instanceof FieldConfigColour) {
FieldConfigColour colourField = (FieldConfigColour) field;
expFillColour = colourField.getColourExpression();
}
}
field = fieldConfigManager.get(fillFieldConfig.getOpacity());
if (field != null) {
expFillColourOpacity = field.getExpression();
}
fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
}
field = fieldConfigManager.get(FieldIdEnum.STROKE_WIDTH);
if (field != null) {
Expression strokeWidth = field.getExpression();
stroke.setWidth(strokeWidth);
}
Expression symbolSize = null;
field = fieldConfigManager.get(FieldIdEnum.STROKE_SYMBOL_SIZE);
if (field != null) {
symbolSize = field.getExpression();
}
Expression rotation = null;
Mark mark = getStyleFactory().createMark(wellKnownName, stroke, fill, symbolSize, rotation);
symbolList.add(mark);
}
}
}
return symbolList;
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class FieldConfigMarkerTest method testGetValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#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;
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 field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, null);
assertNull(field.getStringValue());
GraphicPanelFieldManager fieldConfigManager = null;
Expression symbolType = null;
List<GraphicalSymbol> actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
assertNull(actualValue);
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));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(null, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", 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);
assertNull(actualSymbol.getWellKnownName());
// Try with symbol type of solid
FieldConfigMarker field2 = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, symbolSelectionFieldId);
actualValue = field2.getValue(fieldConfigManager, symbolType, false, false);
assertNotNull(actualValue);
assertEquals(1, actualValue.size());
actualSymbol = (Mark) actualValue.get(0);
assertNull(actualSymbol.getWellKnownName());
// Try with symbol type of circle
actualMarkerSymbol = "circle";
symbolType = styleBuilder.literalExpression(actualMarkerSymbol);
actualValue = field2.getValue(fieldConfigManager, symbolType, false, false);
assertNotNull(actualValue);
assertEquals(1, actualValue.size());
actualSymbol = (Mark) actualValue.get(0);
assertTrue(actualSymbol.getWellKnownName().toString().compareTo(actualMarkerSymbol) == 0);
assertNull(actualSymbol.getFill());
assertNull(actualSymbol.getStroke());
// Enable stroke and fill flags
actualValue = field2.getValue(fieldConfigManager, symbolType, true, true);
assertNotNull(actualValue);
assertEquals(1, actualValue.size());
actualSymbol = (Mark) actualValue.get(0);
assertTrue(actualSymbol.getWellKnownName().toString().compareTo(actualMarkerSymbol) == 0);
assertNotNull(actualSymbol.getFill());
assertNotNull(actualSymbol.getStroke());
}
use of org.opengis.style.GraphicalSymbol in project sldeditor by robward-scisys.
the class FieldConfigFilenameTest method testGetValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, org.opengis.filter.expression.Expression, boolean, boolean)}.
*/
@Test
public void testGetValue() {
boolean valueOnly = true;
FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
assertNull(field.getValue(null, null, false, false));
field.createUI();
List<GraphicalSymbol> actualValue = field.getValue(null, null, false, false);
assertFalse(actualValue.isEmpty());
}
Aggregations