use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class LinkingContainerEditpart method updateConnectionListForLinkedOpi.
private void updateConnectionListForLinkedOpi(DisplayModel displayModel) {
connectionList = displayModel.getConnectionList();
if (!connectionList.isEmpty()) {
if (originalPoints != null)
originalPoints.clear();
else
originalPoints = new HashMap<ConnectionModel, PointList>();
}
for (ConnectionModel conn : connectionList) {
conn.setLoadedFromLinkedOpi(true);
if (conn.getPoints() != null)
originalPoints.put(conn, conn.getPoints().getCopy());
conn.setScrollPane(((LinkingContainerFigure) getFigure()).getScrollPane());
}
}
use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class LinkingContainerEditpart method updateConnectionList.
private void updateConnectionList() {
if (connectionList == null || originalPoints == null)
return;
double scaleFactor = ((LinkingContainerFigure) getFigure()).getZoomManager().getZoom();
final Point tranlateSize = getRelativeToRoot();
tranlateSize.scale(scaleFactor);
log.log(Level.FINEST, String.format("Relative to root translation (scaled by %s): %s ", scaleFactor, tranlateSize));
Point scaledCropTranslation = new Point();
if (cropTranslation != null)
scaledCropTranslation = cropTranslation.getCopy();
scaledCropTranslation.scale(scaleFactor);
for (ConnectionModel conn : connectionList) {
PointList points = originalPoints.get(conn).getCopy();
if (points == null)
continue;
log.log(Level.FINER, "Connector: " + conn.getName());
for (int i = 0; i < points.size(); i++) {
Point point = points.getPoint(i);
if (getWidgetModel().isAutoSize()) {
point.translate(scaledCropTranslation);
// box
if (point.x() <= tranlateSize.x())
point.translate(conn.getLineWidth() / 2, 0);
if (point.y() <= tranlateSize.y())
point.translate(0, conn.getLineWidth() / 2);
}
point.scale(scaleFactor);
points.setPoint(point, i);
}
conn.setPoints(points);
}
}
use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class LinkingContainerEditpart method performAutosize.
/**
* Automatically set the container size according its children's geography size.
*/
@Override
public void performAutosize() {
Rectangle childrenRange = GeometryUtil.getChildrenRange(this);
if (connectionList != null) {
for (ConnectionModel connModel : connectionList) {
final PointList connectionPoints = connModel.getPoints();
childrenRange.union(connectionPoints.getBounds());
}
}
cropTranslation = new Point(-childrenRange.x, -childrenRange.y);
getWidgetModel().setSize(new Dimension(childrenRange.width + figure.getInsets().left + figure.getInsets().right, childrenRange.height + figure.getInsets().top + figure.getInsets().bottom));
for (Object editPart : getChildren()) {
AbstractWidgetModel widget = ((AbstractBaseEditPart) editPart).getWidgetModel();
widget.setLocation(widget.getLocation().translate(cropTranslation));
}
}
use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class ReplaceWidgetCommand method redo.
@Override
public void redo() {
index = container.getIndexOf(srcWidget);
container.removeChild(srcWidget);
container.addChild(index, targetWidget);
for (ConnectionModel conn : sourceConnections) {
if (conn.getSource() == srcWidget)
conn.setSource(targetWidget);
}
for (ConnectionModel conn : targetConnections) {
if (conn.getTarget() == srcWidget)
conn.setTarget(targetWidget);
}
removeConnections(sourceConnections);
removeConnections(targetConnections);
List<AbstractWidgetModel> allDescendants = container.getAllDescendants();
for (ConnectionModel conn : sourceConnections) {
if (allDescendants.contains(conn.getSource()))
conn.reconnect();
}
for (ConnectionModel conn : targetConnections) {
if (allDescendants.contains(conn.getTarget()))
conn.reconnect();
}
}
use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class WidgetDeleteCommand method getAllConnections.
private List<ConnectionModel> getAllConnections(AbstractWidgetModel widget, boolean source) {
List<ConnectionModel> result = new ArrayList<ConnectionModel>();
result.addAll(source ? widget.getSourceConnections() : widget.getTargetConnections());
if (widget instanceof AbstractContainerModel) {
for (AbstractWidgetModel child : ((AbstractContainerModel) widget).getAllDescendants()) {
result.addAll(source ? child.getSourceConnections() : child.getTargetConnections());
}
}
return result;
}
Aggregations