private void setUpTransitions(int length) { List<Value> sequences = sequenceToShowChooser.getSelectedValuesList(); if (this.serializeSequencesBox.isSelected() && sequences.size() > 1) { int numSeq = sequences.size(); timeController.setEndTime(length * numSeq); addTransitionsSerialized(timeController.getAllFadedTime(), true); } else { timeController.setEndTime(length); addTransitions(timeController.getAllFadedTime(), true); } }
/** * @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; } }
private void addTransitions(double newTargetTime, boolean highlightStates) { List<Value> selected = sequenceToShowChooser.getSelectedValuesList(); List<ArrayList<FCAElement>> objectSequences = calculateObjectSequences(); Iterator<Value> seqValIt = sequenceValues.iterator(); int styleNum = 0; boolean start = true; for (List<FCAElement> sequence : objectSequences) { Value curSequenceValue = seqValIt.next(); if (start) { start = false; this.targetTime = newTargetTime; this.lastAnimationTime = 0; } ArrowStyle[] styles = DiagramSchema.getCurrentSchema().getArrowStyles(); if (selected.contains(curSequenceValue)) { addTransitions(curSequenceValue, sequence, styles[styleNum], highlightStates, 0); } styleNum = (styleNum + 1) % styles.length; } }