Class SegmentedBar<T extends SegmentedBar.Segment>

  • Type Parameters:
    T - the segment type
    All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    public class SegmentedBar<T extends SegmentedBar.Segment>
    extends Control
    A control that makes it easy to create 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 (see totalProperty()). The bar can be customized by setting a factory for the creation of the segment views. Another factory can be set for for the creation of info nodes shown by a PopOver.
    Segmented Bar

    Example 1:

    The most basic version of the bar. It is using the default segment view factory.
     SegmentedBar bar = new SegmentedBar();
     bar.getSegments().addAll(
         new Segment(10, "10"),
         new Segment(10, "10"),
         new Segment(10, "10"),
         new Segment(10, "10"),
         new Segment(10, "10"),
         new Segment(50, "50"));
     

    Example 1:

    In this example the bar is used to visualize the usage of disk space for various media types (photos, videos, music, ...). A special info node factory is supplied to present a useful detailed description of the segment. The type "TypeSegment" is a subclass of SegmentedBar.Segment
     typesBar.setSegmentViewFactory(segment -> new TypeSegmentView(segment));
     typesBar.setInfoNodeFactory(segment -> new InfoLabel(segment.getText() + " " + segment.getValue() + " GB"));
     typesBar.getSegments().addAll(
         new TypeSegment(14, MediaType.PHOTOS),
         new TypeSegment(32, MediaType.VIDEO),
         new TypeSegment(9, MediaType.APPS),
         new TypeSegment(40, MediaType.MUSIC),
         new TypeSegment(5, MediaType.OTHER),
         new TypeSegment(35, MediaType.FREE));
     
    See Also:
    setSegmentViewFactory(Callback), setInfoNodeFactory(Callback)