Ejemplo n.º 1
0
  /**
   * @todo Copy and paste code, refactor. Maybe it is best to add the transitions once they are
   *     known and not every time a button is pressed. The buttons would then change only the time
   *     controller and not affect the canvas items directly.
   */
  private void addTransitionsSerialized(final double newTargetTime, final boolean highlightStates) {
    List<Value> selected = sequenceToShowChooser.getSelectedValuesList();
    List<ArrayList<FCAElement>> objectSequences = calculateObjectSequences();
    Iterator<Value> seqValIt = sequenceValues.iterator();
    int seqNum = 0;
    int seqLength = timelineValues.size();
    List<FCAElement> lastSequence = null;
    ArrowStyle[] styles = DiagramSchema.getCurrentSchema().getArrowStyles();
    ArrowStyle style = null;
    int trailCount = 0;
    for (ArrayList<FCAElement> sequence : objectSequences) {
      Value curSequenceValue = seqValIt.next();
      if (!selected.contains(curSequenceValue)) {
        seqNum++;
        continue;
      }
      if (lastSequence != null) {
        Color nextColor = styles[seqNum % styles.length].getColor();
        DiagramNode endLast = findObjectConceptNode(lastSequence.get(lastSequence.size() - 1));
        DiagramNode startNew = findObjectConceptNode(sequence.get(0));
        if (endLast == null) {
          continue;
        }
        if (endLast != startNew) {
          SimpleLineDiagram diagram = (SimpleLineDiagram) diagramView.getDiagram();
          diagram.addExtraCanvasItem(
              new InterSequenceTransitionArrow(
                  endLast,
                  startNew,
                  style,
                  nextColor,
                  trailCount * seqLength + 0.5,
                  timeController));
        }
      }

      style = styles[seqNum % styles.length];
      if (lastSequence == null) {
        this.targetTime = newTargetTime;
        this.lastAnimationTime = 0;
      }
      addTransitions(curSequenceValue, sequence, style, highlightStates, trailCount * seqLength);
      seqNum++;
      trailCount++;
      lastSequence = sequence;
    }
  }
Ejemplo n.º 2
0
 private void addTransitions(
     Value curSequenceValue,
     List<FCAElement> sequence,
     ArrowStyle style,
     boolean highlightStates,
     int countStart) {
   SimpleLineDiagram diagram = (SimpleLineDiagram) diagramView.getDiagram();
   DiagramNode oldNode = null;
   int count = countStart;
   boolean first = true;
   for (Iterator<FCAElement> iterator = sequence.iterator(); iterator.hasNext(); ) {
     FCAElement object = iterator.next();
     count++;
     final DiagramNode curNode = findObjectConceptNode(object);
     if (curNode == null) {
       continue;
     }
     if (highlightStates) {
       diagram.addExtraCanvasItem(new StateRing(curNode, style.getColor(), count, timeController));
     }
     if (oldNode != null && oldNode != curNode) {
       TransitionArrow arrow =
           new TransitionArrow(oldNode, curNode, style, count - 0.5, timeController);
       diagram.addExtraCanvasItem(arrow);
       if (style.getLabelUse().shouldShow(first, !iterator.hasNext())) {
         ArrowLabelView label =
             new ArrowLabelView(
                 diagramView,
                 arrow,
                 style,
                 curSequenceValue.getDisplayString(),
                 count - 0.5,
                 timeController);
         diagram.addExtraCanvasItem(label);
       }
       first = false;
     }
     oldNode = curNode;
   }
 }