Gridarta Editor
MapListCellRenderer.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 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.gomap;
21 
22 import java.awt.Component;
23 import javax.swing.DefaultListCellRenderer;
24 import javax.swing.JList;
27 import org.jetbrains.annotations.NotNull;
28 
34 public class MapListCellRenderer extends DefaultListCellRenderer {
35 
39  private static final long serialVersionUID = 1L;
40 
44  @NotNull
45  private final MapsIndex mapsIndex;
46 
51  public MapListCellRenderer(@NotNull final MapsIndex mapsIndex) {
52  this.mapsIndex = mapsIndex;
53  }
54 
55  @NotNull
56  @Override
57  public Component getListCellRendererComponent(@NotNull final JList<?> list, @NotNull final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
58  super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
59  final MapFile file = (MapFile) value;
60  final String name = mapsIndex.getName(file);
61  setText((name == null ? "?" : name) + " (" + file.getMapPath() + ")");
62  setToolTipText(value.toString());
63  return this;
64  }
65 
66 }
name
name
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:2
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.gui.dialog.gomap.MapListCellRenderer.MapListCellRenderer
MapListCellRenderer(@NotNull final MapsIndex mapsIndex)
Creates a new instance.
Definition: MapListCellRenderer.java:51
net.sf.gridarta.gui.dialog.gomap.MapListCellRenderer.getListCellRendererComponent
Component getListCellRendererComponent(@NotNull final JList<?> list, @NotNull final Object value, final int index, final boolean isSelected, final boolean cellHasFocus)
Definition: MapListCellRenderer.java:57
net.sf
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net.sf.gridarta.model.mapmodel.MapFile.getMapPath
AbsoluteMapPath getMapPath()
Returns the map path within getMapsDir().
Definition: MapFile.java:93
net
net.sf.gridarta.model.index.AbstractIndex.getName
String getName(@NotNull final V value)
Returns the name associated with a value.
Definition: AbstractIndex.java:233
list
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing list
Definition: Developer_README.txt:13
net.sf.gridarta.model.mapmodel.MapFile
The location of a map file with a map directory.
Definition: MapFile.java:31
net.sf.gridarta.model.index
Definition: AbstractIndex.java:20
net.sf.gridarta.model
net.sf.gridarta.model.index.MapsIndex
Indexes maps by map name.
Definition: MapsIndex.java:28
net.sf.gridarta.gui.dialog.gomap.MapListCellRenderer
A DefaultListCellRenderer that renders values of a {}.
Definition: MapListCellRenderer.java:34
net.sf.gridarta.gui.dialog.gomap.MapListCellRenderer.mapsIndex
final MapsIndex mapsIndex
The displayed MapsIndex.
Definition: MapListCellRenderer.java:45
net.sf.gridarta.gui.dialog.gomap.MapListCellRenderer.serialVersionUID
static final long serialVersionUID
The serial version UID.
Definition: MapListCellRenderer.java:39