Search in sources :

Example 1 with Line

use of net.sf.sdedit.drawable.Line in project abstools by abstools.

the class Lifeline method toggleWaitingStatus.

public void toggleWaitingStatus() {
    if (!active) {
        throw new IllegalArgumentException("an inactive lifeline cannot change its waiting status");
    }
    waiting = !waiting;
    int y = view.getTop() + view.getHeight();
    if (waiting) {
        lastLine = new Line(1, this);
        lastLine.setLeft(view.getLeft() + view.getWidth() / 2);
        view = lastLine;
    } else {
        view = new Rectangle(computeDrawableWidth(), this);
    }
    view.setTop(y);
}
Also used : Line(net.sf.sdedit.drawable.Line) Rectangle(net.sf.sdedit.drawable.Rectangle)

Example 2 with Line

use of net.sf.sdedit.drawable.Line in project abstools by abstools.

the class Lifeline method setActive.

public void setActive(boolean active) {
    if (this.active == active) {
        return;
    }
    this.active = active;
    if (this != getRoot()) {
        if (active) {
            view.setTop(parent.getView().getTop() + parent.getView().getHeight());
            view.setHeight(0);
        } else {
            diagram.clearMnemonic(this);
        }
        return;
    }
    int y = view.getTop() + view.getHeight();
    if (active) {
        view = new Rectangle(computeDrawableWidth(), this);
    } else {
        // view = new Line(computeDrawableWidth(), this);
        view = new Line(1, this);
        diagram.clearMnemonic(this);
        lastLine = (Line) view;
    }
    view.setTop(y);
}
Also used : Line(net.sf.sdedit.drawable.Line) Rectangle(net.sf.sdedit.drawable.Rectangle)

Example 3 with Line

use of net.sf.sdedit.drawable.Line in project abstools by abstools.

the class PaintDevice method computeAxes.

public void computeAxes(int leftAxis) {
    int n = diagram.getNumberOfLifelines();
    int axis = leftAxis;
    int mainWidth = diagram.getConfiguration().getMainLifelineWidth();
    int subWidth = diagram.getConfiguration().getSubLifelineWidth();
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            axis += diagram.getConfiguration().getGlue();
        }
        for (ExtensibleDrawable view : diagram.getLifelineAt(i).getAllViews()) {
            if (view instanceof Line) {
                view.setLeft(axis + mainWidth / 2);
            } else {
                switch(view.getLifeline().getDirection()) {
                    case CENTER:
                        view.setLeft(axis);
                        break;
                    case LEFT:
                        view.setLeft(axis - view.getLifeline().getSideLevel() * subWidth);
                        break;
                    case RIGHT:
                        view.setLeft(axis + mainWidth + (view.getLifeline().getSideLevel() - 1) * subWidth);
                }
            }
        }
        Lifeline lifeline = diagram.getLifelineAt(i);
        Drawable head = lifeline.getHead();
        int offset = mainWidth / 2;
        // int offset = lifeline.getView().getWidth() / 2;
        head.setLeft(axis - head.getWidth() / 2 + offset);
        if (lifeline.getCross() != null) {
            lifeline.getCross().setLeft(axis - diagram.getConfiguration().getDestructorWidth() / 2 + mainWidth / 2);
        }
        if (i < diagram.getNumberOfLifelines() - 1) {
            axis += head.getWidth() / 2 + diagram.getLifelineAt(i + 1).getHead().getWidth() / 2;
        } else {
            axis += head.getWidth() / 2 + mainWidth / 2;
        }
        // to the left of the (i+1)-th lifeline
        for (SequenceElement arrow : leftOf.get(i)) {
            int left = arrow.getLeftLimit().getRight();
            int level;
            if (arrow.getRightLimit() == rightBound) {
                level = 0;
            } else {
                level = arrow.getRightLimit().getLifeline().getSideLevel();
            }
            axis = Math.max(axis, left + arrow.getSpace() + arrow.getWidth() + level * subWidth);
        }
    }
    rightBound.setLeft(axis);
}
Also used : Line(net.sf.sdedit.drawable.Line) ExtensibleDrawable(net.sf.sdedit.drawable.ExtensibleDrawable) SequenceElement(net.sf.sdedit.drawable.SequenceElement) Drawable(net.sf.sdedit.drawable.Drawable) ExtensibleDrawable(net.sf.sdedit.drawable.ExtensibleDrawable)

Aggregations

Line (net.sf.sdedit.drawable.Line)3 Rectangle (net.sf.sdedit.drawable.Rectangle)2 Drawable (net.sf.sdedit.drawable.Drawable)1 ExtensibleDrawable (net.sf.sdedit.drawable.ExtensibleDrawable)1 SequenceElement (net.sf.sdedit.drawable.SequenceElement)1