org.geoserver.wms.GetLegendGraphicRequest.getLegendOptions()方法的使用及代码示例

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

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

GetLegendGraphicRequest.getLegendOptions介绍

[英]Returns the possibly empty set of key/value pair parameters to control some aspects of legend generation.

These parameters are meant to be passed as the request parameter "LEGEND_OPTIONS" with the format LEGEND_OPTIONS=multiKey:val1,val2,val3;singleKey:val.

The known options, all optional, are:

  • fontName: name of the system font used for legend rule names. Defaults to "Sans-Serif"
  • fontStyle: one of "plain", "italic" or "bold"
  • fontSize: integer for the font size in pixels
  • fontColor: a String that represents an opaque color as a 24-bit integer
  • bgColor: allows to override the legend background color
  • fontAntiAliasing: a boolean indicating whether to use antia aliasing in font rendering. Anything of the following works: "yes", "true", "1". Anything else means false.
  • forceLabels: "on" means labels will always be drawn, even if only one rule is available. "off" means labels will never be drawn, even if multiple rules are available.
  • forceTitles: "off" means titles will never be drawn, even if multiple layers are available.
  • minSymbolSize: a number defining the minimum size to be rendered for a symbol (defaults to 3).
    [中]返回一组可能为空的键/值对参数,以控制图例生成的某些方面。
    这些参数将作为请求参数"LEGEND_OPTIONS"传递,格式为LEGEND_OPTIONS=multiKey:val1,val2,val3;singleKey:val
    已知选项(均为可选)包括:
    *fontName:用于图例规则名称的系统字体的名称。默认为“无衬线”
    *fontStyle:“普通”、“斜体”或“粗体”之一
    *fontSize:字体大小的整数,以像素为单位
    *fontColor:将不透明颜色表示为24位整数的String
    *bgColor:允许覆盖图例背景色
    *fontAntiAliasing:一个布尔值,指示是否在字体呈现中使用抗锯齿。以下任何作品:“是”、“正确”、“1”。其他任何东西都是假的。
    *forceLabels:“on”表示将始终绘制标签,即使只有一条规则可用。“关闭”表示即使有多条规则可用,也不会绘制标签。
    *forceTitles:“关闭”表示即使有多个图层可用,也不会绘制标题。
    *minSymbolSize:定义符号要呈现的最小大小的数字(默认为3)。

代码示例

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

/**
 * Checks if the graphics should be text antialiasing
 *
 * @param req the {@link GetLegendGraphicRequest} from which to extract font antialiasing
 *     information.
 * @return true if the fontAntiAliasing is set to on
 */
public static boolean isFontAntiAliasing(final GetLegendGraphicRequest req) {
  if (req.getLegendOptions().get("fontAntiAliasing") instanceof String) {
    String aaVal = (String) req.getLegendOptions().get("fontAntiAliasing");
    if (aaVal.equalsIgnoreCase("on")
        || aaVal.equalsIgnoreCase("true")
        || aaVal.equalsIgnoreCase("yes")
        || aaVal.equalsIgnoreCase("1")) {
      return true;
    }
  }
  return false;
}

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

/**
 * Retrieves column height of legend from the provided {@link GetLegendGraphicRequest}.
 *
 * @param req a {@link GetLegendGraphicRequest} from which we should extract column height
 *     information.
 * @return the column height specified in the provided {@link GetLegendGraphicRequest} or a
 *     default DEFAULT_COLUMN_HEIGHT.
 */
public static int getColumnHeight(final GetLegendGraphicRequest req) {
  ensureNotNull(req, "GetLegendGraphicRequestre");
  final Map<String, Object> legendOptions = req.getLegendOptions();
  int columnheight = DEFAULT_COLUMN_HEIGHT;
  if (legendOptions != null && legendOptions.get("columnheight") != null) {
    try {
      columnheight = Integer.parseInt((String) legendOptions.get("columnheight"));
    } catch (NumberFormatException e) {
    }
  }
  return columnheight;
}

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

/**
 * Retrieves row width of legend from the provided {@link GetLegendGraphicRequest}.
 *
 * @param req a {@link GetLegendGraphicRequest} from which we should extract row width
 *     information.
 * @return the row width specified in the provided {@link GetLegendGraphicRequest} or a default
 *     DEFAULT_ROW_WIDTH.
 */
public static int getRowWidth(final GetLegendGraphicRequest req) {
  ensureNotNull(req, "GetLegendGraphicRequestre");
  final Map<String, Object> legendOptions = req.getLegendOptions();
  int rowwidth = DEFAULT_ROW_WIDTH;
  if (legendOptions != null && legendOptions.get("rowwidth") != null) {
    try {
      rowwidth = Integer.parseInt((String) legendOptions.get("rowwidth"));
    } catch (NumberFormatException e) {
    }
  }
  return rowwidth;
}

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

/**
 * Retrieves rows of legend from the provided {@link GetLegendGraphicRequest}.
 *
 * @param req a {@link GetLegendGraphicRequest} from which we should extract rows information.
 * @return the rows specified in the provided {@link GetLegendGraphicRequest} or a default
 *     DEFAULT_ROWS.
 */
public static int getRows(final GetLegendGraphicRequest req) {
  ensureNotNull(req, "GetLegendGraphicRequestre");
  final Map<String, Object> legendOptions = req.getLegendOptions();
  int rows = DEFAULT_ROWS;
  if (legendOptions != null && legendOptions.get("rows") != null) {
    try {
      rows = Integer.parseInt((String) legendOptions.get("rows"));
    } catch (NumberFormatException e) {
    }
  }
  return rows;
}

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

/**
 * Retrieves columns of legend from the provided {@link GetLegendGraphicRequest}.
 *
 * @param req a {@link GetLegendGraphicRequest} from which we should extract columns
 *     information.
 * @return the columns specified in the provided {@link GetLegendGraphicRequest} or a default
 *     DEFAULT_COLUMNS.
 */
public static int getColumns(final GetLegendGraphicRequest req) {
  ensureNotNull(req, "GetLegendGraphicRequestre");
  final Map<String, Object> legendOptions = req.getLegendOptions();
  int columns = DEFAULT_COLUMNS;
  if (legendOptions != null && legendOptions.get("columns") != null) {
    try {
      columns = Integer.parseInt((String) legendOptions.get("columns"));
    } catch (NumberFormatException e) {
    }
  }
  return columns;
}

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

/**
 * Retrieves the group legend layout from the provided {@link GetLegendGraphicRequest}.
 *
 * @param req a {@link GetLegendGraphicRequest} from which we should extract the group {@link
 *     LegendLayout} information.
 * @return the group {@link LegendLayout} specified in the provided {@link
 *     GetLegendGraphicRequest} or a default DEFAULT_LAYOUT.
 */
public static LegendLayout getGroupLayout(final GetLegendGraphicRequest req) {
  ensureNotNull(req, "GetLegendGraphicRequestre");
  final Map<String, Object> legendOptions = req.getLegendOptions();
  LegendLayout layout = DEFAULT_LAYOUT;
  if (legendOptions != null && legendOptions.get("grouplayout") != null) {
    try {
      layout =
          LegendLayout.valueOf(
              ((String) legendOptions.get("grouplayout")).toUpperCase());
    } catch (IllegalArgumentException e) {
    }
  }
  return layout;
}

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

/**
 * Retrieves the legend layout from the provided {@link GetLegendGraphicRequest}.
 *
 * @param req a {@link GetLegendGraphicRequest} from which we should extract the {@link
 *     LegendLayout} information.
 * @return the {@link LegendLayout} specified in the provided {@link GetLegendGraphicRequest} or
 *     a default DEFAULT_LAYOUT.
 */
public static LegendLayout getLayout(final GetLegendGraphicRequest req) {
  ensureNotNull(req, "GetLegendGraphicRequestre");
  final Map<String, Object> legendOptions = req.getLegendOptions();
  LegendLayout layout = DEFAULT_LAYOUT;
  if (legendOptions != null && legendOptions.get("layout") != null) {
    try {
      layout = LegendLayout.valueOf(((String) legendOptions.get("layout")).toUpperCase());
    } catch (IllegalArgumentException e) {
    }
  }
  return layout;
}

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

final Map<String, Object> legendOptions = req.getLegendOptions();
if (legendOptions == null) return DEFAULT_FONT;
String legendFontName = LegendUtils.DEFAULT_FONT_NAME;
double dpi = RendererUtilities.getDpi(req.getLegendOptions());
double standardDpi = RendererUtilities.getDpi(Collections.emptyMap());
if (dpi != standardDpi) {

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

final Map<String, Object> legendOptions = req.getLegendOptions();
final String color = legendOptions != null ? (String) legendOptions.get("fontColor") : null;
if (color == null) {

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

final Map<String, Object> legendOptions = req.getLegendOptions();
if (legendOptions == null) return DEFAULT_BG_COLOR;
Object clr = legendOptions.get("bgColor");

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

if (request.getLegendOptions().get("forceLabels") instanceof String) {
  String forceLabelsOpt = (String) request.getLegendOptions().get("forceLabels");
  if (forceLabelsOpt.equalsIgnoreCase("on")) {
    forceLabelsOn = true;
if (request.getLegendOptions().get("forceTitles") instanceof String) {
  String forceTitlesOpt = (String) request.getLegendOptions().get("forceTitles");
  if (forceTitlesOpt.equalsIgnoreCase("off")) {
    forceTitlesOff = true;
  double dpi = RendererUtilities.getDpi(request.getLegendOptions());
  double standardDpi = RendererUtilities.getDpi(Collections.emptyMap());
  if (dpi != standardDpi) {
    double pixelsPerMeters =
        RendererUtilities.calculatePixelsPerMeterRatio(
            request.getScale(), request.getLegendOptions());
    UomRescaleStyleVisitor rescaleVisitor = new UomRescaleStyleVisitor(pixelsPerMeters);
    rescaleVisitor.visit(gt2Style);
    if (request.getLegendOptions().get("minSymbolSize") instanceof String) {
      String minSymbolSizeOpt =
          (String) request.getLegendOptions().get("minSymbolSize");
      try {
        minimumSymbolSize = Double.parseDouble(minSymbolSizeOpt);
    if (!StringUtils.isEmpty(request.getLegendOptions().get("labelMargin"))) {
      labelMargin =
          Integer.parseInt(

代码示例来源:origin: robward-scisys/sldeditor

if (request.getLegendOptions().get("forceLabels") instanceof String) {
  String forceLabelsOpt = (String) request.getLegendOptions().get("forceLabels");
  if (forceLabelsOpt.equalsIgnoreCase("on")) {
    forceLabelsOn = true;
if (request.getLegendOptions().get("forceTitles") instanceof String) {
  String forceTitlesOpt = (String) request.getLegendOptions().get("forceTitles");
  if (forceTitlesOpt.equalsIgnoreCase("off")) {
    forceTitlesOff = true;
if (request.getLegendOptions().get("imageSizeFactor") instanceof String) {
  String imageSizeFactorOpt = (String) request.getLegendOptions().get("imageSizeFactor");
  double dpi = RendererUtilities.getDpi(request.getLegendOptions());
  double standardDpi = RendererUtilities.getDpi(Collections.emptyMap());
  if (dpi != standardDpi) {
    double pixelsPerMeters =
        RendererUtilities.calculatePixelsPerMeterRatio(
            request.getScale(), request.getLegendOptions());
    UomRescaleStyleVisitor rescaleVisitor = new UomRescaleStyleVisitor(pixelsPerMeters);
    rescaleVisitor.visit(gt2Style);
    if (request.getLegendOptions().get("minSymbolSize") instanceof String) {
      String minSymbolSizeOpt =
          (String) request.getLegendOptions().get("minSymbolSize");
      try {
        minimumSymbolSize = Double.parseDouble(minSymbolSizeOpt);

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

cmapLegendBuilder.setAdditionalOptions(request.getLegendOptions());

相关文章