示例#1
0
 /** Linearizes the line attributes of the tspan elements in the tspan vector. */
 public void linearizeTSpanVector() {
   boolean linearFromZero = false;
   int currentLine = 0;
   for (int i = 0; i < tspanVector.size(); i++) {
     TSpanElement tspanElement = tspanVector.elementAt(i);
     int nextLine = tspanElement.getLine();
     if (nextLine == 0) linearFromZero = true;
     if (nextLine - currentLine == 1)
       if (!linearFromZero) tspanElement.setLine(0);
       else currentLine = nextLine;
     if (nextLine - currentLine > 1) tspanElement.setLine(currentLine + 1);
   }
 }
示例#2
0
 /**
  * Creates a new tail tpsan element for this text element before the specified next tspan element.
  *
  * @param nextTSpanElement next tspan element
  * @param line line number
  */
 public TSpanElement createTailTSpanElementBefore(TSpanElement nextTSpanElement, int line) {
   TSpanElement tspanElement =
       new TSpanElement(treeRepresentation, "|", "fill:none;", line, TSpanElement.TAIL_TYPE);
   if (nextTSpanElement == null) {
     element.appendChild(tspanElement.getElement());
     tspanVector.add(tspanElement);
   }
   if (nextTSpanElement != null) {
     element.insertBefore(tspanElement.getElement(), nextTSpanElement.getElement());
     int index = tspanVector.indexOf(nextTSpanElement);
     tspanVector.insertElementAt(tspanElement, index);
   }
   return tspanElement;
 }
示例#3
0
 /**
  * Creates a new text tspan element for this text element before the specified next tspan element.
  *
  * @param nextTSpanElement next tspan element
  * @param text text
  * @param style style
  * @param line line
  */
 public TSpanElement createTextTSpanElement(
     TSpanElement nextTSpanElement, String text, String style, int line) {
   TSpanElement tspanElement =
       new TSpanElement(treeRepresentation, text, style, line, TSpanElement.TEXT_TYPE);
   if (nextTSpanElement == null) {
     element.appendChild(tspanElement.getElement());
     tspanVector.add(tspanElement);
   }
   if (nextTSpanElement != null) {
     element.insertBefore(tspanElement.getElement(), nextTSpanElement.getElement());
     int index = tspanVector.indexOf(nextTSpanElement);
     tspanVector.insertElementAt(tspanElement, index);
   }
   return tspanElement;
 }
示例#4
0
  public TextElement duplicate(NodeElement nodeElement) {
    TextElement textElement = new TextElement(treeRepresentation, nodeElement, DEFAULT_TEXT);

    textElement.setVisible(this.isVisible());

    // remove initial tspan element
    while (textElement.getTSpanVector().size() > 0) {
      textElement.getElement().removeChild(textElement.getTSpanVector().lastElement().getElement());
      textElement.getTSpanVector().removeElement(textElement.getTSpanVector().lastElement());
    }

    // duplicate tspan elements
    for (int i = 0; i < this.getTSpanVector().size(); i++) {
      TSpanElement tspanElement = this.getTSpanVector().elementAt(i).duplicate(textElement);
      textElement.getTSpanVector().add(tspanElement);
      textElement.getElement().appendChild(tspanElement.getElement());
    }

    return textElement;
  }
示例#5
0
 public void removeTSpanElement(TSpanElement tspanElement) {
   element.removeChild(tspanElement.getElement());
   tspanVector.removeElement(tspanElement);
 }