Example #1
0
 @Override
 public void setDeleted(boolean deleted) {
   boolean locked = writeLock();
   try {
     for (Node n : nodes) {
       if (deleted) {
         n.removeReferrer(this);
       } else {
         n.addReferrer(this);
       }
       n.clearCachedStyle();
     }
     fireNodesChanged();
     super.setDeleted(deleted);
   } finally {
     writeUnlock(locked);
   }
 }
Example #2
0
  /**
   * Set new list of nodes to way. This method is preferred to multiple calls to addNode/removeNode
   * and similar methods because nodes are internally saved as array which means lower memory
   * overhead but also slower modifying operations.
   *
   * @param nodes New way nodes. Can be null, in that case all way nodes are removed
   * @since 1862
   */
  public void setNodes(List<Node> nodes) {
    boolean locked = writeLock();
    try {
      for (Node node : this.nodes) {
        node.removeReferrer(this);
        node.clearCachedStyle();
      }

      if (nodes == null) {
        this.nodes = new Node[0];
      } else {
        this.nodes = nodes.toArray(new Node[nodes.size()]);
      }
      for (Node node : this.nodes) {
        node.addReferrer(this);
        node.clearCachedStyle();
      }

      clearCachedStyle();
      fireNodesChanged();
    } finally {
      writeUnlock(locked);
    }
  }