Search in sources :

Example 6 with Message

use of net.sf.sdedit.message.Message in project abstools by abstools.

the class Fragment method computeLayoutInformation.

/**
 * @see net.sf.sdedit.drawable.Drawable#computeLayoutInformation()
 */
public void computeLayoutInformation() {
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
    for (SequenceElement element : includedElements) {
        int left = element.getLeft();
        int right = element.getLeft() + element.getWidth();
        if (element instanceof Arrow) {
            Message msg = ((Arrow) element).getMessage();
            if (msg instanceof ConstructorMessage) {
                if (msg.getCallee().getPosition() < msg.getCaller().getPosition()) {
                    left = msg.getCallee().getHead().getLeft();
                } else {
                    right = msg.getCallee().getHead().getLeft() + msg.getCallee().getHead().getWidth();
                }
            }
            if (((Arrow) element).getStroke() != ArrowStroke.NONE) {
                right += element.getRightEndpoint().getWidth();
            }
        // nothing to add for pseudo arrows (primitive messages)
        // with
        // ArrowStroke.NONE
        }
        min = Math.min(min, left);
        max = Math.max(max, right);
    }
    int width = max - min;
    int padding = diagram.getConfiguration().getFragmentPadding();
    int margin = diagram.getConfiguration().getFragmentMargin();
    setLeft(min - padding - level * padding);
    setWidth(2 * level * padding + width + 2 * padding + margin);
}
Also used : Message(net.sf.sdedit.message.Message) ConstructorMessage(net.sf.sdedit.message.ConstructorMessage) ConstructorMessage(net.sf.sdedit.message.ConstructorMessage)

Aggregations

Message (net.sf.sdedit.message.Message)6 BroadcastMessage (net.sf.sdedit.message.BroadcastMessage)3 ForwardMessage (net.sf.sdedit.message.ForwardMessage)3 Point (java.awt.Point)2 ConstructorMessage (net.sf.sdedit.message.ConstructorMessage)2 HashSet (java.util.HashSet)1 Configuration (net.sf.sdedit.config.Configuration)1 Note (net.sf.sdedit.drawable.Note)1 SemanticError (net.sf.sdedit.error.SemanticError)1 AnswerToSelf (net.sf.sdedit.message.AnswerToSelf)1 Pair (net.sf.sdedit.util.Pair)1