org.zaval.lw
Class LwScroll
java.lang.Object
|
+--org.zaval.lw.LwCanvas
|
+--org.zaval.lw.LwPanel
|
+--org.zaval.lw.LwScroll
- All Implemented Interfaces:
- java.util.EventListener, Layoutable, LayoutContainer, LwActionListener, LwComponent, LwComposite, LwContainer, LwLayout, LwMouseListener, LwMouseMotionListener, PosInfo, PosListener, Validationable
- public class LwScroll
- extends LwPanel
- implements LwActionListener, LwMouseListener, LwMouseMotionListener, PosInfo, PosListener, LwLayout, LwComposite
This is scrollbar component. The component is used as the vertical and horizontal scrolls by the scroll
bar panel (LwScrollPan). The component reads the following resources:
- "scroll.hbg" - this is a background view of the horizontal scrollbar
- "scroll.vbg" - this is a background view of the vertical scrollbar
-
"sb.b.out", "sb.b.over", "sb.b.disabled", "sb.b.pressed" -
these are the lower button face views of the vertical scrollbar
-
"sb.t.out", "sb.t.over", "sb.t.disabled", "sb.t.pressed" -
these are the upper button face views of the vertical scrollbar
-
"sb.l.out", "sb.l.over", "sb.l.disabled", "sb.l.pressed" -
these are the left button face views of the horizontal scrollbar
-
"sb.r.out", "sb.r.over", "sb.r.disabled", "sb.r.pressed" -
these are the right button face views of the horizontal scrollbar
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 by
a pos controller of the component. Use the getMaxOffset, setMaxOffset
methods of the component and the 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:
-
By pressing the scrollbar buttons. In this case, the component uses "unitIncrement" value to
increase or decrease the value property.
-
By pressing a mouse button inside the scrollbar area. In this case "pageIncrement" value is
used to increase or decrease the scrollbar value property.
-
By dragging the scrollbar bundle element. In this case the scrollbar value will be
calculated basing on the current bundle location.
To control "unitIncrement" and "pageIncrement" properties use the setPageIncremet
and setUnitIncremet methods.
The component is a container that implements own layout manager. Use the defined by the component
constraints to customize the container elements.
|
Field Summary |
static java.lang.Integer |
BUNDLE_EL
The bundle element constraint. |
static java.lang.Integer |
DECBUTTON_EL
The decrement button element constraint. |
static java.lang.Integer |
INCBUTTON_EL
The increment button element constraint. |
| Fields inherited from class org.zaval.lw.LwCanvas |
bits, bottom, height, isValidValue, left, parent, psHeight, psWidth, right, skins, temporary, top, width, x, y |
|
Constructor Summary |
LwScroll(int t)
Constructs a scrollbar component with the specified orientation.
|
| Methods inherited from class org.zaval.lw.LwPanel |
add, add, calcPreferredSize, count, get, getLayoutOffset, getLwComponentAt, getLwLayout, getPreferredSize, indexOf, insert, insert, invalidate, isInvalidatedByChild, laidout, paintOnTop, remove, remove, removeAll, setBackground, setLwLayout, setOpaque, setSize, toFront, updateCashedPs, validate |
| Methods inherited from class org.zaval.lw.LwCanvas |
calcInsets, canHaveFocus, customize, cvp, getBackground, getBottom, getBounds, getHeight, getInsets, getLeft, getLocation, getLwParent, getOrigin, getPSImpl, getRight, getSize, getTop, getViewMan, getVisiblePart, getWidth, getX, getY, hasFocus, isEnabled, isOpaque, isValid, isVisible, paint, recalc, repaint, repaint, repaint, requestFocus, setEnabled, setInsets, setLocation, setLwParent, setPSSize, setViewMan, setVisible, update, viewManChanged, vrp |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.zaval.lw.LwComponent |
canHaveFocus, getBackground, getLwComponentAt, getLwParent, getOrigin, getViewMan, getVisiblePart, isEnabled, isOpaque, paint, repaint, repaint, repaint, setBackground, setEnabled, setInsets, setLwParent, setOpaque, setViewMan, setVisible, update |
| Methods inherited from interface org.zaval.lw.Layoutable |
getBounds, getHeight, getInsets, getLocation, getPreferredSize, getSize, getWidth, getX, getY, isVisible, setLocation, setSize |
BUNDLE_EL
public static final java.lang.Integer BUNDLE_EL
- The bundle element constraint.
INCBUTTON_EL
public static final java.lang.Integer INCBUTTON_EL
- The increment button element constraint.
DECBUTTON_EL
public static final java.lang.Integer DECBUTTON_EL
- The decrement button element constraint.
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.
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.
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.
getPageIncrement
public int getPageIncrement()
- Gets the page increment value.
- Returns:
- a page increment value.
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.
getUnitIncrement
public int getUnitIncrement()
- Gets the unit increment value.
- Returns:
- a unit increment value.
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.
actionPerformed
public void actionPerformed(java.lang.Object src,
java.lang.Object data)
- Description copied from interface:
LwActionListener
- Invoked when an action event occurred.
- Specified by:
actionPerformed in interface LwActionListener
- Following copied from interface:
org.zaval.lw.event.LwActionListener
- Parameters:
src - the specified source where the event has been originated.data - the event data.
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(LwMouseEvent 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 event.
startDragged
public void startDragged(LwMouseEvent 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 event.
endDragged
public void endDragged(LwMouseEvent 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 event.
mouseDragged
public void mouseDragged(LwMouseEvent 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 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(java.lang.Object target,
int po,
int pl,
int pc)
- 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:
target - the specified pos controller.prevOffset - the previous offset.prevLine - the previous line.prevColumn - the previous column.
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()
- Get the extra size.
- Returns:
- an extra size.
setExtraSize
public void setExtraSize(int e)
- Sets the extra size. By the size it is possible to control bundle size depending on the maximal possible
size.
- Parameters:
e - the given extra size.
componentAdded
public void componentAdded(java.lang.Object id,
Layoutable lw,
int index)
- Description copied from interface:
LwLayout
- Invoked when the specified layoutable component was added to the layout container
(that uses the layout manager). The specified constraints, layoutable component
and child index are passed as arguments into the method.
- Specified by:
componentAdded in interface LwLayout
- Following copied from interface:
org.zaval.lw.LwLayout
- Parameters:
id - the layoutable component constraints.lw - the layoutable component that has been added.index - the child index.
componentRemoved
public void componentRemoved(Layoutable lw,
int index)
- Description copied from interface:
LwLayout
- Invoked when the specified layoutable component was removed from the layout
container, that uses the layout manager.
- Specified by:
componentRemoved in interface LwLayout
- Following copied from interface:
org.zaval.lw.LwLayout
- Parameters:
lw - the layoutable component that has been removed.index - the child component index.
calcPreferredSize
public java.awt.Dimension calcPreferredSize(LayoutContainer target)
- Description copied from interface:
LwLayout
- Calculates the preferred size dimension for the layout container.
The method has to calculate "pure" preferred size, it means that container insets
should not be taken into account.
- Specified by:
calcPreferredSize in interface LwLayout
- Following copied from interface:
org.zaval.lw.LwLayout
- Parameters:
target - the layout container.- Returns:
- a "pure" preferred size.
layout
public void layout(LayoutContainer target)
- Description copied from interface:
LwLayout
- Lays out the child layoutable components inside the layout container.
- Specified by:
layout in interface LwLayout
- Following copied from interface:
org.zaval.lw.LwLayout
- Parameters:
target - the layout container.
catchInput
public boolean catchInput(LwComponent child)
- Description copied from interface:
LwComposite
- Checks if the input event for the specified child component should be caught by the parent.
- Specified by:
catchInput in interface LwComposite
- Following copied from interface:
org.zaval.lw.LwComposite
- Parameters:
child - the specified child component.- Returns:
true if input events for the child component should be caught by this
component; false otherwise.
getElement
public LwComponent getElement(java.lang.Object key)
- Gets the element of the scroll bar by the given constraint. Using the method it is possible
to get bundle, increment or decrement buttons components.
- Parameters:
key - the specified constraint. Use the BUNDLE_EL, INCBUTTON_EL, DECBUTTON_EL
constants as the argument value.- Returns:
- an element.
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 "def.lay" key.
- Overrides:
getDefaultLayout in class LwPanel
- Following copied from class:
org.zaval.lw.LwPanel
- Returns:
- a layout manager.
|