fi.hut.tml.xsmiles.csslayout.view
Class BaseView

java.lang.Object
  extended byfi.hut.tml.xsmiles.csslayout.view.BaseView
All Implemented Interfaces:
View
Direct Known Subclasses:
BlockView, ComponentView, FloatContainer, ImageView, ListView, ParagraphView, TableView, TableView.RowGroupView, TableView.RowView, TextView

public class BaseView
extends java.lang.Object
implements View

Author:
mpohja,honkkis

Nested Class Summary
protected  class BaseView.ViewDimensions
          Contains all the dimensions of a view.
 
Field Summary
protected  java.util.Vector absoluteChildViews
           
protected  boolean absolutePosition
           
protected  CSSBackgroundImage backImage
           
protected  java.awt.Color bgColor
          cache the bg color
protected  CSSBorder border
           
protected  java.util.Vector childViews
           
protected  boolean closeFloat
           
protected  BaseView.ViewDimensions dimensions
           
protected  org.w3c.dom.Node domElement
           
protected  boolean floatLeft
           
protected  boolean floatRight
           
protected  boolean hasRelativeHeight
           
protected  boolean hasRelativeWidth
           
protected  View parent
           
protected  int posX
           
protected  int posY
           
protected  java.util.Vector relativeChildViews
           
protected  boolean relativePosition
           
protected  CSSRenderer renderer
           
protected  SizeRequirements sizeRequirements
           
protected  org.w3c.dom.css.CSSStyleDeclaration style
           
protected  boolean visible
           
protected  double zoom
           
 
Fields inherited from interface fi.hut.tml.xsmiles.csslayout.view.View
X_AXIS, Y_AXIS
 
Constructor Summary
BaseView(CSSRenderer r, org.w3c.dom.Node node, View parent)
          Creates a new instance of BaseView
 
Method Summary
 void addAbsoluteChildView(View v)
           
 void addChildView(View v)
           
 void addRelativeChildView(View v)
           
protected  void addView(org.w3c.dom.Node node, View view, View parentView, java.lang.String display)
           
 java.awt.Rectangle calculateIntersection(java.awt.Rectangle rect1, java.awt.Rectangle rect2)
           
 View createChildView(org.w3c.dom.Node child, org.w3c.dom.Node parent)
           
 void createChildViews(org.w3c.dom.Node parent)
           
 View createComponentView(VisualComponentService e)
           
 View createView(org.w3c.dom.Node node, java.lang.String display)
           
 void doLayout()
          do the layout for this and its children
 void dump(java.lang.String indent)
           
protected  View findContainingBlock(BaseView view)
           
 int getAbsolutePositionX()
           
 int getAbsolutePositionY()
           
 java.util.Vector getChildren()
           
 View getChildView(int index)
           
 CSSRenderer getCSSRenderer()
           
 BaseView.ViewDimensions getDimensions()
           
 org.w3c.dom.Node getDOMElement()
           
 View getFirstChild()
          This is called by XSmilesVisualElement when a node is removed from the DOM, let's remove all components from view
 int getMaximumSpan(int axis)
          get maximum span of this view that corresponds to an axis
 int getMinimumSpan(int axis)
          get minimum span of this view that corresponds to an axis
 View getParentView()
           
 int getPreferredSpan(int axis)
          get maximum span of this view that corresponds to an axis
 java.awt.Rectangle getRectangle()
           
 SizeRequirements getSizeRequirements()
           
 org.w3c.dom.css.CSSStyleDeclaration getStyle()
           
static java.lang.String getText(org.w3c.dom.Element elem)
           
 View getViewAtPoint(java.awt.Point pt)
          Returns a view, which embeds the given point.
 int getViewHeight()
           
 int getViewWidth()
           
 void handleRelativeView()
           
 boolean hasAbsoluteChildren()
          This is called by XSmilesVisualElement when a node is removed from the DOM, let's remove all components from view
 boolean hasAbsolutePosition()
          Returns true if view is absolute positioned.
 boolean hasRelativePosition()
          Returns true if view is relative positioned.
 void insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
           
 boolean isInTable()
          Checks if this view is inside TableView.
 boolean isLeftFloated()
          Returns true if view has float left.
 boolean isRightFloated()
          Returns true if view has float right.
protected  void moveChildViews(int x, int y)
           
 void moveView(int axis, int pixels)
          Moves view and its children.
protected  void notifyViewRemovedRecursively(View child)
          go through all descendant views and notify them of removal
 void paint(java.awt.Graphics g)
          paints this view
 void paintBackground(java.awt.Graphics g)
           
 void paintBorder(java.awt.Graphics g)
           
 void removeChild(View child)
           
 void removeChildren()
           
 void removeFromTree()
          Removes this view from the view tree.
 void repaint(java.awt.Image img)
           
 void repaintDocument()
           
 void repaintDocument(View view)
           
 void repaintView()
           
 void setAbsoluteCoordinates()
          This is called for absolute positioned views.
 void setAbsolutePosition(int x, int y)
          set the absolute position of this view, only the parent is allowed to call this
 void setContentHeight(int height)
           
 void setContentWidth(int width)
           
protected  void setMaxContentSize()
           
 void setParentView(View parent)
           
protected  void setRelativePosition()
           
 void setSizeRequirements()
           
 void setStyle(org.w3c.dom.css.CSSStyleDeclaration s)
           
 void setViewHeight(int height)
           
 void setViewWidth(int width)
           
protected  boolean testValue(java.lang.String text)
          Check if the text node is real text or just indentation in original xhtml document.
 void viewRemoved()
          this method is called when a view is removed from the hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

posX

protected int posX

posY

protected int posY

childViews

protected java.util.Vector childViews

absoluteChildViews

protected java.util.Vector absoluteChildViews

relativeChildViews

protected java.util.Vector relativeChildViews

renderer

protected CSSRenderer renderer

domElement

protected org.w3c.dom.Node domElement

style

protected org.w3c.dom.css.CSSStyleDeclaration style

parent

protected View parent

dimensions

protected BaseView.ViewDimensions dimensions

absolutePosition

protected boolean absolutePosition

relativePosition

protected boolean relativePosition

visible

protected boolean visible

bgColor

protected java.awt.Color bgColor
cache the bg color


sizeRequirements

protected SizeRequirements sizeRequirements

border

protected CSSBorder border

backImage

protected CSSBackgroundImage backImage

zoom

protected double zoom

hasRelativeWidth

protected boolean hasRelativeWidth

hasRelativeHeight

protected boolean hasRelativeHeight

floatLeft

protected boolean floatLeft

floatRight

protected boolean floatRight

closeFloat

protected boolean closeFloat
Constructor Detail

BaseView

public BaseView(CSSRenderer r,
                org.w3c.dom.Node node,
                View parent)
Creates a new instance of BaseView

Method Detail

addChildView

public void addChildView(View v)
Specified by:
addChildView in interface View

addAbsoluteChildView

public void addAbsoluteChildView(View v)

addRelativeChildView

public void addRelativeChildView(View v)

getChildView

public View getChildView(int index)

getDOMElement

public org.w3c.dom.Node getDOMElement()
Specified by:
getDOMElement in interface View

getStyle

public org.w3c.dom.css.CSSStyleDeclaration getStyle()
Specified by:
getStyle in interface View

getMaximumSpan

public int getMaximumSpan(int axis)
Description copied from interface: View
get maximum span of this view that corresponds to an axis

Specified by:
getMaximumSpan in interface View

getMinimumSpan

public int getMinimumSpan(int axis)
Description copied from interface: View
get minimum span of this view that corresponds to an axis

Specified by:
getMinimumSpan in interface View

getPreferredSpan

public int getPreferredSpan(int axis)
Description copied from interface: View
get maximum span of this view that corresponds to an axis

Specified by:
getPreferredSpan in interface View

setAbsolutePosition

public void setAbsolutePosition(int x,
                                int y)
Description copied from interface: View
set the absolute position of this view, only the parent is allowed to call this

Specified by:
setAbsolutePosition in interface View

getAbsolutePositionX

public int getAbsolutePositionX()
Specified by:
getAbsolutePositionX in interface View

getAbsolutePositionY

public int getAbsolutePositionY()
Specified by:
getAbsolutePositionY in interface View

getViewWidth

public int getViewWidth()
Specified by:
getViewWidth in interface View

getViewHeight

public int getViewHeight()
Specified by:
getViewHeight in interface View

setContentWidth

public void setContentWidth(int width)

setContentHeight

public void setContentHeight(int height)

setViewWidth

public void setViewWidth(int width)

setViewHeight

public void setViewHeight(int height)

getDimensions

public BaseView.ViewDimensions getDimensions()

getCSSRenderer

public CSSRenderer getCSSRenderer()
Specified by:
getCSSRenderer in interface View

doLayout

public void doLayout()
Description copied from interface: View
do the layout for this and its children

Specified by:
doLayout in interface View

setMaxContentSize

protected void setMaxContentSize()

hasAbsolutePosition

public boolean hasAbsolutePosition()
Returns true if view is absolute positioned.

Specified by:
hasAbsolutePosition in interface View

hasRelativePosition

public boolean hasRelativePosition()
Returns true if view is relative positioned.


isLeftFloated

public boolean isLeftFloated()
Returns true if view has float left.


isRightFloated

public boolean isRightFloated()
Returns true if view has float right.


setAbsoluteCoordinates

public void setAbsoluteCoordinates()
This is called for absolute positioned views.


handleRelativeView

public void handleRelativeView()

setRelativePosition

protected void setRelativePosition()

moveChildViews

protected void moveChildViews(int x,
                              int y)

getRectangle

public java.awt.Rectangle getRectangle()
Specified by:
getRectangle in interface View

paint

public void paint(java.awt.Graphics g)
paints this view

Specified by:
paint in interface View

paintBorder

public void paintBorder(java.awt.Graphics g)

paintBackground

public void paintBackground(java.awt.Graphics g)

repaint

public void repaint(java.awt.Image img)
Specified by:
repaint in interface View

calculateIntersection

public java.awt.Rectangle calculateIntersection(java.awt.Rectangle rect1,
                                                java.awt.Rectangle rect2)

createChildViews

public void createChildViews(org.w3c.dom.Node parent)
Specified by:
createChildViews in interface View

createChildView

public View createChildView(org.w3c.dom.Node child,
                            org.w3c.dom.Node parent)
Specified by:
createChildView in interface View

addView

protected void addView(org.w3c.dom.Node node,
                       View view,
                       View parentView,
                       java.lang.String display)

createComponentView

public View createComponentView(VisualComponentService e)

createView

public View createView(org.w3c.dom.Node node,
                       java.lang.String display)

insertBefore

public void insertBefore(org.w3c.dom.Node newChild,
                         org.w3c.dom.Node refChild)

getText

public static java.lang.String getText(org.w3c.dom.Element elem)

getViewAtPoint

public View getViewAtPoint(java.awt.Point pt)
Returns a view, which embeds the given point.


findContainingBlock

protected View findContainingBlock(BaseView view)

testValue

protected boolean testValue(java.lang.String text)
Check if the text node is real text or just indentation in original xhtml document.


dump

public void dump(java.lang.String indent)

getParentView

public View getParentView()
Specified by:
getParentView in interface View

setParentView

public void setParentView(View parent)
Specified by:
setParentView in interface View

setStyle

public void setStyle(org.w3c.dom.css.CSSStyleDeclaration s)
Specified by:
setStyle in interface View

removeFromTree

public void removeFromTree()
Removes this view from the view tree.

Specified by:
removeFromTree in interface View

getFirstChild

public View getFirstChild()
This is called by XSmilesVisualElement when a node is removed from the DOM, let's remove all components from view

Specified by:
getFirstChild in interface View

viewRemoved

public void viewRemoved()
this method is called when a view is removed from the hierarchy. for instance, components can then be removed from the containers

Specified by:
viewRemoved in interface View

notifyViewRemovedRecursively

protected void notifyViewRemovedRecursively(View child)
go through all descendant views and notify them of removal


removeChild

public void removeChild(View child)
Specified by:
removeChild in interface View

removeChildren

public void removeChildren()
Specified by:
removeChildren in interface View

repaintDocument

public void repaintDocument()
Specified by:
repaintDocument in interface View

repaintDocument

public void repaintDocument(View view)
Specified by:
repaintDocument in interface View

repaintView

public void repaintView()
Specified by:
repaintView in interface View

getChildren

public java.util.Vector getChildren()
Specified by:
getChildren in interface View

hasAbsoluteChildren

public boolean hasAbsoluteChildren()
Description copied from interface: View
This is called by XSmilesVisualElement when a node is removed from the DOM, let's remove all components from view

Specified by:
hasAbsoluteChildren in interface View

setSizeRequirements

public void setSizeRequirements()
Specified by:
setSizeRequirements in interface View

getSizeRequirements

public SizeRequirements getSizeRequirements()
Specified by:
getSizeRequirements in interface View

moveView

public void moveView(int axis,
                     int pixels)
Moves view and its children. Negative values moves to up or left.


isInTable

public boolean isInTable()
Checks if this view is inside TableView. This is called for every block at the moment. Optimization wanted.

Returns:
boolean


X-Smiles 1.2