org.geotools.styling.Halo类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(173)

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

Halo介绍

[英]A Halo fills an extended area outside the glyphs of a rendered textlabel to make it easier to read over a background.

The details of this object are taken from the OGC Styled-Layer Descriptor Report (OGC 02-070) version 1.0.0.:

<xsd:element name="Halo"> 
<xsd:annotation> 
<xsd:documentation> 
A "Halo" fills an extended area outside the glyphs of a rendered 
text label to make the label easier to read over a background. 
</xsd:documentation> 
</xsd:annotation> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element ref="sld:Radius" minOccurs="0"/> 
<xsd:element ref="sld:Fill" minOccurs="0"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element>

Renderers can use this information when displaying styled features, though it must be remembered that not all renderers will be able to fully represent strokes as set out by this interface. For example, opacity may not be supported.

Notes:

  • The graphical parameters and their values are derived from SVG/CSS2 standards with names and semantics which are as close as possible.
    $Id$
    [中]光晕会填充渲染文本标签图示符外的扩展区域,以便于在背景上阅读。
    此对象的详细信息取自OGC Styled-Layer Descriptor Report (OGC 02-070) version 1.0.0.
<xsd:element name="Halo"> 
<xsd:annotation> 
<xsd:documentation> 
A "Halo" fills an extended area outside the glyphs of a rendered 
text label to make the label easier to read over a background. 
</xsd:documentation> 
</xsd:annotation> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element ref="sld:Radius" minOccurs="0"/> 
<xsd:element ref="sld:Fill" minOccurs="0"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element>

渲染器可以在显示样式化特征时使用此信息,但必须记住,并非所有渲染器都能够完全表示此接口设置的笔划。例如,不透明度可能不受支持。
笔记:
*图形参数及其值源自SVG/CSS2标准,其名称和语义尽可能接近。
$Id$

代码示例

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

/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Halo) */
public void visit(Halo halo) {
  if (halo.getFill() != null) {
    halo.getFill().accept(this);
  }
  if (halo.getRadius() != null) {
    halo.getRadius().accept(this, null);
  }
}

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

/**
 * Null safe copy of halo.
 *
 * @param halo
 * @return copy of halo if provided
 */
protected Halo copy(Halo halo) {
  if (halo == null) return null;
  halo.accept(this);
  return (Halo) pages.pop();
}

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

public Halo createHalo(Fill fill, Expression radius) {
  Halo halo = new HaloImpl(filterFactory);
  halo.setFill(fill);
  halo.setRadius(radius);
  return halo;
}

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

@Override
public void visit(Halo halo) {
  if (halo.getFill() != null) {
    halo.getFill().accept(this);
  }
}

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

copy.getHalo().setRadius(rescale(copy.getHalo().getRadius()));

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

/**
 * Retrieves the halo width from a TextSymbolizer.
 *
 * @param symbolizer Text symbolizer information.
 * @return the halo's width, or 0 if unavailable.
 */
public static int textHaloWidth(TextSymbolizer symbolizer) {
  Halo halo = symbolizer.getHalo();
  if (halo == null) {
    return 0;
  }
  Expression exp = halo.getRadius();
  if (exp == null) {
    return 0;
  }
  int width = (int) Float.parseFloat(exp.toString());
  if (width != 0) {
    return width;
  }
  return 0;
}

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

@Override
  protected void fill(Fill fill) {
    halo.setFill(fill);
  }
});

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    sym.setHalo(halo);
    YamlMap map = obj.map();
    context.push(
        new FillParser(factory) {
          @Override
          protected void fill(Fill fill) {
            halo.setFill(fill);
          }
        });
    if (map.has("radius")) {
      halo.setRadius(Util.expression(map.str("radius"), factory));
    }
  }
}

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

/**
 * Retrieves the colour of the halo fill a TextSymbolizer.
 *
 * @param symbolizer Text symbolizer information.
 * @return Color of the halo's fill, or null if unavailable.
 */
public static Color textHaloFill(TextSymbolizer symbolizer) {
  Halo halo = symbolizer.getHalo();
  if (halo == null) {
    return null;
  }
  Fill fill = halo.getFill();
  if (fill == null) {
    return null;
  }
  return color(fill.getColor());
}

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

copy.getHalo().setRadius(rescale(copy.getHalo().getRadius(), uom));

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

/**
 * Retrieves the halo width from a TextSymbolizer.
 *
 * @param symbolizer Text symbolizer information.
 *
 * @return the halo's width, or 0 if unavailable.
 */
public static int textHaloWidth(TextSymbolizer symbolizer) {
  Halo halo = symbolizer.getHalo();
  if (halo == null) {
    return 0;
  }
  Expression exp = halo.getRadius();
  if (exp == null) {
    return 0;
  }
  int width = (int) Float.parseFloat(exp.toString());
  if (width != 0) {
    return width;
  }
  return 0;
}

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

@Override
  protected void fill(Fill fill) {
    halo.setFill(fill);
  }
});

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    sym.setHalo(halo);
    YamlMap map = obj.map();
    context.push(
        new FillParser(factory) {
          @Override
          protected void fill(Fill fill) {
            halo.setFill(fill);
          }
        });
    if (map.has("radius")) {
      halo.setRadius(Util.expression(map.str("radius"), factory));
    }
  }
}

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

public void visit(Halo halo) {
  start("Halo");
  if (halo.getRadius() != null) {
    encodeValue("Radius", null, halo.getRadius(), null);
  }
  if (halo.getFill() != null) {
    halo.getFill().accept(this);
  }
  end("Halo");
}

代码示例来源: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

@Override
public void visit(TextSymbolizer text) {
  if (text.getDescription() != null) {
    text.getDescription().accept(this);
  }
  if (text.getFill() != null) {
    text.getFill().accept(this);
  }
  if (text.getHalo() != null) {
    text.getHalo().accept(this);
  }
  if (text.getLabelPlacement() != null) {
    text.getLabelPlacement().accept(this);
  }
}

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

/** Internal parse method - made protected for unit testing */
protected Halo parseHalo(Node root) {
  if (LOGGER.isLoggable(Level.FINEST)) {
    LOGGER.finest("parsing halo");
  }
  Halo halo = factory.createHalo(factory.createFill(ff.literal("#FFFFFF")), ff.literal(1.0));
  NodeList children = root.getChildNodes();
  final int length = children.getLength();
  for (int i = 0; i < length; i++) {
    Node child = children.item(i);
    if ((child == null) || (child.getNodeType() != Node.ELEMENT_NODE)) {
      continue;
    }
    String childName = child.getLocalName();
    if (childName == null) {
      childName = child.getNodeName();
    }
    if (childName.equalsIgnoreCase(fillSt)) {
      halo.setFill(parseFill(child));
    } else if (childName.equalsIgnoreCase("Radius")) {
      halo.setRadius(parseCssParameter(child));
    }
  }
  return halo;
}

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

copy.getHalo().setRadius(rescale(copy.getHalo().getRadius()));

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

/**
 * Grabs the halo width from the first TextSymbolizer.
 * 
 * <p>
 * If you are using something fun like symbols you  will need to do your
 * own thing.
 * </p>
 *
 * @param symbolizer Text symbolizer information.
 *
 * @return float of the halo's width, or null if unavailable.
 */
public static int textHaloWidth(TextSymbolizer symbolizer) {
  Halo halo = symbolizer.getHalo();
  if (halo == null) {
    return 0;
  }
  Expression exp = halo.getRadius();
  if (exp == null) {
    return 0;
  }
  int width = (int) Float.parseFloat(exp.toString());
  if (width != 0) {
    return width;
  }
  return 0;
}

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

public void visit(Halo halo) {
  Fill fill = copy(halo.getFill());
  Expression radius = copy(halo.getRadius());
  Halo copy = sf.createHalo(fill, radius);
  if (STRICT && !copy.equals(halo)) {
    throw new IllegalStateException("Was unable to duplicate provided raster:" + halo);
  }
  pages.push(copy);
}

相关文章