Search in sources :

Example 1 with ExtensibleDrawable

use of net.sf.sdedit.drawable.ExtensibleDrawable 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)

Example 2 with ExtensibleDrawable

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

the class PaintDevice method addSequenceElement.

public void addSequenceElement(SequenceElement elem) {
    int index;
    ExtensibleDrawable left, right;
    if (elem.getAlign() == Direction.RIGHT) {
        index = elem.getLeftEndpoint().getLifeline().getPosition();
        left = elem.getLeftEndpoint().getLifeline().getRightmost().getView();
        if (index == diagram.getNumberOfLifelines() - 1) {
            right = rightBound;
        } else {
            right = diagram.getLifelineAt(index + 1).getLeftmost().getView();
        }
    } else {
        // Direction.LEFT
        index = elem.getRightEndpoint().getLifeline().getPosition() - 1;
        right = elem.getRightEndpoint().getLifeline().getLeftmost().getView();
        left = diagram.getLifelineAt(index).getRightmost().getView();
    }
    leftOf.get(index).add(elem);
    elem.setLeftLimit(left);
    elem.setRightLimit(right);
    diagram.getFragmentManager().addSequenceElement(elem);
}
Also used : ExtensibleDrawable(net.sf.sdedit.drawable.ExtensibleDrawable)

Example 3 with ExtensibleDrawable

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

the class Lifeline method terminate.

public void terminate() {
    ExtensibleDrawable _view = lastLine != null ? lastLine : view;
    if (alive && autodestroy) {
        int lengthOfLastLine = Math.max(6, rectangleBottom - _view.getTop());
        cross = new Cross(this);
        int y = _view.getTop() + lengthOfLastLine + cross.getHeight();
        if (y > diagram.getVerticalPosition()) {
            diagram.extendLifelines(y - diagram.getVerticalPosition());
        }
        cross.setTop(_view.getTop() + lengthOfLastLine);
        diagram.getPaintDevice().addOtherDrawable(cross);
        _view.setHeight(lengthOfLastLine);
    }
    alive = false;
}
Also used : Cross(net.sf.sdedit.drawable.Cross) ExtensibleDrawable(net.sf.sdedit.drawable.ExtensibleDrawable)

Aggregations

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