Exemplo n.º 1
0
 /**
  * Applies the appropriate Stroke color and Filter (if any) to an element.
  *
  * <p>mmdOrderElementName = e.g., MapMetadata.EL_HOLD
  */
 public static void makeStyled(
     SVGElement element, MapMetadata mmd, String mmdOrderElementName, Power power) {
   element.setAttributeNS(null, CSSConstants.CSS_STROKE_PROPERTY, mmd.getPowerColor(power));
   String filter = mmd.getOrderParamString(mmdOrderElementName, MapMetadata.ATT_FILTERID);
   if (filter.length() > 0) {
     StringBuffer sb = new StringBuffer(filter.length() + 6);
     sb.append("url(#");
     sb.append(filter);
     sb.append(')');
     element.setAttributeNS(null, SVGConstants.SVG_FILTER_ATTRIBUTE, sb.toString());
   }
 } // makeStyled()
Exemplo n.º 2
0
 /** Sets the higlight of an array of elements. Assumes that hilight is not set to 'none' */
 public static void makeHilight(
     SVGElement[] elements, MapMetadata mmd, String mmdOrderElementName) {
   String cssStyle = mmd.getOrderParamString(mmdOrderElementName, MapMetadata.ATT_HILIGHT_CLASS);
   for (int i = 0; i < elements.length; i++) {
     elements[i].setAttributeNS(null, SVGConstants.SVG_CLASS_ATTRIBUTE, cssStyle);
   }
 } // makeHilight()
Exemplo n.º 3
0
  private SVGElement[] drawOrder(MapInfo mapInfo) {
    MapMetadata mmd = mapInfo.getMapMetadata();
    Point2D.Float center = mmd.getUnitPt(src.getProvince(), src.getCoast());

    // get 'integer' and float data
    float radius = mmd.getOrderRadius(MapMetadata.EL_BUILD, mapInfo.getSymbolName(srcUnitType));

    // calculate failPt.
    failPt = new Point2D.Float(center.x + radius, center.y - radius);

    // A BUILD consists of the Built Unit ontop of a BuildUnit symbol
    // elements added in drawing order (thus BuildUnit must come first,
    // otherwise the unit built will be obscured by the BuilUnit symbol).
    //
    SVGElement[] elements = new SVGElement[2];

    // BuildUnit symbol
    MapMetadata.SymbolSize symbolSize = mmd.getSymbolSize(DefaultMapRenderer2.SYMBOL_BUILDUNIT);

    elements[0] =
        SVGUtils.createUseElement(
            mapInfo.getDocument(),
            "#" + DefaultMapRenderer2.SYMBOL_BUILDUNIT,
            null, // no ID
            null, // no special style
            center.x,
            center.y,
            symbolSize);

    // Unit symbol
    final String symbolName = mapInfo.getSymbolName(srcUnitType);
    symbolSize = mmd.getSymbolSize(symbolName);

    elements[1] =
        SVGUtils.createUseElement(
            mapInfo.getDocument(),
            "#" + symbolName,
            null, // no ID
            mapInfo.getUnitCSS(power), // unit style
            center.x,
            center.y,
            symbolSize);

    return elements;
  } // drawOrder()
Exemplo n.º 4
0
  /**
   * Applies the appropriate Stroke color and Filter (if any) to an array of elements
   *
   * <p>mmdOrderElementName = e.g., MapMetadata.EL_HOLD
   */
  public static void makeStyled(
      SVGElement[] elements, MapMetadata mmd, String mmdOrderElementName, Power power) {
    String filter = mmd.getOrderParamString(mmdOrderElementName, MapMetadata.ATT_FILTERID);
    if (filter.length() > 0) {
      StringBuffer sb = new StringBuffer(filter.length() + 6);
      sb.append("url(#");
      sb.append(filter);
      sb.append(')');
      filter = sb.toString();
    } else {
      filter = null;
    }

    String powerColor = mmd.getPowerColor(power);

    for (int i = 0; i < elements.length; i++) {
      elements[i].setAttributeNS(null, CSSConstants.CSS_STROKE_PROPERTY, powerColor);
      if (filter != null) {
        elements[i].setAttributeNS(null, SVGConstants.SVG_FILTER_ATTRIBUTE, filter);
      }
    }
  } // makeStyled()
Exemplo n.º 5
0
 /** Sets the tab icons for each power. */
 private void setTabIcons() {
   if (mmd != null) {
     final World world = clientFrame.getWorld();
     final int tabCount = tabPane.getTabCount();
     for (int i = 1; i < tabCount; i++) // no icon for 'game' info
     {
       Power power = world.getMap().getPower(tabPane.getTitleAt(i));
       assert (power != null);
       String colorName = mmd.getPowerColor(power);
       Color color = SVGColorParser.parseColor(colorName);
       tabPane.setIconAt(i, new ColorRectIcon(12, 12, color));
     }
   }
 } // setTabIcons()
Exemplo n.º 6
0
 /** Adds the given end-Marker to an element (usually a Line) */
 public static void addMarker(SVGElement element, MapMetadata mmd, String mmdOrderElementName) {
   element.setAttributeNS(
       null,
       CSSConstants.CSS_MARKER_END_PROPERTY,
       "url(#" + mmd.getOrderParamString(mmdOrderElementName, MapMetadata.ATT_MARKERID) + ')');
 } // addMarker()
Exemplo n.º 7
0
 /** Sets the higlight of an element. Assumes that hilight is not set to 'none' */
 public static void makeHilight(SVGElement element, MapMetadata mmd, String mmdOrderElementName) {
   String cssStyle = mmd.getOrderParamString(mmdOrderElementName, MapMetadata.ATT_HILIGHT_CLASS);
   element.setAttributeNS(null, SVGConstants.SVG_CLASS_ATTRIBUTE, cssStyle);
 } // makeHilight()