Gridarta Editor
MapParameterCellRenderer.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.plugin.parameter.map;
21 
22 import java.awt.Component;
23 import javax.swing.DefaultListCellRenderer;
24 import javax.swing.JList;
27 import org.jetbrains.annotations.NotNull;
28 import org.jetbrains.annotations.Nullable;
29 
30 public class MapParameterCellRenderer extends DefaultListCellRenderer {
31 
35  private static final long serialVersionUID = 1L;
36 
40  @NotNull
42 
48  this.mapManager = mapManager;
49  }
50 
51  @Override
52  public Component getListCellRendererComponent(@NotNull final JList<?> list, @Nullable final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
53  final String newVal;
54  if (value instanceof MapControl) {
55  newVal = ((MapControl<?, ?, ?>) value).getMapModel().getMapArchObject().getMapName();
56  } else {
57  final MapControl<?, ?, ?> mapControl = mapManager.getCurrentMap();
58  final String mapName = mapControl == null ? "" : mapControl.getMapModel().getMapArchObject().getMapName();
59  newVal = "Current - " + mapName;
60  }
61  return super.getListCellRendererComponent(list, newVal, index, isSelected, cellHasFocus);
62  }
63 
64 }
net.sf.gridarta.model.mapmanager
Definition: AbstractMapManager.java:20
net.sf.gridarta
net.sf
net.sf.gridarta.model.mapmanager.MapManager.getCurrentMap
MapControl< G, A, R > getCurrentMap()
net.sf.gridarta.gui.dialog.plugin.parameter.map.MapParameterCellRenderer.mapManager
final MapManager<?, ?, ?> mapManager
Definition: MapParameterCellRenderer.java:41
net.sf.gridarta.model.mapcontrol
Definition: DefaultMapControl.java:20
net
net.sf.gridarta.gui.dialog.plugin.parameter.map.MapParameterCellRenderer
Definition: MapParameterCellRenderer.java:30
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.MapModel.getMapArchObject
A getMapArchObject()
net.sf.gridarta.model.mapmanager.MapManager
Definition: MapManager.java:37
net.sf.gridarta.model.mapcontrol.MapControl
Definition: MapControl.java:35
net.sf.gridarta.model
net.sf.gridarta.gui.dialog.plugin.parameter.map.MapParameterCellRenderer.MapParameterCellRenderer
MapParameterCellRenderer(@NotNull final MapManager<?, ?, ?> mapManager)
Definition: MapParameterCellRenderer.java:47
net.sf.gridarta.gui.dialog.plugin.parameter.map.MapParameterCellRenderer.getListCellRendererComponent
Component getListCellRendererComponent(@NotNull final JList<?> list, @Nullable final Object value, final int index, final boolean isSelected, final boolean cellHasFocus)
Definition: MapParameterCellRenderer.java:52
net.sf.gridarta.model.mapcontrol.MapControl.getMapModel
MapModel< G, A, R > getMapModel()
net.sf.gridarta.gui.dialog.plugin.parameter.map.MapParameterCellRenderer.serialVersionUID
static final long serialVersionUID
Definition: MapParameterCellRenderer.java:35