org.zaval.lw
Class LwScroll

java.lang.Object
  |
  +--org.zaval.util.ValidationObject
        |
        +--org.zaval.lw.LwCanvas
              |
              +--org.zaval.lw.LwPanel
                    |
                    +--org.zaval.lw.LwScroll
All Implemented Interfaces:
Drawable, java.util.EventListener, Layoutable, LayoutContainer, LwActionListener, LwComponent, LwContainer, LwMouseListener, LwMouseMotionListener, PosInfo, PosListener, Validationable

public class LwScroll
extends LwPanel
implements LwActionListener, LwMouseListener, LwMouseMotionListener, PosInfo, PosListener

This is scrollbar component. The component is used as the scrollbar component in the scroll bar panel (LwScrollPan) or it can be used for other purposes. The following resources are used with the component:

The scrollbar component defines a value that should be less than certain maximal value and cannot be less zero. The maximal possible value and the current value are defined with a pos controller of the component. Use getMaxOffset, setMaxOffset methods of the component and getOffset, setOffset methods of the pos controller to control the scrollbar properties. The sample below illustrates the scrollbar properties usage:

   ...
   LwScroll scroll = new LwScroll(LwToolkit.VERTICAL);
   scroll.setMaxOffset(100); // Setting the maximal posiible value of the scrollbar
   scroll.getPosController().getOffset();    // Getting the current value of the scrollbar
   scroll.getPosController().setOffset(10);  // Setting the current value of the scrollbar
   ...
 

A user can interact with the component using following actions:

To control "unitIncrement" and "pageIncrement" properties use setPageIncremet and setUnitIncremet methods.

It is possible to change bundle element view using setBundleView method.


Fields inherited from class org.zaval.lw.LwPanel
children
 
Fields inherited from class org.zaval.lw.LwCanvas
bits, height, insets, parent, psHeight, psWidth, skins, width, x, y
 
Fields inherited from class org.zaval.util.ValidationObject
isValidFlag
 
Constructor Summary
LwScroll(int t)
          Constructs a scrollbar component with the specified orientation.
 
Method Summary
 void actionPerformed(LwActionEvent e)
          Invoked when an action event occured.
 void endDragged(LwMouseMotionEvent e)
          Invoked when the mouse ends dragged.
protected  LwLayout getDefaultLayout()
          Gets the default layout manager that is set with the container during initialization.
 int getExtraSize()
           
 int getLines()
          Gets the number of lines.
 int getLineSize(int line)
          Gets the line size for the specified line number.
 int getMaxOffset()
          Gets the maximal offset.
 PosController getPosController()
          Gets the position controller.
 void mouseClicked(LwMouseEvent e)
          Invoked when the mouse button has been clicked on a light weight component.
 void mouseDragged(LwMouseMotionEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(LwMouseEvent e)
          Invoked when the mouse enters a light weight component.
 void mouseExited(LwMouseEvent e)
          Invoked when the mouse exits a light weight component.
 void mouseMoved(LwMouseMotionEvent e)
          Invoked when the mouse pointer has been moved on a light weight component (with no buttons no down).
 void mousePressed(LwMouseEvent e)
          Invoked when the mouse button has been pressed on a light weight component.
 void mouseReleased(LwMouseEvent e)
          Invoked when the mouse button has been released on a light weight component.
 void paint(java.awt.Graphics g)
          Paints this drawable component.
 void posChanged(PosEvent e)
          Invoked when a virtual position has been changed.
 void setBundleSize(int s)
          Sets the bundle size.
 void setBundleView(LwView v)
          Sets the bundle view.
 void setExtraSize(int e)
           
 void setMaximum(int m)
          Sets the specified maximal value for the scrollbar component.
 void setPageIncrement(int pi)
          Sets the page increment value.
 void setPosController(PosController p)
          Sets the specified position controller.
 void setUnitIncrement(int li)
          Sets the unit increment value.
 void startDragged(LwMouseMotionEvent e)
          Invoked when the mouse starts dragged.
 
Methods inherited from class org.zaval.lw.LwPanel
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, indexOf, insert, insert, invalidate, paintOnTop, recalc, remove, remove, removeAll, setBackground, setLwLayout, setOpaque, toFront, updateCashedPs
 
Methods inherited from class org.zaval.lw.LwCanvas
canHaveFocus, getBackground, getBounds, getHeight, getInsets, getLocation, getLwParent, getOrigin, getPreferredSize, getSize, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isVisible, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setSize, setViewMan, setVisible, toString, update, validate, viewManChanged, vrp
 
Methods inherited from class org.zaval.util.ValidationObject
isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zaval.lw.LwComponent
canHaveFocus, getLwParent, getViewMan, getVisiblePart, setEnabled, setLwParent, setViewMan, setVisible
 
Methods inherited from interface org.zaval.lw.Drawable
getBackground, getOrigin, isEnabled, isOpaque, repaint, repaint, update
 
Methods inherited from interface org.zaval.util.Validationable
isValid, validate
 
Methods inherited from interface org.zaval.lw.Layoutable
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize
 

Constructor Detail

LwScroll

public LwScroll(int t)
Constructs a scrollbar component with the specified orientation. The orientation value can be LwToolkit.VERTICAL or LwToolkit.HORIZONTAL, otherwise the IllegalArgumentException will be thrown.
Parameters:
t - the specified orientation.
Method Detail

setMaximum

public void setMaximum(int m)
Sets the specified maximal value for the scrollbar component. The scrollbar value cannot be more than the maximal value, so the method sets the current value to maximal value if the current value is more than the new maximal value.
Parameters:
m - the specified maximal value.

setBundleSize

public void setBundleSize(int s)
Sets the bundle size. The size is a bundle with if this is horizontal scrollbar or a bundle height if this is vertical scrollbar.
Parameters:
s - the specified bundle size.

setPageIncrement

public void setPageIncrement(int pi)
Sets the page increment value. The value is used to decrease or increase the scrollbar value whenever a mouse button has been pressed inside the component area.
Parameters:
pi - the specified page increment.

setUnitIncrement

public void setUnitIncrement(int li)
Sets the unit increment value. The value is used to decrease or increase the scrollbar value whenever one of the scrollbar button has been pressed.
Parameters:
li - the specified unit increment.

setBundleView

public void setBundleView(LwView v)
Sets the bundle view. The view is used to reneder the bundle element of the scrollbar component.
Parameters:
v - the specified bundle view.

setPosController

public void setPosController(PosController p)
Sets the specified position controller. The controller is used to control the scrollbar value.
Parameters:
p - the specified position controller.

getPosController

public PosController getPosController()
Gets the position controller.
Returns:
a position controller.

paint

public void paint(java.awt.Graphics g)
Description copied from interface: Drawable
Paints this drawable component.
Overrides:
paint in class LwCanvas
Following copied from interface: org.zaval.lw.Drawable
Parameters:
g - the graphics context to be used for painting.

actionPerformed

public void actionPerformed(LwActionEvent e)
Description copied from interface: LwActionListener
Invoked when an action event occured. The specified action event is passed to the method.
Specified by:
actionPerformed in interface LwActionListener
Following copied from interface: org.zaval.lw.event.LwActionListener
Parameters:
e - the specified action event.

mouseClicked

public void mouseClicked(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been clicked on a light weight component.
Specified by:
mouseClicked in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseEntered

public void mouseEntered(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse enters a light weight component.
Specified by:
mouseEntered in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseExited

public void mouseExited(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse exits a light weight component.
Specified by:
mouseExited in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseReleased

public void mouseReleased(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been released on a light weight component.
Specified by:
mouseReleased in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

mouseMoved

public void mouseMoved(LwMouseMotionEvent e)
Description copied from interface: LwMouseMotionListener
Invoked when the mouse pointer has been moved on a light weight component (with no buttons no down).
Specified by:
mouseMoved in interface LwMouseMotionListener
Following copied from interface: org.zaval.lw.event.LwMouseMotionListener
Parameters:
e - the specified mouse motion event.

startDragged

public void startDragged(LwMouseMotionEvent e)
Description copied from interface: LwMouseMotionListener
Invoked when the mouse starts dragged.
Specified by:
startDragged in interface LwMouseMotionListener
Following copied from interface: org.zaval.lw.event.LwMouseMotionListener
Parameters:
e - the specified mouse motion event.

endDragged

public void endDragged(LwMouseMotionEvent e)
Description copied from interface: LwMouseMotionListener
Invoked when the mouse ends dragged.
Specified by:
endDragged in interface LwMouseMotionListener
Following copied from interface: org.zaval.lw.event.LwMouseMotionListener
Parameters:
e - the specified mouse motion event.

mouseDragged

public void mouseDragged(LwMouseMotionEvent e)
Description copied from interface: LwMouseMotionListener
Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).
Specified by:
mouseDragged in interface LwMouseMotionListener
Following copied from interface: org.zaval.lw.event.LwMouseMotionListener
Parameters:
e - the specified mouse motion event.

mousePressed

public void mousePressed(LwMouseEvent e)
Description copied from interface: LwMouseListener
Invoked when the mouse button has been pressed on a light weight component.
Specified by:
mousePressed in interface LwMouseListener
Following copied from interface: org.zaval.lw.event.LwMouseListener
Parameters:
e - the specified mouse event.

posChanged

public void posChanged(PosEvent e)
Description copied from interface: PosListener
Invoked when a virtual position has been changed.
Specified by:
posChanged in interface PosListener
Following copied from interface: org.zaval.misc.event.PosListener
Parameters:
e - the specified pos event.

getLines

public int getLines()
Description copied from interface: PosInfo
Gets the number of lines.
Specified by:
getLines in interface PosInfo
Following copied from interface: org.zaval.misc.PosInfo
Returns:
a number of lines.

getLineSize

public int getLineSize(int line)
Description copied from interface: PosInfo
Gets the line size for the specified line number.
Specified by:
getLineSize in interface PosInfo
Following copied from interface: org.zaval.misc.PosInfo
Parameters:
line - the specified line number.
Returns:
a size of the line.

getMaxOffset

public int getMaxOffset()
Description copied from interface: PosInfo
Gets the maximal offset. The method can return -1 as the result, in this case the pos controller that uses the pos info will try to calculate the maximal offset itself basing on the line number and the lines sizes.
Specified by:
getMaxOffset in interface PosInfo
Following copied from interface: org.zaval.misc.PosInfo
Returns:
a maximal offset.

getExtraSize

public int getExtraSize()

setExtraSize

public void setExtraSize(int e)

getDefaultLayout

protected LwLayout getDefaultLayout()
Description copied from class: LwPanel
Gets the default layout manager that is set with the container during initialization. This implementation of the method returns LwRastLayout as the default layout manager, the layout manager is got as a static object by "layout.raster" key.
Overrides:
getDefaultLayout in class LwPanel
Following copied from class: org.zaval.lw.LwPanel
Returns:
a layout manager.


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org