Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Nebula SegmentedBar

Revision as of 11:42, 31 October 2020 by Laurent.caron.gmail.com (Talk | contribs) (Created page with "< Back to Nebula Main Page ==Introduction== File:Segmentedbar.png A widget that displays a horizontal bar that visualizes the segmentation of a total value....")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

< 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.