fi.hut.tml.xsmiles.gui.components.general
Class ComponentBase

java.lang.Object
  extended byfi.hut.tml.xsmiles.gui.components.general.ComponentBase
Direct Known Subclasses:
AWTStylableComponent, HaviStylableComponent, SwingStylableComponent

public abstract class ComponentBase
extends java.lang.Object

Interface to plain GUI component The GUI component package contains an abstract set of components that can generally be used.

Author:
Mikko Honkala, Juha Vierinen

Field Summary
 java.awt.Component content
          the content component
protected  java.awt.Font currentFont
           
protected  double currentZoom
          The current zoom level of this component (default = 1.00)
protected  java.awt.Color defaultBGColor
          the default background color
protected  java.awt.Font defaultFont
           
protected  java.awt.Dimension defaultSize
           
protected  java.lang.String fInputMode
           
protected  java.lang.String hintText
           
protected static java.awt.Dimension minSize
           
protected  org.w3c.dom.css.CSSStyleDeclaration style
          The CSS for the main component
 
Constructor Summary
ComponentBase()
           
 
Method Summary
 void addActionListener(java.awt.event.ActionListener al)
           
 void addFocusListener(java.awt.event.FocusListener fl)
           
 void addHelpListener(java.awt.event.ActionListener fl)
          add a listener for help events
 void addMouseListener(java.awt.event.MouseListener ml)
           
 java.awt.Component getAddableComponent()
           
 java.awt.Component getComponent()
           
 java.awt.Color getDefaultBackgroundColor()
          the default background color for this type of component null = transparent.
 java.awt.Dimension getDefaultSize()
          returns the default size, calculated in the beginning
 boolean getEnabled()
           
 CSSFormatter getFormatter()
           
 int getHeight()
           
 java.awt.Dimension getMinimumSize()
          return the minimum size for this component at zoom level 1.0
 java.awt.Dimension getPreferredSize(java.awt.Component comp)
          in AWT, we must do extra tricks to get the preferred size before the component is on screen
 java.awt.Component getSizableComponent()
           
 java.awt.Dimension getSize()
           
 java.awt.Component getStylableComponent()
           
 org.w3c.dom.css.CSSStyleDeclaration getStyle()
           
 int getWidth()
           
 int getX()
           
 int getY()
           
 void removeActionListener(java.awt.event.ActionListener al)
           
 void removeFocusListener(java.awt.event.FocusListener fl)
           
 void removeHelpListener(java.awt.event.ActionListener fl)
          remove a listener for help events
 void removeMouseListener(java.awt.event.MouseListener ml)
           
 void setBackground(java.awt.Color bg)
          set the background, if null, then reset to default
 void setBounds(int x, int y, int width, int height)
          Set the bounds of Container
protected  void setDefaultSize()
          Called in the beginning to find out the default size (CSS+component)
 void setEnabled(boolean b)
           
 void setFocus()
          set the focus to this control
 void setFont(java.awt.Font f)
          Sets the content components font
 void setForeground(java.awt.Color bg)
          set the foreground
 void setHintText(java.lang.String text)
          set the hint text
 void setInputMode(java.lang.String inputmode)
          set the input mode attribute (from XForms)
 void setStyle(org.w3c.dom.css.CSSStyleDeclaration a_style)
          Apply a style to the component.
 void setVisible(boolean v)
          Set this drawing area visible.
 void setZoom(double zoom)
          Set's this components zoom (1.0 is the default).
protected  void sizeComponent(double zoom)
           
 void sizeComponent(double zoom, java.awt.Dimension size)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

style

protected org.w3c.dom.css.CSSStyleDeclaration style
The CSS for the main component


minSize

protected static final java.awt.Dimension minSize

currentZoom

protected double currentZoom
The current zoom level of this component (default = 1.00)


currentFont

protected java.awt.Font currentFont

defaultFont

protected java.awt.Font defaultFont

defaultSize

protected java.awt.Dimension defaultSize

defaultBGColor

protected java.awt.Color defaultBGColor
the default background color


hintText

protected java.lang.String hintText

content

public java.awt.Component content
the content component


fInputMode

protected java.lang.String fInputMode
Constructor Detail

ComponentBase

public ComponentBase()
Method Detail

setVisible

public void setVisible(boolean v)
Set this drawing area visible.

Parameters:
v - true=visible, false=invisible

setFont

public void setFont(java.awt.Font f)
Sets the content components font


setInputMode

public void setInputMode(java.lang.String inputmode)
set the input mode attribute (from XForms)


getEnabled

public boolean getEnabled()

setEnabled

public void setEnabled(boolean b)
Parameters:
b - Active or not active

getStyle

public org.w3c.dom.css.CSSStyleDeclaration getStyle()
Returns:
the CSSStyleDeclaration for the main component

getAddableComponent

public java.awt.Component getAddableComponent()

getSizableComponent

public java.awt.Component getSizableComponent()

getStylableComponent

public java.awt.Component getStylableComponent()

getComponent

public java.awt.Component getComponent()

getDefaultBackgroundColor

public java.awt.Color getDefaultBackgroundColor()
the default background color for this type of component null = transparent.


setBackground

public void setBackground(java.awt.Color bg)
set the background, if null, then reset to default


setForeground

public void setForeground(java.awt.Color bg)
set the foreground


setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Set the bounds of Container

Parameters:
x - X location
y - X location
width - X location
height - X location

getDefaultSize

public java.awt.Dimension getDefaultSize()
returns the default size, calculated in the beginning


getX

public int getX()
Returns:
The original coordinated, and the default size of component

getY

public int getY()

getWidth

public int getWidth()

getHeight

public int getHeight()

getSize

public java.awt.Dimension getSize()

getMinimumSize

public java.awt.Dimension getMinimumSize()
return the minimum size for this component at zoom level 1.0


addActionListener

public void addActionListener(java.awt.event.ActionListener al)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener al)

addFocusListener

public void addFocusListener(java.awt.event.FocusListener fl)

removeFocusListener

public void removeFocusListener(java.awt.event.FocusListener fl)

addMouseListener

public void addMouseListener(java.awt.event.MouseListener ml)

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener ml)

setFocus

public void setFocus()
set the focus to this control


setHintText

public void setHintText(java.lang.String text)
set the hint text


setZoom

public void setZoom(double zoom)
Set's this components zoom (1.0 is the default).


sizeComponent

protected void sizeComponent(double zoom)

sizeComponent

public void sizeComponent(double zoom,
                          java.awt.Dimension size)

setStyle

public void setStyle(org.w3c.dom.css.CSSStyleDeclaration a_style)
Apply a style to the component. It is not specified which style can be associated with the component. It can be CSS, but it can also be, non-visual description languages if need be. Example: Apply CSS style to component ALL RELATIVE/ABSOLUTE POSITIONING, BACKGROUND ALIGNMENT ETC is specified with CSS!


setDefaultSize

protected void setDefaultSize()
Called in the beginning to find out the default size (CSS+component)


getPreferredSize

public java.awt.Dimension getPreferredSize(java.awt.Component comp)
in AWT, we must do extra tricks to get the preferred size before the component is on screen


getFormatter

public CSSFormatter getFormatter()

addHelpListener

public void addHelpListener(java.awt.event.ActionListener fl)
add a listener for help events


removeHelpListener

public void removeHelpListener(java.awt.event.ActionListener fl)
remove a listener for help events



X-Smiles 1.2