Example #1
0
  private ModelSwitch getSwitch(Element ele) {
    int x = getIntValue(ele, "x");
    int y = getIntValue(ele, "y");

    ModelSwitch mSwitch = new ModelSwitch(new Point(x, y));

    mSwitch.setCurrentDir(getIntValue(ele, "currentdirection"));

    NodeList nl = ele.getElementsByTagName("direction");
    if (nl != null && nl.getLength() > 0) {
      for (int i = 0; i < nl.getLength(); ++i) {
        Element el = (Element) nl.item(i);
        mSwitch.addDirection(string2Direction(el.getFirstChild().getNodeValue()));
      }
    }

    return mSwitch;
  }