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

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

本文整理了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

/**
 * 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);
}

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

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

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

/**
 * Computes the Composite equivalent to the opacity in the SLD Fill
 *
 * @param fill
 * @param feature
 */
protected Composite getComposite(Fill fill, Object feature) {
  if (fill == null) {
    return null;
  }
  // get the opacity and prepare the composite
  float opacity = evalOpacity(fill.getOpacity(), feature);
  Composite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity);
  return composite;
}

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

/** Computes and returns the fill composite based on the feature and the symbolizer */
  public Composite getFillComposite() {
    Fill fill = ps.getFill();

    if (fill == null) {
      return null;
    }

    // get the opacity and prepare the composite
    float opacity = ((Float) fill.getOpacity().evaluate(feature, Float.class)).floatValue();

    if (opacity == 1) {
      return null;
    }

    return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity);
  }
}

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

/** Reset to produce the default Fill. */
public FillBuilder reset() {
  unset = false;
  color = Fill.DEFAULT.getColor();
  opacity = Fill.DEFAULT.getOpacity();
  graphic.unset();
  return this;
}

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

/**
 * 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);
}

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

public void visit(Fill fill) {
  Fill copy = sf.getDefaultFill();
  copy.setBackgroundColor(copy(fill.getBackgroundColor()));
  copy.setColor(copy(fill.getColor()));
  copy.setGraphicFill(copy(fill.getGraphicFill()));
  copy.setOpacity(copy(fill.getOpacity()));
  if (STRICT && !copy.equals(fill)) {
    throw new IllegalStateException("Was unable to duplicate provided Fill:" + fill);
  }
  pages.push(copy);
}

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

/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Fill) */
public void visit(Fill fill) {
  if (fill.getBackgroundColor() != null) {
    fill.getBackgroundColor().accept(this, null);
  }
  if (fill.getColor() != null) {
    fill.getColor().accept(this, null);
  }
  if (fill.getGraphicFill() != null) {
    fill.getGraphicFill().accept(this);
  }
  if (fill.getOpacity() != null) {
    fill.getOpacity().accept(this, null);
  }
}

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

/**
 * Retrieves the point 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 opacity, or NaN if unavailable.
 */
public static double pointOpacity(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;
      Fill fill = mark.getFill();
      if (fill != null) {
        Expression expr = fill.getOpacity();
        if (expr != null) {
          return SLD.opacity(expr);
        }
      }
    }
  }
  return Double.NaN;
}

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

public Fill createFill(
    Expression color, Expression backgroundColor, Expression opacity, Graphic graphicFill) {
  Fill fill = new FillImpl(filterFactory);
  if (color == null) {
    color = Fill.DEFAULT.getColor();
  }
  fill.setColor(color);
  if (backgroundColor == null) {
    backgroundColor = Fill.DEFAULT.getBackgroundColor();
  }
  fill.setBackgroundColor(backgroundColor);
  if (opacity == null) {
    opacity = Fill.DEFAULT.getOpacity();
  }
  // would be nice to check if this was within bounds but we have to wait until use since it
  // may depend on an attribute
  fill.setOpacity(opacity);
  fill.setGraphicFill(graphicFill);
  return fill;
}

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

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

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

public void visit(Fill fill) {
  start("Fill");
  if (fill.getGraphicFill() != null) {
    start("GraphicFill");
    fill.getGraphicFill().accept(this);
    end("GraphicFill");
  }
  encodeCssParam("fill", fill.getColor(), "#808080");
  encodeCssParam("fill-opacity", fill.getOpacity(), 1.0);
  end("Fill");
}

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

public static double opacity(Fill fill) {
  if (fill == null) {
    return Double.NaN;
  }
  Expression opacityExp = fill.getOpacity();
  double opacity = Double.parseDouble(opacityExp.toString());
  return opacity;
}

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

private boolean isStaticTransparentFill(Fill fill) {
  if (fill.getOpacity() instanceof Literal) {
    // weird case of people setting opacity to 0. In case the opacity is really attribute
    // driven,
    // we'll leave it be
    Double staticOpacity = fill.getOpacity().evaluate(null, Double.class);
    if (staticOpacity == null || staticOpacity == 0) {
      return true;
    }
  }
  return false;
}

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

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

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

@Override
public void visit(Fill fill) {
  if (fill.getColor() != null) {
    //fill.getColor().accept(visitor, extraData)
  }
  if (fill.getGraphicFill() != null) {
    fill.getGraphicFill().accept(this);
  }
  if (fill.getOpacity() != null) {
    //fill.getOpacity().accept(visitor, extraData)
  }
}

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

public void visit(Fill fill) {
  Fill copy = sf.getDefaultFill();
  copy.setBackgroundColor( copy( fill.getBackgroundColor()) );
  copy.setColor(copy( fill.getColor()));
  copy.setGraphicFill( copy(fill.getGraphicFill()));
  copy.setOpacity( copy(fill.getOpacity()));
  
  if( STRICT && !copy.equals( fill )){
    throw new IllegalStateException("Was unable to duplicate provided Fill:"+fill );
  }
  pages.push(copy);
}

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

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

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

public void visit(Fill fill) {
  start("Fill");
  if (fill.getGraphicFill() != null) {
    start("GraphicFill");
    fill.getGraphicFill().accept(this);
    end("GraphicFill");
  }
  encodeCssParam("fill", fill.getColor(), "#808080");
  encodeCssParam("fill-opacity", fill.getOpacity(), 1.0);
  end("Fill");
}

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

public void visit(Fill fill) {
  start("Fill");
  if (fill.getGraphicFill() != null) {
    start("GraphicFill");
    fill.getGraphicFill().accept(this);
    end("GraphicFill");
  }
  encodeCssParam("fill", fill.getColor());
  encodeCssParam("fill-opacity", fill.getOpacity());
  end("Fill");
}

相关文章