Пример #1
0
 /** @param parent the parent to set */
 public void setParent(Node parent) {
   int parentDirectionIndex = -1;
   if (Arrays.asList(forwardChildren).contains(parent)) {
     this.setDirection(NodeDirection.REVERSE);
     parentDirectionIndex = Arrays.asList(forwardChildren).indexOf(parent);
   }
   if (Arrays.asList(reverseChildren).contains(parent)) {
     this.setDirection(NodeDirection.FORWARD);
     parentDirectionIndex = Arrays.asList(reverseChildren).indexOf(parent) + 3;
   }
   if (getTyp() == NodeTyp.Y) {
     parentDirectionIndex = parentDirectionIndex + 6;
   }
   if (parentDirectionIndex < 0 || parentDirectionIndex > 11 || parent == null) {
     parentDirection = ParentDirection.NONE;
   } else {
     parentDirection = ParentDirection.values()[parentDirectionIndex];
   }
   //        System.out.println("index: "+parentDirectionIndex+" enum: "+parentDirection);
   if (parent != null && getTyp() == parent.getTyp()) {
     setStraightCount(parent.getStraightCount() + 1);
   } else {
     setStraightCount(0);
   }
   this.parent = parent;
   changedValue();
 }
Пример #2
0
 protected void changedValue() {
   for (NodeListener listener : listeners) {
     listener.updateValue(
         String.format(
             "<HTML>%.2f<BR/>%d/%C/%s<HTML>",
             getValue(),
             straightCount,
             getDirection().toString().charAt(0),
             parentDirection.getArrow()));
   }
 }