com.inet.html.views
Class ImageView

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

public class ImageView
extends BoxView

This is the view to display images or image-buttons. It will load the image itself or retrieve it from the internal image cache. If there is no image to load an missing-image will be displayed and the ALT-text will be drawn. If this view cannot determine the size of the image by either the image or the attributes, it uses a default size of 32x32 pixels.


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
ImageView(javax.swing.text.Element elem)
          Creates a new Image view for the element elem
ImageView(javax.swing.text.Element elem, ViewPainter painter)
          Creates a new Image view for the element elem with a paged paint controller
 
Method Summary
 int getContentHeight()
          This is the layouted height in pixel.
 int getContentWidth()
          This is the layouted width in pixel.
 java.awt.Image getImage()
          Threadsafe image accessor
 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)
          
 int getResizeWeight(int axis)
          
 java.net.URL getUrl()
          Returns the effective URL of the image which is currently display if this image was loaded by URL
 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.
 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 layout all fixed values and to calculate it's minimum and preferred width.
 void predictSource(java.lang.String newSource)
          If this method is called with a non-null value, the SRC attribute of this image view will be replaced by this string.
 void setBase(java.net.URL base)
          Explicitly sets the base URL of this image.
 void setListItemFallback(BoxView view)
          Registers a view, which will set the size and the paint operation of this view, if this image is to be used as a list item but could not be loaded
 void setParent(javax.swing.text.View parent)
          
 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, getBottomInset, getBox, getBoxPainter, getClear, getCompleteHight, getContentVerticalOffset, getDirection, getDisplay, getEndOffset, getFirstLineBaseLine, getFloat, getFontSize, getHeightUnit, getHTMLRoot, getJustification, getLeftInset, getLineHeight, getMargins, getOverflow, getPainter, getPosition, getRenderContext, getRightInset, getSpan, 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, changedUpdate, createFragment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, insert, insertUpdate, 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

ImageView

public ImageView(javax.swing.text.Element elem)
Creates a new Image view for the element elem

Parameters:
elem - the image element

ImageView

public ImageView(javax.swing.text.Element elem,
                 ViewPainter painter)
Creates a new Image view for the element elem with a paged paint controller

Parameters:
elem - the image element
painter - the painter info, to paint on paged media
Method Detail

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

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

getPreferredSpan

public float getPreferredSpan(int axis)

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

getResizeWeight

public int getResizeWeight(int axis)

Overrides:
getResizeWeight in class BoxView

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

getImage

public java.awt.Image getImage()
Threadsafe image accessor

Returns:
the current image

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

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:

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

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

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

predictSource

public void predictSource(java.lang.String newSource)
If this method is called with a non-null value, the SRC attribute of this image view will be replaced by this string. It will not modify the attributes of the underlying document element!

Parameters:
newSource - the new source URL

setBase

public void setBase(java.net.URL base)
Explicitly sets the base URL of this image. The image URL will be resolved using this base.

Parameters:
base - the base url to replace the documents base url

setListItemFallback

public void setListItemFallback(BoxView view)
Registers a view, which will set the size and the paint operation of this view, if this image is to be used as a list item but could not be loaded

Parameters:
view - the view to display instead of this one

getUrl

public java.net.URL getUrl()
Returns the effective URL of the image which is currently display if this image was loaded by URL

Returns:
the effective image URL or null

setParent

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

Overrides:
setParent in class BoxView