Ejemplo n.º 1
0
 /**
  * Get all Links for a Story
  *
  * @param allLinks ArrayList<Link>
  * @return ArrayList<Link>
  */
 public ArrayList<Link> getAllLinks(ArrayList<Link> allLinks) {
   allLinks.add(this);
   for (Link l : this.links) {
     l.getAllLinks(allLinks);
   }
   return allLinks;
 }
Ejemplo n.º 2
0
 /**
  * Print XML
  *
  * @param XMLProject boolean
  * @return String
  */
 public String printXML(boolean XMLProject) {
   String XMLString = "";
   if (!printed) {
     XMLString += "<link.name>" + this.name + "</link.name>\r\n";
     XMLString += "<link.id>" + this.id + "</link.id>\r\n";
     if (p1 != null) {
       XMLString += "<from>\r\n";
       XMLString += this.p1.printXML(XMLProject);
       XMLString += "</from>\r\n";
     }
     if (p2 != null) {
       XMLString += "<to>\r\n";
       XMLString += this.p2.printXML(XMLProject);
       XMLString += "</to>\r\n";
     }
     XMLString += "<queue>\r\n";
     for (MediaItem item : this.mediaItems) {
       XMLString += item.printXML(XMLProject);
     }
     XMLString += "</queue>\r\n";
     if (this.links.size() > 0) {
       XMLString += "<links>\r\n";
       for (Link link : this.links) {
         XMLString += "<link>\r\n";
         XMLString += link.printXML(XMLProject);
         XMLString += "</link>\r\n";
       }
       XMLString += "</links>\r\n";
     }
   } else {
     XMLString += "<link.shortcut>" + this.id + "</link.shortcut>\r\n";
   }
   this.printed = true;
   return XMLString;
 }
Ejemplo n.º 3
0
 /**
  * Overload constructor (2)
  *
  * @param link Link
  * @param id long
  */
 public Link(Link link, long id) {
   this.name = link.getName();
   this.p1 = link.getP1();
   this.p2 = link.getP2();
   this.links = new ArrayList<Link>();
   this.mediaItems = link.getMediaItems();
   this.color = Color.RED;
   this.id = id;
 }
Ejemplo n.º 4
0
 /**
  * Get routes that are part of this given Node
  *
  * @param node Node
  * @return boolean
  */
 public boolean getRoutesFromNode(Node node) {
   if (this.getP2().equals(node)) {
     return true;
   } else {
     for (Link currentLink : links) {
       return currentLink.getRoutesFromNode(node);
     }
     return false;
   }
 }
Ejemplo n.º 5
0
 /**
  * Return true if the given Link is part of a Route
  *
  * @param link Link
  * @return boolean
  */
 public boolean getRouteForLink(Link link) {
   if (this.equals(link)) {
     return true;
   } else {
     for (Link currentLink : links) {
       if (currentLink.getRouteForLink(link)) {
         return true;
       }
     }
     return false;
   }
 }
Ejemplo n.º 6
0
 /**
  * Get Link for given endNode
  *
  * @param endNode Node
  * @return Link
  */
 public Link getLinkForEndNode(Node endNode) {
   if (this.getP2().equals(endNode)) {
     return this;
   } else {
     for (Link currentLink : links) {
       Link link = currentLink.getLinkForEndNode(endNode);
       if (link != null) {
         return link;
       }
     }
     return null;
   }
 }
Ejemplo n.º 7
0
 /**
  * Get the identifier from this link
  *
  * @return the id
  */
 public ArrayList<Link> getParentsFromLink(ArrayList<Link> parents, Link link, Link parent) {
   if (this == link) {
     boolean found = false;
     for (Link link1 : parents) {
       if (parent == link1) {
         found = true;
       }
     }
     if (!found) {
       parents.add(parent);
     }
   }
   for (Link currentLink : links) {
     currentLink.getParentsFromLink(parents, link, this);
   }
   return parents;
 }
Ejemplo n.º 8
0
 /**
  * Get all previous Links for given endNode
  *
  * @param node Node
  * @param prevLinks ArrayList<Link>
  * @return ArrayList<Link>
  */
 public ArrayList<Link> getPrevLinksForNode(Node node, ArrayList<Link> prevLinks) {
   boolean found = false;
   if (this.getP2() == node) {
     for (Link link : prevLinks) {
       if (link == this) {
         found = true;
       }
     }
     if (!found) {
       prevLinks.add(this);
     }
   }
   for (Link currentLink : links) {
     prevLinks = currentLink.getPrevLinksForNode(node, prevLinks);
   }
   return prevLinks;
 }
Ejemplo n.º 9
0
 /**
  * Set all printed boolean
  *
  * @param printed boolean
  */
 public void setAllPrinted(boolean printed) {
   this.printed = printed;
   for (Link link : this.links) {
     link.setAllPrinted(printed);
   }
 }