public boolean step() throws SyntaxError { Note note = diagram.getDataProvider().getNote(); if (note != null) { freeNoteNumber = Math.max(freeNoteNumber, note.getNumber() + 1); diagram.getPaintDevice().addSequenceElement(note); notes.add(note); closeNote(note.getLocation().getName()); diagram.getFragmentManager().openFragments(); diagram.getPaintDevice().announce(note.getHeight()); note.setTop(diagram.getVerticalPosition()); if (note.isConsuming()) { diagram.extendLifelines(note.getHeight()); } else { pendingNotes.put(note.getLocation().getName(), note); } if (diagram.getDataProvider().getState() != null) { diagram.addToStateMap(note, diagram.getDataProvider().getState()); } diagram.getFragmentManager().clearLabels(); return true; } Pair<Lifeline, Integer> eventAssoc = diagram.getDataProvider().getEventAssociation(); if (eventAssoc != null) { associateEvent(eventAssoc.getFirst(), eventAssoc.getSecond()); return true; } return false; }
/** * @param lifeline the name of a lifeline that may have a non-consuming note box associated to it */ void closeNote(String lifeline) { Note note = pendingNotes.get(lifeline); if (note != null) { int diff = note.getTop() + note.getHeight() - diagram.getVerticalPosition(); if (diff > 0) { diagram.extendLifelines(diff); } pendingNotes.remove(lifeline); } }