public interface ComponentWrapper
Known subtypesContainerWrapper
A class that wraps the important parts of a Component.
NOTE!.equals() and .hashcode() should be forwarded to the wrapped component. E.g.
public int hashCode()
{
return getComponent().hashCode();
}
public final boolean equals(Object o)
{
if (o instanceof ComponentWrapper == false)
return false;
return getComponent().equals(((ComponentWrapper) o).getComponent());
}
Fields
Methods
public abstract Object getComponent() | Returns the actual object that this wrapper is aggregating. |
public abstract int getX() | Returns the current x coordinate for this component. |
public abstract int getY() | Returns the current y coordinate for this component. |
public abstract int getWidth() | Returns the current width for this component. |
public abstract int getHeight() | Returns the current height for this component. |
public abstract int getScreenLocationX() | Returns the screen x-coordinate for the upper left coordinate of the component layout-able bounds. |
public abstract int getScreenLocationY() | Returns the screen y-coordinate for the upper left coordinate of the component layout-able bounds. |
public abstract int getMinimumWidth(int hHint) | Returns the minimum width of the component. |
public abstract int getMinimumHeight(int wHint) | Returns the minimum height of the component. |
public abstract int getPreferredWidth(int hHint) | Returns the preferred width of the component. |
public abstract int getPreferredHeight(int wHint) | Returns the preferred height of the component. |
public abstract int getMaximumWidth(int hHint) | Returns the maximum width of the component. |
public abstract int getMaximumHeight(int wHint) | Returns the maximum height of the component. |
public abstract void setBounds(int x, int y, int width, int height) | Sets the component’s bounds. |
public abstract boolean isVisible() | Returns if the component’s visibility is set to true. |
public abstract int getBaseline(int width, int height) | Returns the baseline for the component given the suggested height. |
public abstract boolean hasBaseline() | Returns if the component has a baseline and if it can be retrieved. |
public abstract ContainerWrapper getParent() | Returns the container for this component. |
public abstract float getPixelUnitFactor(boolean isHor) | Returns the pixel unit factor for the horizontal or vertical dimension. |
public abstract int getHorizontalScreenDPI() | Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the default screen if the component is not visible. |
public abstract int getVerticalScreenDPI() | Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the default screen if the component is not visible. |
public abstract int getScreenWidth() | Returns the pixel size of the screen that the component is currently in or for the default screen if the component is not visible or null. |
public abstract int getScreenHeight() | Returns the pixel size of the screen that the component is currently in or for the default screen if the component is not visible or null. |
public abstract String getLinkId() | Returns a String id that can be used to reference the component in link constraints. |
public abstract int getLayoutHashCode() | Returns a hash code that should be reasonably different for anything that might change the layout. |
public abstract int[] getVisualPadding() | Returns the padding on a component by component basis. |
public abstract void paintDebugOutline(boolean showVisualPadding) | Paints component outline to indicate where it is. |
public abstract int getComponentType(boolean disregardScrollPane) | Returns the type of component that this wrapper is wrapping. |
public abstract int getContentBias() | Returns in what way the min/pref/max sizes relates to it’s height or width for the current settings of the component (like wrapText). |
Field details
TYPE_UNSET
public static final int TYPE_UNSET = -1TYPE_UNKNOWN
public static final int TYPE_UNKNOWN = 0TYPE_CONTAINER
public static final int TYPE_CONTAINER = 1TYPE_LABEL
public static final int TYPE_LABEL = 2TYPE_TEXT_FIELD
public static final int TYPE_TEXT_FIELD = 3TYPE_TEXT_AREA
public static final int TYPE_TEXT_AREA = 4TYPE_BUTTON
public static final int TYPE_BUTTON = 5TYPE_LIST
public static final int TYPE_LIST = 6TYPE_TABLE
public static final int TYPE_TABLE = 7TYPE_SCROLL_PANE
public static final int TYPE_SCROLL_PANE = 8TYPE_IMAGE
public static final int TYPE_IMAGE = 9TYPE_PANEL
public static final int TYPE_PANEL = 10TYPE_COMBO_BOX
public static final int TYPE_COMBO_BOX = 11TYPE_SLIDER
public static final int TYPE_SLIDER = 12TYPE_SPINNER
public static final int TYPE_SPINNER = 13TYPE_PROGRESS_BAR
public static final int TYPE_PROGRESS_BAR = 14TYPE_TREE
public static final int TYPE_TREE = 15TYPE_CHECK_BOX
public static final int TYPE_CHECK_BOX = 16TYPE_SCROLL_BAR
public static final int TYPE_SCROLL_BAR = 17TYPE_SEPARATOR
public static final int TYPE_SEPARATOR = 18TYPE_TABBED_PANE
public static final int TYPE_TABBED_PANE = 19Method details
getComponent
public abstract Object getComponent()Returns the actual object that this wrapper is aggregating. This might be needed for getting information about the object that the wrapper interface does not provide.
If this is a container the container should be returned instead.
Returns
null.getX
public abstract int getX()Returns
getY
public abstract int getY()Returns
getWidth
public abstract int getWidth()Returns
getHeight
public abstract int getHeight()Returns
getScreenLocationX
public abstract int getScreenLocationX()Returns
getScreenLocationY
public abstract int getScreenLocationY()Returns
getMinimumWidth
public abstract int getMinimumWidth(int hHint)Parameters
hHintintThe Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns
getMinimumHeight
public abstract int getMinimumHeight(int wHint)Parameters
wHintintThe Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns
getPreferredWidth
public abstract int getPreferredWidth(int hHint)Parameters
hHintintThe Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns
getPreferredHeight
public abstract int getPreferredHeight(int wHint)Parameters
wHintintThe Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns
getMaximumWidth
public abstract int getMaximumWidth(int hHint)Parameters
hHintintThe Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns
getMaximumHeight
public abstract int getMaximumHeight(int wHint)Parameters
wHintintThe Size hint for the other dimension. An implementation can use this value or the current size for the widget in this dimension, or a combination of both, to calculate the correct size.
Use -1 to denote that there is no hint. This corresponds with SWT.DEFAULT.
Returns
setBounds
public abstract void setBounds(int x, int y, int width, int height)Parameters
xint- The x coordinate.
yint- The y coordinate.
widthint- The width.
heightint- The height.
isVisible
public abstract boolean isVisible()true. This should not return if the component is
actually visible, but if the visibility is set to true or not.Returns
true means visible.getBaseline
public abstract int getBaseline(int width, int height)Parameters
widthint- The width to calculate for if other than the current. If
-1the current size should be used. heightint- The height to calculate for if other than the current. If
-1the current size should be used.
Returns
hasBaseline
public abstract boolean hasBaseline()false for Swing before mustang.Returns
getParent
public abstract ContainerWrapper getParent()Returns
null if the component has no parent.getPixelUnitFactor
public abstract float getPixelUnitFactor(boolean isHor)Returns the pixel unit factor for the horizontal or vertical dimension.
The factor is 1 for both dimensions on the normal font in a JPanel on Windows. The factor should increase with a bigger “X”.
This is the Swing version:
Rectangle2D r = fm.getStringBounds("X", parent.getGraphics());
wFactor = r.getWidth() / 6;
hFactor = r.getHeight() / 13.27734375f;
Parameters
isHorboolean- If it is the horizontal factor that should be returned.
Returns
getHorizontalScreenDPI
public abstract int getHorizontalScreenDPI()Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the default screen if the component is not visible.
If headless mode net.miginfocom.layout.PlatformDefaults#getDefaultDPI will be returned.
Returns
getVerticalScreenDPI
public abstract int getVerticalScreenDPI()Returns the DPI (Dots Per Inch) of the screen the component is currently in or for the default screen if the component is not visible.
If headless mode net.miginfocom.layout.PlatformDefaults#getDefaultDPI will be returned.
Returns
getScreenWidth
public abstract int getScreenWidth()Returns the pixel size of the screen that the component is currently in or for the default
screen if the component is not visible or null.
If in headless mode 1024 is returned.
Returns
1280.getScreenHeight
public abstract int getScreenHeight()Returns the pixel size of the screen that the component is currently in or for the default
screen if the component is not visible or null.
If in headless mode 768 is returned.
Returns
1024.getLinkId
public abstract String getLinkId()Returns a String id that can be used to reference the component in link constraints. This value should
return the default id for the component. The id can be set for a component in the constraints and if
so the value returned by this method will never be used. If there are no sensible id for the component
null should be returned.
For instance the Swing implementation returns the string returned from Component.getName().
Returns
null.getLayoutHashCode
public abstract int getLayoutHashCode()Returns
getVisualPadding
public abstract int[] getVisualPadding()Returns the padding on a component by component basis. This method can be overridden to return padding to compensate for example for borders that have shadows or where the outer most pixel is not the visual “edge” to align to.
Default implementation returns null for all components except for Windows XP’s JTabbedPane which will return new Insets(0, 0, 2, 2).
NOTE! To reduce generated garbage the returned padding should never be changed so that the same insets can be returned many times.
Returns
null if no padding. NOTE! To reduce generated garbage the returned padding should never be changed so that
the same insets can be returned many times. [top, left, bottom, right]paintDebugOutline
public abstract void paintDebugOutline(boolean showVisualPadding)Parameters
showVisualPaddingboolean- If the visual padding should be shown in the debug drawing.
getComponentType
public abstract int getComponentType(boolean disregardScrollPane)Returns the type of component that this wrapper is wrapping.
This method can be invoked often so the result should be cached.
Parameters
disregardScrollPaneboolean- Is
trueany wrapping scroll pane should be disregarded and the type of the scrolled component should be returned.
Returns
#TYPE_LABEL.getContentBias
public abstract int getContentBias()net.miginfocom.layout.LayoutUtil#HORIZONTAL
If the min/pref/max width depends on it’s height (not common) return net.miginfocom.layout.LayoutUtil#VERTICAL
If there is no connection between the preferred min/pref/max and the size of the component return -1.