|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.inet.html.views.layouts.StackManager
public class StackManager
This class gathers all informations about floats on a site. It helps to find wrapping edges and new line positions. Here's a list of rules, which have to be fulfilled by floats and flowing content. (This list is not equal to the spec, it's was generated by observing the Gecko 1.9 Behavior) - A flow-line will be terminated if it hits a float-right - A flow-line will start after a flow-left( except if there's an earlier flow-right, than it starts at the beginning of the box and ends at the flow-right) - All floats generated in a flow-line will be placed AFTER the end of this line(the end means: end of the box, flow-content on the next line, ...) --> A float cannot influence the content layouted before this float! - A higher position is better than a position more to the left or the the right - A float cannot be placed higher than any float generated before - Absolute- or Float-Blocks are the root for their inner floats! - if the parent has no size yet, all sub-floats are layouted like inline-blocks and taken out of the flow after any boundary is reached(this case is really hard to control) - if there is any limit given by the parent the floats try to limit ther width to this size What this Class needs to place a new line: - current box position and width - minimum y to start searching - minimum width to place the content(there's no sense in placing a new line which is to small to hold content) When to notify this class(add floats an start placing them)? - Generating a new float - Starting a box - Start of a new line When to query this class(get lines respecting the floats)? - Start of a new line - Adding content which changes the baseline/height of a line Remember: Floats are boxes with a predefined Width. They do not belong to the text flow but will influence it. Float-positions are unique among it's absolute parent's space. Floats can never overlap except by using negative margins!
Nested Class Summary | |
---|---|
static class |
StackManager.LineSpaceInfo
The LineSpaceInfo contains all informations, which are required to place a new line or a snippet of content. |
Field Summary | |
---|---|
static byte |
CLEAR_BOTH
Request the StackManager to fetch the top-most position for the current element, where is no float on either side |
static byte |
CLEAR_LEFT
Request the StackManager to fetch the top-most position for the current element, where is no float to the left |
static byte |
CLEAR_NONE
Request the StackManager to fetch the top-most position for the current element |
static byte |
CLEAR_RIGHT
Request the StackManager to fetch the top-most position for the current element, where is no float to the rigth |
static int |
MODE_ALL_NON_NEGATIVE
internal mode to iterate over all elements in this stack manager |
static int |
MODE_FLOATING
Constant to address all floats and absolute positioned views with auto z-index |
static int |
MODE_NEGATIVE
Constant to address all absolute positioned views with negative z-index |
static int |
MODE_NEUTRAL
Constant to address all absolute positioned views unset z-index, ignored on paint, used on getSpan |
static int |
MODE_POSITIVE
Constant to address all absolute positioned views with positive z-index |
Constructor Summary | |
---|---|
StackManager(BoxView root)
Creates a float manager bound to a root block element |
Method Summary | |
---|---|
void |
addView(BoxView box,
BlockView outerBox,
int topY)
Adds a new float |
void |
addView(BoxView box,
BlockView outerBox,
int x,
int y)
Adds a position relative. |
void |
clear()
Removes all known float informations |
void |
clearMyFloats(BoxView parent)
Removes all floats with parent set as their parent. |
StackManager.LineSpaceInfo |
findClearSpace(java.awt.Rectangle minRequired,
java.awt.Rectangle bounds,
int clear,
int textAlign)
Tries to find a position, where there is enough room to place the content. |
StackManager.LineSpaceInfo |
findLineSpace(java.awt.Rectangle minRequired,
java.awt.Rectangle bounds,
int clear,
int textAlign)
Tries to find a position, where there is enough room to place the content. |
int |
getAvailableVSpace(int y,
int leftX,
int rightX)
Returns the available vertical space within the selected bounds |
int |
getBottomPosition(BlockView parent)
The difference between the top of the root-View and the bottom of the lowest float in pixel. |
com.inet.html.views.layouts.StackManager.PositionInfo |
getNextFloatBelow(int y,
int leftX,
int rightX,
boolean typeleft)
Tries to find the next lower float of the requested type |
java.awt.Point |
getPositionInfo(BoxView child)
Tries to find the location information about a child. |
java.awt.Rectangle |
getSpan()
Returns the maximum span in positive direction of the floats handled by this manager |
java.awt.Rectangle |
getSpan(int mode)
Returns the span of a stack group |
ViewPositionInfo |
getViewForPosition(java.awt.Point position,
java.awt.Rectangle a,
int mode)
Finds the view and it's location for a specific point of the screen |
boolean |
hasViews()
Returns the number of floats currently managed by this instance |
java.awt.Shape |
modelToView(int pos,
java.awt.Shape a,
javax.swing.text.Position.Bias b,
int mode)
Tries to resolve a model offset to a screen location |
void |
notifyBlockFinished(boolean hard)
Notifies the manager, that the containing block, which holds this manager, has finished layouting. |
void |
notifyNewLine(float topY)
placed the recently added floats |
void |
paint(java.awt.Graphics g,
java.awt.Shape allocation,
int mode)
Paint the Blocks of this manager |
int |
viewToModel(float x,
float y,
java.awt.Shape a,
javax.swing.text.Position.Bias[] biasReturn,
int mode)
Tries to resolve a position to a model offset |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte CLEAR_NONE
public static final byte CLEAR_LEFT
public static final byte CLEAR_RIGHT
public static final byte CLEAR_BOTH
public static final int MODE_NEGATIVE
public static final int MODE_FLOATING
public static final int MODE_NEUTRAL
public static final int MODE_POSITIVE
public static final int MODE_ALL_NON_NEGATIVE
Constructor Detail |
---|
public StackManager(BoxView root)
root
- the root block elementMethod Detail |
---|
public java.awt.Point getPositionInfo(BoxView child)
child
- the child to search for
public void addView(BoxView box, BlockView outerBox, int topY)
box
- new floating boxouterBox
- parent of this floattopY
- the highest position this float may havepublic void addView(BoxView box, BlockView outerBox, int x, int y)
box
- new floating boxouterBox
- parent of this floatx
- the layouted position of the elementy
- the layouted position of the elementpublic void paint(java.awt.Graphics g, java.awt.Shape allocation, int mode)
g
- the graphics to pain toallocation
- the location to draw atmode
- the part of the views, which have to be paintedMODE_NEGATIVE
,
MODE_FLOATING
,
MODE_POSITIVE
public int viewToModel(float x, float y, java.awt.Shape a, javax.swing.text.Position.Bias[] biasReturn, int mode)
x
- the x coordinatey
- the y coordinatea
- the shape to search inbiasReturn
- the direction of the returned offsetmode
- the mode constant to address a certain stack group
MODE_NEGATIVE
,
MODE_FLOATING
,
MODE_NEUTRAL
,
MODE_POSITIVE
public java.awt.Shape modelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b, int mode) throws javax.swing.text.BadLocationException
pos
- the model offseta
- the shape to place the location intob
- the caret directionmode
- the mode constant to address a certain stack group
javax.swing.text.BadLocationException
- thrown if there are model errorsMODE_NEGATIVE
,
MODE_FLOATING
,
MODE_NEUTRAL
,
MODE_POSITIVE
public com.inet.html.views.layouts.StackManager.PositionInfo getNextFloatBelow(int y, int leftX, int rightX, boolean typeleft)
y
- Y index to start fromleftX
- Left border of the space to searchrightX
- Right border of the space to searchtypeleft
- true if searching for left-floats, false otherwise
public int getAvailableVSpace(int y, int leftX, int rightX)
y
- Y index to start fromleftX
- left boundrightX
- right bound
public StackManager.LineSpaceInfo findLineSpace(java.awt.Rectangle minRequired, java.awt.Rectangle bounds, int clear, int textAlign)
minRequired
- The minimum of required space to place the contentbounds
- Maximum ABSOULTE bounds to place the content. The height will be ignored, it's up to the
layout to deal with heights beyond its box. The upper bound has to be the topclear
- The clear attribute of the requesting elementtextAlign
- The text-align attribute of the requesting element
public StackManager.LineSpaceInfo findClearSpace(java.awt.Rectangle minRequired, java.awt.Rectangle bounds, int clear, int textAlign)
minRequired
- The minimum of required space to place the contentbounds
- Maximum ABSOULTE bounds to place the content. The height will be ignored, it's up to the
layout to deal with heights beyond its box. The upper bound has to be the topclear
- The clear attribute of the requesting elementtextAlign
- The text-align attribute of the requesting element
public void notifyNewLine(float topY)
topY
- The highest position possible for the recently added floatspublic int getBottomPosition(BlockView parent)
parent
- The parent view
public void clear()
public void clearMyFloats(BoxView parent)
parent
- the parentpublic boolean hasViews()
public ViewPositionInfo getViewForPosition(java.awt.Point position, java.awt.Rectangle a, int mode)
position
- the location to searcha
- the bounds of THIS viewmode
- the part of the views, which have to be painted
MODE_NEGATIVE
,
MODE_FLOATING
,
MODE_POSITIVE
,
MODE_ALL_NON_NEGATIVE
public java.awt.Rectangle getSpan()
public void notifyBlockFinished(boolean hard)
hard
- set to true, if the status of the childviews should be overridden, and all children are requested
to update their layoutpublic java.awt.Rectangle getSpan(int mode)
mode
- the mode constant to address a certain stack group
MODE_NEGATIVE
,
MODE_FLOATING
,
MODE_NEUTRAL
,
MODE_POSITIVE
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |