Package org.geomajas.configuration

Examples of org.geomajas.configuration.LabelStyleInfo


      }
    }
  }

  private void drawLabel(PdfContext context, InternalFeature f) {
    LabelStyleInfo labelType = styleInfo.getLabelStyle();
    String label = f.getLabel();
    if (label != null) {
      Font font = new Font("Helvetica", Font.ITALIC, 10);
      Color fontColor = Color.black;
      if (labelType.getFontStyle() != null) {
        fontColor = context
            .getColor(labelType.getFontStyle().getColor(), labelType.getFontStyle().getOpacity());
      }
      Rectangle rect = calculateLabelRect(context, f, label, font);
      Color bgColor = Color.white;
      if (labelType.getBackgroundStyle() != null) {
        bgColor = context.getColor(labelType.getBackgroundStyle().getFillColor(), labelType
            .getBackgroundStyle().getFillOpacity());
      }
      context.fillRoundRectangle(rect, bgColor, 3);
      Color borderColor = Color.black;
      if (labelType.getBackgroundStyle() != null) {
        borderColor = context.getColor(labelType.getBackgroundStyle().getStrokeColor(), labelType
            .getBackgroundStyle().getStrokeOpacity());
      }
      float linewidth = 0.5f;
      if (labelType.getBackgroundStyle() != null) {
        linewidth = labelType.getBackgroundStyle().getStrokeWidth();
      }
      context.strokeRoundRectangle(rect, borderColor, linewidth, 3);
      context.drawText(label, font, rect, fontColor);
      if (f.getGeometry() instanceof Point) {
        context.drawLine(0.5f * (rect.getLeft() + rect.getRight()), rect.getBottom(),
View Full Code Here


    return namedStyleInfo;
  }

  private NamedStyleInfo convert(UserStyleInfo userStyle, FeatureInfo featureInfo) {
    NamedStyleInfo namedStyleInfo = new NamedStyleInfo();
    LabelStyleInfo labelStyleInfo = new LabelStyleInfo();
    List<FeatureStyleInfo> featureStyleInfos = new ArrayList<FeatureStyleInfo>();
    for (FeatureTypeStyleInfo featureTypeStyleInfo : userStyle.getFeatureTypeStyleList()) {
      int styleIndex = 0;
      for (RuleInfo ruleInfo : featureTypeStyleInfo.getRuleList()) {
        FeatureStyleInfo featureStyleInfo = new FeatureStyleInfo();
        if (ruleInfo.getChoice() != null) {
          if (ruleInfo.getChoice().ifFilter()) {
            featureStyleInfo.setFormula(convertFormula(ruleInfo.getChoice().getFilter(), featureInfo));
          }
        }
        for (SymbolizerTypeInfo symbolizerTypeInfo : ruleInfo.getSymbolizerList()) {
          if (symbolizerTypeInfo instanceof PointSymbolizerInfo) {
            PointSymbolizerInfo pointInfo = (PointSymbolizerInfo) symbolizerTypeInfo;
            convertSymbol(featureStyleInfo, pointInfo);
          } else if (symbolizerTypeInfo instanceof LineSymbolizerInfo) {
            LineSymbolizerInfo lineInfo = (LineSymbolizerInfo) symbolizerTypeInfo;
            convertStroke(featureStyleInfo, lineInfo.getStroke());
          } else if (symbolizerTypeInfo instanceof PolygonSymbolizerInfo) {
            PolygonSymbolizerInfo polygonInfo = (PolygonSymbolizerInfo) symbolizerTypeInfo;
            convertFill(featureStyleInfo, polygonInfo.getFill());
            convertStroke(featureStyleInfo, polygonInfo.getStroke());
          } else if (symbolizerTypeInfo instanceof TextSymbolizerInfo) {
            TextSymbolizerInfo textInfo = (TextSymbolizerInfo) symbolizerTypeInfo;
            labelStyleInfo.setFontStyle(convertFont(textInfo.getFont()));
            for (ExpressionInfo expr : textInfo.getLabel().getExpressionList()) {
              labelStyleInfo.setLabelAttributeName(expr.getValue());
            }
            convertFontFill(labelStyleInfo.getFontStyle(), textInfo.getFill());
            FeatureStyleInfo background = new FeatureStyleInfo();
            if (textInfo.getHalo() != null) {
              convertFill(background, textInfo.getHalo().getFill());
            }
            labelStyleInfo.setBackgroundStyle(background);
          }
        }
        if (featureStyleInfo.getStrokeColor() == null && featureStyleInfo.getFillColor() != null) {
          // avoid default stroke by setting invisible
          featureStyleInfo.setStrokeColor("black");
View Full Code Here

TOP

Related Classes of org.geomajas.configuration.LabelStyleInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.