Class SegmentedBar
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.nebula.widgets.segmentedbar.SegmentedBar
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class SegmentedBar
extends org.eclipse.swt.widgets.Canvas
Instances of this class provide an horizontal bar that represents the segmentation of a total value.
It consists of several segments, each one associated to a value. The sum of all values is the total value of the bar.
It consists of several segments, each one associated to a value. The sum of all values is the total value of the bar.
- Styles:
- BORDER
- Events:
- (none)
-
Field Summary
Fields Modifier and Type Field Description (package private) int
currentX
(package private) org.eclipse.swt.graphics.GC
gc
(package private) boolean
isFirstItem
(package private) boolean
isLastItem
-
Constructor Summary
Constructors Constructor Description SegmentedBar(org.eclipse.swt.widgets.Composite parent, int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. -
Method Summary
Modifier and Type Method Description void
addSegment(Segment segment)
Add a segment to this widgetorg.eclipse.swt.graphics.Point
computeSize(int wHint, int hHint, boolean changed)
java.util.List<Segment>
getSegments()
Returns the list of all segmentsint
getSpacing()
Return the spacing between 2 segmentsdouble
getTotal()
Returns the total value of the bar (sum of segments values).void
removeSegment(Segment segment)
Remove a segment to this widgetvoid
setSegments(java.util.List<Segment> segments)
Sets the receiver's list of segmentsvoid
setSpacing(int spacing)
Sets the receiver's spacing between 2 segmentsMethods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Field Details
-
gc
org.eclipse.swt.graphics.GC gc -
currentX
int currentX -
isFirstItem
boolean isFirstItem -
isLastItem
boolean isLastItem
-
-
Constructor Details
-
SegmentedBar
public SegmentedBar(org.eclipse.swt.widgets.Composite parent, int style)Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.The style value is either one of the style constants defined in class
SWT
which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint
"|" operator) two or more of thoseSWT
style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.- Parameters:
parent
- a composite control which will be the parent of the new instance (cannot be null)style
- the style of control to construct- Throws:
java.lang.IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the parent is null
org.eclipse.swt.SWTException
-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
-
-
Method Details
-
getTotal
public double getTotal()Returns the total value of the bar (sum of segments values).- Returns:
- the total value of the bar (sum of segments values).
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getSegments
Returns the list of all segments- Returns:
- the list of all segments (may be empty)
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSegments
Sets the receiver's list of segments- Parameters:
segments
- the new list of segments- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- ERROR_NULL_ARGUMENT - if the list is null
-
getSpacing
public int getSpacing()Return the spacing between 2 segments- Returns:
- the spacing in pixels between 2 segments
- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setSpacing
public void setSpacing(int spacing)Sets the receiver's spacing between 2 segments- Parameters:
spacing
- new spacing between 2 segments- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- ERROR_INVALID_ARGUMENT - if the new value is lower than 0
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)- Overrides:
computeSize
in classorg.eclipse.swt.widgets.Control
- See Also:
Control.computeSize(int, int, boolean)
-
addSegment
Add a segment to this widget- Parameters:
segment
- segment to add- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- ERROR_NULL_ARGUMENT - if the segment is null
-
removeSegment
Remove a segment to this widget- Parameters:
segment
- segment to remove- Throws:
org.eclipse.swt.SWTException
-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
- ERROR_NULL_ARGUMENT - if the segment is null
-