org.geotools.styling.Fill.getOpacity()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中org.geotools.styling.Fill.getOpacity()方法的一些代码示例,展示了Fill.getOpacity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fill.getOpacity()方法的具体详情如下:
包路径:org.geotools.styling.Fill
类名称:Fill
方法名:getOpacity

Fill.getOpacity介绍

[英]This specifies the level of translucency to use when rendering the fill.
The value is encoded as a floating-point value between 0.0 and 1.0 with 0.0 representing totally transparent and 1.0 representing totally opaque, with a linear scale of translucency for intermediate values.
For example, "0.65" would represent 65% opacity. The default value is 1.0 (opaque).
[中]这指定渲染填充时要使用的半透明级别。
该值被编码为介于0.0和1.0之间的浮点值,0.0表示完全透明,1.0表示完全不透明,中间值具有半透明的线性比例。
例如,“0.65”表示65%的不透明度。默认值为1.0(不透明)。

代码示例

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Retrieve the opacity from the provided fill; or return the default.
  3. *
  4. * @param fill
  5. * @return opacity from the above fill; or return the Fill.DEFAULT value
  6. */
  7. public static double opacity(Fill fill) {
  8. if (fill == null) {
  9. fill = Fill.DEFAULT;
  10. }
  11. Expression opacityExp = fill.getOpacity();
  12. if (opacityExp == null) {
  13. opacityExp = Fill.DEFAULT.getOpacity();
  14. }
  15. return Filters.asDouble(opacityExp);
  16. }

代码示例来源:origin: geotools/geotools

  1. public void visit(Fill fill) {
  2. checkOpacity(fill.getOpacity());
  3. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Computes the Composite equivalent to the opacity in the SLD Fill
  3. *
  4. * @param fill
  5. * @param feature
  6. */
  7. protected Composite getComposite(Fill fill, Object feature) {
  8. if (fill == null) {
  9. return null;
  10. }
  11. // get the opacity and prepare the composite
  12. float opacity = evalOpacity(fill.getOpacity(), feature);
  13. Composite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity);
  14. return composite;
  15. }

代码示例来源:origin: geotools/geotools

  1. /** Computes and returns the fill composite based on the feature and the symbolizer */
  2. public Composite getFillComposite() {
  3. Fill fill = ps.getFill();
  4. if (fill == null) {
  5. return null;
  6. }
  7. // get the opacity and prepare the composite
  8. float opacity = ((Float) fill.getOpacity().evaluate(feature, Float.class)).floatValue();
  9. if (opacity == 1) {
  10. return null;
  11. }
  12. return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity);
  13. }
  14. }

代码示例来源:origin: geotools/geotools

  1. /** Reset to produce the default Fill. */
  2. public FillBuilder reset() {
  3. unset = false;
  4. color = Fill.DEFAULT.getColor();
  5. opacity = Fill.DEFAULT.getOpacity();
  6. graphic.unset();
  7. return this;
  8. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Retrieves the halo opacity from the first TextSymbolizer.
  3. *
  4. * @param symbolizer Text symbolizer information.
  5. * @return double of the halo's opacity, or NaN if unavailable.
  6. */
  7. public static double textHaloOpacity(TextSymbolizer symbolizer) {
  8. if (symbolizer == null) {
  9. return Double.NaN;
  10. }
  11. Halo halo = symbolizer.getHalo();
  12. if (halo == null) {
  13. return Double.NaN;
  14. }
  15. Fill fill = halo.getFill();
  16. if (fill == null) {
  17. return Double.NaN;
  18. }
  19. Expression expr = fill.getOpacity();
  20. if (expr == null) {
  21. return Double.NaN;
  22. }
  23. return Filters.asDouble(expr);
  24. }

代码示例来源:origin: geotools/geotools

  1. public void visit(Fill fill) {
  2. Fill copy = sf.getDefaultFill();
  3. copy.setBackgroundColor(copy(fill.getBackgroundColor()));
  4. copy.setColor(copy(fill.getColor()));
  5. copy.setGraphicFill(copy(fill.getGraphicFill()));
  6. copy.setOpacity(copy(fill.getOpacity()));
  7. if (STRICT && !copy.equals(fill)) {
  8. throw new IllegalStateException("Was unable to duplicate provided Fill:" + fill);
  9. }
  10. pages.push(copy);
  11. }

代码示例来源:origin: geotools/geotools

  1. /** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Fill) */
  2. public void visit(Fill fill) {
  3. if (fill.getBackgroundColor() != null) {
  4. fill.getBackgroundColor().accept(this, null);
  5. }
  6. if (fill.getColor() != null) {
  7. fill.getColor().accept(this, null);
  8. }
  9. if (fill.getGraphicFill() != null) {
  10. fill.getGraphicFill().accept(this);
  11. }
  12. if (fill.getOpacity() != null) {
  13. fill.getOpacity().accept(this, null);
  14. }
  15. }

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Retrieves the point opacity from a PointSymbolizer.
  3. *
  4. * <p>If you are using something fun like rules you will need to do your own thing.
  5. *
  6. * @param symbolizer Point symbolizer information.
  7. * @return double of the point's opacity, or NaN if unavailable.
  8. */
  9. public static double pointOpacity(PointSymbolizer symbolizer) {
  10. if (symbolizer == null) {
  11. return Double.NaN;
  12. }
  13. Graphic graphic = symbolizer.getGraphic();
  14. if (graphic == null) {
  15. return Double.NaN;
  16. }
  17. for (GraphicalSymbol gs : graphic.graphicalSymbols()) {
  18. if (gs != null && gs instanceof Mark) {
  19. Mark mark = (Mark) gs;
  20. Fill fill = mark.getFill();
  21. if (fill != null) {
  22. Expression expr = fill.getOpacity();
  23. if (expr != null) {
  24. return SLD.opacity(expr);
  25. }
  26. }
  27. }
  28. }
  29. return Double.NaN;
  30. }

代码示例来源:origin: geotools/geotools

  1. public Fill createFill(
  2. Expression color, Expression backgroundColor, Expression opacity, Graphic graphicFill) {
  3. Fill fill = new FillImpl(filterFactory);
  4. if (color == null) {
  5. color = Fill.DEFAULT.getColor();
  6. }
  7. fill.setColor(color);
  8. if (backgroundColor == null) {
  9. backgroundColor = Fill.DEFAULT.getBackgroundColor();
  10. }
  11. fill.setBackgroundColor(backgroundColor);
  12. if (opacity == null) {
  13. opacity = Fill.DEFAULT.getOpacity();
  14. }
  15. // would be nice to check if this was within bounds but we have to wait until use since it
  16. // may depend on an attribute
  17. fill.setOpacity(opacity);
  18. fill.setGraphicFill(graphicFill);
  19. return fill;
  20. }

代码示例来源:origin: geotools/geotools

  1. @Override
  2. protected void encode(Fill fill) {
  3. putColor("fill-color", fill.getColor());
  4. put("fill-opacity", nullIf(fill.getOpacity(), 1d));
  5. if (fill.getGraphicFill() != null) {
  6. push("fill-graphic").inline(new GraphicEncoder(fill.getGraphicFill()));
  7. }
  8. }
  9. }

代码示例来源:origin: geotools/geotools

  1. public void visit(Fill fill) {
  2. start("Fill");
  3. if (fill.getGraphicFill() != null) {
  4. start("GraphicFill");
  5. fill.getGraphicFill().accept(this);
  6. end("GraphicFill");
  7. }
  8. encodeCssParam("fill", fill.getColor(), "#808080");
  9. encodeCssParam("fill-opacity", fill.getOpacity(), 1.0);
  10. end("Fill");
  11. }

代码示例来源:origin: org.geotools/gt2-main

  1. public static double opacity(Fill fill) {
  2. if (fill == null) {
  3. return Double.NaN;
  4. }
  5. Expression opacityExp = fill.getOpacity();
  6. double opacity = Double.parseDouble(opacityExp.toString());
  7. return opacity;
  8. }

代码示例来源:origin: org.geoserver/gs-wms

  1. private boolean isStaticTransparentFill(Fill fill) {
  2. if (fill.getOpacity() instanceof Literal) {
  3. // weird case of people setting opacity to 0. In case the opacity is really attribute
  4. // driven,
  5. // we'll leave it be
  6. Double staticOpacity = fill.getOpacity().evaluate(null, Double.class);
  7. if (staticOpacity == null || staticOpacity == 0) {
  8. return true;
  9. }
  10. }
  11. return false;
  12. }

代码示例来源:origin: geotools/geotools

  1. opacity = evalOpacity(symbolizer.getFill().getOpacity(), feature);

代码示例来源:origin: org.geotools/gt-main

  1. @Override
  2. public void visit(Fill fill) {
  3. if (fill.getColor() != null) {
  4. //fill.getColor().accept(visitor, extraData)
  5. }
  6. if (fill.getGraphicFill() != null) {
  7. fill.getGraphicFill().accept(this);
  8. }
  9. if (fill.getOpacity() != null) {
  10. //fill.getOpacity().accept(visitor, extraData)
  11. }
  12. }

代码示例来源:origin: org.geotools/gt-main

  1. public void visit(Fill fill) {
  2. Fill copy = sf.getDefaultFill();
  3. copy.setBackgroundColor( copy( fill.getBackgroundColor()) );
  4. copy.setColor(copy( fill.getColor()));
  5. copy.setGraphicFill( copy(fill.getGraphicFill()));
  6. copy.setOpacity( copy(fill.getOpacity()));
  7. if( STRICT && !copy.equals( fill )){
  8. throw new IllegalStateException("Was unable to duplicate provided Fill:"+fill );
  9. }
  10. pages.push(copy);
  11. }

代码示例来源:origin: org.geoserver/gs-wms

  1. /** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Fill) */
  2. public void visit(Fill fill) {
  3. handleColor(fill.getBackgroundColor());
  4. handleColor(fill.getColor());
  5. if (fill.getGraphicFill() != null) fill.getGraphicFill().accept(this);
  6. handleOpacity(fill.getOpacity());
  7. }

代码示例来源:origin: org.geotools/gt-main

  1. public void visit(Fill fill) {
  2. start("Fill");
  3. if (fill.getGraphicFill() != null) {
  4. start("GraphicFill");
  5. fill.getGraphicFill().accept(this);
  6. end("GraphicFill");
  7. }
  8. encodeCssParam("fill", fill.getColor(), "#808080");
  9. encodeCssParam("fill-opacity", fill.getOpacity(), 1.0);
  10. end("Fill");
  11. }

代码示例来源:origin: org.geotools/gt2-main

  1. public void visit(Fill fill) {
  2. start("Fill");
  3. if (fill.getGraphicFill() != null) {
  4. start("GraphicFill");
  5. fill.getGraphicFill().accept(this);
  6. end("GraphicFill");
  7. }
  8. encodeCssParam("fill", fill.getColor());
  9. encodeCssParam("fill-opacity", fill.getOpacity());
  10. end("Fill");
  11. }

相关文章