use of org.geotools.styling.LineSymbolizer in project hale by halestudio.
the class StyledInstanceMarker method strokeStyle.
/**
* retrieves the stroke for the map marker
*
* @param rule a certain rule to apply, maybe null
* @param context the InstanceWayPoint, wich gets marked
*/
private synchronized void strokeStyle(Rule rule, InstanceWaypoint context) {
// retrieve stroke
Stroke stroke = null;
for (int i = 0; rule != null && stroke == null && i < rule.getSymbolizers().length; i++) {
if (rule.getSymbolizers()[i] instanceof LineSymbolizer) {
stroke = SLD.stroke((LineSymbolizer) rule.getSymbolizers()[i]);
} else if (rule.getSymbolizers()[i] instanceof PolygonSymbolizer) {
stroke = SLD.stroke((PolygonSymbolizer) rule.getSymbolizers()[i]);
} else if (rule.getSymbolizers()[i] instanceof PointSymbolizer) {
stroke = SLD.stroke((PointSymbolizer) rule.getSymbolizers()[i]);
}
}
// if we have a stroke now
if (stroke != null) {
// XXX is there any Geotools stroke to AWT stroke lib/code
// somewhere?!
// XXX have a look at the renderer code (StreamingRenderer)
// stroke color
Color sldColor = SLD.color(stroke);
double opacity = SLD.opacity(stroke);
if (Double.isNaN(opacity)) {
// fall back to default opacity
opacity = StyleHelper.DEFAULT_FILL_OPACITY;
}
if (sldColor != null) {
styleStrokeColor = new Color(sldColor.getRed(), sldColor.getGreen(), sldColor.getBlue(), (int) (opacity * 255));
} else {
styleStrokeColor = super.getBorderColor(context);
}
// stroke width
int strokeWidth = SLD.width(stroke);
if (strokeWidth == SLD.NOTFOUND) {
// fall back to default width
strokeWidth = StylePreferences.getDefaultWidth();
}
styleStroke = new BasicStroke(strokeWidth);
} else {
styleStroke = null;
styleStrokeColor = null;
}
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SelectedSymbolTest method testReplacment.
/**
* Test method for
* {@link com.sldeditor.common.data.SelectedSymbol#removeRule(org.geotools.styling.Rule)}.
*/
@Test
public void testReplacment() {
SelectedSymbol.destroyInstance();
SelectedSymbol instance = SelectedSymbol.getInstance();
Rule rule = DefaultSymbols.createNewRule();
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
Style style = DefaultSymbols.createNewStyle();
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
instance.createNewSLD(sld);
instance.setSld(sld);
instance.addNewStyledLayer(namedLayer);
instance.setStyledLayer(namedLayer);
instance.addNewStyle(style);
instance.setStyle(style);
instance.addNewFeatureTypeStyle(fts);
instance.setFeatureTypeStyle(fts);
instance.addNewRule(rule);
instance.setRule(rule);
instance.addSymbolizerToRule(polygonSymbolizer);
instance.addNewRule(DefaultSymbols.createNewRule());
instance.setSymbolizer(polygonSymbolizer);
LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
DummySLDTreeUpdated dummyTreeUpdated = new DummySLDTreeUpdated();
instance.setTreeUpdateListener(dummyTreeUpdated);
instance.replaceSymbolizer(lineSymbolizer);
assertEquals(lineSymbolizer, instance.getSymbolizer());
assertEquals(dummyTreeUpdated.objectOld, polygonSymbolizer);
assertEquals(dummyTreeUpdated.objectNew, lineSymbolizer);
Rule newRule = DefaultSymbols.createNewRule();
newRule.setTitle("Replacement rule");
instance.replaceRule(newRule);
assertEquals(newRule, instance.getRule());
assertNull(instance.getSymbolizer());
FeatureTypeStyle newFts = DefaultSymbols.createNewFeatureTypeStyle();
newFts.setName("Replacement fts");
instance.replaceFeatureTypeStyle(newFts);
assertEquals(newFts, instance.getFeatureTypeStyle());
assertNull(instance.getRule());
Style newStyle = DefaultSymbols.createNewStyle();
newStyle.setName("Replacement style");
instance.replaceStyle(newStyle);
assertEquals(newStyle, instance.getStyle());
assertNull(instance.getRule());
NamedLayer newNamedLayer = DefaultSymbols.createNewNamedLayer();
newNamedLayer.setName("Replacement named layer");
instance.replaceStyledLayer(newNamedLayer);
assertEquals(newNamedLayer, instance.getStyledLayer());
assertNull(instance.getStyle());
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SymbolDataTest method testSetSymbolizer.
@Test
public void testSetSymbolizer() {
SymbolData symbolData = new SymbolData();
LineSymbolizer symbolizer = DefaultSymbols.createDefaultLineSymbolizer();
symbolData.setSymbolizer(symbolizer);
assertEquals(symbolizer, symbolData.getSymbolizer());
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDTreeLeafFactoryTest method testUpdateFill.
/**
* Test method for
* {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#updateFill(boolean, org.opengis.style.Symbolizer)}.
*/
@Test
public void testUpdateFill() {
assertNull(SLDTreeLeafFactory.getInstance().updateFill(true, null));
PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
assertEquals(SLDTreeLeafFactory.getInstance().updateFill(false, polygonSymbolizer), styleFactory.getDefaultFill());
assertTrue(SLDTreeLeafFactory.getInstance().updateFill(true, polygonSymbolizer) != null);
PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
assertEquals(SLDTreeLeafFactory.getInstance().updateFill(false, pointSymbolizer), styleFactory.getDefaultFill());
assertTrue(SLDTreeLeafFactory.getInstance().updateFill(true, pointSymbolizer) != null);
LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
assertEquals(SLDTreeLeafFactory.getInstance().updateFill(false, lineSymbolizer), styleFactory.getDefaultFill());
assertEquals(SLDTreeLeafFactory.getInstance().updateFill(true, lineSymbolizer), styleFactory.getDefaultFill());
TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
assertEquals(SLDTreeLeafFactory.getInstance().updateFill(false, textSymbolizer), styleFactory.getDefaultFill());
assertEquals(SLDTreeLeafFactory.getInstance().updateFill(true, textSymbolizer), styleFactory.getDefaultFill());
}
use of org.geotools.styling.LineSymbolizer in project sldeditor by robward-scisys.
the class SLDTreeLeafFactoryTest method testIsItemSelected.
/**
* Test method for
* {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#isItemSelected(java.lang.Object, org.geotools.styling.Symbolizer)}.
*/
@Test
public void testIsItemSelected() {
assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(null, null));
PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
assertTrue(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultFill(), polygonSymbolizer));
assertTrue(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultStroke(), polygonSymbolizer));
PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
assertTrue(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultFill(), pointSymbolizer));
assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultStroke(), pointSymbolizer));
LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultFill(), lineSymbolizer));
assertTrue(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultStroke(), lineSymbolizer));
TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultFill(), textSymbolizer));
assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultStroke(), textSymbolizer));
}
Aggregations