com.inet.html.views
Class BlockView

java.lang.Object
  extended by javax.swing.text.View
      extended by com.inet.html.views.BoxView
          extended by com.inet.html.views.BlockView
All Implemented Interfaces:
ILayouted, java.lang.Cloneable, javax.swing.SwingConstants
Direct Known Subclasses:
HtmlRootView

public class BlockView
extends BoxView
implements java.lang.Cloneable, ILayouted

The block view is a view for any 'normal' block-element except tables, controls and images. It can be layouted to hold other block-elements or to display inline content. Any block-element has the ability to be the root of floated ancestors(if it's either the html-element view or floated).

See Also:
http://www.w3.org/TR/1998/REC-CSS2/visuren.html#box-gen

Field Summary
 
Fields inherited from class com.inet.html.views.BoxView
BASELINE, STATUS_REQ_LAYOUT, STATUS_REQ_PRELAYOUT, STATUS_UPTODATE
 
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
BlockView(javax.swing.text.Element elem)
          Create a new View object
BlockView(javax.swing.text.Element elem, ViewPainter painter)
          create a new view object
 
Method Summary
 void changedUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 javax.swing.text.View createFragment(int start, int end)
          
 java.awt.Shape getChildAllocation(int index, java.awt.Shape a)
          
 javax.swing.text.View[] getChildViews()
          Returns all child views of this view
 int getCompleteHight()
          This represents the real maximum-hight of all inner components including floats.
 int getContentHeight()
          This is the layouted height in pixel.
 Layout getLayout()
          Returns the layout of this View
 java.awt.Point getLeftUpperCorner(BoxView child)
          This methos calulates the left upper corner of a childs content relative to the left upper corner of the Document.
 java.util.concurrent.atomic.AtomicInteger getListValue()
          Returns the list value counter of this block
 java.awt.Insets getMargins()
          Get the CSS margins
 float getMinimumSpan(int axis)
          
 java.awt.Insets getOriginalMargins()
          Returns the original set of margins of this block.
 int getOuterHeight()
          Returns the outer height of this box which is content+padding+border.
 StackManager getPositionManager(boolean create)
          Returns the float position manager for all descendands of this view.
 float getPreferredSpan(int axis)
          
 java.awt.Rectangle getSpan()
          Returns the span of this view.
 int getTextIndent()
          Returns the CSS.TextIndent property
 javax.swing.text.View getView(int n)
          
 int getViewCount()
          
 void insertUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 boolean isPositionRoot()
          Returns whether this block is a root for positioned or floated elements
 java.awt.Shape modelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b)
          
 void paint(java.awt.Graphics g, java.awt.Shape allocation)
          
 java.awt.Rectangle performLayout(boolean hard)
          Causes this view to update its layout.
 void performLayoutVAlign(int baseline)
          If this box has a overall vertical align, like in table cells for instance, this method calculates teh offset to align the content.
 void performLayoutWidth()
          Layout what is required to determin the width of this view.
 void performPreLayout()
          Causes this view to update its preLayout data.
 void predictWidth(int width)
          Can be used to force a view to a specified width.
 void removeUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 void replace(int offset, int count, javax.swing.text.View[] newViews)
          
 boolean replace(int elementIndex, java.util.List<javax.swing.text.Element> oldElements, java.util.List<javax.swing.text.Element> newElements)
          Replaces the views responsible for the elements.
 void setParent(javax.swing.text.View parent)
          
 void toExternalBox(java.awt.Rectangle span)
          Converts the size of the content to the size of the size of the outer box area of this view.
 java.lang.String toString()
          
 void updateListMarkers()
          Updates the list markers of all children, which are list items with marker.
 int viewToModel(float x, float y, java.awt.Shape a, javax.swing.text.Position.Bias[] biasReturn)
          
 
Methods inherited from class com.inet.html.views.BoxView
addBoxPainter, factoryPreset, forceLayout, forceLayout, getAlignment, getAutoMarginJustify, getBackgroundValue, getBorderBottomColor, getBorderLeftColor, getBorderRightColor, getBorderTopColor, getBottomInset, getBox, getBoxPainter, getClear, getContentVerticalOffset, getContentWidth, getDirection, getDisplay, getEndOffset, getFirstLineBaseLine, getFloat, getFontSize, getHeightUnit, getHTMLRoot, getJustification, getLeftInset, getLineHeight, getOuterWidth, getOverflow, getPainter, getPosition, getRenderContext, getResizeWeight, getRightInset, getStartOffset, getStatus, getSwingAlign, getTopInset, getUnicodeBidi, getViewForPosition, getViewIndex, getViewIndex, getVisibility, getWhiteSpace, getWidthUnit, isAbsolutePositioned, isBlock, isBreak, isBreakable, isFloating, isInFlow, isListItemWithMarker, isLTR, isMarker, isNativeLTR, isTableCell, isWidthSet, setBackgroundValue, setBorderBottomColor, setBorderLeftColor, setBorderRightColor, setBorderTopColor, setContentVerticalOffset, setContentWidth, setFirstLineBaseLine, setIsNativeLTR, setJustification, setMarker, setPainter, setRoot, setSize, setSizeContent, setStartAndEndOffset, setStatus, setStatusLocal
 
Methods inherited from class javax.swing.text.View
append, breakView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getNextVisualPositionFrom, getParent, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, viewToModel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BlockView

public BlockView(javax.swing.text.Element elem)
Create a new View object

Parameters:
elem - Element to present

BlockView

public BlockView(javax.swing.text.Element elem,
                 ViewPainter painter)
create a new view object

Parameters:
elem - element to present
painter - painter to use for painting the view
Method Detail

getListValue

public java.util.concurrent.atomic.AtomicInteger getListValue()
Returns the list value counter of this block

Returns:
the list value counter of this block

setParent

public void setParent(javax.swing.text.View parent)

Overrides:
setParent in class BoxView

getViewCount

public int getViewCount()

Overrides:
getViewCount in class javax.swing.text.View

getView

public javax.swing.text.View getView(int n)

Overrides:
getView in class javax.swing.text.View

getChildViews

public javax.swing.text.View[] getChildViews()
Returns all child views of this view

Returns:
array of views or null if none

replace

public void replace(int offset,
                    int count,
                    javax.swing.text.View[] newViews)

Overrides:
replace in class javax.swing.text.View

createFragment

public javax.swing.text.View createFragment(int start,
                                            int end)

Overrides:
createFragment in class javax.swing.text.View

getPreferredSpan

public float getPreferredSpan(int axis)

Specified by:
getPreferredSpan in class javax.swing.text.View

getMinimumSpan

public float getMinimumSpan(int axis)

Overrides:
getMinimumSpan in class javax.swing.text.View

modelToView

public java.awt.Shape modelToView(int pos,
                                  java.awt.Shape a,
                                  javax.swing.text.Position.Bias b)
                           throws javax.swing.text.BadLocationException

Specified by:
modelToView in class javax.swing.text.View
Throws:
javax.swing.text.BadLocationException

viewToModel

public int viewToModel(float x,
                       float y,
                       java.awt.Shape a,
                       javax.swing.text.Position.Bias[] biasReturn)

Specified by:
viewToModel in class javax.swing.text.View

getChildAllocation

public java.awt.Shape getChildAllocation(int index,
                                         java.awt.Shape a)

Overrides:
getChildAllocation in class javax.swing.text.View

paint

public void paint(java.awt.Graphics g,
                  java.awt.Shape allocation)

Overrides:
paint in class BoxView

getLeftUpperCorner

public java.awt.Point getLeftUpperCorner(BoxView child)
This methos calulates the left upper corner of a childs content relative to the left upper corner of the Document. If child is this object(the parent) the location of the parent is returned.

Parameters:
child - The child to find the coordinates of or this view
Returns:
coordinatas of the left upper corner

isPositionRoot

public boolean isPositionRoot()
Returns whether this block is a root for positioned or floated elements

Returns:
true if this block is a root element, false otherwise

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getPositionManager

public StackManager getPositionManager(boolean create)
Returns the float position manager for all descendands of this view. Any descendand of this view has to query this manager before performing any positioning.

Parameters:
create - if true, a stack manager will be created on the next subsequent position root, if false this is only a search for the next root an may very likely return null
Returns:
float manager which is responsible for this view

getLayout

public Layout getLayout()
Returns the layout of this View

Specified by:
getLayout in interface ILayouted
Returns:
layout of this view or null, if none

performPreLayout

public void performPreLayout()
Causes this view to update its preLayout data. The event will be passed down to all descendands by the layout.

Specified by:
performPreLayout in interface ILayouted
Overrides:
performPreLayout in class BoxView

performLayout

public java.awt.Rectangle performLayout(boolean hard)
Causes this view to update its layout. The event will be passed down to all descendants by the layout itself(has to be done while layouting).

Specified by:
performLayout in class BoxView
Parameters:
hard - if set to true, the current layout state will be ignored and the view will be re-layouted anyways
Returns:
the area spanned by this view an it's siblings

toExternalBox

public void toExternalBox(java.awt.Rectangle span)
Converts the size of the content to the size of the size of the outer box area of this view. This respects the overflow settings an clips the box if required

Parameters:
span - the box to modify

performLayoutWidth

public void performLayoutWidth()
Layout what is required to determin the width of this view. In most cases this method only requires the CSS width setting, the parent's width and the minumum and preferred span. ATTENTION: This method mus be called before layouting the children of a view. Otherwise the children don't get a corrent parent's size.

Specified by:
performLayoutWidth in class BoxView

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 interface ILayouted
Parameters:
width - Width to set

getContentHeight

public int getContentHeight()
This is the layouted height in pixel. This value is without margin, border and insets.

Overrides:
getContentHeight in class BoxView
Returns:
the current height

getOuterHeight

public int getOuterHeight()
Returns the outer height of this box which is content+padding+border.
NOTE: This does not include the margin since the margin is outside the box and has to be evaluated by the layout!

Overrides:
getOuterHeight in class BoxView
Returns:
outer height in pixel

getCompleteHight

public int getCompleteHight()
This represents the real maximum-hight of all inner components including floats. Has to be used the calculate table cells or hight:100%. ATTENTION: This is the content height, not the outer bounds

Overrides:
getCompleteHight in class BoxView
Returns:
maximum of ALL inner components

performLayoutVAlign

public void performLayoutVAlign(int baseline)
If this box has a overall vertical align, like in table cells for instance, this method calculates teh offset to align the content. It has to be called after the box has it's final size an was layouted. NOTE: If the content is larger than the box or valign is top this method will have no visible effect!

Specified by:
performLayoutVAlign in class BoxView
Parameters:
baseline - external prediction of the first baseline for BASELINE alignment

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent e,
                         java.awt.Shape a,
                         javax.swing.text.ViewFactory f)

Overrides:
insertUpdate in class javax.swing.text.View

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent e,
                         java.awt.Shape a,
                         javax.swing.text.ViewFactory f)

Overrides:
removeUpdate in class javax.swing.text.View

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent e,
                          java.awt.Shape a,
                          javax.swing.text.ViewFactory f)

Overrides:
changedUpdate in class javax.swing.text.View

updateListMarkers

public void updateListMarkers()
Updates the list markers of all children, which are list items with marker. This is required


replace

public boolean replace(int elementIndex,
                       java.util.List<javax.swing.text.Element> oldElements,
                       java.util.List<javax.swing.text.Element> newElements)
Replaces the views responsible for the elements. NOTE: This will work only if the replace does not intersect an implied element!

Parameters:
elementIndex - This will ONLY be used if oldElements is empty!
oldElements - The elements whose views have to be removed
newElements - The new element, which require views
Returns:
true if views for all old elements were found, false otherwise

getTextIndent

public int getTextIndent()
Returns the CSS.TextIndent property

Returns:
CSS.TextIndent value in px

getMargins

public java.awt.Insets getMargins()
Get the CSS margins

Overrides:
getMargins in class BoxView
Returns:
never null

getOriginalMargins

public java.awt.Insets getOriginalMargins()
Returns the original set of margins of this block. Required by the BlockLayouter to collapse the margins.

Returns:
the original set of margins

getSpan

public java.awt.Rectangle getSpan()
Returns the span of this view. The span is the bounding rectangle from the top left of this subtree to the bottom right. It's relative to the elements top left corner of it's outer box. It may be larger than the element itself.

Overrides:
getSpan in class BoxView
Returns:
the bounding outer rectangle of this subtree