Skip to main content

Class JtvColorGroupList

public class JtvColorGroupList
extends JtvListViewer

A list viewer that displays the colour groups in a JtvColorDialog.

TColorGroupList shows the top-level colour categories (e.g., "Desktop", "Menus") from a list of JtvColorGroup objects. When the user focuses a group, this viewer broadcasts cmNewColorItem so the companion JtvColorItemList can update itself to show that group's items.

When a cmSaveColorIndex broadcast is received, the viewer stores the currently focused item index back into the active group's JtvColorGroup.index so the selection can be restored later.

org.viktor44.jtvision.dialogs.JtvColorGroupList

Summary​

Constructors​

VisibilitySignature
publicJtvColorGroupList(JtvRect bounds, JtvScrollBar aScrollBar, List<org.viktor44.jtvision.dialogs.JtvColorGroup> aGroups)

Fields​

ModifiersField nameType
privategroupsList<org.viktor44.jtvision.dialogs.JtvColorGroup>

Methods​

ModifiersMethod signatureReturn type
publicaddGroup(JtvColorGroup item)org.viktor44.jtvision.dialogs.JtvColorGroupList
publicfocusItem(int item)void
publicgetText(int item, int maxLen)String
publichandleEvent(JtvEvent ev)void
publicsetGroupIndex(int groupNum, int itemNum)void
publicgetGroup(int groupNum)org.viktor44.jtvision.dialogs.JtvColorGroup
publicgetGroupIndex(int groupNum)int
publicgetNumGroups()int

Constructors​

JtvColorGroupList(JtvRect bounds, JtvScrollBar aScrollBar, List<org.viktor44.jtvision.dialogs.JtvColorGroup> aGroups)​

Creates a colour group list with the given bounds, scroll bar, and group list.

Parameters

  • bounds - the bounding rectangle
  • aScrollBar - the vertical scroll bar
  • aGroups - the list of colour groups

Fields​

List<org.viktor44.jtvision.dialogs.JtvColorGroup> groups​

The list of JtvColorGroup objects to display.

Methods​

addGroup(JtvColorGroup item)​

Adds item to the group list, updates the range, and returns this list for chaining.

Parameters

  • item - the group to add

Returns

this list

focusItem(int item)​

Overrides:

focusItem(int item) in org.viktor44.jtvision.views.JtvListViewer

Focuses item item and broadcasts cmNewColorItem with the corresponding JtvColorGroup so the item list updates.

Parameters

  • item - the zero-based group index to focus

getText(int item, int maxLen)​

Overrides:

getText(int item, int maxLen) in org.viktor44.jtvision.views.JtvListViewer

Returns the display name of the group at position item, truncated to maxLen characters.

Parameters

  • item - the zero-based group index
  • maxLen - the maximum number of characters to return

Returns

the group name, or an empty string if out of range

handleEvent(JtvEvent ev)​

Handles cmSaveColorIndex broadcasts by persisting the item index from the event into the currently focused group.

Parameters

  • ev - the incoming event

setGroupIndex(int groupNum, int itemNum)​

Stores item index itemNum into the JtvColorGroup.index of group groupNum.

Parameters

  • groupNum - the zero-based group index
  • itemNum - the item index to store

getGroup(int groupNum)​

Returns the JtvColorGroup at position groupNum in the list.

Parameters

  • groupNum - the zero-based group index

Returns

the group, or null if out of range

getGroupIndex(int groupNum)​

Returns the stored focused-item index for the group at groupNum.

Parameters

  • groupNum - the zero-based group index

Returns

the saved item index, or 0 if the group does not exist

getNumGroups()​

Returns the total number of groups in the list.

Returns

the group count