use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class PrepareStyleVisitor method visit.
@Override
public Object visit(PolygonSymbolizer ps, Object o) {
Displacement disp = ps.getDisplacement();
Fill fill = ps.getFill();
Expression offset = ps.getPerpendicularOffset();
Stroke stroke = ps.getStroke();
if (disp != null) {
disp = (Displacement) disp.accept(this, o);
}
if (fill != null) {
fill = (Fill) fill.accept(this, o);
}
if (offset != null) {
offset = (Expression) visit(offset);
}
if (stroke != null) {
stroke = (Stroke) stroke.accept(this, o);
}
// recreate symbolizer
return SF.polygonSymbolizer(ps.getName(), visitGeometryExpression(ps, o), ps.getDescription(), ps.getUnitOfMeasure(), stroke, fill, disp, offset);
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class PrepareStyleVisitor method visit.
@Override
public Object visit(LineSymbolizer ls, Object o) {
Expression offset = ls.getPerpendicularOffset();
Stroke stroke = ls.getStroke();
if (offset != null) {
visit(offset);
}
if (stroke != null) {
stroke = (Stroke) stroke.accept(this, o);
}
// recreate symbolizer
return SF.lineSymbolizer(ls.getName(), visitGeometryExpression(ls, o), ls.getDescription(), ls.getUnitOfMeasure(), stroke, offset);
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class InterpolateTest method interpolate.
@Test
public void interpolate() {
final String attribut = "att_value";
final FilterFactory ff = FilterUtilities.FF;
final MutableStyleFactory sf = new DefaultStyleFactory();
final FeatureTypeBuilder sftb = new FeatureTypeBuilder();
sftb.setName("test");
sftb.addAttribute(Double.class).setName(attribut);
final FeatureType sft = sftb.build();
final Feature f1 = sft.newInstance();
f1.setPropertyValue(attribut, 0d);
final Feature f2 = sft.newInstance();
f2.setPropertyValue(attribut, 5d);
final Feature f3 = sft.newInstance();
f3.setPropertyValue(attribut, 10d);
final Feature f4 = sft.newInstance();
f4.setPropertyValue(attribut, 15d);
final Expression Lookup = ff.property(attribut);
final List<InterpolationPoint> values = new ArrayList<>();
// test color interpolation ---------------------------------------------
values.clear();
values.add(new DefaultInterpolationPoint(0d, ff.literal(BLACK)));
values.add(new DefaultInterpolationPoint(10d, ff.literal(RED)));
values.add(new DefaultInterpolationPoint(20d, ff.literal(BLUE)));
Interpolate interpolate = new DefaultInterpolate(Lookup, values, Method.COLOR, Mode.CUBIC, null);
Color c = (Color) interpolate.apply(f1);
assertEquals(c, BLACK);
c = (Color) interpolate.apply(f2);
assertEquals(c.getAlpha(), 255);
assertEquals(c.getRed(), 127);
assertEquals(c.getGreen(), 0);
assertEquals(c.getBlue(), 0);
c = (Color) interpolate.apply(f3);
assertEquals(c, RED);
// test color interpolation ---------------------------------------------
values.clear();
values.add(new DefaultInterpolationPoint(0d, sf.literal(BLACK)));
values.add(new DefaultInterpolationPoint(10d, sf.literal(RED)));
values.add(new DefaultInterpolationPoint(20d, sf.literal(BLUE)));
interpolate = new DefaultInterpolate(Lookup, values, Method.COLOR, Mode.CUBIC, null);
c = (Color) interpolate.apply(f1);
assertEquals(c, BLACK);
c = (Color) interpolate.apply(f2);
assertEquals(c.getAlpha(), 255);
assertEquals(c.getRed(), 127);
assertEquals(c.getGreen(), 0);
assertEquals(c.getBlue(), 0);
c = (Color) interpolate.apply(f3);
assertEquals(c, RED);
// test number interpolation --------------------------------------------
values.clear();
values.add(new DefaultInterpolationPoint(0d, ff.literal(0d)));
values.add(new DefaultInterpolationPoint(10d, ff.literal(100d)));
values.add(new DefaultInterpolationPoint(20d, ff.literal(50d)));
interpolate = new DefaultInterpolate(Lookup, values, Method.COLOR, Mode.CUBIC, null);
Double d = (Double) interpolate.apply(f1);
assertEquals(d.doubleValue(), 0d, 0d);
d = (Double) interpolate.apply(f2);
assertEquals(d.doubleValue(), 50d, 0d);
d = (Double) interpolate.apply(f3);
assertEquals(d.doubleValue(), 100d, 0d);
d = (Double) interpolate.apply(f4);
assertEquals(d.doubleValue(), 75d, 0d);
// test get lookup property
Collection<String> requieredAttributs = new HashSet<String>();
ListingPropertyVisitor.VISITOR.visit(interpolate, requieredAttributs);
assertEquals(requieredAttributs.size(), 1);
assertEquals(requieredAttributs.iterator().next(), attribut);
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class RandomStyleBuilder method createRandomLineSymbolizer.
public static LineSymbolizer createRandomLineSymbolizer() {
final Unit uom = Units.POINT;
final String geom = StyleConstants.DEFAULT_GEOM;
final String name = null;
final Stroke stroke = SF.stroke(randomColor(), 1);
final Expression offset = FF.literal(0);
return SF.lineSymbolizer(name, geom, StyleConstants.DEFAULT_DESCRIPTION, uom, stroke, offset);
}
use of org.opengis.filter.Expression in project geotoolkit by Geomatys.
the class RandomStyleBuilder method createRandomPolygonSymbolizer.
public static PolygonSymbolizer createRandomPolygonSymbolizer() {
final Unit uom = Units.POINT;
final String geom = StyleConstants.DEFAULT_GEOM;
final String name = null;
final Fill fill = SF.fill(SF.literal(randomColor()), FF.literal(0.6f));
final Stroke stroke = SF.stroke(randomColor(), 1);
final Displacement displacement = SF.displacement(0, 0);
final Expression offset = FF.literal(0);
return SF.polygonSymbolizer(name, geom, StyleConstants.DEFAULT_DESCRIPTION, uom, stroke, fill, displacement, offset);
}
Aggregations