Search in sources :

Example 6 with Diagram

use of net.sf.sdedit.diagram.Diagram in project abstools by abstools.

the class Tab method getSuggestions.

/**
 * @see net.sf.sdedit.ui.components.AutoCompletion.SuggestionProvider#getSuggestions(java.lang.String)
 */
public List<String> getSuggestions(String prefix) {
    List<String> suggestions = new LinkedList<String>();
    Diagram diag = getDiagram();
    if (diag != null) {
        for (Lifeline lifeline : diag.getAllLifelines()) {
            String name = lifeline.getName();
            if (name.startsWith(prefix)) {
                suggestions.add(name);
            }
        }
    }
    return suggestions;
}
Also used : Lifeline(net.sf.sdedit.diagram.Lifeline) LinkedList(java.util.LinkedList) Diagram(net.sf.sdedit.diagram.Diagram)

Example 7 with Diagram

use of net.sf.sdedit.diagram.Diagram in project abstools by abstools.

the class UserInterfaceImpl method isDiagramBlank.

public boolean isDiagramBlank() {
    Tab tab = currentTab();
    if (tab == null) {
        return true;
    }
    Diagram diagram = tab.getDiagram();
    if (diagram != null) {
        return ((PanelPaintDevice) diagram.getPaintDevice()).isBlank();
    }
    return true;
}
Also used : PanelPaintDevice(net.sf.sdedit.ui.PanelPaintDevice) Diagram(net.sf.sdedit.diagram.Diagram)

Example 8 with Diagram

use of net.sf.sdedit.diagram.Diagram in project abstools by abstools.

the class Tab method renderDiagram.

void renderDiagram() {
    PanelPaintDevice paintDevice = new PanelPaintDevice(true);
    for (PanelPaintDeviceListener listener : ppdListeners) {
        paintDevice.addListener(listener);
    }
    TextHandler textHandler = new TextHandler(getCode());
    Diagram diagram = new Diagram(configuration.getDataObject(), textHandler, paintDevice);
    DiagramError newError = null;
    try {
        diagram.generate();
    } catch (RuntimeException e) {
        newError = new FatalError(textHandler, e);
    } catch (DiagramError e) {
        newError = e;
    }
    synchronized (diagramStack) {
        diagramStack.addLast(diagram);
        synchronized (this) {
            error = newError;
        }
    }
}
Also used : FatalError(net.sf.sdedit.error.FatalError) PanelPaintDeviceListener(net.sf.sdedit.ui.PanelPaintDeviceListener) PanelPaintDevice(net.sf.sdedit.ui.PanelPaintDevice) TextHandler(net.sf.sdedit.text.TextHandler) DiagramError(net.sf.sdedit.error.DiagramError) Diagram(net.sf.sdedit.diagram.Diagram)

Example 9 with Diagram

use of net.sf.sdedit.diagram.Diagram in project abstools by abstools.

the class Tab method getDiagram.

Diagram getDiagram() {
    synchronized (diagramStack) {
        switch(diagramStack.size()) {
            case 0:
                return null;
            case 1:
                return diagramStack.getLast();
            default:
                Diagram diagram = diagramStack.getLast();
                diagramStack.clear();
                diagramStack.addLast(diagram);
                return diagram;
        }
    }
}
Also used : Diagram(net.sf.sdedit.diagram.Diagram)

Example 10 with Diagram

use of net.sf.sdedit.diagram.Diagram in project abstools by abstools.

the class Tab method scrollToCurrentDrawable.

private void scrollToCurrentDrawable() {
    int begin = textArea.getCurrentLineBegin();
    Diagram diagram = getDiagram();
    if (diagram != null) {
        PanelPaintDevice ppd = (PanelPaintDevice) diagram.getPaintDevice();
        Drawable drawable = diagram.getDrawableForState(begin);
        if (drawable instanceof Arrow) {
            Arrow arrow = (Arrow) drawable;
            Point textPosition = arrow.getTextPosition();
            int x = textPosition != null ? textPosition.x : arrow.getLeft();
            float xratio = 1F * x / ppd.getWidth();
            int y = drawable.getTop();
            float yratio = 1F * y / ppd.getHeight();
            zoomPane.scrollToPosition(xratio, yratio);
        } else {
            if (drawable != null) {
                int x = drawable.getLeft();
                float xratio = 1F * x / ppd.getWidth();
                int y = drawable.getTop();
                float yratio = 1F * y / ppd.getHeight();
                zoomPane.scrollToPosition(xratio, yratio);
            } else {
                int caret = textArea.getCaretPosition();
                if (textArea.getText().substring(caret).trim().length() == 0) {
                    zoomPane.scrollToBottom();
                }
            }
        }
    }
}
Also used : Arrow(net.sf.sdedit.drawable.Arrow) Drawable(net.sf.sdedit.drawable.Drawable) PanelPaintDevice(net.sf.sdedit.ui.PanelPaintDevice) Point(java.awt.Point) Point(java.awt.Point) Diagram(net.sf.sdedit.diagram.Diagram)

Aggregations

Diagram (net.sf.sdedit.diagram.Diagram)14 TextHandler (net.sf.sdedit.text.TextHandler)7 File (java.io.File)6 IOException (java.io.IOException)4 PanelPaintDevice (net.sf.sdedit.ui.PanelPaintDevice)4 Configuration (net.sf.sdedit.config.Configuration)3 ImagePaintDevice (net.sf.sdedit.ui.ImagePaintDevice)3 DiagramError (net.sf.sdedit.error.DiagramError)2 FatalError (net.sf.sdedit.error.FatalError)2 XMLException (net.sf.sdedit.util.DocUtil.XMLException)2 Image (java.awt.Image)1 Point (java.awt.Point)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1 LinkedList (java.util.LinkedList)1 BoxLayout (javax.swing.BoxLayout)1 JLabel (javax.swing.JLabel)1