Search in sources :

Example 1 with PanelPaintDevice

use of net.sf.sdedit.ui.PanelPaintDevice 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 2 with PanelPaintDevice

use of net.sf.sdedit.ui.PanelPaintDevice 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 3 with PanelPaintDevice

use of net.sf.sdedit.ui.PanelPaintDevice 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)

Example 4 with PanelPaintDevice

use of net.sf.sdedit.ui.PanelPaintDevice in project abstools by abstools.

the class UserInterfaceImpl method fullScreen.

public void fullScreen() {
    if (fullScreen == null) {
        errorMessage("Full-screen mode is not supported\nby your graphics environment.");
        return;
    }
    Diagram diag = getDiagram();
    if (diag != null) {
        PanelPaintDevice ppd = (PanelPaintDevice) diag.getPaintDevice();
        setVisible(false);
        fullScreen.display(ppd.getPanel());
        fullScreen.getZoomPane().fitSize();
    }
}
Also used : PanelPaintDevice(net.sf.sdedit.ui.PanelPaintDevice) Diagram(net.sf.sdedit.diagram.Diagram)

Aggregations

Diagram (net.sf.sdedit.diagram.Diagram)4 PanelPaintDevice (net.sf.sdedit.ui.PanelPaintDevice)4 Point (java.awt.Point)1 Arrow (net.sf.sdedit.drawable.Arrow)1 Drawable (net.sf.sdedit.drawable.Drawable)1 DiagramError (net.sf.sdedit.error.DiagramError)1 FatalError (net.sf.sdedit.error.FatalError)1 TextHandler (net.sf.sdedit.text.TextHandler)1 PanelPaintDeviceListener (net.sf.sdedit.ui.PanelPaintDeviceListener)1