Package edu.cnu.mdi.swing
Class SwingSizingUtils
java.lang.Object
edu.cnu.mdi.swing.SwingSizingUtils
Scale-aware helpers for deriving Swing sizes from rendered content.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intReturn usable width to the right of an internal frame within its virtual desktop column.static intfontHeight(Component component, Font font, int verticalPadding) Return rendered font height plus total vertical padding.static DimensioniconButtonSize(Icon icon, Insets margins, Dimension minimum) Return an icon-safe size including margins and a minimum baseline.static DimensionpreferredSizeAtLeast(Component component, int minimumWidth, int minimumHeight) Return a component's preferred size enlarged to the given baselines.static intpreferredWidth(int minimumWidth, Component... components) Return the greatest preferred width among a baseline and components.static intrequiredHorizontalToolbarHeight(JToolBar toolbar) Return the minimum height that can contain every visible component in a horizontal toolbar, including the toolbar's border insets.static inttextColumnWidth(Component component, int columns, int minimumWidth, int horizontalPadding) Return a conservative rendered width for a number of text columns.static intReturn the rendered width of text plus total horizontal padding.
-
Method Details
-
preferredWidth
Return the greatest preferred width among a baseline and components. -
preferredSizeAtLeast
public static Dimension preferredSizeAtLeast(Component component, int minimumWidth, int minimumHeight) Return a component's preferred size enlarged to the given baselines. -
fontHeight
Return rendered font height plus total vertical padding. -
textWidth
Return the rendered width of text plus total horizontal padding. -
textColumnWidth
public static int textColumnWidth(Component component, int columns, int minimumWidth, int horizontalPadding) Return a conservative rendered width for a number of text columns. -
iconButtonSize
Return an icon-safe size including margins and a minimum baseline. -
requiredHorizontalToolbarHeight
Return the minimum height that can contain every visible component in a horizontal toolbar, including the toolbar's border insets.- Parameters:
toolbar- toolbar to measure, ornull- Returns:
- minimum safe height, at least one pixel
-
availableDesktopWidth
Return usable width to the right of an internal frame within its virtual desktop column.MDI implements virtual columns by offsetting frame X coordinates by whole desktop widths. Consequently, an off-screen frame can have a very large positive or negative X coordinate. Reducing that coordinate modulo the desktop width recovers its column-local position.
-