Skip to content

Commit

Permalink
Add Margin Border to Subapp Content
Browse files Browse the repository at this point in the history
In order to have space for any hidden connection labels ad the pins of
the subapp a margin border was introduced to the subapp content.
  • Loading branch information
azoitl committed May 2, 2024
1 parent f9744a6 commit 067dd49
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public abstract class EditorWithInterfaceEditPart extends AbstractFBNetworkEditP

private static final int MIN_EXP_SUBAPP_BAR_WIDTH_CHARS = org.eclipse.fordiac.ide.gef.Activator.getDefault()
.getPreferenceStore().getInt(DiagramPreferences.MIN_INTERFACE_BAR_SIZE);
private static final int MAX_HIDDEN_CONNECTION_LABEL_SIZE_CHARS = org.eclipse.fordiac.ide.gef.Activator.getDefault()
.getPreferenceStore().getInt(DiagramPreferences.MAX_HIDDEN_CONNECTION_LABEL_SIZE);
private static final int TOP_BOTTOM_MARGIN = 1;
private static final int LEFT_RIGHT_MARGIN = 5;
private static final Insets RIGHT_LIST_BORDER_INSET = new Insets(TOP_BOTTOM_MARGIN, 0, TOP_BOTTOM_MARGIN,
Expand Down Expand Up @@ -187,6 +189,10 @@ protected IFigure createFigure() {

contentContainer = new FreeformLayer();
contentContainer.setLayoutManager(new FreeformLayout());
// add a margin to the left and right to have enough space for hidden connection
// labels
contentContainer.setBorder(
new MarginBorder(0, getMaxHiddenConnectionLabelSize(), 0, getMaxHiddenConnectionLabelSize()));
mainFigure.add(contentContainer, BorderLayout.CENTER);

createRightInterface(mainFigure);
Expand Down Expand Up @@ -550,4 +556,15 @@ public static int getMinInterfaceBarWidth() {
return minSubappBarWidhtPixels;
}

private static int maxHiddenConnectionLabelSize = -1;

public static int getMaxHiddenConnectionLabelSize() {
if (maxHiddenConnectionLabelSize == -1) {
final Dimension singleCharLength = FigureUtilities.getStringExtents(" ", //$NON-NLS-1$
JFaceResources.getFontRegistry().get(PreferenceConstants.DIAGRAM_FONT));
maxHiddenConnectionLabelSize = singleCharLength.width * MAX_HIDDEN_CONNECTION_LABEL_SIZE_CHARS;
}
return maxHiddenConnectionLabelSize;
}

}

0 comments on commit 067dd49

Please sign in to comment.