use of net.sf.sdedit.drawable.Text in project abstools by abstools.
the class Diagram method generate.
/**
* Generates the diagram, based on the data of the
* <tt>DiagramDataProvider</tt> passed to the constructor.
*
* @throws SyntaxError
* if a message or object specification is syntactically wrong
* @throws SemanticError
* if a message or object specification is semantically wrong
*/
public void generate() throws SemanticError, SyntaxError {
Fragment frame = null;
Text text = null;
String title = provider.getTitle();
String[] description = provider.getDescription();
if (description != null) {
text = new Text(description, paintDevice);
text.setTop(conf.getUpperMargin());
text.setLeft(conf.getLeftMargin());
verticalPosition = text.getBottom() + 3;
} else {
verticalPosition = conf.getUpperMargin();
}
if (title != null) {
frame = new Fragment(title, "", this);
frame.setTop(verticalPosition);
verticalPosition += frame.getLabelHeight() + 5;
}
readObjects();
if (lifelineList.isEmpty()) {
return;
}
paintDevice.reinitialize();
try {
for (Lifeline lifeline : lifelineList) {
paintDevice.addOtherDrawable(lifeline.getHead());
verticalPosition = Math.max(verticalPosition, lifeline.getHead().getTop() + lifeline.getHead().getHeight());
}
for (Lifeline lifeline : lifelineList) {
lifeline.getView().setBottom(verticalPosition);
}
extendLifelines(conf.getInitialSpace());
for (Lifeline lifeline : lifelineList) {
if (lifeline.hasThread()) {
lifeline.setActive(true);
}
}
readMessages();
} finally {
fragmentManager.finishFragments();
if (getNumberOfLifelines() > 0) {
paintDevice.computeAxes(conf.getLeftMargin() + 6 + getLifelineAt(0).getHead().getWidth() / 2);
paintDevice.computeBounds();
// fixes bug 2019730 (notes appear outside of diagram)
for (Lifeline lifeline : getAllLifelines()) {
noteManager.closeNote(lifeline.getName());
}
//
noteManager.computeArrowAssociations();
if (frame != null) {
frame.setLeft(conf.getLeftMargin());
frame.setRight(paintDevice.getWidth() - conf.getRightMargin() + 6);
frame.setBottom(verticalPosition + 4);
paintDevice.addOtherDrawable(frame);
}
if (text != null) {
paintDevice.addOtherDrawable(text);
}
}
finished = true;
paintDevice.close();
}
}