Search in sources :

Example 1 with Fragment

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();
    }
}
Also used : Text(net.sf.sdedit.drawable.Text) Fragment(net.sf.sdedit.drawable.Fragment)

Example 2 with Fragment

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--;
    }
}
Also used : Fragment(net.sf.sdedit.drawable.Fragment)

Example 3 with Fragment

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);
}
Also used : SyntaxError(net.sf.sdedit.error.SyntaxError) Fragment(net.sf.sdedit.drawable.Fragment)

Example 4 with Fragment

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);
        }
    }
}
Also used : Arrow(net.sf.sdedit.drawable.Arrow) Fragment(net.sf.sdedit.drawable.Fragment)

Example 5 with Fragment

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;
                }
            }
        }
    }
}
Also used : JPanel(javax.swing.JPanel) Drawable(net.sf.sdedit.drawable.Drawable) ExtensibleDrawable(net.sf.sdedit.drawable.ExtensibleDrawable) Point(java.awt.Point) Fragment(net.sf.sdedit.drawable.Fragment)

Aggregations

Fragment (net.sf.sdedit.drawable.Fragment)6 Point (java.awt.Point)1 JPanel (javax.swing.JPanel)1 Arrow (net.sf.sdedit.drawable.Arrow)1 Drawable (net.sf.sdedit.drawable.Drawable)1 ExtensibleDrawable (net.sf.sdedit.drawable.ExtensibleDrawable)1 Text (net.sf.sdedit.drawable.Text)1 SyntaxError (net.sf.sdedit.error.SyntaxError)1