/** * Retrieve the opacity value of an Expression. * * @param opacity Expression object * @returna double value or 1.0 if unavailable. */ private static double opacity(Expression opacity) { if (opacity == null) { return 1.0; } double value = Filters.asDouble(opacity); return (Double.isNaN(value) ? 1.0 : value); }
/** * Retrieves the opacity from a RasterSymbolizer. * * <p>If you are using something fun like rules you will need to do your own thing. * * @param symbolizer Raster symbolizer information. * @return opacity of the first RasterSymbolizer or NaN if unavailable. */ public static double rasterOpacity(RasterSymbolizer symbolizer) { if (symbolizer == null) { return Double.NaN; } return Filters.asDouble(symbolizer.getOpacity()); }
/** * Retrieve the opacity from the provided fill; or return the default. * * @param fill * @return opacity from the above fill; or return the Fill.DEFAULT value */ public static double opacity(Fill fill) { if (fill == null) { fill = Fill.DEFAULT; } Expression opacityExp = fill.getOpacity(); if (opacityExp == null) { opacityExp = Fill.DEFAULT.getOpacity(); } return Filters.asDouble(opacityExp); }
/** * Retrieves the halo opacity from the first TextSymbolizer. * * @param symbolizer Text symbolizer information. * @return double of the halo's opacity, or NaN if unavailable. */ public static double textHaloOpacity(TextSymbolizer symbolizer) { if (symbolizer == null) { return Double.NaN; } Halo halo = symbolizer.getHalo(); if (halo == null) { return Double.NaN; } Fill fill = halo.getFill(); if (fill == null) { return Double.NaN; } Expression expr = fill.getOpacity(); if (expr == null) { return Double.NaN; } return Filters.asDouble(expr); }
/** * Retrieves the point border opacity from a PointSymbolizer. * * <p>If you are using something fun like rules you will need to do your own thing. * * @param symbolizer Point symbolizer information. * @return double of the point's border opacity, or NaN if unavailable. */ public static double pointBorderOpacity(PointSymbolizer symbolizer) { if (symbolizer == null) { return Double.NaN; } Graphic graphic = symbolizer.getGraphic(); if (graphic == null) { return Double.NaN; } for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs != null && gs instanceof Mark) { Mark mark = (Mark) gs; Stroke stroke = mark.getStroke(); if (stroke != null) { Expression exp = stroke.getOpacity(); return Filters.asDouble(exp); } } } return Double.NaN; }
/** * This method is here for backward compatability. * * @param expr DOCUMENT ME! * * @return DOCUMENT ME! * * @see Filters#doubleValue(Expression) * @deprecated */ public static double doubleValue(Expression expr) { return Filters.asDouble(expr); }
/** * Retrieve the opacity value of an Expression. * * @param opacity Expression object * * @returna double value or 1.0 if unavailable. */ private static double opacity( Expression opacity ) { if( opacity == null ){ return 1.0; } double value = Filters.asDouble(opacity); return (Double.isNaN(value) ? 1.0 : value); }
/** * Retrieves the opacity from a RasterSymbolizer. * <p> * If you are using something fun like rules you will need to do your own * thing. * </p> * * @param symbolizer Raster symbolizer information. * @return opacity of the first RasterSymbolizer or NaN if unavailable. */ public static double rasterOpacity(RasterSymbolizer symbolizer) { if (symbolizer == null) { return Double.NaN; } return Filters.asDouble(symbolizer.getOpacity()); }
/** * Retrieve the opacity from the provided fill; or return the default. * @param fill * @return opacity from the above fill; or return the Fill.DEFAULT value */ public static double opacity(Fill fill) { if (fill == null) { fill = Fill.DEFAULT; } Expression opacityExp = fill.getOpacity(); if( opacityExp == null ){ opacityExp = Fill.DEFAULT.getOpacity(); } return Filters.asDouble(opacityExp); }
valeur = Filters.asDouble(sym.getFill().getOpacity()); } else if (value instanceof PointSymbolizer) { PointSymbolizer sym = (PointSymbolizer) value; valeur = Filters.asDouble(sym.getGraphic().getOpacity()); } else if (value instanceof LineSymbolizer) { LineSymbolizer sym = (LineSymbolizer) value; valeur = Filters.asDouble(sym.getStroke().getOpacity()); } else if (value instanceof RasterSymbolizer) { RasterSymbolizer sym = (RasterSymbolizer) value; valeur = Filters.asDouble(sym.getOpacity());
assertEquals(0.5, Filters.asDouble(placement.getAnchorPoint().getAnchorPointX()), 0.1); assertEquals(0.0, Filters.asDouble(placement.getAnchorPoint().getAnchorPointY()), 0.1); assertEquals(0, Filters.asInt(placement.getDisplacement().getDisplacementX())); assertEquals(5, Filters.asInt(placement.getDisplacement().getDisplacementY()));
/** * Retrieves the halo opacity from the first TextSymbolizer. * * @param symbolizer Text symbolizer information. * * @return double of the halo's opacity, or NaN if unavailable. */ public static double textHaloOpacity(TextSymbolizer symbolizer) { if (symbolizer == null) { return Double.NaN; } Halo halo = symbolizer.getHalo(); if (halo == null) { return Double.NaN; } Fill fill = halo.getFill(); if (fill == null) { return Double.NaN; } Expression expr = fill.getOpacity(); if( expr == null ){ return Double.NaN; } return Filters.asDouble(expr); }
assertEquals(0.5, Filters.asDouble(placement.getAnchorPoint().getAnchorPointX()), 0.1); assertEquals(0.0, Filters.asDouble(placement.getAnchorPoint().getAnchorPointY()), 0.1); assertEquals(0, Filters.asInt(placement.getDisplacement().getDisplacementX())); assertEquals(25, Filters.asInt(placement.getDisplacement().getDisplacementY()));
@Test public void testRasterWithTransparentGradient() throws Exception { // <UserStyle> // <Title>SLD Cook Book: Transparent gradient</Title> // <FeatureTypeStyle> // <Rule> // <RasterSymbolizer> // <Opacity>0.3</Opacity> // <ColorMap> // <ColorMapEntry color="#008000" quantity="70" /> // <ColorMapEntry color="#663333" quantity="256" /> // </ColorMap> // </RasterSymbolizer> // </Rule> // </FeatureTypeStyle> // </UserStyle> Style style = parse("raster", "transparent-gradient.sld"); RasterSymbolizer raster = SLD.rasterSymbolizer(style); assertEquals(0.3, Filters.asDouble(raster.getOpacity()), 0.1); ColorMapEntry e = raster.getColorMap().getColorMapEntry(0); assertEquals("#008000", Filters.asString(e.getColor())); assertEquals(70, Filters.asInt(e.getQuantity())); e = raster.getColorMap().getColorMapEntry(1); assertEquals("#663333", Filters.asString(e.getColor())); assertEquals(256, Filters.asInt(e.getQuantity())); }
private Double format(MapLayer layer) { FeatureTypeStyle[] sty = layer.getStyle().getFeatureTypeStyles(); double valeur = 1d; Rule[] rules = sty[0].getRules(); for (int i = 0; i < rules.length; i++) { Rule r = rules[i]; //on regarde si la regle s'applique au maplayer (s'il n'y a aucun filtre) if (r.getFilter() == null) { Symbolizer[] symbolizers = r.getSymbolizers(); for (int j = 0; j < symbolizers.length; j++) { if (symbolizers[j] instanceof PolygonSymbolizer) { PolygonSymbolizer sym = (PolygonSymbolizer) symbolizers[j]; valeur = Filters.asDouble(sym.getFill().getOpacity()); } else if (symbolizers[j] instanceof PointSymbolizer) { PointSymbolizer sym = (PointSymbolizer) symbolizers[j]; //valeur = SLD.pointOpacity(sym); valeur = Filters.asDouble(sym.getGraphic().getOpacity()); } else if (symbolizers[j] instanceof LineSymbolizer) { LineSymbolizer sym = (LineSymbolizer) symbolizers[j]; valeur = Filters.asDouble(sym.getStroke().getOpacity()); } else if (symbolizers[j] instanceof RasterSymbolizer) { RasterSymbolizer sym = (RasterSymbolizer) symbolizers[j]; valeur = Filters.asDouble(sym.getOpacity()); } } } } return valeur; }
assertEquals(7.5, Filters.asDouble(stroke.getDashOffset()), 0.1);
assertEquals(0.5, Filters.asDouble(contrast.getGammaValue()), 0.1); assertEquals(ContrastMethod.NORMALIZE, contrast.getMethod());
/** * Retrieves the point border opacity from a PointSymbolizer. * <p> * If you are using something fun like rules you will need to do your own * thing. * * @param symbolizer Point symbolizer information. * * @return double of the point's border opacity, or NaN if unavailable. */ public static double pointBorderOpacity(PointSymbolizer symbolizer) { if (symbolizer == null) { return Double.NaN; } Graphic graphic = symbolizer.getGraphic(); if (graphic == null) { return Double.NaN; } for (GraphicalSymbol gs : graphic.graphicalSymbols()) { if (gs != null && gs instanceof Mark) { Mark mark = (Mark) gs; Stroke stroke = mark.getStroke(); if (stroke != null) { Expression exp = stroke.getOpacity(); return Filters.asDouble(exp); } } } return Double.NaN; }