com.inet.html.views.layouts
Class ControlLayout

java.lang.Object
  extended by com.inet.html.views.layouts.Layout
      extended by com.inet.html.views.layouts.ControlLayout

public class ControlLayout
extends Layout

Layouter for ControlViews. This layouter is basically broker between the HTML layout process and the Swing control component.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.inet.html.views.layouts.Layout
Layout.PositionInfo, Layout.ViewPosition
 
Field Summary
 
Fields inherited from class com.inet.html.views.layouts.Layout
MARKER_OFFSET
 
Constructor Summary
ControlLayout(ControlView view)
          Creates a new control layout for a control view
 
Method Summary
 java.awt.Rectangle getSpan()
          Returns the area affected by the current layout or any of it's siblings, relative the it's own left upper corner.
 ViewPositionInfo getViewForPosition(java.awt.Point position, java.awt.Rectangle a)
          Finds the view and it's location for a specific point of the screen
 java.awt.Rectangle layout(boolean hard)
          This method will do the final layouting
 void layoutVerticalAlign(int align, int baselineOffset)
          This method performs the vertical alignment of the whole content within the box.
 void layoutWidth()
          Set the width of the layouted component.
 java.awt.Shape modelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b)
          Tries to find the rectangle representing a given model-position.
 void predictWidth(int width)
          Can be used to force a view to a specified width.
 void preLayout()
          This method doe's the part of the layouting, which has to be called only once per website.
 void setPreferredSize(int width, int height)
          Sets the preferred size of this layout
 int viewToModel(float x, float y, java.awt.Shape a, javax.swing.text.Position.Bias[] biasReturn)
          Searches the view-tree for a specified point and returns the model-offset for this position.
 
Methods inherited from class com.inet.html.views.layouts.Layout
getChildAllocation, getChildPosition, getChildren, getCurrentHeight, getCurrentLeft, getCurrentSpan, getCurrentTop, getCurrentWidth, getMinimumHeight, getMinimumSpan, getMinimumWidth, getPreferredHeight, getPreferredSpan, getPreferredWidth, getView, getViewCount, isPreLayouted, offsetRelative, replace, setCurrentHeight, setCurrentWidth, setPreLayouted, toString, union, union
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ControlLayout

public ControlLayout(ControlView view)
Creates a new control layout for a control view

Parameters:
view - the view to layout
Method Detail

layoutWidth

public void layoutWidth()
Set the width of the layouted component. Is required by the Float managers to determine the position of their floats

Specified by:
layoutWidth in class Layout

layout

public java.awt.Rectangle layout(boolean hard)
This method will do the final layouting

Specified by:
layout in class Layout
Parameters:
hard - If set to true, the status of the children will be ignored and all views will be layouted. This should be done on view-size changes. If set to false the status of the children will be respected and up-to-date views will not be layouted again.
Returns:
the area which is affectd ba this view and any of it's siblings

modelToView

public java.awt.Shape modelToView(int pos,
                                  java.awt.Shape a,
                                  javax.swing.text.Position.Bias b)
                           throws javax.swing.text.BadLocationException
Tries to find the rectangle representing a given model-position. The position will be searched top-down by querying ALL subviews and sub-floats of the current view. If there is no absolute match to a leaf-view, the nearest leaf-view(if any is in range) will be returned. Since views may overlap or may be floated this method may query all views!

Specified by:
modelToView in class Layout
Parameters:
pos - the model position to be found
a - the reference area for the search process, is supposed to be the surrounding rectangle of the current view
b - the search direction, empty interface implementation, has no effect
Returns:
the root-relative rectangle for the requested position or null
Throws:
javax.swing.text.BadLocationException - will be thrown if pos is outside the model's range

preLayout

public void preLayout()
This method doe's the part of the layouting, which has to be called only once per website. It also calculates the width, which the elements would use if there's no absolute size. E.g. imagine floats without a give size. In that case the float will use the size of it's content or, if that size is smaller, the maximum width. NOTE: The implementation has to be deepth-first!!!

Specified by:
preLayout in class Layout

viewToModel

public int viewToModel(float x,
                       float y,
                       java.awt.Shape a,
                       javax.swing.text.Position.Bias[] biasReturn)
Searches the view-tree for a specified point and returns the model-offset for this position.

Specified by:
viewToModel in class Layout
Parameters:
x - root-relative X offset in pixel
y - root-relative Y offset in pixel
a - the bounds of the current view
biasReturn - the search direction, empty interface implementation, has no effect
Returns:
the model position for the requested point of -1 if no leaf view was found for this position

setPreferredSize

public void setPreferredSize(int width,
                             int height)
Sets the preferred size of this layout

Parameters:
width - the preferred width
height - the preferre height

predictWidth

public void predictWidth(int width)
Can be used to force a view to a specified width. This will ignore the minWidh!

Specified by:
predictWidth in class Layout
Parameters:
width - Width to set

layoutVerticalAlign

public void layoutVerticalAlign(int align,
                                int baselineOffset)
This method performs the vertical alignment of the whole content within the box. It is supposed to be called after the layout was done and after the height has been set by CSS.

Specified by:
layoutVerticalAlign in class Layout
Parameters:
align - The AlignValue constant
baselineOffset - The difference between the contents top and the first baseline in pixel

getViewForPosition

public ViewPositionInfo getViewForPosition(java.awt.Point position,
                                           java.awt.Rectangle a)
Finds the view and it's location for a specific point of the screen

Specified by:
getViewForPosition in class Layout
Parameters:
position - the location to search
a - the bounds of THIS view
Returns:
The bounds and view for the position

getSpan

public java.awt.Rectangle getSpan()
Returns the area affected by the current layout or any of it's siblings, relative the it's own left upper corner.
NOTE: For performance reasons the returned object is not cloned, it should not be modified!

Specified by:
getSpan in class Layout
Returns:
the area affected by the current layout or any of it's siblings