Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Nebula SegmentedBar

< Back to Nebula Main Page

Introduction

Segmentedbar.png

A widget that displays a horizontal bar that visualizes the segmentation of a total value. It consists of several segments, each segment representing a value. The sum of all values is the total value of the bar.

Usage

The first thing to do is to instantiate the widget, then you add segment(s) (by calling the methods setSegments or addSegment).

SegmentedBar sb1 = new SegmentedBar(shell, SWT.NONE);
sb1.addSegment(Segment.create().setBackground(blue).setValue(10d));
sb1.addSegment(Segment.create().setBackground(blue).setValue(10d));
sb1.addSegment(Segment.create().setBackground(blue).setValue(10d));
sb1.addSegment(Segment.create().setBackground(blue).setValue(20d));
sb1.addSegment(Segment.create().setBackground(blue).setValue(50d));

The spacing between different segments can changed by using the method setSpacing on the SegmentedBar widget.


You can customize also a segment :

  • Specify a text : setText()
  • Specify a tooltip : setTooltip()
  • Specify a numeric (Double) value : setValue()
  • Specify a font : setFont()
  • Specify a background color : setBackground()
  • Specify a foreground color (for the text) : setForeground()


You can also store data : setData(Object value) and setData(String key, Object value)

Segment is based on the Builder pattern, so you chain setters.

Example

An example called SegmentedBarSnippet.java is located in the plugin org.eclipse.nebula.widgets.segmentedbar.snippets.

This example is also available here : SegmentedBarSnippet.java

Copyright © Eclipse Foundation, Inc. All Rights Reserved.