com.inet.html.views.layouts
Class InlineLayout

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

public class InlineLayout
extends Layout

The implementation of the inline format. Supports all inline layout features exception a correct vertical alignment. http://www.w3.org/TR/1998/REC-CSS2/visuren.html#inline-formatting


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
InlineLayout(BlockView view)
          Initializes the layout for a given 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.
static java.util.List<javax.swing.text.View> reflow(BoxView child, boolean checkTabs)
          Reflows(splits) the content of a ContentView.
 void resetPreLayouted()
          Resets the reflowed status.
 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

InlineLayout

public InlineLayout(BlockView view)
Initializes the layout for a given view.
Has no program logic.

Parameters:
view - the view, which will be layouted
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

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

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

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

resetPreLayouted

public void resetPreLayouted()
Resets the reflowed status. This is required to force the preLayout method to split all content parts.


reflow

public static java.util.List<javax.swing.text.View> reflow(BoxView child,
                                                           boolean checkTabs)
                                                    throws javax.swing.text.BadLocationException
Reflows(splits) the content of a ContentView.
WARNING: This method does not check whether child is a child of this layout!

Parameters:
child - The view to handle.
checkTabs - true, if tab stops should be interpreted
Returns:
new list of children for the current view
Throws:
javax.swing.text.BadLocationException - Thrown if the content of this view has incorrect references.

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