return false;
}
private void relayout(Set<Widget> oldVisibleWidgets) {
Diagram diagram = getModel().getDiagramToView();
HashSet<Figure> figures = new HashSet<Figure>();
for (Figure f : diagram.getFigures()) {
FigureWidget w = figureWidgets.get(f);
if (w.isVisible()) {
figures.add(f);
}
}
HashSet<Connection> edges = new HashSet<Connection>();
for (Connection c : diagram.getConnections()) {
if (isVisible(c)) {
edges.add(c);
}
}
if (getModel().getShowBlocks()) {
HierarchicalClusterLayoutManager m = new HierarchicalClusterLayoutManager(OldHierarchicalLayoutManager.Combine.SAME_OUTPUTS);
HierarchicalLayoutManager manager = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.SAME_OUTPUTS);
manager.setMaxLayerLength(9);
manager.setMinLayerDifference(3);
m.setManager(manager);
m.setSubManager(new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.SAME_OUTPUTS));
m.doLayout(new LayoutGraph(edges, figures));
} else {
HierarchicalLayoutManager manager = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.SAME_OUTPUTS);
manager.setMaxLayerLength(10);
manager.doLayout(new LayoutGraph(edges, figures));
}
int maxX = -BORDER_SIZE;
int maxY = -BORDER_SIZE;
for (Figure f : diagram.getFigures()) {
FigureWidget w = figureWidgets.get(f);
if (w.isVisible()) {
Point p = f.getPosition();
Dimension d = f.getSize();
maxX = Math.max(maxX, p.x + d.width);
maxY = Math.max(maxY, p.y + d.height);
}
}
for (Connection c : diagram.getConnections()) {
List<Point> points = c.getControlPoints();
FigureWidget w1 = figureWidgets.get((Figure) c.getTo().getVertex());
FigureWidget w2 = figureWidgets.get((Figure) c.getFrom().getVertex());
if (w1.isVisible() && w2.isVisible()) {
for (Point p : points) {
if (p != null) {
maxX = Math.max(maxX, p.x);
maxY = Math.max(maxY, p.y);
}
}
}
}
if (getModel().getShowBlocks()) {
for (Block b : diagram.getBlocks()) {
BlockWidget w = blockWidgets.get(b.getInputBlock());
if (w != null && w.isVisible()) {
Rectangle r = b.getBounds();
maxX = Math.max(maxX, r.x + r.width);
maxY = Math.max(maxY, r.y + r.height);
}
}
}
bottomRight.setPreferredLocation(new Point(maxX + BORDER_SIZE, maxY + BORDER_SIZE));
int offx = 0;
int offy = 0;
int curWidth = maxX + 2 * BORDER_SIZE;
int curHeight = maxY + 2 * BORDER_SIZE;
Rectangle bounds = this.getScrollPane().getBounds();
if (curWidth < bounds.width) {
offx = (bounds.width - curWidth) / 2;
}
if (curHeight < bounds.height) {
offy = (bounds.height - curHeight) / 2;
}
final int offx2 = offx;
final int offy2 = offy;
SceneAnimator animator = this.getSceneAnimator();
connectionLayer.removeChildren();
int visibleFigureCount = 0;
for (Figure f : diagram.getFigures()) {
if (figureWidgets.get(f).isVisible()) {
visibleFigureCount++;
}
}
for (Figure f : diagram.getFigures()) {
for (OutputSlot s : f.getOutputSlots()) {
SceneAnimator anim = animator;
if (visibleFigureCount > ANIMATION_LIMIT) {
anim = null;
}
processOutputSlot(s, s.getConnections(), 0, null, null, offx2, offy2, anim);
}
}
for (Figure f : diagram.getFigures()) {
FigureWidget w = figureWidgets.get(f);
if (w.isVisible()) {
Point p = f.getPosition();
Point p2 = new Point(p.x + offx2, p.y + offy2);
Rectangle r = new Rectangle(p.x + offx2, p.y + offy2, f.getSize().width, f.getSize().height);
if (oldVisibleWidgets.contains(w)) {
if (visibleFigureCount > ANIMATION_LIMIT) {
w.setPreferredLocation(p2);
} else {
animator.animatePreferredLocation(w, p2);
}
} else {
w.setPreferredLocation(p2);
}
}
}
if (getModel().getShowBlocks()) {
for (Block b : diagram.getBlocks()) {
BlockWidget w = blockWidgets.get(b.getInputBlock());
if (w != null && w.isVisible()) {
Point location = new Point(b.getBounds().x + offx2, b.getBounds().y + offy2);
Rectangle r = new Rectangle(location.x, location.y, b.getBounds().width, b.getBounds().height);
if (oldVisibleWidgets.contains(w)) {