com.inet.html.views
Class VariableSpaceView

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

public class VariableSpaceView
extends ContentView

This is very special type of view. It represents one(of more, if this is within a pre) spaces within a flow-text. It may have a weight depending on the spaces it represents. This view will draw all backgrounds an borders of the elements between it's root an leaf. That way it can be part of all lineboxes at one specified location. If a paint type is set it can be used for the left or right edge of a line box. In that case it has a fixed width, which consists of the border and padding of the line box. This view will take part in the normal inline layout process an can flow like any other content block.


Field Summary
 
Fields inherited from class com.inet.html.views.ContentView
CJK_TYPE_CHARACTER, CJK_TYPE_NONE, CJK_TYPE_PUNCTUATION
 
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
VariableSpaceView(javax.swing.text.Element leaf)
          Constructs a space with variable width, which uses ALL styles from the leaf to the root element.
VariableSpaceView(javax.swing.text.Element leaf, boolean isBreakChar)
          Constructs a space with variable width, which uses ALL styles from the leaf to the root element.
VariableSpaceView(javax.swing.text.Element elem, boolean isBreakChar, ViewPainter painter)
          Creates the object, and sets the paint controller
VariableSpaceView(javax.swing.text.Element leaf, int paintMode)
          Constructs a space with variable width, which uses ALL styles from the leaf to the root element.
VariableSpaceView(javax.swing.text.Element elem, int paintMode, ViewPainter painter)
          Creates the object, and sets the paint controller
VariableSpaceView(javax.swing.text.Element elem, int paintMode, ViewPainter painter, ContentPainter contentPainter)
          Creates the object, and sets the paint controller
VariableSpaceView(javax.swing.text.Element elem, ViewPainter painter)
          Creates the object, and sets the paint controller
 
Method Summary
 int getContentHeight()
          This is the layouted height in pixel.
 int getContentWidth()
          This is the layouted width in pixel.
 float getMinimumSpan(int axis)
          
 int getOuterHeight()
          Returns the outer height of this box which is content+padding+border.
 int getOuterWidth()
          Returns the outer width of this box which is content+padding+border.
 float getPreferredSpan(int axis)
          
 boolean isBreak()
          Returns true if this View refers to a BR element
 boolean isBreakable()
          Returns true, if this view may be used to break an inline layout
 boolean isFixed()
           
 boolean isTab()
          Returns true if this represents a tab stop
 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)
          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!
 void performPreLayout()
          Causes this view to layout all fixed values and to calculate it's minimum and preferred width.
 void setBreakable(boolean isBreakable)
          Returns true, if this is a white space, which can be wrapped
 void setFixed(boolean isFixed)
          Sets this view to fixed or layout-defined width
 void setHeight(int height)
          Explicitly sets the height of this space.
 void setIsBreakChar()
          Marks this view as a break character in PRE context.
 void setPaintMode(int paintMode)
          Sets the paint mode of this view.
 void setParent(javax.swing.text.View parent)
          
 void setPre(boolean isPre)
          Sets the White-Space=PRE property on this view (not on the underlying content!)
 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.
 void setStartAndEndOffset(int start, int end)
          Set a new start and end position
 void setTab(boolean isTab)
          Sets the tab stop property of this view
 void setWidth(int width)
          Explicitly sets the width of this space.
 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.ContentView
createFragment, getBottomInset, getCJKType, getContentPainter, getFont, getLeftInset, getMargins, getRightInset, getTextLength, getTopInset, insertUpdate, isBlock, paramString, performLayoutVAlign, performLayoutWidth, setCJKType, setIsNativeLTR, setSizeContent
 
Methods inherited from class com.inet.html.views.BoxView
addBoxPainter, factoryPreset, forceLayout, forceLayout, getAlignment, getAutoMarginJustify, getBackgroundValue, getBorderBottomColor, getBorderLeftColor, getBorderRightColor, getBorderTopColor, getBox, getBoxPainter, getClear, getCompleteHight, getContentVerticalOffset, getDirection, getDisplay, getEndOffset, getFirstLineBaseLine, getFloat, getFontSize, getHeightUnit, getHTMLRoot, getJustification, getLineHeight, getOverflow, getPainter, getPosition, getRenderContext, getResizeWeight, getSpan, getStartOffset, getStatus, getSwingAlign, getUnicodeBidi, getViewForPosition, getViewIndex, getViewIndex, getVisibility, getWhiteSpace, getWidthUnit, isAbsolutePositioned, isFloating, isInFlow, isListItemWithMarker, isLTR, isMarker, isNativeLTR, isTableCell, isWidthSet, setBackgroundValue, setBorderBottomColor, setBorderLeftColor, setBorderRightColor, setBorderTopColor, setContentVerticalOffset, setContentWidth, setFirstLineBaseLine, setJustification, setMarker, setPainter, setRoot, 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
 

Constructor Detail

VariableSpaceView

public VariableSpaceView(javax.swing.text.Element leaf)
Constructs a space with variable width, which uses ALL styles from the leaf to the root element.

Parameters:
leaf - The leaf within the content tree, which matches this space area

VariableSpaceView

public VariableSpaceView(javax.swing.text.Element leaf,
                         boolean isBreakChar)
Constructs a space with variable width, which uses ALL styles from the leaf to the root element.

Parameters:
leaf - The leaf within the content tree, which matches this space area
isBreakChar - set this to true to indicate that the content of this element is a \n, relevant for PRE

VariableSpaceView

public VariableSpaceView(javax.swing.text.Element leaf,
                         int paintMode)
Constructs a space with variable width, which uses ALL styles from the leaf to the root element. NOTE: This method can make this a FIXED width space! It uses the border and Padding of the leaf to calculate it's width. The width may be 0 - in that case the view should not be used.

Parameters:
leaf - The leaf within the content tree, which matches this space area
paintMode - Sets the paint mode for this view(uses BoxPainter constants). If the mode is not centered this view draws the edge of the leafs line box.

VariableSpaceView

public VariableSpaceView(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

VariableSpaceView

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

Parameters:
elem - the element this view ill display, must not be null
isBreakChar - set to true, if the white space of this view is a line break in text/plain
painter - the paint controller to use, may be null if there is none

VariableSpaceView

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

Parameters:
elem - the element this view ill display, must not be null
paintMode - the BoxPainter.PAINT_MODE constant to use on paint operations of this view
painter - the paint controller to use, may be null if there is none
See Also:
IBoxPainter.PAINT_MODE_NORMAL, IBoxPainter.PAINT_MODE_LEFTEDGE, IBoxPainter.PAINT_MODE_CENTER, IBoxPainter.PAINT_MODE_RIGHTEDGE

VariableSpaceView

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

Parameters:
elem - the element this view ill display, must not be null
paintMode - the BoxPainter.PAINT_MODE constant to use on paint operations of this view
painter - the paint controller to use, may be null if there is none
contentPainter - the content painter to use
See Also:
IBoxPainter.PAINT_MODE_NORMAL, IBoxPainter.PAINT_MODE_LEFTEDGE, IBoxPainter.PAINT_MODE_CENTER, IBoxPainter.PAINT_MODE_RIGHTEDGE
Method Detail

setParent

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

Overrides:
setParent in class ContentView

setPaintMode

public void setPaintMode(int paintMode)
Sets the paint mode of this view. This is only allowed before setParent was called!

Parameters:
paintMode - a BoxPainter constant

getPreferredSpan

public float getPreferredSpan(int axis)

Overrides:
getPreferredSpan in class ContentView

getMinimumSpan

public float getMinimumSpan(int axis)

Overrides:
getMinimumSpan in class ContentView

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!

Overrides:
performLayout in class ContentView
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

setWidth

public void setWidth(int width)
Explicitly sets the width of this space. If the widht is >=0, this space will be set to fixed, otherwise to not-fixed.

Parameters:
width - The width in pixel.

setHeight

public void setHeight(int height)
Explicitly sets the height of this space. NOTE: This is the CONTENT height or the line height - never the outer height including padding and border.

Parameters:
height - The height in pixel.

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

getOuterWidth

public int getOuterWidth()
Returns the outer width 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:
getOuterWidth in class BoxView
Returns:
outer width in pixel

isFixed

public boolean isFixed()
Returns:
true if this view has a fixed width, false otherwise

setFixed

public void setFixed(boolean isFixed)
Sets this view to fixed or layout-defined width

Parameters:
isFixed - true set a fixed width

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 ContentView
Parameters:
newWidth - the new width in px
newHeight - the new height in px

setStartAndEndOffset

public void setStartAndEndOffset(int start,
                                 int end)
Set a new start and end position

Overrides:
setStartAndEndOffset in class BoxView
Parameters:
start - the new start position
end - must be larger as start

getContentWidth

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

Overrides:
getContentWidth in class BoxView
Returns:
the current width

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

performPreLayout

public void performPreLayout()
Causes this view to layout all fixed values and to calculate it's minimum and preferred width. Uses the CSS-Values set by setPropertiesFromAttributes.

Overrides:
performPreLayout in class BoxView

toString

public java.lang.String toString()

Overrides:
toString in class ContentView

modelToView

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

Overrides:
modelToView in class ContentView
Throws:
javax.swing.text.BadLocationException

viewToModel

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

Overrides:
viewToModel in class ContentView

paint

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

Overrides:
paint in class ContentView

setPre

public void setPre(boolean isPre)
Sets the White-Space=PRE property on this view (not on the underlying content!)

Parameters:
isPre - true, if this is a PRE-View

isBreak

public boolean isBreak()
Returns true if this View refers to a BR element

Overrides:
isBreak in class BoxView
Returns:
Returns true if this View refers to a BR element

setIsBreakChar

public void setIsBreakChar()
Marks this view as a break character in PRE context. This vill cause this view to behave like a BR


isBreakable

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

Overrides:
isBreakable in class ContentView
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

Overrides:
setBreakable in class ContentView
Parameters:
isBreakable - Returns true, if this is a white space, which can be wrapped

isTab

public boolean isTab()
Returns true if this represents a tab stop

Returns:
true if this represents a tab stop

setTab

public void setTab(boolean isTab)
Sets the tab stop property of this view

Parameters:
isTab - true, if this represents a tab stop