use of org.geotools.styling.Symbolizer in project hale by halestudio.
the class RuleStylePage method addRule.
/**
* Add a new {@link Rule}
*/
protected void addRule() {
SymbolizerDialog symDlg = new SymbolizerDialog(getShell());
symDlg.open();
Symbolizer symbolizer = symDlg.getSymbolizer();
if (symbolizer != null) {
Rule rule = styleBuilder.createRule(symbolizer);
RuleItem item = new RuleItem(rule);
rules.add(item);
listViewer.add(item);
updateButtonState();
changed = true;
}
}
use of org.geotools.styling.Symbolizer in project hale by halestudio.
the class SimpleLineStylePage method createControl.
/**
* @see IDialogPage#createControl(Composite)
*/
@Override
public void createControl(Composite parent) {
// create new controls
Composite page = new Composite(parent, SWT.NONE);
RowLayout layout = new RowLayout(SWT.HORIZONTAL);
page.setLayout(layout);
Style style = getParent().getStyle();
LineSymbolizer line = null;
try {
Symbolizer[] symbolizers = SLD.symbolizers(style);
for (Symbolizer symbol : symbolizers) {
if (symbol instanceof LineSymbolizer) {
line = (LineSymbolizer) symbol;
break;
}
}
} catch (Exception e) {
// ignore
}
if (line == null) {
line = styleBuilder.createLineSymbolizer();
}
lineEditor = new LineSymbolizerEditor(page, line);
setControl(page);
}
use of org.geotools.styling.Symbolizer in project hale by halestudio.
the class StyleServiceImpl method getSelectedStyle.
/**
* Convert the given style for selection
*
* @param fts the feature type style to convert
*
* @return the converted feature type style
*/
private FeatureTypeStyle getSelectedStyle(FeatureTypeStyle fts) {
List<Rule> rules = fts.rules();
List<Rule> newRules = new ArrayList<Rule>();
for (Rule rule : rules) {
Symbolizer[] symbolizers = rule.getSymbolizers();
List<Symbolizer> newSymbolizers = new ArrayList<Symbolizer>();
for (Symbolizer symbolizer : symbolizers) {
// get symbolizers
List<Symbolizer> addSymbolizers = getSelectionSymbolizers(symbolizer);
if (addSymbolizers != null) {
newSymbolizers.addAll(addSymbolizers);
}
}
// create new rule
Rule newRule = styleBuilder.createRule(newSymbolizers.toArray(new Symbolizer[newSymbolizers.size()]));
newRule.setFilter(rule.getFilter());
newRule.setElseFilter(rule.isElseFilter());
newRule.setName(rule.getName());
newRules.add(newRule);
}
// TODO Handle case if there is more than one featureTypeName
return styleBuilder.createFeatureTypeStyle(fts.featureTypeNames().stream().findFirst().orElse(new NameImpl("Feature")).getLocalPart(), newRules.toArray(new Rule[newRules.size()]));
}
use of org.geotools.styling.Symbolizer in project hale by halestudio.
the class StyleServiceImpl method getSelectionSymbolizers.
/**
* Get the symbolizers representing the given symbolizer for a selection
*
* @param symbolizer the symbolizer
*
* @return the selection symbolizers
*/
private List<Symbolizer> getSelectionSymbolizers(Symbolizer symbolizer) {
List<Symbolizer> result = new ArrayList<Symbolizer>();
Color color = StylePreferences.getSelectionColor();
int width = StylePreferences.getSelectionWidth();
if (symbolizer instanceof PolygonSymbolizer) {
result.add(StyleHelper.createPolygonSymbolizer(color, width));
} else if (symbolizer instanceof LineSymbolizer) {
result.add(StyleHelper.createLineSymbolizer(color, width));
} else if (symbolizer instanceof PointSymbolizer) {
result.add(StyleHelper.mutatePointSymbolizer((PointSymbolizer) symbolizer, color, width));
// result.add(createPointSymbolizer(color, width));
} else {
// do not fall-back to original symbolizer cause we are painting
// over it
// result.add(symbolizer);
}
return result;
}
use of org.geotools.styling.Symbolizer in project hale by halestudio.
the class SimplePointStylePage method createControl.
/**
* @see IDialogPage#createControl(Composite)
*/
@Override
public void createControl(Composite parent) {
// create new controls
Composite page = new Composite(parent, SWT.NONE);
RowLayout layout = new RowLayout(SWT.HORIZONTAL);
page.setLayout(layout);
Style style = getParent().getStyle();
PointSymbolizer point = null;
try {
Symbolizer[] symbolizers = SLD.symbolizers(style);
for (Symbolizer symbol : symbolizers) {
if (symbol instanceof LineSymbolizer) {
point = (PointSymbolizer) symbol;
break;
}
}
} catch (Exception e) {
// ignore
}
if (point == null) {
point = styleBuilder.createPointSymbolizer();
}
pointEditor = new PointSymbolizerEditor(page, point);
setControl(page);
}
Aggregations