use of net.sf.sdedit.drawable.Fragment 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();
}
}
use of net.sf.sdedit.drawable.Fragment in project abstools by abstools.
the class FragmentManager method openFragment.
private void openFragment(String type, String text) {
Fragment fragment = new Fragment(type, text, diagram);
int textHeight = diagram.getPaintDevice().getTextHeight();
int extension = 5 + (fragment.getCondition().length() > 0 ? textHeight * 2 : textHeight);
diagram.getPaintDevice().announce(diagram.getConfiguration().getFragmentMargin() + extension);
diagram.extendLifelines(diagram.getConfiguration().getFragmentMargin());
fragment.setTop(diagram.getVerticalPosition());
diagram.extendLifelines(extension);
openFragments.addLast(fragment);
diagram.getPaintDevice().addOtherDrawable(fragment);
int l = openFragments.size() - 1;
for (Fragment open : openFragments) {
open.setLevel(l);
l--;
}
}
use of net.sf.sdedit.drawable.Fragment in project abstools by abstools.
the class FragmentManager method closeRecentFragment.
private void closeRecentFragment() throws SyntaxError {
if (openFragments.isEmpty()) {
throw new SyntaxError(diagram.getDataProvider(), "There is no open comment");
}
Fragment comment = openFragments.removeLast();
closingFragments.addLast(comment);
}
use of net.sf.sdedit.drawable.Fragment in project abstools by abstools.
the class FragmentManager method finishFragmentsNotIncluding.
/**
* Sets the closing fragments that do not include the message to which the
* given answer is the answer into finished state.
*
* @param answer
* an answer
*/
public void finishFragmentsNotIncluding(Answer answer) {
ListIterator<Fragment> lic = closingFragments.listIterator();
Arrow arrow = answer.getForwardMessage().getArrow();
while (lic.hasNext()) {
Fragment comment = lic.next();
if (!comment.containsElement(arrow)) {
lic.remove();
finishFragment(comment);
}
}
}
use of net.sf.sdedit.drawable.Fragment in project abstools by abstools.
the class PanelPaintDevice method mouseMoved.
/**
* This method is called when the mouse moved over the panel. If it has
* exited or entered a drawable object,
* {@linkplain PanelPaintDeviceListener}s are notified.
*
* @param e
*/
public void mouseMoved(MouseEvent e) {
if (interactive) {
JPanel zp = panel.getZoomPane().getPanel();
Point point = e.getPoint();
if (lastDrawableMovedOver != null) {
if (!lastDrawableMovedOver.contains(point)) {
for (PanelPaintDeviceListener listener : listeners) {
listener.mouseExitedDrawable(lastDrawableMovedOver);
zp.setCursor(Cursor.getDefaultCursor());
}
} else {
return;
}
}
lastDrawableMovedOver = null;
for (Drawable drawable : this) {
if (!(drawable instanceof Fragment)) {
if (drawable.contains(point)) {
lastDrawableMovedOver = drawable;
for (PanelPaintDeviceListener listener : listeners) {
if (listener.mouseEnteredDrawable(drawable)) {
zp.setCursor(HAND_CURSOR);
}
}
return;
}
}
}
}
}
Aggregations