Class RelativeLayout
- java.lang.Object
-
- org.processmining.logfiltering.algorithms.RelativeLayout
-
- All Implemented Interfaces:
java.awt.LayoutManager,java.awt.LayoutManager2,java.io.Serializable
public class RelativeLayout extends java.lang.Object implements java.awt.LayoutManager2, java.io.SerializableTheRelativeLayoutclass is a layout manager that lays out a container's components on the specified X or Y axis. Components can be layed out at their preferred size or at a relative size. When relative sizing is used the component must be added to the container using a relative size constraint, which is simply a Float value. The space available for relative sized components is determined by subtracting the preferred size of the other components from the space available in the container. Each component is then assigned a size based on its relative size value. For example: container.add(component1, new Float(1)); container.add(component2, new Float(2)); There is a total of 3 relative units. If the container has 300 pixels of space available then component1 will get 100 and component2, 200. It is possible that rounding errors will occur in which case you can specify a rounding policy to use to allocate the extra pixels. By defaults components are center aligned on the secondary axis however this can be changed at the container or component level.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RelativeLayout()Creates a relative layout with the components layed out on the X-Axis using the default gapRelativeLayout(int axis)Creates a relative layout with the components layed out on the specified axis using the default gapRelativeLayout(int axis, int gap)Creates a relative layout with the components layed out on the specified axis using the specfied gap
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLayoutComponent(java.awt.Component component, java.lang.Object constraint)voidaddLayoutComponent(java.lang.String name, java.awt.Component component)Not supportedprotected voidadjustForRounding(int[] relativeSpace, int spaceRemaining)floatgetAlignment()Gets the alignment of the components on the opposite axis.intgetAxis()Gets the layout axis.intgetBorderGap()Gets the initial gap.java.lang.FloatgetConstraints(java.awt.Component component)Gets the constraints for the specified component.intgetFillGap()Gets the fill gap amount.intgetGap()Gets the gap between components.floatgetLayoutAlignmentX(java.awt.Container parent)Returns the alignment along the x axis.floatgetLayoutAlignmentY(java.awt.Container parent)Returns the alignment along the y axis.intgetRoundingPolicy()Gets the rounding policy.voidinvalidateLayout(java.awt.Container target)Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.booleanisFill()Gets the fill property for the component size on the opposite edge.voidlayoutContainer(java.awt.Container parent)Lays out the specified container using this layout.java.awt.DimensionmaximumLayoutSize(java.awt.Container target)There is no maximum.java.awt.DimensionminimumLayoutSize(java.awt.Container parent)Determines the minimum size of the container argument using this column layout.java.awt.DimensionpreferredLayoutSize(java.awt.Container parent)Determines the preferred size of the container argument using this column layout.voidremoveLayoutComponent(java.awt.Component comp)Removes the specified component from the layout.voidsetAlignment(float alignment)voidsetAxis(int axis)Sets the layout axisvoidsetBorderGap(int borderGap)Sets the initial gap.voidsetFill(boolean fill)Change size of relative components to fill the space available For X-AXIS aligned components the height will be filled.voidsetFillGap(int fillGap)Specify the number of pixels by which the fill size is decreased when setFill(true) has been specified.voidsetGap(int gap)Sets the gap between components to the specified value.voidsetRoundingPolicy(int roundingPolicy)Specify the rounding policy to be used when all the avialable pixels have not been allocated to a component.java.lang.StringtoString()Returns the string representation of this column layout's values.
-
-
-
Field Detail
-
X_AXIS
public static final int X_AXIS
- See Also:
- Constant Field Values
-
Y_AXIS
public static final int Y_AXIS
- See Also:
- Constant Field Values
-
LEADING
public static final float LEADING
- See Also:
- Constant Field Values
-
CENTER
public static final float CENTER
- See Also:
- Constant Field Values
-
TRAILING
public static final float TRAILING
- See Also:
- Constant Field Values
-
COMPONENT
public static final float COMPONENT
- See Also:
- Constant Field Values
-
DO_NOTHING
public static final int DO_NOTHING
- See Also:
- Constant Field Values
-
FIRST
public static final int FIRST
- See Also:
- Constant Field Values
-
LAST
public static final int LAST
- See Also:
- Constant Field Values
-
LARGEST
public static final int LARGEST
- See Also:
- Constant Field Values
-
EQUAL
public static final int EQUAL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RelativeLayout
public RelativeLayout()
Creates a relative layout with the components layed out on the X-Axis using the default gap
-
RelativeLayout
public RelativeLayout(int axis)
Creates a relative layout with the components layed out on the specified axis using the default gap- Parameters:
axis- X-AXIS or Y_AXIS
-
RelativeLayout
public RelativeLayout(int axis, int gap)Creates a relative layout with the components layed out on the specified axis using the specfied gapAll
RelativeLayoutconstructors defer to this one.- Parameters:
axis- X-AXIS or Y_AXISgap- the gap
-
-
Method Detail
-
getAxis
public int getAxis()
Gets the layout axis.- Returns:
- the layout axis
-
setAxis
public void setAxis(int axis)
Sets the layout axis- Parameters:
axis- the layout axis
-
getGap
public int getGap()
Gets the gap between components.- Returns:
- the gap between components
-
setGap
public void setGap(int gap)
Sets the gap between components to the specified value.- Parameters:
gap- the gap between components
-
getBorderGap
public int getBorderGap()
Gets the initial gap. This gap is used before the leading component and after the trailing component.- Returns:
- the leading/trailing gap
-
setBorderGap
public void setBorderGap(int borderGap)
Sets the initial gap. This gap is used before the leading component and after the trailing component. The default is set to the gap.- Parameters:
borderGap- the leading/trailing gap
-
getAlignment
public float getAlignment()
Gets the alignment of the components on the opposite axis.- Returns:
- the alignment
-
setAlignment
public void setAlignment(float alignment)
-
isFill
public boolean isFill()
Gets the fill property for the component size on the opposite edge.- Returns:
- the fill property
-
setFill
public void setFill(boolean fill)
Change size of relative components to fill the space available For X-AXIS aligned components the height will be filled. For Y-AXIS aligned components the width will be filled.
-
getFillGap
public int getFillGap()
Gets the fill gap amount.- Returns:
- the fill gap value
-
setFillGap
public void setFillGap(int fillGap)
Specify the number of pixels by which the fill size is decreased when setFill(true) has been specified.
-
getRoundingPolicy
public int getRoundingPolicy()
Gets the rounding policy.- Returns:
- the rounding policy
-
setRoundingPolicy
public void setRoundingPolicy(int roundingPolicy)
Specify the rounding policy to be used when all the avialable pixels have not been allocated to a component. DO_NOTHING FIRST - extra pixels added to the first relative component LAST - extra pixels added to the last relative component LARGEST (default) - extra pixels added to the larger relative component EQUAL - a single pixel is added to each relative component (until pixels are used up)
-
getConstraints
public java.lang.Float getConstraints(java.awt.Component component)
Gets the constraints for the specified component.- Parameters:
component- the component to be queried- Returns:
- the constraint for the specified component, or null if component is null or is not present in this layout
-
addLayoutComponent
public void addLayoutComponent(java.lang.String name, java.awt.Component component)Not supported- Specified by:
addLayoutComponentin interfacejava.awt.LayoutManager
-
addLayoutComponent
public void addLayoutComponent(java.awt.Component component, java.lang.Object constraint)- Specified by:
addLayoutComponentin interfacejava.awt.LayoutManager2
-
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.- Specified by:
removeLayoutComponentin interfacejava.awt.LayoutManager- Parameters:
comp- the component to be removed
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Determines the preferred size of the container argument using this column layout.The preferred width of a column layout is the largest preferred width of each column in the container, plus the horizontal padding times the number of columns minus one, plus the left and right insets of the target container.
The preferred height of a column layout is the largest preferred height of each row in the container, plus the vertical padding times the number of rows minus one, plus the top and bottom insets of the target container.
- Specified by:
preferredLayoutSizein interfacejava.awt.LayoutManager- Parameters:
target- the container in which to do the layout- Returns:
- the preferred dimensions to lay out the subcomponents of the specified container
- See Also:
java.awt.RelativeLayout#minimumLayoutSize,Container.getPreferredSize()
-
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Determines the minimum size of the container argument using this column layout.The minimum width of a grid layout is the largest minimum width of each column in the container, plus the horizontal padding times the number of columns minus one, plus the left and right insets of the target container.
The minimum height of a column layout is the largest minimum height of each row in the container, plus the vertical padding times the number of rows minus one, plus the top and bottom insets of the target container.
- Specified by:
minimumLayoutSizein interfacejava.awt.LayoutManager- Parameters:
target- the container in which to do the layout- Returns:
- the minimum dimensions needed to lay out the subcomponents of the specified container
- See Also:
java.awt.RelativeLayout#preferredLayoutSize,Container.doLayout()
-
layoutContainer
public void layoutContainer(java.awt.Container parent)
Lays out the specified container using this layout.This method reshapes the components in the specified target container in order to satisfy the constraints of the
RelativeLayoutobject.The grid layout manager determines the size of individual components by dividing the free space in the container into equal-sized portions according to the number of rows and columns in the layout. The container's free space equals the container's size minus any insets and any specified horizontal or vertical gap. All components in a grid layout are given the same size.
- Specified by:
layoutContainerin interfacejava.awt.LayoutManager- Parameters:
target- the container in which to do the layout- See Also:
Container,Container.doLayout()
-
adjustForRounding
protected void adjustForRounding(int[] relativeSpace, int spaceRemaining)
-
maximumLayoutSize
public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
There is no maximum.- Specified by:
maximumLayoutSizein interfacejava.awt.LayoutManager2
-
getLayoutAlignmentX
public float getLayoutAlignmentX(java.awt.Container parent)
Returns the alignment along the x axis. Use center alignment.- Specified by:
getLayoutAlignmentXin interfacejava.awt.LayoutManager2
-
getLayoutAlignmentY
public float getLayoutAlignmentY(java.awt.Container parent)
Returns the alignment along the y axis. Use center alignment.- Specified by:
getLayoutAlignmentYin interfacejava.awt.LayoutManager2
-
invalidateLayout
public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.- Specified by:
invalidateLayoutin interfacejava.awt.LayoutManager2
-
toString
public java.lang.String toString()
Returns the string representation of this column layout's values.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of this grid layout
-
-