Crossfire JXClient, Trunk
GUIList.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff
19  * Copyright (C) 2006-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.gui.list;
24 
35 import java.awt.Adjustable;
36 import java.awt.Dimension;
37 import java.awt.Point;
38 import java.awt.Rectangle;
39 import java.awt.event.MouseEvent;
40 import javax.swing.DefaultListModel;
41 import javax.swing.JList;
42 import javax.swing.JScrollPane;
43 import javax.swing.JViewport;
44 import javax.swing.ListSelectionModel;
45 import javax.swing.ScrollPaneConstants;
46 import javax.swing.border.EmptyBorder;
47 import javax.swing.event.ListSelectionListener;
48 import org.jetbrains.annotations.NotNull;
49 import org.jetbrains.annotations.Nullable;
50 
56 public abstract class GUIList<T extends GUIElement> extends ActivatableGUIElement implements GUIScrollable {
57 
61  private static final long serialVersionUID = 1;
62 
66  private final int cellHeight;
67 
71  @NotNull
73 
78  @Nullable
80 
84  @NotNull
85  private final GuiFactory guiFactory;
86 
90  @NotNull
91  private final DefaultListModel<T> model = new DefaultListModel<>();
92 
96  @NotNull
97  private final JList<T> list = new JList<>(model);
98 
102  @NotNull
103  private final GUIListViewport viewport = new GUIListViewport();
104 
108  @NotNull
109  private final JScrollPane scrollPane;
110 
115  private int tooltipIndex = -1;
116 
120  @Nullable
121  private Rectangle tooltipRectangle;
122 
126  @NotNull
127  private final ListSelectionListener listSelectionListener = e -> selectionChanged();
128 
141  protected 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) {
143  this.cellHeight = cellHeight;
144  this.listCellRenderer = listCellRenderer;
145  this.doubleClickCommandList = doubleClickCommandList;
146  this.guiFactory = guiFactory;
147 
148  list.setCellRenderer(listCellRenderer);
149  list.setFixedCellWidth(cellWidth);
150  list.setFixedCellHeight(cellHeight);
151  list.setOpaque(false);
152  list.setFocusable(false);
153  list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
154  list.addListSelectionListener(listSelectionListener);
155 
156  viewport.setView(list);
157  viewport.setScrollMode(JViewport.BLIT_SCROLL_MODE);
158  viewport.setOpaque(false);
159  viewport.setFocusable(false);
160 
161  scrollPane = new JScrollPane(null, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
162  scrollPane.setViewport(viewport);
163  scrollPane.setOpaque(false);
164  scrollPane.setFocusable(false);
165  scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
166 
167  add(scrollPane);
168 
169  listCellRenderer.setSize(getWidth(), cellHeight);
170  }
171 
172  @Override
173  public void dispose() {
174  super.dispose();
175  list.removeListSelectionListener(listSelectionListener);
176  synchronized (getTreeLock()) {
177  resizeElements(0);
178  }
179  }
180 
186  @NotNull
187  public T getElement(final int index) {
188  return model.get(index);
189  }
190 
195  protected void addElement(@NotNull final T element) {
196  assert Thread.holdsLock(getTreeLock());
197  model.addElement(element);
198  list.setSize(getWidth(), Integer.MAX_VALUE);
199  viewport.update();
200  if (model.getSize() == 1) {
201  setSelectedIndex(0);
202  }
203  }
204 
212  protected int resizeElements(final int newSize) {
213  assert Thread.holdsLock(getTreeLock());
214  final int index = list.getSelectedIndex();
215  final int oldSize = model.getSize();
216  if (newSize < oldSize) {
217  for (int i = newSize; i < oldSize; i++) {
218  final GUIElement element = model.get(i);
219  if (element instanceof GUIItemItem) {
220  element.dispose();
221  }
222  }
223  model.removeRange(newSize, oldSize-1);
224  list.setSize(getWidth(), Integer.MAX_VALUE);
225  if (index >= newSize && newSize > 0) {
226  setSelectedIndex(newSize-1);
227  }
228  setChanged();
229  }
230  return oldSize;
231  }
232 
239  public boolean canMoveSelection(final int diffLines, final int diffElements) {
240  synchronized (getTreeLock()) {
241  //noinspection SwitchStatementWithTooFewBranches
242  final int distance = switch (list.getLayoutOrientation()) {
243  case JList.HORIZONTAL_WRAP -> (list.getWidth()/cellHeight)*diffLines+diffElements;
244  default -> diffLines+diffElements;
245  };
246  final int index = list.getSelectedIndex();
247  if (distance > 0) {
248  return index == -1 || index+distance < list.getModel().getSize();
249  }
250  //noinspection SimplifiableIfStatement
251  if (distance < 0) {
252  return index == -1 || index >= -distance;
253  }
254  return false;
255  }
256  }
257 
263  public void moveSelection(final int diffLines, final int diffElements) {
264  synchronized (getTreeLock()) {
265  //noinspection SwitchStatementWithTooFewBranches
266  final int distance = switch (list.getLayoutOrientation()) {
267  case JList.HORIZONTAL_WRAP -> (list.getWidth()/cellHeight)*diffLines+diffElements;
268  default -> diffLines+diffElements;
269  };
270  final int index = list.getSelectedIndex();
271  final int newIndex;
272  if (distance > 0) {
273  newIndex = index == -1 ? 0 : Math.min(index+distance, list.getModel().getSize()-1);
274  } else if (distance < 0) {
275  //noinspection IfMayBeConditional
276  if (index == -1) {
277  newIndex = list.getModel().getSize()-1;
278  } else {
279  newIndex = Math.max(index+distance, 0);
280  }
281  } else {
282  newIndex = index == -1 ? 0 : index;
283  }
284  setSelectedIndex(newIndex);
285  }
286  }
287 
293  @Override
294  public boolean canScroll(final int distance) {
295  synchronized (getTreeLock()) {
296  final Adjustable scrollBar = scrollPane.getVerticalScrollBar();
297  if (distance > 0) {
298  return scrollBar.getValue() < scrollBar.getMaximum()-scrollBar.getVisibleAmount();
299  }
300  //noinspection SimplifiableIfStatement
301  if (distance < 0) {
302  return scrollBar.getValue() > scrollBar.getMinimum();
303  }
304  return false;
305  }
306  }
307 
312  @Override
313  public void scroll(final int distance) {
314  synchronized (getTreeLock()) {
315  final Adjustable scrollBar = scrollPane.getVerticalScrollBar();
316  final int value = scrollBar.getValue()+distance*cellHeight;
317  scrollBar.setValue(value);
318  final int index = list.getSelectedIndex();
319  if (index != -1) {
320  final int firstIndex = list.getFirstVisibleIndex();
321  if (index < firstIndex) {
322  //noinspection SwitchStatementWithTooFewBranches
323  switch (list.getLayoutOrientation()) {
324  case JList.HORIZONTAL_WRAP:
325  final int columns = list.getWidth()/cellHeight;
326  setSelectedIndex(firstIndex+index%columns);
327  break;
328 
329  default:
330  setSelectedIndex(firstIndex);
331  break;
332  }
333  } else {
334  final int lastIndex = list.getLastVisibleIndex();
335  if (index > lastIndex) {
336  //noinspection SwitchStatementWithTooFewBranches
337  switch (list.getLayoutOrientation()) {
338  case JList.HORIZONTAL_WRAP:
339  final int columns = list.getWidth()/cellHeight;
340  final int newTmpColumn = lastIndex-lastIndex%columns+index%columns;
341  final int newColumn;
342  if (newTmpColumn <= lastIndex) {
343  newColumn = newTmpColumn;
344  } else {
345  newColumn = newTmpColumn >= columns ? newTmpColumn-columns : lastIndex;
346  }
347  setSelectedIndex(newColumn);
348  break;
349 
350  default:
351  setSelectedIndex(lastIndex);
352  break;
353  }
354  }
355  }
356  }
357  }
358  setChanged();
359  }
360 
361  @Override
362  public void resetScroll() {
363  setSelectedIndex(0);
364  }
365 
366  @Override
367  public void mouseClicked(@NotNull final MouseEvent e) {
368  if (isEnabled()) {
369  doSelect(e);
370  if (doubleClickCommandList != null && e.getClickCount() > 1) {
372  }
373  }
374  super.mouseClicked(e);
375  }
376 
377  @Override
378  public void mouseEntered(@NotNull final MouseEvent e) {
379  super.mouseEntered(e);
380  if (isEnabled()) {
381  doTooltip(e);
382  }
383  }
384 
385  @Override
386  public void mouseExited(@NotNull final MouseEvent e) {
387  super.mouseExited(e);
388  if (isEnabled()) {
389  doTooltip(e);
390  }
391  }
392 
393  @Override
394  public void mousePressed(@NotNull final MouseEvent e) {
395  super.mousePressed(e);
396  if (isEnabled()) {
397  doSelect(e);
398  }
399  }
400 
401  @Override
402  public void mouseMoved(@NotNull final MouseEvent e) {
403  super.mouseMoved(e);
404  if (isEnabled()) {
405  doTooltip(e);
406  }
407  }
408 
409  @Override
410  public void mouseDragged(@NotNull final MouseEvent e) {
411  super.mouseDragged(e);
412  if (isEnabled()) {
413  doSelect(e);
414  }
415  }
416 
417  @Override
418  public void mouseWheelMoved(final int wheelRotation) {
419  super.mouseWheelMoved(wheelRotation);
420  scroll(wheelRotation);
421  }
422 
427  private void doSelect(@NotNull final MouseEvent e) {
428  synchronized (getTreeLock()) {
429  final Rec rec = getIndex(e);
430  if (rec != null) {
431  setSelectedIndex(rec.getIndex());
432  }
433  }
434  }
435 
440  private void doTooltip(@NotNull final MouseEvent e) {
441  synchronized (getTreeLock()) {
442  final Rec rec = getIndex(e);
443  if (rec == null) {
444  tooltipIndex = -1;
445  tooltipRectangle = null;
446  tooltipChanged();
447  return;
448  }
449 
450  tooltipIndex = rec.getIndex();
451  tooltipRectangle = rec.getRectangle();
452  tooltipChanged();
453  }
454  }
455 
461  @Nullable
462  private Rec getIndex(@NotNull final MouseEvent e) {
463  final Point point = e.getPoint();
464  final Point location = list.getLocation();
465  point.translate(-location.x, -location.y);
466 
467  final int index = list.locationToIndex(point);
468  if (index == -1) {
469  return null;
470  }
471 
472  final Rectangle rectangle = list.getCellBounds(index, index);
473  if (rectangle == null || !rectangle.contains(point)) {
474  return null;
475  }
476  rectangle.translate(location.x, location.y);
477 
478  return new Rec(index, rectangle);
479  }
480 
485  protected void setSelectedIndex(final int newIndex) {
486  synchronized (getTreeLock()) {
487  final int newIndex2 = Math.min(Math.max(newIndex, 0), list.getModel().getSize()-1);
488  final int index = list.getSelectedIndex();
489  if (newIndex2 == index) {
490  return;
491  }
492 
493  list.setSelectedIndex(newIndex2);
494  if (newIndex2 >= 0) {
495  list.ensureIndexIsVisible(newIndex2);
496  }
497  }
498  setChanged();
499  }
500 
504  protected void selectionChanged() {
505  synchronized (getTreeLock()) {
506  selectionChanged(list.getSelectedIndex());
507  }
508  }
509 
514  protected abstract void selectionChanged(final int selectedIndex);
515 
516  @Override
517  public void setChanged() {
518  super.setChanged();
519  tooltipChanged();
520  }
521 
522  @Nullable
523  @Override
525  if (tooltipIndex == -1) {
526  return null;
527  }
528 
529  final Rectangle rectangle = tooltipRectangle;
530  if (rectangle == null) {
531  return null;
532  }
533 
534  final Gui gui = guiFactory.getGui(this);
535  if (gui == null) {
536  tooltipIndex = -1;
537  tooltipRectangle = null;
538  return null;
539  }
540 
541  final String text = getTooltip(tooltipIndex);
542  return text == null ? null : new TooltipText(text, gui.getComponent().getX()+getX()+rectangle.x, gui.getComponent().getY()+getY()+rectangle.y, rectangle.width, rectangle.height);
543  }
544 
545  @Override
546  public void execute() {
547  // ignore
548  }
549 
555  @Nullable
556  protected abstract String getTooltip(final int index);
557 
564  protected void setLayoutOrientation(final int layoutOrientation, final int visibleRowCount) {
565  synchronized (getTreeLock()) {
566  list.setLayoutOrientation(layoutOrientation);
567  list.setVisibleRowCount(visibleRowCount);
568  }
569  }
570 
575  @NotNull
576  protected Object getSelectedObject() {
577  synchronized (getTreeLock()) {
578  return list.getSelectedValue();
579  }
580  }
581 
582  @Override
583  @SuppressWarnings("MethodDoesntCallSuperMethod")
584  public Dimension getPreferredSize() {
585  return new Dimension(64, 64);
586  }
587 
588  @Override
589  @SuppressWarnings("MethodDoesntCallSuperMethod")
590  public Dimension getMinimumSize() {
591  return list.getMinimumSize();
592  }
593 
594  @Override
595  @SuppressWarnings("MethodDoesntCallSuperMethod")
596  public Dimension getMaximumSize() {
597  return new Dimension(320, 160);
598  }
599 
600  @Override
601  public void setBounds(final int x, final int y, final int width, final int height) {
602  super.setBounds(x, y, width, height);
603  scrollPane.setSize(width, height);
605  }
606 
610  private static class Rec {
611 
615  private final int index;
616 
620  @NotNull
621  private final Rectangle rectangle;
622 
628  private Rec(final int index, @NotNull final Rectangle rectangle) {
629  this.index = index;
630  this.rectangle = rectangle;
631  }
632 
637  public int getIndex() {
638  return index;
639  }
640 
645  @NotNull
646  public Rectangle getRectangle() {
647  return rectangle;
648  }
649 
650  }
651 
652 }
com.realtime.crossfire.jxclient.gui.list.GUIList.tooltipIndex
int tooltipIndex
The index of the currently shown tooltip.
Definition: GUIList.java:115
com.realtime.crossfire.jxclient.gui.list.GUIList.Rec
Stores information about a list item.
Definition: GUIList.java:610
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.skin.skin
Definition: DefaultJXCSkin.java:23
com.realtime.crossfire.jxclient.gui.list.GUIList.getMaximumSize
Dimension getMaximumSize()
Definition: GUIList.java:596
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.tooltipChanged
void tooltipChanged()
Must be called whenever the tooltip may have changed.
Definition: AbstractGUIElement.java:264
com.realtime.crossfire.jxclient.gui.gui.Gui
Combines a list of GUIElements to for a gui.
Definition: Gui.java:49
com.realtime.crossfire.jxclient.skin.skin.GuiFactory.getGui
Gui getGui(@NotNull final AbstractGUIElement element)
Returns the Gui an element is part of.
Definition: GuiFactory.java:110
com.realtime.crossfire.jxclient.gui.list.GUIList.GUIList
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)
Creates a new instance.
Definition: GUIList.java:141
com.realtime.crossfire.jxclient.gui.list.GUIList.list
final JList< T > list
The list used to display the cells.
Definition: GUIList.java:97
com.realtime.crossfire.jxclient.gui.list.GUIList.mousePressed
void mousePressed(@NotNull final MouseEvent e)
Will be called when the user has pressed the mouse inside this element.
Definition: GUIList.java:394
com.realtime.crossfire.jxclient.skin
com.realtime.crossfire.jxclient.gui.list.GUIList.Rec.getIndex
int getIndex()
Returns the list item index.
Definition: GUIList.java:637
com.realtime.crossfire.jxclient.gui.list.GUIList
A GUIElement that displays a list of entries.
Definition: GUIList.java:56
com.realtime.crossfire.jxclient.gui.scrollable.GUIScrollable
Interface for GUIElements that support scrolling.
Definition: GUIScrollable.java:32
com.realtime.crossfire.jxclient.gui.list.GUIList.canScroll
boolean canScroll(final int distance)
Returns whether the list can be scrolled.
Definition: GUIList.java:294
com.realtime.crossfire.jxclient.gui.list.GUIList.execute
void execute()
Executes the actions associated with this GUI element.
Definition: GUIList.java:546
com.realtime.crossfire.jxclient.gui.list.GUIList.setBounds
void setBounds(final int x, final int y, final int width, final int height)
Definition: GUIList.java:601
com.realtime.crossfire.jxclient.gui.list.GUIList.Rec.Rec
Rec(final int index, @NotNull final Rectangle rectangle)
Creates a new instance.
Definition: GUIList.java:628
com.realtime.crossfire.jxclient.gui.commandlist
Definition: CommandList.java:23
com.realtime.crossfire.jxclient.gui.list.GUIList.mouseMoved
void mouseMoved(@NotNull final MouseEvent e)
Will be called when the mouse moves within this component.
Definition: GUIList.java:402
com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement
A GUIElement that can be set to active or inactive.
Definition: ActivatableGUIElement.java:33
com.realtime.crossfire.jxclient.gui.gui.GUIElement.dispose
void dispose()
Releases all allocated resources.
com.realtime.crossfire.jxclient.gui.list.GUIList.Rec.index
final int index
The list item index.
Definition: GUIList.java:615
com.realtime.crossfire.jxclient.gui.list.GUIList.dispose
void dispose()
Releases all allocated resources.
Definition: GUIList.java:173
com.realtime.crossfire.jxclient.gui.list.GUIList.model
final DefaultListModel< T > model
The list model of list.
Definition: GUIList.java:91
com.realtime.crossfire.jxclient.gui.list.GUIList.serialVersionUID
static final long serialVersionUID
The serial version UID.
Definition: GUIList.java:61
com.realtime.crossfire.jxclient.gui.list.GUIList.doubleClickCommandList
final CommandList doubleClickCommandList
The CommandList to execute on double-clicks or.
Definition: GUIList.java:79
com.realtime.crossfire.jxclient.gui.item.GUIItemItem
A GUIElement instance representing an in-game item.
Definition: GUIItemItem.java:46
com.realtime.crossfire.jxclient.gui.gui.GUIElement
Interface defining an abstract GUI element.
Definition: GUIElement.java:33
com.realtime.crossfire.jxclient.gui.list.GUIList.resizeElements
int resizeElements(final int newSize)
Changes the number of list elements.
Definition: GUIList.java:212
com.realtime.crossfire.jxclient.gui.list.GUIList.mouseDragged
void mouseDragged(@NotNull final MouseEvent e)
Will be called when the mouse moves within this component while the button is pressed.
Definition: GUIList.java:410
com.realtime.crossfire.jxclient.gui.list.GUIList.doSelect
void doSelect(@NotNull final MouseEvent e)
Selects the list entry corresponding to a MouseEvent instance.
Definition: GUIList.java:427
com.realtime.crossfire.jxclient.gui.list.GUIList.getMinimumSize
Dimension getMinimumSize()
Definition: GUIList.java:590
com.realtime.crossfire.jxclient.gui.list.GUIList.resetScroll
void resetScroll()
Resets the scroll index to the default value.
Definition: GUIList.java:362
com.realtime.crossfire.jxclient.gui.list.GUIList.cellHeight
final int cellHeight
The height of a list cell in pixels.
Definition: GUIList.java:66
com.realtime.crossfire.jxclient.gui.list.GUIList.scrollPane
final JScrollPane scrollPane
The scroll pane instance used to display the list.
Definition: GUIList.java:109
com.realtime.crossfire.jxclient.gui.list.GUIList.listSelectionListener
final ListSelectionListener listSelectionListener
The ListSelectionListener attached to list.
Definition: GUIList.java:127
com.realtime.crossfire.jxclient.gui.list.GUIList.mouseWheelMoved
void mouseWheelMoved(final int wheelRotation)
Will be called when the mouse wheel has been moved.
Definition: GUIList.java:418
com.realtime.crossfire.jxclient.gui.list.GUIList.selectionChanged
void selectionChanged()
Called whenever the selected list entry has changed.
Definition: GUIList.java:504
com.realtime.crossfire.jxclient.gui.list.GUIList.addElement
void addElement(@NotNull final T element)
Adds an GUIElement to the list.
Definition: GUIList.java:195
com.realtime.crossfire.jxclient.gui.list.GUIListViewport.update
void update()
Updates the viewport state.
Definition: GUIListViewport.java:41
com.realtime.crossfire.jxclient.gui.list.GUIList.listCellRenderer
final GUIListCellRenderer<? extends T > listCellRenderer
The GUIListCellRenderer for the list.
Definition: GUIList.java:72
com.realtime.crossfire.jxclient.gui.list.GUIListCellRenderer.setSize
void setSize(final int width, int height)
Updates the component's size.
com.realtime.crossfire.jxclient.gui.list.GUIListCellRenderer<? extends T >
com.realtime.crossfire.jxclient.gui.list.GUIList.getPreferredSize
Dimension getPreferredSize()
Definition: GUIList.java:584
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.gui.list.GUIList.viewport
final GUIListViewport viewport
The viewport used by scrollPane.
Definition: GUIList.java:103
com.realtime.crossfire.jxclient.gui.list.GUIList.scroll
void scroll(final int distance)
Moves the list.
Definition: GUIList.java:313
com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement.elementListener
final GUIElementListener elementListener
The GUIElementListener to notify.
Definition: ActivatableGUIElement.java:44
com.realtime.crossfire.jxclient.gui.list.GUIList.Rec.rectangle
final Rectangle rectangle
The bounding box of the list item index.
Definition: GUIList.java:621
com.realtime.crossfire.jxclient.gui.gui.Gui.getComponent
JComponent getComponent()
Returns the JComponent for this instance.
Definition: Gui.java:161
com.realtime.crossfire.jxclient.gui.list.GUIList.getElement
T getElement(final int index)
Returns the GUIElement for a given index.
Definition: GUIList.java:187
com.realtime.crossfire.jxclient.gui.gui.TooltipText
Information for displaying tooltips.
Definition: TooltipText.java:31
com.realtime.crossfire.jxclient.gui.list.GUIList.getTooltip
TooltipText getTooltip()
Returns the current tooltip text.
Definition: GUIList.java:524
com.realtime.crossfire.jxclient.skin.skin.GuiFactory
Factory for creating Gui instances.
Definition: GuiFactory.java:41
com.realtime.crossfire.jxclient.gui.commandlist.CommandList.execute
void execute()
Execute the command list by calling GUICommand#execute() for each command in order.
Definition: CommandList.java:99
com.realtime.crossfire.jxclient.gui.commandlist.CommandList
A list of GUICommand instances.
Definition: CommandList.java:34
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.name
final String name
The name of this element.
Definition: AbstractGUIElement.java:77
com.realtime.crossfire.jxclient.gui.gui
Definition: AbstractGUIElement.java:23
com.realtime.crossfire.jxclient.gui.list.GUIList.tooltipRectangle
Rectangle tooltipRectangle
The location of the tooltip.
Definition: GUIList.java:121
com.realtime.crossfire.jxclient.gui.list.GUIList.setLayoutOrientation
void setLayoutOrientation(final int layoutOrientation, final int visibleRowCount)
Sets the layout orientation.
Definition: GUIList.java:564
com.realtime.crossfire
com.realtime.crossfire.jxclient.gui.list.GUIList.getSelectedObject
Object getSelectedObject()
Returns the selected list object.
Definition: GUIList.java:576
com.realtime.crossfire.jxclient.gui.gui.TooltipManager
Manages the tooltip display.
Definition: TooltipManager.java:33
com.realtime.crossfire.jxclient.gui.list.GUIList.canMoveSelection
boolean canMoveSelection(final int diffLines, final int diffElements)
Returns whether the selection can be moved.
Definition: GUIList.java:239
com.realtime
com.realtime.crossfire.jxclient.gui.list.GUIList.guiFactory
final GuiFactory guiFactory
The global GuiFactory instance.
Definition: GUIList.java:85
com.realtime.crossfire.jxclient.gui.scrollable
Definition: GUIScrollable.java:23
com
com.realtime.crossfire.jxclient.gui.list.GUIList.moveSelection
void moveSelection(final int diffLines, final int diffElements)
Moves the selection.
Definition: GUIList.java:263
com.realtime.crossfire.jxclient.gui.item
Definition: GUIItem.java:23
com.realtime.crossfire.jxclient.gui.list.GUIList.setChanged
void setChanged()
Records that the contents have changed and must be repainted.
Definition: GUIList.java:517
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.tooltipManager
final TooltipManager tooltipManager
The TooltipManager to update.
Definition: AbstractGUIElement.java:83
com.realtime.crossfire.jxclient.gui.list.GUIList.getIndex
Rec getIndex(@NotNull final MouseEvent e)
Returns the list item from a mouse event.
Definition: GUIList.java:462
com.realtime.crossfire.jxclient.gui.list.GUIList.doTooltip
void doTooltip(@NotNull final MouseEvent e)
Updates the tooltip text corresponding to a MouseEvent instance.
Definition: GUIList.java:440
com.realtime.crossfire.jxclient.gui.list.GUIList.mouseEntered
void mouseEntered(@NotNull final MouseEvent e)
Will be called when the mouse has entered the bounding box of this element.
Definition: GUIList.java:378
com.realtime.crossfire.jxclient.gui.list.GUIList.setSelectedIndex
void setSelectedIndex(final int newIndex)
Update the selected list entry.
Definition: GUIList.java:485
com.realtime.crossfire.jxclient.gui.list.GUIList.mouseExited
void mouseExited(@NotNull final MouseEvent e)
Will be called when the mouse has left the bounding box of this element.
Definition: GUIList.java:386
com.realtime.crossfire.jxclient.gui.list.GUIList.mouseClicked
void mouseClicked(@NotNull final MouseEvent e)
Will be called when the user has clicked (pressed+released) this element.
Definition: GUIList.java:367
com.realtime.crossfire.jxclient.gui.list.GUIList.Rec.getRectangle
Rectangle getRectangle()
Returns the bounding box of the list item.
Definition: GUIList.java:646
com.realtime.crossfire.jxclient.gui.gui.GUIElementListener
Listener for GUIElement related events.
Definition: GUIElementListener.java:32
com.realtime.crossfire.jxclient.gui.list.GUIListViewport
A JViewport that allows updating the viewport state.
Definition: GUIListViewport.java:31