Package zebkit.layout

Layout package provides number of classes, interfaces, methods and variables that allows developers easily implement rules based layouting of hierarchy of rectangular elements. The package has no relation to any concrete UI, but it can be applied to a required UI framework very easily. In general layout manager requires an UI component to provide:

  • setLocation(x,y) method
  • setSize(w,h) method
  • setBounds() method
  • getPreferredSize(x,y) method
  • getTop(), getBottom(), getRight(), getLeft() methods
  • constraints read only property
  • width, height, x, y read only metrics properties
  • kids read only property that keep all children components


public <zebkit.layout.Layoutable> getDirectAt (x, y, parent)

Find a direct component located at the given location of the specified parent component and the specified parent component


Parameters:
  • x <Integer>

    a x coordinate relatively to the parent component

  • y <Integer>

    a y coordinate relatively to the parent component

  • parent <zebkit.layout.Layoutable>

    a parent component


Returns: <zebkit.layout.Layoutable>

an index of direct children component or -1 if no a children component can be found

public <zebkit.layout.Layoutable> getDirectChild (parent, child)

Find a direct children element for the given children component and the specified parent component


Parameters:
Returns: <zebkit.layout.Layoutable>

a direct children component

public <Object> getMaxPreferredSize (target)

Calculate maximal preferred width and height of children component of the given target component.


Parameters:
Returns: <Object>

a maximal preferred width and height

       { width:{Integer}, height:{Integer} }
public <zebkit.layout.Layoutable> getTopParent (c)

Get a top (the highest in component hierarchy) parent component of the given component


Parameters:
Returns: <zebkit.layout.Layoutable>

a top parent component

public <Boolean> isAncestorOf (p, c)

Test if the given parent component is ancestor of the specified component.


Parameters:
Returns: <Boolean>

true if the given parent is ancestor of the specified component

public <Object> toChildOrigin (x, y, p, c)

Convert the given component location into relative location of the specified children component successor.


Parameters:
Returns: <Object>

a relative location

 { x:{Integer}, y:{Integer} }
public <Object> toParentOrigin ([x], [y], c, [p])

Translate the given relative location into the parent relative location.


Parameters:
Returns: <Object>

a relative to the given parent UI component location:

       { x:{Integer}, y:{Integer} }