20 package net.sf.gridarta.gui.dialog.goexit;
22 import java.awt.Component;
23 import java.awt.Point;
24 import java.util.Comparator;
25 import javax.swing.DefaultListCellRenderer;
26 import javax.swing.JList;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
39 public class MapListCellRenderer extends DefaultListCellRenderer implements Comparator<GameObject<?, ?, ?>> {
62 public Component
getListCellRendererComponent(
final JList<?> list,
final Object value,
final int index,
final boolean isSelected,
final boolean cellHasFocus) {
63 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
67 setIcon(faceObjectProviders.getFace(gameObject));
68 final StringBuilder sb =
new StringBuilder();
69 sb.append(gameObject.getBestName());
71 if (mapLocation == null) {
77 sb.append(mapCoordinate.x);
79 sb.append(mapCoordinate.y);
82 setText(sb.toString());
102 final String name1 = o1.getBestName();
103 final String name2 = o2.getBestName();
104 final int cmp1 = name1.compareToIgnoreCase(name2);
111 if (mapLocation1 == null) {
112 if (mapLocation2 != null) {
115 }
else if (mapLocation2 == null) {
118 final int cmp2 = mapLocation1.
compareTo(mapLocation2);
124 final String faceObjName1 = o1.getFaceObjName();
125 final String faceObjName2 = o2.getFaceObjName();
126 if (faceObjName1 == null) {
127 if (faceObjName2 != null) {
130 }
else if (faceObjName2 == null) {
133 final int cmp3 = faceObjName1.compareTo(faceObjName2);
Exception thrown if a game object does not specify a valid exit path.
static final long serialVersionUID
The serial version UID.
int compareTo(@NotNull final MapLocation o)
MapListCellRenderer(@NotNull final FaceObjectProviders faceObjectProviders)
Creates a new instance.
int compare(final GameObject<?, ?, ?> o1, final GameObject<?, ?, ?> o2)
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Component getListCellRendererComponent(final JList<?> list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus)
MapPath getMapPath()
Returns the map path.
final FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.
GameObjects are the objects based on Archetypes found on maps.
A net.sf.gridarta.gui.panel.connectionview.CellRenderer for the locked items view.
Provider for faces of GameObjects and Archetypes.
The face is the appearance of an object.
static MapLocation getMapLocation(@NotNull final GameObject<?, ?, ?> gameObject)
Returns the MapLocation for a GameObject.
static MapLocation newAbsoluteMapLocation(@NotNull final GameObject<?, ?, ?> gameObject, final boolean allowRandomMapParameters)
Creates a new instance from a BaseObject instance.
Represents a location on a map consisting of a map path and a map coordinate.
Point getMapCoordinate()
Returns the map coordinate.