Crossfire JXClient, Trunk
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement > Class Template Referenceabstract
Inheritance diagram for com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >:
Inheritance graph
Collaboration diagram for com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >:
Collaboration graph

Classes

class  Rec
 

Public Member Functions

boolean canMoveSelection (final int diffLines, final int diffElements)
 
boolean canScroll (final int distance)
 
void dispose ()
 
void execute ()
 
getElement (final int index)
 
Dimension getMaximumSize ()
 
Dimension getMinimumSize ()
 
Dimension getPreferredSize ()
 
TooltipText getTooltip ()
 
void mouseClicked (@NotNull final MouseEvent e)
 
void mouseDragged (@NotNull final MouseEvent e)
 
void mouseEntered (@NotNull final MouseEvent e)
 
void mouseExited (@NotNull final MouseEvent e)
 
void mouseMoved (@NotNull final MouseEvent e)
 
void mousePressed (@NotNull final MouseEvent e)
 
void mouseWheelMoved (final int wheelRotation)
 
void moveSelection (final int diffLines, final int diffElements)
 
void resetScroll ()
 
void scroll (final int distance)
 
void setBounds (final int x, final int y, final int width, final int height)
 
void setChanged ()
 
- Public Member Functions inherited from com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement
void activateNextElement ()
 
void activatePrevElement ()
 
boolean isActive ()
 
void setActive (final boolean active)
 
void setNextActive (@NotNull final ActivatableGUIElement next)
 
void setPrevActive (@NotNull final ActivatableGUIElement prev)
 
- Public Member Functions inherited from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement
int getDialogBorderBottom ()
 
int getDialogBorderLeft ()
 
int getDialogBorderRight ()
 
int getDialogBorderTop ()
 
String getName ()
 
void inhibitListeners ()
 
boolean isDefault ()
 
boolean isIgnore ()
 
void mouseReleased (@NotNull final MouseEvent e)
 
void setChangedListener (@Nullable final GUIElementChangedListener changedListener)
 
void setDefault (final boolean isDefault)
 
void setIgnore ()
 
String toString ()
 
- Public Member Functions inherited from com.realtime.crossfire.jxclient.gui.gui.GUIElement
void notifyOpen ()
 

Protected Member Functions

void addElement (@NotNull final T element)
 
Object getSelectedObject ()
 
abstract String getTooltip (final int index)
 
 GUIList (@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, final int cellWidth, final int cellHeight, @NotNull final GUIListCellRenderer< T > listCellRenderer, @Nullable final CommandList doubleClickCommandList, @NotNull final GuiFactory guiFactory)
 
int resizeElements (final int newSize)
 
void selectionChanged ()
 
abstract void selectionChanged (final int selectedIndex)
 
void setLayoutOrientation (final int layoutOrientation, final int visibleRowCount)
 
void setSelectedIndex (final int newIndex)
 
- Protected Member Functions inherited from com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement
 ActivatableGUIElement (@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, final boolean opaque, @NotNull final GuiFactory guiFactory)
 
abstract void activeChanged ()
 
void markInactivePending ()
 
void setInactiveIfPending ()
 
- Protected Member Functions inherited from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement
 AbstractGUIElement (@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, final boolean opaque, @NotNull final GuiFactory guiFactory)
 
TooltipText newTooltipText (@Nullable final String tooltipText)
 
void tooltipChanged ()
 

Private Member Functions

void doSelect (@NotNull final MouseEvent e)
 
void doTooltip (@NotNull final MouseEvent e)
 
Rec getIndex (@NotNull final MouseEvent e)
 

Private Attributes

final int cellHeight
 
final CommandList doubleClickCommandList
 
final GuiFactory guiFactory
 
final JList< T > list = new JList<>(model)
 
final GUIListCellRenderer<? extends T > listCellRenderer
 
final ListSelectionListener listSelectionListener = e -> selectionChanged()
 
final DefaultListModel< T > model = new DefaultListModel<>()
 
final JScrollPane scrollPane
 
int tooltipIndex = -1
 
Rectangle tooltipRectangle
 
final GUIListViewport viewport = new GUIListViewport()
 

Static Private Attributes

static final long serialVersionUID = 1
 

Detailed Description

A GUIElement that displays a list of entries.

Parameters
<T>the type of the list elements
Author
Andreas Kirschbaum

Definition at line 56 of file GUIList.java.

Constructor & Destructor Documentation

◆ GUIList()

com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.GUIList ( @NotNull final TooltipManager  tooltipManager,
@NotNull final GUIElementListener  elementListener,
@NotNull final String  name,
final int  cellWidth,
final int  cellHeight,
@NotNull final GUIListCellRenderer< T >  listCellRenderer,
@Nullable final CommandList  doubleClickCommandList,
@NotNull final GuiFactory  guiFactory 
)
protected

Creates a new instance.

Parameters
tooltipManagerthe tooltip manager to update
elementListenerthe element listener to notify
namethe name of this element
cellWidththe width of each cell
cellHeightthe height of each cell
listCellRendererthe renderer for the list
doubleClickCommandListthe command list to execute on double-click or
null
to ignore double-clicks
guiFactorythe global GUI factory instance

Definition at line 141 of file GUIList.java.

Member Function Documentation

◆ addElement()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.addElement ( @NotNull final T  element)
protected

Adds an GUIElement to the list.

Parameters
elementthe element to add

Definition at line 195 of file GUIList.java.

◆ canMoveSelection()

boolean com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.canMoveSelection ( final int  diffLines,
final int  diffElements 
)

Returns whether the selection can be moved.

Parameters
diffLinesthe distance in lines to move
diffElementsthe distance in elements to move
Returns
whether moving is possible

Definition at line 239 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.commands.MoveSelectionCommand.canExecute(), and com.realtime.crossfire.jxclient.gui.commands.MoveSelectionCommand.execute().

Here is the caller graph for this function:

◆ canScroll()

boolean com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.canScroll ( final int  distance)

Returns whether the list can be scrolled.

Parameters
distancethe distance to scroll
Returns
whether scrolling is possible

Implements com.realtime.crossfire.jxclient.gui.scrollable.GUIScrollable.

Definition at line 306 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.commands.MoveSelectionCommand.canExecute().

Here is the caller graph for this function:

◆ dispose()

Releases all allocated resources.

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.

Definition at line 173 of file GUIList.java.

◆ doSelect()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.doSelect ( @NotNull final MouseEvent  e)
private

Selects the list entry corresponding to a MouseEvent instance.

Parameters
ethe mouse event instance

Definition at line 439 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.mouseClicked(), com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.mouseDragged(), and com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.mousePressed().

Here is the caller graph for this function:

◆ doTooltip()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.doTooltip ( @NotNull final MouseEvent  e)
private

Updates the tooltip text corresponding to a MouseEvent instance.

Parameters
ethe mouse event instance

Definition at line 452 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.mouseEntered(), com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.mouseExited(), and com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.mouseMoved().

Here is the caller graph for this function:

◆ execute()

Executes the actions associated with this GUI element. Does nothing if this element has no associated actions.

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement.

Definition at line 558 of file GUIList.java.

◆ getElement()

T com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.getElement ( final int  index)

Returns the GUIElement for a given index.

Parameters
indexthe index
Returns
the gui element

Definition at line 187 of file GUIList.java.

◆ getIndex()

Rec com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.getIndex ( @NotNull final MouseEvent  e)
private

Returns the list item from a mouse event.

Parameters
ethe mouse event
Returns
the list item or
null
for none

Definition at line 474 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.doSelect(), and com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.doTooltip().

Here is the caller graph for this function:

◆ getMaximumSize()

Dimension com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.getMaximumSize ( )

Definition at line 608 of file GUIList.java.

◆ getMinimumSize()

Dimension com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.getMinimumSize ( )

Definition at line 602 of file GUIList.java.

◆ getPreferredSize()

Dimension com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.getPreferredSize ( )

Definition at line 596 of file GUIList.java.

◆ getSelectedObject()

Object com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.getSelectedObject ( )
protected

Returns the selected list object.

Returns
the selected object or
null
if none is selected

Definition at line 588 of file GUIList.java.

◆ getTooltip() [1/2]

Returns the current tooltip text.

Returns
the tooltip text or
null
to not show a tooltip

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.

Definition at line 536 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.getTooltip().

Here is the caller graph for this function:

◆ getTooltip() [2/2]

abstract String com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.getTooltip ( final int  index)
abstractprotected

Returns the tooltip text.

Parameters
indexthe index to use
Returns
the tooltip text

◆ mouseClicked()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.mouseClicked ( @NotNull final MouseEvent  e)

Will be called when the user has clicked (pressed+released) this element. This event will be delivered after mouseReleased(MouseEvent).

Parameters
ethe mouse event relative to this element

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.

Definition at line 379 of file GUIList.java.

◆ mouseDragged()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.mouseDragged ( @NotNull final MouseEvent  e)

Will be called when the mouse moves within this component while the button is pressed. This event will be delivered after mouseMoved(MouseEvent).

Note: if the mouse leaves this element's bounding box while the mouse button is still pressed, further

(but no

) events will be generated.

Parameters
ethe mouse event relative to this element

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.

Definition at line 422 of file GUIList.java.

◆ mouseEntered()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.mouseEntered ( @NotNull final MouseEvent  e)

Will be called when the mouse has entered the bounding box of this element.

Parameters
ethe mouse event relative to this element

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.

Definition at line 390 of file GUIList.java.

◆ mouseExited()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.mouseExited ( @NotNull final MouseEvent  e)

Will be called when the mouse has left the bounding box of this element. This function will not be called unless mouseEntered(MouseEvent) has been called before.

Parameters
ethe mouse event relative to this element

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.

Definition at line 398 of file GUIList.java.

◆ mouseMoved()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.mouseMoved ( @NotNull final MouseEvent  e)

Will be called when the mouse moves within this component. before.

Parameters
ethe mouse event relative to this element

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.

Definition at line 414 of file GUIList.java.

◆ mousePressed()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.mousePressed ( @NotNull final MouseEvent  e)

Will be called when the user has pressed the mouse inside this element.

Parameters
ethe mouse event relative to this element

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement.

Definition at line 406 of file GUIList.java.

◆ mouseWheelMoved()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.mouseWheelMoved ( final int  wheelRotation)

Will be called when the mouse wheel has been moved.

Parameters
wheelRotationthe movement amount; negative=away from the user, positive=towards the user

Reimplemented from com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.

Definition at line 430 of file GUIList.java.

◆ moveSelection()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.moveSelection ( final int  diffLines,
final int  diffElements 
)

Moves the selection.

Parameters
diffLinesthe distance in lines to move
diffElementsthe distance in elements to move

Definition at line 269 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.commands.MoveSelectionCommand.execute().

Here is the caller graph for this function:

◆ resetScroll()

Resets the scroll index to the default value.

Implements com.realtime.crossfire.jxclient.gui.scrollable.GUIScrollable.

Definition at line 374 of file GUIList.java.

◆ resizeElements()

int com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.resizeElements ( final int  newSize)
protected

Changes the number of list elements. If the new element count is less than the current count, excess elements are cut off. Otherwise, the caller has to add elements with addElement(GUIElement).

Parameters
newSizethe new element count
Returns
the number of elements to add by the caller

Definition at line 212 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.dispose().

Here is the caller graph for this function:

◆ scroll()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.scroll ( final int  distance)

Moves the list.

Parameters
distancethe distance to scroll

Implements com.realtime.crossfire.jxclient.gui.scrollable.GUIScrollable.

Definition at line 325 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.commands.MoveSelectionCommand.execute(), and com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.mouseWheelMoved().

Here is the caller graph for this function:

◆ selectionChanged() [1/2]

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.selectionChanged ( )
protected

Called whenever the selected list entry has changed.

Definition at line 516 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.selectionChanged().

Here is the caller graph for this function:

◆ selectionChanged() [2/2]

abstract void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.selectionChanged ( final int  selectedIndex)
abstractprotected

Called whenever the selected list entry has changed.

Parameters
selectedIndexthe selected list entry

◆ setBounds()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.setBounds ( final int  x,
final int  y,
final int  width,
final int  height 
)

Definition at line 613 of file GUIList.java.

◆ setChanged()

◆ setLayoutOrientation()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.setLayoutOrientation ( final int  layoutOrientation,
final int  visibleRowCount 
)
protected

Sets the layout orientation. See JList#setLayoutOrientation(int) and JList#setVisibleRowCount(int).

Parameters
layoutOrientationthe layout orientation
visibleRowCountthe number of visible rows

Definition at line 576 of file GUIList.java.

◆ setSelectedIndex()

void com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.setSelectedIndex ( final int  newIndex)
protected

Member Data Documentation

◆ cellHeight

final int com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.cellHeight
private

◆ doubleClickCommandList

final CommandList com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.doubleClickCommandList
private

◆ guiFactory

◆ list

final JList<T> com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.list = new JList<>(model)
private

◆ listCellRenderer

final GUIListCellRenderer<? extends T> com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.listCellRenderer
private

◆ listSelectionListener

final ListSelectionListener com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.listSelectionListener = e -> selectionChanged()
private

◆ model

final DefaultListModel<T> com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.model = new DefaultListModel<>()
private

◆ scrollPane

final JScrollPane com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.scrollPane
private

◆ serialVersionUID

final long com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.serialVersionUID = 1
staticprivate

The serial version UID.

Definition at line 61 of file GUIList.java.

◆ tooltipIndex

int com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.tooltipIndex = -1
private

The index of the currently shown tooltip. Set to

-1

if no tooltip is shown.

Definition at line 115 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.doTooltip(), and com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.getTooltip().

◆ tooltipRectangle

Rectangle com.realtime.crossfire.jxclient.gui.list.GUIList< T extends GUIElement >.tooltipRectangle
private

The location of the tooltip. Set to

null

if no tooltip is shown.

Definition at line 121 of file GUIList.java.

Referenced by com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.doTooltip(), and com.realtime.crossfire.jxclient.gui.list.GUIList< GUICharacter >.getTooltip().

◆ viewport


The documentation for this class was generated from the following file:
com.realtime.crossfire.jxclient.gui.list.GUIList.mouseDragged
void mouseDragged(@NotNull final MouseEvent e)
Definition: GUIList.java:422
com.realtime.crossfire.jxclient.gui.list.GUIList.mouseMoved
void mouseMoved(@NotNull final MouseEvent e)
Definition: GUIList.java:414