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;
}
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;
}
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;
}
}
}
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;
}
}
}
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();
}
}
}
}
}
Aggregations