Ejemplo n.º 1
0
 public void addElement(Element el, BoxBounds bounds) {
   Layer layer = new Layer(el, bounds);
   layers.add(layer);
   el.getStyle().setPosition(Style.Position.ABSOLUTE);
   presetLayerBounds(layer);
   container.appendChild(el);
 }
Ejemplo n.º 2
0
  /**
   * @param sourceFile File to read from
   * @return List of String objects with the shas
   */
  public static FileRequestFileContent readRequestFile(final File sourceFile) {
    if (!sourceFile.isFile() || !(sourceFile.length() > 0)) {
      return null;
    }
    Document d = null;
    try {
      d = XMLTools.parseXmlFile(sourceFile.getPath());
    } catch (final Throwable t) {
      logger.log(Level.SEVERE, "Exception in readRequestFile, during XML parsing", t);
      return null;
    }

    if (d == null) {
      logger.log(Level.SEVERE, "Could'nt parse the request file");
      return null;
    }

    final Element rootNode = d.getDocumentElement();

    if (rootNode.getTagName().equals(TAG_FrostFileRequestFile) == false) {
      logger.severe(
          "Error: xml request file does not contain the root tag '"
              + TAG_FrostFileRequestFile
              + "'");
      return null;
    }

    final String timeStampStr = XMLTools.getChildElementsTextValue(rootNode, TAG_timestamp);
    if (timeStampStr == null) {
      logger.severe("Error: xml file does not contain the tag '" + TAG_timestamp + "'");
      return null;
    }
    final long timestamp = Long.parseLong(timeStampStr);

    final List<Element> nodelist = XMLTools.getChildElementsByTagName(rootNode, TAG_shaList);
    if (nodelist.size() != 1) {
      logger.severe("Error: xml request files must contain only one element '" + TAG_shaList + "'");
      return null;
    }

    final Element rootShaNode = nodelist.get(0);

    final List<String> shaList = new LinkedList<String>();
    final List<Element> xmlKeys = XMLTools.getChildElementsByTagName(rootShaNode, TAG_sha);
    for (final Element el : xmlKeys) {

      final Text txtname = (Text) el.getFirstChild();
      if (txtname == null) {
        continue;
      }

      final String sha = txtname.getData();
      shaList.add(sha);
    }

    final FileRequestFileContent content = new FileRequestFileContent(timestamp, shaList);
    return content;
  }
Ejemplo n.º 3
0
 public synchronized List<Element> getRestriccionColored() {
   List<Element> resp = new ArrayList();
   for (Element e : restriccion) {
     if (!e.getCol().equals(WHITE)) {
       resp.add(e);
     }
   }
   return resp;
 }
Ejemplo n.º 4
0
 /**
  * set container
  *
  * @param container container
  * @return content layer
  */
 public Element init(
     Element container, int insetLeft, int insetTop, int insetRight, int insetBottom) {
   this.container = container;
   if (!"absolute".equals(container.getStyle().getPosition())
       && !"relative".equals(container.getStyle().getPosition())) {
     container.getStyle().setPosition(Style.Position.RELATIVE);
   }
   Element contentLayer = DOM.createDiv();
   contentLayer.getStyle().setPosition(Style.Position.ABSOLUTE);
   if (insetTop > 0) contentLayer.getStyle().setPaddingTop(insetTop, Style.Unit.PX);
   if (insetLeft > 0) contentLayer.getStyle().setPaddingLeft(insetLeft, Style.Unit.PX);
   if (insetRight > 0) contentLayer.getStyle().setPaddingRight(insetRight, Style.Unit.PX);
   if (insetBottom > 0) contentLayer.getStyle().setPaddingBottom(insetBottom, Style.Unit.PX);
   container.appendChild(contentLayer);
   return contentLayer;
 }
Ejemplo n.º 5
0
  /**
   * @param chkKeys List of String objects with the shas
   * @param targetFile target file
   * @return true if write was successful
   */
  public static boolean writeRequestFile(
      final FileRequestFileContent content, final File targetFile) {

    final Document doc = XMLTools.createDomDocument();
    if (doc == null) {
      logger.severe("Error - writeRequestFile: factory could'nt create XML Document.");
      return false;
    }

    final Element rootElement = doc.createElement(TAG_FrostFileRequestFile);
    doc.appendChild(rootElement);

    final Element timeStampElement = doc.createElement(TAG_timestamp);
    final Text timeStampText = doc.createTextNode(Long.toString(content.getTimestamp()));
    timeStampElement.appendChild(timeStampText);
    rootElement.appendChild(timeStampElement);

    final Element rootChkElement = doc.createElement(TAG_shaList);
    rootElement.appendChild(rootChkElement);

    for (final String chkKey : content.getShaStrings()) {

      final Element nameElement = doc.createElement(TAG_sha);
      final Text text = doc.createTextNode(chkKey);
      nameElement.appendChild(text);

      rootChkElement.appendChild(nameElement);
    }

    boolean writeOK = false;
    try {
      writeOK = XMLTools.writeXmlFile(doc, targetFile);
    } catch (final Throwable t) {
      logger.log(Level.SEVERE, "Exception in writeRequestFile/writeXmlFile", t);
    }

    return writeOK;
  }
Ejemplo n.º 6
0
 private void tickDown(Player z, Element x, ArrayList<Element> d) {
   if ((z.getY() - (x.getY() - 15)) > 0
       && (z.getY() - (x.getY() - 15)) < 15
       && (z.getX() - x.getX()) < 10
       && (z.getX() - x.getX()) > -5) {
     if (z.getCol().equals(x.getCol())) {
       d.add(x);
     } else if (x.getCol().equals(BLUE)) {
       if (meta.equals(NO)) {
         meta = WINNERS;
       } else {
         d.add(x);
       }
     } else {
       z.setY(z.getY() - (z.getY() - (x.getY() - 15)));
     }
   }
 }