Esempio n. 1
0
  /** Places a unit in the desired area. */
  @Override
  public void updateDOM(MapInfo mapInfo) {
    // if we are not displayable, we exit, after remove the order (if
    // it was created)
    if (!GUIOrderUtils.isDisplayable(power, mapInfo)) {
      removeFromDOM(mapInfo);
      return;
    }

    // determine if any change has occured. If no change has occured,
    // we will not change the DOM.
    //
    // we have nothing (yet) to check for change; isDependent() == false.
    // so just return if we have not been drawn.
    if (group != null) {
      return;
    }

    // there has been a change, if we are at this point.
    //

    // if we've not yet been created, we will create; if we've
    // already been created, we must remove the existing elements
    // in our group
    if (group == null) {
      // create group
      group =
          (SVGGElement)
              mapInfo
                  .getDocument()
                  .createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_G_TAG);

      mapInfo.getPowerSVGGElement(power, LAYER_HIGHEST).appendChild(group);
    } else {
      // remove group children
      GUIOrderUtils.deleteChildren(group);
    }

    // now, render the order
    // (no highlight + shadow required here)
    // no offset required
    //
    SVGElement[] elements = drawOrder(mapInfo);
    for (int i = 0; i < elements.length; i++) {
      group.appendChild(elements[i]);
    }

    // draw 'failed' marker, if appropriate.
    if (!mapInfo.getTurnState().isOrderSuccessful(this)) {
      SVGElement useElement = GUIOrderUtils.createFailedOrderSymbol(mapInfo, failPt.x, failPt.y);
      group.appendChild(useElement);
    }
  } // updateDOM()