com.inet.html.views
Class BackgroundPainter

java.lang.Object
  extended by com.inet.html.views.BackgroundPainter
All Implemented Interfaces:
IBackgroundPainter
Direct Known Subclasses:
BoxPainter

public class BackgroundPainter
extends java.lang.Object
implements IBackgroundPainter

The background painter is the implementation of the CSS 'background' attribute. It defines how to draw the background of a box or table.


Constructor Summary
BackgroundPainter(javax.swing.text.Element elem, BoxView startReference)
          Creates a painter, which takes the view as parent reference for relative values and the element to get it's styles.
BackgroundPainter(javax.swing.text.Element elem, RenderContext renderContext)
          Creates a painter which is dedicated to this view
 
Method Summary
 com.inet.html.parser.converter.ColorValue getBackgroundValue()
          Returns the background color, may be null
 javax.swing.text.Element getElement()
          Returns the element which is the value source for this painter
 java.awt.Rectangle getLastPaint()
          Returns the coordinates of the last paint operation
 BoxView getReferenceView()
          Returns the view this painter is bound to, will not be null
 boolean isInitDone()
          Returns true if a table layout has modified this painter
 boolean isRelevant()
          Returns true if this box painter has any visible effect (note: padding is visible as well!)
 void paintBackground(java.awt.Graphics g, int x, int y, int width, int height, BoxView currentView)
          Paints the background fill and/or image
 void setBackgroundValue(com.inet.html.parser.converter.ColorValue backgroundValue)
          Set the background color of this painter, may be null
 void setInitDone()
          To be used in table context.
 void setLastPaint(java.awt.Rectangle lastPaint)
          Sets the coordinates of the last paint operation
 void setReferenceView(BoxView view)
          Sets the view which is the first view to be painted by this painter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackgroundPainter

public BackgroundPainter(javax.swing.text.Element elem,
                         RenderContext renderContext)
Creates a painter which is dedicated to this view

Parameters:
elem - the element which is source of the values for this painter
renderContext - the current render context, must not be null

BackgroundPainter

public BackgroundPainter(javax.swing.text.Element elem,
                         BoxView startReference)
Creates a painter, which takes the view as parent reference for relative values and the element to get it's styles. The painter will be bound to this element and stored within the elements attributes.

Parameters:
elem - the element which is source of the values for this painter
startReference - the element, which is the start coordinate of this painter. Required for seamless background images
Method Detail

paintBackground

public void paintBackground(java.awt.Graphics g,
                            int x,
                            int y,
                            int width,
                            int height,
                            BoxView currentView)
Paints the background fill and/or image

Specified by:
paintBackground in interface IBackgroundPainter
Parameters:
g - the graphics to draw on, must not be null
x - the x offset in pixel relative to the graphics
y - the y offset in pixel relative to the graphics
width - the width to draw in pixel
height - the height to draw in pixel
currentView - the view for which the background is painted, required to create seamless BG-Images

getReferenceView

public BoxView getReferenceView()
Returns the view this painter is bound to, will not be null

Specified by:
getReferenceView in interface IBackgroundPainter
Returns:
the view this painter is bound to, will not be null

isInitDone

public boolean isInitDone()
Returns true if a table layout has modified this painter

Specified by:
isInitDone in interface IBackgroundPainter
Returns:
true if a table layout has modified this painter

setInitDone

public void setInitDone()
To be used in table context. The table changes several layout settings - this has to be done only once! This flag has to be set to true afterwards.

Specified by:
setInitDone in interface IBackgroundPainter

getBackgroundValue

public com.inet.html.parser.converter.ColorValue getBackgroundValue()
Returns the background color, may be null

Specified by:
getBackgroundValue in interface IBackgroundPainter
Returns:
the background color, may be null

setBackgroundValue

public void setBackgroundValue(com.inet.html.parser.converter.ColorValue backgroundValue)
Set the background color of this painter, may be null

Specified by:
setBackgroundValue in interface IBackgroundPainter
Parameters:
backgroundValue - the background color of this painter, may be null

setReferenceView

public void setReferenceView(BoxView view)
Sets the view which is the first view to be painted by this painter. All subsequent calls will be painted relatively to this view

Specified by:
setReferenceView in interface IBackgroundPainter
Parameters:
view - the coordinate root for this painter

getElement

public javax.swing.text.Element getElement()
Returns the element which is the value source for this painter

Specified by:
getElement in interface IBackgroundPainter
Returns:
the element which is the value source for this painter

getLastPaint

public java.awt.Rectangle getLastPaint()
Returns the coordinates of the last paint operation

Specified by:
getLastPaint in interface IBackgroundPainter
Returns:
the coordinates of the last paint operation

setLastPaint

public void setLastPaint(java.awt.Rectangle lastPaint)
Sets the coordinates of the last paint operation

Specified by:
setLastPaint in interface IBackgroundPainter
Parameters:
lastPaint - the coordinates of the last paint operation

isRelevant

public boolean isRelevant()
Returns true if this box painter has any visible effect (note: padding is visible as well!)

Specified by:
isRelevant in interface IBackgroundPainter
Returns:
true if this box painter has any visible effect