com.inet.html.views
Class ContentView

java.lang.Object
  extended by javax.swing.text.View
      extended by com.inet.html.views.BoxView
          extended by com.inet.html.views.ContentView
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.SwingConstants
Direct Known Subclasses:
BulletView, InsertedContentView, VariableSpaceView

public class ContentView
extends BoxView
implements java.lang.Cloneable

The Content view displays one block of text(in most cases a word) or several whitespaces. A content view is responsible for displaying all inline styles of itself and all inline elements up to the next paragraph.


Field Summary
static int CJK_TYPE_CHARACTER
          This view represents only CJK characters an thus can be broken at any character position
static int CJK_TYPE_NONE
          there are no CJK characters represented by this view
static int CJK_TYPE_PUNCTUATION
          this view represents one or more CJK punctuation marks, which should be preceded by an CJK character on line breaks
 
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
ContentView(javax.swing.text.Element elem)
          Creates the object, does nothing else.
ContentView(javax.swing.text.Element elem, ViewPainter painter)
          Creates the object, and sets the paint controller
ContentView(javax.swing.text.Element elem, ViewPainter painter, ContentPainter contentPainter)
          Creates the object, and sets the paint controller
 
Method Summary
 javax.swing.text.View createFragment(int start, int end)
          
 int getBottomInset()
          Gets the bottom inset.
 int getCJKType()
          Returns the content type regarding CJK characters of this view.
 ContentPainter getContentPainter()
          Returns the content painter used by this view
 java.awt.Font getFont()
          Returns the font used by this view
 int getLeftInset()
          Gets the left inset.
 java.awt.Insets getMargins()
          Get the CSS margins
 float getMinimumSpan(int axis)
          
 float getPreferredSpan(int axis)
          
 int getRightInset()
          Gets the right inset.
 int getTextLength()
          Returns the number of displayed by this view.
 int getTopInset()
          Gets the top inset.
 void insertUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 boolean isBlock()
          Returns true if this is a block by CSS display attribute
 boolean isBreakable()
          Returns true, if this view may be used to break an inline layout
 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.lang.String paramString()
          Returns a custom toString version
 java.awt.Rectangle performLayout(boolean hard)
          This is the final layout method.
 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 setBreakable(boolean isBreakable)
          Returns true, if this is a white space, which can be wrapped
 void setCJKType(int cjkType)
          Sets the content type regarding CJK characters of this view.
 void setIsNativeLTR(boolean isLTR)
          Sets the native LTR flag of this view.
 void setParent(javax.swing.text.View parent)
          
 void setSize(float newWidth, float newHeight)
          BLOCKED FOR CONTENT
This method changes the OUTER box size, which is the box around the border of this box.
 void setSizeContent(float newWidth, float newHeight)
          BLOCKED FOR CONTENT
This method changes the CONTENT size, which is the inner box of the box model.
 java.lang.String toString()
          
 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, getBox, getBoxPainter, getClear, getCompleteHight, getContentHeight, getContentVerticalOffset, getContentWidth, getDirection, getDisplay, getEndOffset, getFirstLineBaseLine, getFloat, getFontSize, getHeightUnit, getHTMLRoot, getJustification, getLineHeight, getOuterHeight, getOuterWidth, getOverflow, getPainter, getPosition, getRenderContext, getResizeWeight, getSpan, getStartOffset, getStatus, getSwingAlign, getUnicodeBidi, getViewForPosition, getViewIndex, getViewIndex, getVisibility, getWhiteSpace, getWidthUnit, isAbsolutePositioned, isBreak, isFloating, isInFlow, isListItemWithMarker, isLTR, isMarker, isNativeLTR, isTableCell, isWidthSet, performPreLayout, setBackgroundValue, setBorderBottomColor, setBorderLeftColor, setBorderRightColor, setBorderTopColor, setContentVerticalOffset, setContentWidth, setFirstLineBaseLine, setJustification, setMarker, setPainter, setRoot, setStartAndEndOffset, setStatus, setStatusLocal
 
Methods inherited from class javax.swing.text.View
append, breakView, changedUpdate, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getNextVisualPositionFrom, getParent, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, removeUpdate, replace, viewToModel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CJK_TYPE_NONE

public static final int CJK_TYPE_NONE
there are no CJK characters represented by this view

See Also:
Constant Field Values

CJK_TYPE_PUNCTUATION

public static final int CJK_TYPE_PUNCTUATION
this view represents one or more CJK punctuation marks, which should be preceded by an CJK character on line breaks

See Also:
Constant Field Values

CJK_TYPE_CHARACTER

public static final int CJK_TYPE_CHARACTER
This view represents only CJK characters an thus can be broken at any character position

See Also:
Constant Field Values
Constructor Detail

ContentView

public ContentView(javax.swing.text.Element elem)
Creates the object, does nothing else.

Parameters:
elem - The element this view ill display, must not be null

ContentView

public ContentView(javax.swing.text.Element elem,
                   ViewPainter painter)
Creates the object, and sets the paint controller

Parameters:
elem - the element this view ill display, must not be null
painter - the paint controller to use, may be null if there is none

ContentView

public ContentView(javax.swing.text.Element elem,
                   ViewPainter painter,
                   ContentPainter contentPainter)
Creates the object, and sets the paint controller

Parameters:
elem - the element this view ill display, must not be null
painter - the paint controller to use, may be null if there is none
contentPainter - the painter to be used by this view
Method Detail

setParent

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

Overrides:
setParent in class BoxView

setSize

public void setSize(float newWidth,
                    float newHeight)
BLOCKED FOR CONTENT
This method changes the OUTER box size, which is the box around the border of this box. The content size will be set to a size which fits into this box.

Overrides:
setSize in class BoxView
Parameters:
newWidth - the new width in px
newHeight - the new height in px

setSizeContent

public void setSizeContent(float newWidth,
                           float newHeight)
BLOCKED FOR CONTENT
This method changes the CONTENT size, which is the inner box of the box model. The outer size will be set to a size which fits around this box.

Overrides:
setSizeContent in class BoxView
Parameters:
newWidth - the new width in px
newHeight - the new height in px

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

paint

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

Overrides:
paint in class BoxView

getTextLength

public int getTextLength()
Returns the number of displayed by this view. Since the length of the displayed text may differ to the number of characters in the model covered by this view, please call this function whenever referring to the number of really displayed characters!

Returns:
the number of displayed by this view

getLeftInset

public int getLeftInset()
Gets the left inset.

Overrides:
getLeftInset in class BoxView
Returns:
the inset >= 0

isBlock

public boolean isBlock()
Returns true if this is a block by CSS display attribute

Overrides:
isBlock in class BoxView
Returns:
Returns true if this is a block by CSS display attribute

getRightInset

public int getRightInset()
Gets the right inset.

Overrides:
getRightInset in class BoxView
Returns:
the inset >= 0

getTopInset

public int getTopInset()
Gets the top inset.

Overrides:
getTopInset in class BoxView
Returns:
the inset >= 0

getBottomInset

public int getBottomInset()
Gets the bottom inset.

Overrides:
getBottomInset in class BoxView
Returns:
the inset >= 0

getMargins

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

Overrides:
getMargins in class BoxView
Returns:
never null

paramString

public java.lang.String paramString()
Returns a custom toString version

Returns:
a custom toString version

performLayout

public java.awt.Rectangle performLayout(boolean hard)
This is the final layout method. It has to perform a layout of this view and call the layout of all children. Every change to the size of any view in the document will at least call the performLayout method!

Specified by:
performLayout in class BoxView
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 bottom-right point of the layout span, required for overflow calculations

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

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

isBreakable

public boolean isBreakable()
Returns true, if this view may be used to break an inline layout

Overrides:
isBreakable in class BoxView
Returns:
Returns true, if this view may be used to break an inline layout

setBreakable

public void setBreakable(boolean isBreakable)
Returns true, if this is a white space, which can be wrapped

Parameters:
isBreakable - Returns true, if this is a white space, which can be wrapped

getFont

public java.awt.Font getFont()
Returns the font used by this view

Returns:
the font used by this view

setIsNativeLTR

public void setIsNativeLTR(boolean isLTR)
Sets the native LTR flag of this view. This will influence the text alignment, if no explicit alignment is set.

Overrides:
setIsNativeLTR in class BoxView
Parameters:
isLTR - true for native LTR, false for native RTL

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getContentPainter

public ContentPainter getContentPainter()
Returns the content painter used by this view

Returns:
the content painter used by this view

getCJKType

public int getCJKType()
Returns the content type regarding CJK characters of this view.

Returns:
the CJK type of this view
See Also:
CJK_TYPE_NONE, CJK_TYPE_PUNCTUATION, CJK_TYPE_CHARACTER

setCJKType

public void setCJKType(int cjkType)
Sets the content type regarding CJK characters of this view.

Parameters:
cjkType - the CJK type of this view
See Also:
CJK_TYPE_NONE, CJK_TYPE_PUNCTUATION, CJK_TYPE_CHARACTER