private void removeFigureForNode(InternalNodeLayout internalNode) { IFigure figure = internalNode.getNode().getFigure(); GraphLabel label = (GraphLabel) nodeFigureToLabel.get(figure); if (label != null && label.getParent() != null) { label.getParent().remove(label); } nodeFigureToLabel.remove(figure); }
private void refreshLabelBounds(IFigure figure, GraphLabel label) { Rectangle figureBounds = figure.getBounds(); if (figureBounds.width * figureBounds.height > 0) { label.setText(label.getText()); // hack: resets label's size Dimension labelSize = label.getSize(); labelSize.expand(-6, -4); Point anchorPoint = figure.getBounds().getBottomRight(); anchorPoint.x -= labelSize.width / 2; anchorPoint.y -= labelSize.height / 2; Rectangle bounds = new Rectangle(anchorPoint, labelSize); label.setBounds(bounds); label.getParent().setConstraint(label, bounds); } else { label.getParent().setConstraint(label, new Rectangle(figureBounds.x, figureBounds.y, 0, 0)); label.setBounds(new Rectangle(figureBounds.x, figureBounds.y, 0, 0)); } }