use of org.geotools.styling.Rule in project hale by halestudio.
the class StyledInstanceMarker method initStyle.
/**
* Initialize the style information.
*
* @param context the context
*/
private synchronized void initStyle(InstanceWaypoint context) {
if (!styleInitialized.compareAndSet(false, true)) {
// already initialized
return;
}
// check if there is a Rule from the Rulestyle-Page and apply to the
// instancemarker on the map
// performs a special task if the found symbolizer is a point symbolizer
Rule honoredRule = honorRules(context);
pointSymbolizer = null;
for (Symbolizer sym : honoredRule.symbolizers()) {
if (sym instanceof PointSymbolizer) {
pointSymbolizer = (PointSymbolizer) sym;
break;
}
}
fillStyle(honoredRule, context);
strokeStyle(honoredRule, context);
}
use of org.geotools.styling.Rule in project hale by halestudio.
the class StyledInstanceMarker method sortRules.
/**
* Sorts an array of rules, so the else-filter-rules are at the end
*
* @param rules an array of Rules
* @return a new array of Rules with sorted elements
*/
private Rule[] sortRules(Rule[] rules) {
ArrayList<Rule> temp = new ArrayList<Rule>();
for (int i = 0; i < rules.length; i++) {
if (!rules[i].isElseFilter()) {
temp.add(rules[i]);
}
}
for (int i = 0; i < rules.length; i++) {
if (rules[i].isElseFilter()) {
temp.add(rules[i]);
}
}
Rule[] newRules = new Rule[temp.size()];
return temp.toArray(newRules);
}
use of org.geotools.styling.Rule in project sldeditor by robward-scisys.
the class MXDParser method processLabelRenderer.
/**
* Gets the label renderer.
*
* @param sld the sld
* @param labelRenderArrayElement the label render array element
* @param transparency the transparency
*/
private void processLabelRenderer(StyledLayerDescriptor sld, JsonArray labelRenderArrayElement, int transparency) {
if (sld != null) {
if (labelRenderArrayElement != null) {
List<StyledLayer> styledLayers = sld.layers();
if (!styledLayers.isEmpty()) {
if (styledLayers.get(0) instanceof NamedLayer) {
NamedLayer namedLayer = (NamedLayer) styledLayers.get(0);
List<Style> styleList = namedLayer.styles();
if (!styleList.isEmpty()) {
List<FeatureTypeStyle> ftsList = styleList.get(0).featureTypeStyles();
if (!ftsList.isEmpty()) {
List<Rule> ruleList = ftsList.get(0).rules();
List<Rule> newLabelRuleList = new ArrayList<Rule>();
for (int index = 0; index < labelRenderArrayElement.size(); index++) {
JsonElement labelRenderElement = labelRenderArrayElement.get(index);
JsonObject renderer = labelRenderElement.getAsJsonObject();
boolean found = false;
for (String labelRendererType : labelRendererMap.keySet()) {
JsonElement obj = renderer.get(labelRendererType);
if (obj != null) {
EsriLabelRendererInterface esriLabelRenderer = labelRendererMap.get(labelRendererType);
if (esriLabelRenderer != null) {
for (Rule rule : ruleList) {
esriLabelRenderer.convert(newLabelRuleList, rule, obj, transparency);
}
}
found = true;
break;
}
}
if (!found) {
ConsoleManager.getInstance().error(this, "Unsupported label renderer : " + SymbolUtils.extractName(labelRenderElement));
}
}
ruleList.addAll(newLabelRuleList);
}
}
}
}
}
}
}
use of org.geotools.styling.Rule in project sldeditor by robward-scisys.
the class SLDTreeSymbolizerButtonStateTest method testLine.
/**
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#setGeometryType(com.sldeditor.datasource.impl.GeometryTypeEnum)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isMarkerVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isLineVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isPolygonVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isRasterVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isTextVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlineLineVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlinePolygonVisible(java.lang.Object, java.lang.Object)}.
*/
@Test
public void testLine() {
SLDTreeSymbolizerButtonState obj = new SLDTreeSymbolizerButtonState();
obj.setGeometryType(GeometryTypeEnum.LINE);
obj.showSymbolizerButtons();
assertFalse(obj.isLineVisible(null, null));
assertFalse(obj.isMarkerVisible(null, null));
assertFalse(obj.isPolygonVisible(null, null));
assertFalse(obj.isRasterVisible(null, null));
assertFalse(obj.isTextVisible(null, null));
assertFalse(obj.isImageOutlineLineVisible(null, null));
assertFalse(obj.isImageOutlinePolygonVisible(null, null));
Rule rule = DefaultSymbols.createNewRule();
assertTrue(obj.isLineVisible(null, rule));
assertTrue(obj.isTextVisible(null, rule));
}
use of org.geotools.styling.Rule in project sldeditor by robward-scisys.
the class SLDTreeSymbolizerButtonStateTest method testMarker.
/**
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#setGeometryType(com.sldeditor.datasource.impl.GeometryTypeEnum)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isMarkerVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isLineVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isPolygonVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isRasterVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isTextVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlineLineVisible(java.lang.Object, java.lang.Object)}.
* Test method for {@link com.sldeditor.ui.tree.SLDTreeSymbolizerButtonState#isImageOutlinePolygonVisible(java.lang.Object, java.lang.Object)}.
*/
@Test
public void testMarker() {
SLDTreeSymbolizerButtonState obj = new SLDTreeSymbolizerButtonState();
obj.setGeometryType(GeometryTypeEnum.POINT);
obj.showSymbolizerButtons();
assertFalse(obj.isLineVisible(null, null));
assertFalse(obj.isMarkerVisible(null, null));
assertFalse(obj.isPolygonVisible(null, null));
assertFalse(obj.isRasterVisible(null, null));
assertFalse(obj.isTextVisible(null, null));
assertFalse(obj.isImageOutlineLineVisible(null, null));
assertFalse(obj.isImageOutlinePolygonVisible(null, null));
Rule rule = DefaultSymbols.createNewRule();
assertTrue(obj.isMarkerVisible(null, rule));
assertTrue(obj.isTextVisible(null, rule));
}
Aggregations