public TemporalControlsPanel( final DiagramView diagramView, final DiagramExportSettings diagramExportSettings, final EventBroker eventBroker) { super(); this.diagramView = diagramView; // make sure the factories for the extra canvas items are loaded TransitionArrow.registerFactory(); InterSequenceTransitionArrow.registerFactory(); StateRing.registerFactory(); eventBroker.subscribe(this, ConceptualSchemaChangeEvent.class, Object.class); diagramView .getController() .getEventBroker() .subscribe(this, DisplayedDiagramChangedEvent.class, DiagramView.class); diagramView .getController() .getEventBroker() .subscribe(this, CanvasDrawnEvent.class, Object.class); new TransitionArrowManipulator(diagramView, diagramView.getController().getEventBroker()); this.diagramExportSettings = diagramExportSettings; this.timeController = new AnimationTimeController(0, 0, 0, 0, 0); buildGUI(); fillGUI(); }
private void animate() { if (lastAnimationTime > targetTime) { removeTransitions(); animating = false; if (repeatAnimationCheckbox.isSelected()) { addAnimatedTransitions(); } } else { timeController.calculateCurrentTime(); lastAnimationTime = timeController.getCurrentTime(); diagramView.repaint(); // paint it again as time has past } }
/** * @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( 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; } }