Пример #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()
Пример #2
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()
Пример #3
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()