com.inet.html.views
Class ControlView

java.lang.Object
  extended by javax.swing.text.View
      extended by com.inet.html.views.BoxView
          extended by com.inet.html.views.ControlView
All Implemented Interfaces:
ILayouted, javax.swing.SwingConstants
Direct Known Subclasses:
ObjectView

public class ControlView
extends BoxView
implements ILayouted

This class represents a HTML form control element like a button or an input. It uses regular swing components to render the view and to perform inputs.


Field Summary
static int TYPE_BUTTON
           
static int TYPE_CHECKBOX
           
static int TYPE_HIDDEN
           
static int TYPE_MENU
           
static int TYPE_RADIOBUTTON
           
static int TYPE_SELECT
           
static int TYPE_TEXTAREA
           
static int TYPE_TEXTFIELD
           
 
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
ControlView(javax.swing.text.Element elem)
          Constructs a new ControlView, does nothing else.
ControlView(javax.swing.text.Element elem, ViewPainter painter)
          new ControlView with element and painter
 
Method Summary
 javax.swing.JComponent getControl()
          This will return the component which displays the controls content.
 int getControlHeight()
          Returns the height(in PX) of the control JComponent encapsulated by this view
 javax.swing.JComponent getControlPanel()
          This will return the root swing component which will be triggered to display the complete control.
 int getControlWidth()
          Returns the width(in PX) of the control JComponent encapsulated by this view
 int getFirstLineBaseLine()
          Returns the baseline of the first content descendand of this view relative to the upper bound of this view
 Layout getLayout()
          Returns the layouter object used by this view
 java.lang.String getName()
          Returns the name of this component.
 float getPreferredSpan(int axis)
          
 int getType()
          Returns the type constant, which indicates which tpye of JComponent/HTML Control type is displayed by this view.
 java.lang.Object getValue()
          Returns the current value of the encapsuled control.
 boolean isReset()
          returns true if this control can reset a form
 boolean isSubmit()
          returns true if this control can submit a form
 boolean isSuccessful(ControlView activator)
          Determines the current success status for a submit.
 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 predictWidth(int width)
          Forces a width on the control JComponent encapsulated by this view
 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, getContentHeight, getContentVerticalOffset, getContentWidth, getDirection, getDisplay, getEndOffset, getFloat, getFontSize, getHeightUnit, getHTMLRoot, getJustification, getLeftInset, getLineHeight, getMargins, getOuterHeight, getOuterWidth, getOverflow, getPainter, getPosition, getRenderContext, getResizeWeight, 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
 

Field Detail

TYPE_BUTTON

public static final int TYPE_BUTTON
See Also:
Constant Field Values

TYPE_TEXTFIELD

public static final int TYPE_TEXTFIELD
See Also:
Constant Field Values

TYPE_TEXTAREA

public static final int TYPE_TEXTAREA
See Also:
Constant Field Values

TYPE_RADIOBUTTON

public static final int TYPE_RADIOBUTTON
See Also:
Constant Field Values

TYPE_CHECKBOX

public static final int TYPE_CHECKBOX
See Also:
Constant Field Values

TYPE_SELECT

public static final int TYPE_SELECT
See Also:
Constant Field Values

TYPE_MENU

public static final int TYPE_MENU
See Also:
Constant Field Values

TYPE_HIDDEN

public static final int TYPE_HIDDEN
See Also:
Constant Field Values
Constructor Detail

ControlView

public ControlView(javax.swing.text.Element elem)
Constructs a new ControlView, does nothing else.

Parameters:
elem - the underlying model element for this view, must not be null

ControlView

public ControlView(javax.swing.text.Element elem,
                   ViewPainter painter)
new ControlView with element and painter

Parameters:
elem - element
painter - painter
Method Detail

setParent

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

Overrides:
setParent in class BoxView

getPreferredSpan

public float getPreferredSpan(int axis)

Specified by:
getPreferredSpan 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

paint

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

Overrides:
paint in class BoxView

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

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

getControlWidth

public int getControlWidth()
Returns the width(in PX) of the control JComponent encapsulated by this view

Returns:
the width(in PX) of the control JComponent encapsulated by this view

getControlHeight

public int getControlHeight()
Returns the height(in PX) of the control JComponent encapsulated by this view

Returns:
the height(in PX) of the control JComponent encapsulated by this view

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

getLayout

public Layout getLayout()
Returns the layouter object used by this view

Specified by:
getLayout in interface ILayouted
Returns:
the layouter object used by this view

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.

Specified by:
performPreLayout in interface ILayouted
Overrides:
performPreLayout in class BoxView

predictWidth

public void predictWidth(int width)
Forces a width on the control JComponent encapsulated by this view

Specified by:
predictWidth in interface ILayouted
Parameters:
width - the width to set in PX

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getControl

public javax.swing.JComponent getControl()
This will return the component which displays the controls content. There might be a scroll pane on top of this component.

Returns:
the control component

getControlPanel

public javax.swing.JComponent getControlPanel()
This will return the root swing component which will be triggered to display the complete control. It may be a scroll pane as well.

Returns:
the root swing component which will be triggered to display the complete control

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

getFirstLineBaseLine

public int getFirstLineBaseLine()
Returns the baseline of the first content descendand of this view relative to the upper bound of this view

Overrides:
getFirstLineBaseLine in class BoxView
Returns:
the baseline in px

getType

public int getType()
Returns the type constant, which indicates which tpye of JComponent/HTML Control type is displayed by this view. This may be relevant for the

Returns:
The type constant for this control

isSubmit

public boolean isSubmit()
returns true if this control can submit a form

Returns:
returns true if this control can submit a form

isReset

public boolean isReset()
returns true if this control can reset a form

Returns:
returns true if this control can reset a form

getValue

public java.lang.Object getValue()
Returns the current value of the encapsuled control. The exact return value depends on the type of control.
NOTE: This function does not check, whether the control is valid!

Returns:
the current value of the control

getName

public java.lang.String getName()
Returns the name of this component. The name will be used to transfer the value of this control as well. If the name is null or unset, this control can never be valid!

Returns:
the name of this control

isSuccessful

public boolean isSuccessful(ControlView activator)
Determines the current success status for a submit. If a control is successful it's name and value should be included in the submission data.

Parameters:
activator - the current button, which submitted the form
Returns:
true, if the control is successful
See Also:
http://www.w3.org/TR/REC-html40/interact/forms.html#successful-controls