Skip to content
Snippets Groups Projects
Commit 1f91a0ac authored by Dongyue Mou's avatar Dongyue Mou
Browse files

replaced some magic numbers with constans

refs 153
parent f1f5b9d5
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,24 @@ public abstract class ElementEditPartBase<T extends ILayoutedModelElement & INam
return LayoutDataUtils.getNodeBounds(modelElement);
}
/** {@inheritDoc} */
@Override
protected Rectangle determineLabelFigureBounds() {
Rectangle textBounds = labelFigure.getTextBounds();
Rectangle labelBounds = determineBaseFigureBounds();
labelBounds.y += (labelBounds.height - textBounds.height) / 2;
labelBounds.x += 2 * DefaultLayoutConstants.DEFAULT_SHAPE_INSETS;
labelBounds.width -= 4 * DefaultLayoutConstants.DEFAULT_SHAPE_INSETS;
labelBounds.height = textBounds.height;
return labelBounds;
}
/** {@inheritDoc} */
@Override
protected String determineLabelFigureText() {
return modelElement.getName();
}
/** {@inheritDoc} */
@Override
protected void createEditPolicies() {
......@@ -123,16 +141,6 @@ public abstract class ElementEditPartBase<T extends ILayoutedModelElement & INam
+ ": " + modelElement.getComment(), 100);
baseFigure.setToolTip(new Label(tooltipText));
// center label on base figure with insets
labelFigure.setText(modelElement.getName());
Rectangle textBounds = labelFigure.getTextBounds();
Rectangle labelBounds = new Rectangle(baseFigure.getBounds());
labelBounds.y += (labelBounds.height - textBounds.height) / 2;
labelBounds.x += 2 * DefaultLayoutConstants.DEFAULT_SHAPE_INSETS;
labelBounds.width -= 4 * DefaultLayoutConstants.DEFAULT_SHAPE_INSETS;
labelBounds.height = textBounds.height;
labelFigure.setBounds(labelBounds);
for (EditPart child : (List<EditPart>) getChildren()) {
child.refresh();
}
......
......@@ -99,7 +99,7 @@ public class PrettyRoundedRectangle extends Shape {
/** Returns a copy of the bounds cropped by the insets. */
protected Rectangle getCroppedBounds() {
return bounds.getCropped(insets);
return bounds.getShrinked(insets);
}
/**
......
......@@ -60,4 +60,7 @@ public final class DefaultLayoutConstants {
// connector default constants
/** The size of a default connector. */
public static final int DEFAULT_CONNECTOR_SIZE = 2 * DEFAULT_GRID_SIZE;
/** The default position offset of a shape. */
public static final int DEFAULT_SHAPE_OFFSET = 2 * DEFAULT_GRID_SIZE;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment