Gridarta Editor
ArchComboBoxCellRenderer.java
Go to the documentation of this file.
1
/*
2
* Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3
* Copyright (C) 2000-2015 The Gridarta Developers.
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
*/
19
20
package
net.sf.gridarta.gui.dialog.plugin.parameter.archetype;
21
22
import
java.awt.Component;
23
import
javax.swing.DefaultListCellRenderer;
24
import
javax.swing.JList;
25
import
net
.
sf
.
gridarta
.
model
.
baseobject
.
BaseObject
;
26
import
net
.
sf
.
gridarta
.
model
.
face
.
FaceObjectProviders
;
27
import
org.jetbrains.annotations.NotNull;
28
import
org.jetbrains.annotations.Nullable;
29
30
public
class
ArchComboBoxCellRenderer
extends
DefaultListCellRenderer {
31
32
private
static
final
long
serialVersionUID
= 1L;
33
37
@NotNull
38
private
final
FaceObjectProviders
faceObjectProviders
;
39
45
public
ArchComboBoxCellRenderer
(@NotNull
final
FaceObjectProviders
faceObjectProviders
) {
46
this.faceObjectProviders =
faceObjectProviders
;
47
}
48
49
/* This is the only method defined by ListCellRenderer. We just
50
* reconfigure the label each time we're called.
51
*/
52
53
@NotNull
54
@Override
55
public
Component
getListCellRendererComponent
(@NotNull
final
JList<?> list, @Nullable
final
Object value,
final
int
index,
final
boolean
isSelected,
final
boolean
cellHasFocus) {
56
/* The DefaultListCellRenderer class will take care of
57
* the JLabels text property, it's foreground and background
58
*colors, and so on.
59
*/
60
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
61
62
/* We additionally set the JLabels icon property here.
63
*/
64
final
BaseObject<?, ?, ?, ?>
archetype = (
BaseObject<?, ?, ?, ?>
) value;
65
if
(archetype ==
null
) {
66
setText(
""
);
67
setIcon(
null
);
68
return
this
;
69
}
70
setText(archetype.
getArchetype
().getArchetypeName());
71
72
setIcon(
faceObjectProviders
.getFace(archetype));
73
74
return
this
;
75
}
76
77
}
net.sf.gridarta.gui.dialog.plugin.parameter.archetype.ArchComboBoxCellRenderer
Definition:
ArchComboBoxCellRenderer.java:30
net.sf.gridarta
net.sf
net.sf.gridarta.model.face.FaceObjectProviders
Definition:
FaceObjectProviders.java:46
net.sf.gridarta.model.baseobject.BaseObject.getArchetype
R getArchetype()
net
net.sf.gridarta.model.baseobject.BaseObject
Definition:
BaseObject.java:34
net.sf.gridarta.gui.dialog.plugin.parameter.archetype.ArchComboBoxCellRenderer.faceObjectProviders
final FaceObjectProviders faceObjectProviders
Definition:
ArchComboBoxCellRenderer.java:38
net.sf.gridarta.model
net.sf.gridarta.model.baseobject
Definition:
AbstractBaseObject.java:20
net.sf.gridarta.model.face
Definition:
AbstractFaceObjects.java:20
net.sf.gridarta.gui.dialog.plugin.parameter.archetype.ArchComboBoxCellRenderer.serialVersionUID
static final long serialVersionUID
Definition:
ArchComboBoxCellRenderer.java:32
net.sf.gridarta.gui.dialog.plugin.parameter.archetype.ArchComboBoxCellRenderer.ArchComboBoxCellRenderer
ArchComboBoxCellRenderer(@NotNull final FaceObjectProviders faceObjectProviders)
Definition:
ArchComboBoxCellRenderer.java:45
net.sf.gridarta.gui.dialog.plugin.parameter.archetype.ArchComboBoxCellRenderer.getListCellRendererComponent
Component getListCellRendererComponent(@NotNull final JList<?> list, @Nullable final Object value, final int index, final boolean isSelected, final boolean cellHasFocus)
Definition:
ArchComboBoxCellRenderer.java:55
src
gridarta
src
main
java
net
sf
gridarta
gui
dialog
plugin
parameter
archetype
ArchComboBoxCellRenderer.java
Generated by
1.8.17