Esempio 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;
 }
Esempio 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;
 }
Esempio 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;
 }
Esempio 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;
   }
 }
Esempio 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;
   }
 }
Esempio 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;
   }
 }
Esempio 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;
 }
Esempio 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;
 }
Esempio 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);
   }
 }