From: <aki...@us...> - 2006-12-23 12:26:23
|
Revision: 1220 http://svn.sourceforge.net/gridarta/?rev=1220&view=rev Author: akirschbaum Date: 2006-12-23 04:26:23 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Split MapTileList into control and view. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -225,7 +225,7 @@ if (!mapTileListBottom) { // the map tile list is on the right side - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, mapTileListControl); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, mapTileListControl.getMapTileListView()); splitRightPane.setDividerLocation(divLocationRight); splitRightPane.setDividerSize(BORDER_SIZE); @@ -248,7 +248,7 @@ } else { // the map tile list is merged into the bottom panel mapArchPanel = new CMapArchPanel(mainControl, this); - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl.getMapTileListView()); splitRightPane.setDividerLocation(divLocationRight); splitRightPane.setDividerSize(BORDER_SIZE); @@ -518,7 +518,7 @@ // set bounds to maximum size if (!mapTileListBottom) { - mapView.setBounds(0, 0, mapTileListControl.getX() - BORDER_SIZE - 2, mapArchPanel.getY() - BORDER_SIZE - 4); + mapView.setBounds(0, 0, mapTileListControl.getMapTileListView().getX() - BORDER_SIZE - 2, mapArchPanel.getY() - BORDER_SIZE - 4); } else { mapView.setBounds(0, 0, mapDesktop.getWidth() - 2, mapDesktop.getHeight() - 2); } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -128,7 +128,7 @@ mapCursor = new MapCursor(mapGrid); mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl()); + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl().getMapTileListView()); mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -25,41 +25,24 @@ package cfeditor.gui.maptilelist; -import cfeditor.CFancyButton; import cfeditor.CMainControl; import cfeditor.CMainView; import cfeditor.IGUIConstants; import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; import java.awt.Point; -import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.util.Date; -import javax.swing.BorderFactory; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; import javax.swing.JList; import javax.swing.JPanel; -import javax.swing.JScrollPane; -import static javax.swing.JViewport.SIMPLE_SCROLL_MODE; -import javax.swing.ScrollPaneConstants; -import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; -import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; -import javax.swing.SwingConstants; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gameobject.GameObjectContainer; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -68,23 +51,13 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class MapTileListControl extends JPanel implements MapCursorListener { +public final class MapTileListControl { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Controller of this subview. */ private final CMainControl mainControl; private final CMainView mainView; - /** The "Import..." button. */ - private final JList list; - - private final DefaultListModel model; - - private int listCounter = 0; - /** * Time of last click in the panel (value in msec by Date.getTime()) * and arch-ID of arch that received last click. @@ -96,6 +69,9 @@ /** The currently selected MapSquare. */ private transient Point currentSquare = null; + /** The view for this controller. */ + private final MapTileListView view; + /** * Create a MapTileListControl. * @param mainControl MainControl, used for icons @@ -104,79 +80,44 @@ public MapTileListControl(final CMainControl mainControl, final CMainView mainView) { this.mainControl = mainControl; this.mainView = mainView; - setLayout(new BorderLayout()); - model = new DefaultListModel(); - list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); - list.setBackground(Color.lightGray); - final JScrollPane scrollPane = new JScrollPane(list); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); - add(scrollPane, BorderLayout.CENTER); + view = new MapTileListView(this, mainControl, mainView.isMapTileListBottom()); + } - final JPanel arrows = new JPanel(); - if (mainView.isMapTileListBottom()) { - arrows.setLayout(new GridLayout(2, 1)); - } - final JScrollPane scrollPane2 = new JScrollPane(arrows); - scrollPane2.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER); - scrollPane2.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); - scrollPane2.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); - if (!mainView.isMapTileListBottom()) { - add(scrollPane2, BorderLayout.SOUTH); // put up/down buttons south - } else { - add(scrollPane2, BorderLayout.WEST); // put up/down buttons west - scrollPane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); // don't show the border - } - - final CFancyButton buttonDown = new CFancyButton(null, "Move Tile Position Down", - IGUIConstants.MOVE_DOWN_ICON, - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveDown(); - refresh(); - } + ActionListener getButtonDownActionListener() { + return new ActionListener() { + public void actionPerformed(final ActionEvent event) { + final GameObject arch = getMapTileSelection(); + if (arch != null) { + arch.moveDown(); + refresh(); } - }); - buttonDown.setVerticalTextPosition(SwingConstants.BOTTOM); - buttonDown.setHorizontalTextPosition(SwingConstants.CENTER); - if (!mainView.isMapTileListBottom()) { - arrows.add(buttonDown, BorderLayout.EAST); - } + } + }; + } - final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", - IGUIConstants.MOVE_UP_ICON, - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveUp(); - refresh(); - } + ActionListener getButtonUpActionListener() { + return new ActionListener() { + public void actionPerformed(final ActionEvent event) { + final GameObject arch = getMapTileSelection(); + if (arch != null) { + arch.moveUp(); + refresh(); } - }); - buttonUp.setVerticalTextPosition(SwingConstants.BOTTOM); - buttonUp.setHorizontalTextPosition(SwingConstants.CENTER); - if (!mainView.isMapTileListBottom()) { - arrows.add(buttonUp, BorderLayout.WEST); - } else { - arrows.add(buttonUp); - arrows.add(buttonDown); - } + } + }; + } - list.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(final ListSelectionEvent e) { - mainView.setMapArchPanelObject(getMapTileSelection()); - } - }); + ListSelectionListener getListSelectionListener() { + return new ListSelectionListener() { + public void valueChanged(final ListSelectionEvent e) { + mainView.setMapArchPanelObject(getMapTileSelection()); + } + }; + } - /** - * listen for mouse events in the panel - */ - list.addMouseListener(new MouseAdapter() { + MouseListener getMouseListener() { + return new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { if (e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown()) { // --- left mouse button: select arch --- @@ -198,11 +139,11 @@ if (currentSquare != null && mainControl.getArchPanelHighlight() != null) { mainControl.getCurrentMap().getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N - final int listIndex = getListIndex(e); - if (listIndex >= list.getModel().getSize()) { + final int listIndex = view.getListIndex(e); + if (listIndex >= view.getModelSize()) { mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), null, currentSquare, MapModel.JOIN_ENABLE); } else { - final GameObject entry = (GameObject) model.getElementAt(listIndex); + final GameObject entry = view.getListGameObject(listIndex); mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), entry, currentSquare, MapModel.JOIN_ENABLE); } mainControl.getCurrentMap().getMapModel().endTransaction(); @@ -213,61 +154,31 @@ } } else { // --- middle mouse button: delete arch --- - final int listIndex = getListIndex(e); - if (listIndex < list.getModel().getSize()) { + final int listIndex = view.getListIndex(e); + if (listIndex < view.getModelSize()) { mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N deleteIndexFromList(listIndex); mainControl.getCurrentMap().getMapModel().endTransaction(); } } } - }); + }; } public void selectArchBelow() { - list.setSelectedIndex(list.getSelectedIndex() + 1); + view.setSelectedIndex(view.getSelectedIndex() + 1); } public void selectArchAbove() { - final int index = list.getSelectedIndex(); - if (index > 0) { - list.setSelectedIndex(index - 1); - } + view.setSelectedIndex(view.getSelectedIndex() - 1); } /** - * Determine the list index for a given mouse event. This function differs - * from <code>list.locationTopIndex(e.getPoint())</code> in that it always - * returns a valid list index, or the list size (i.e., one element past the - * last list index) if the point is after the end of the list. - * - * @param e the mouse event containing the position to check - * - * @return the selected list index - */ - private int getListIndex(final MouseEvent e) { - final int lastIndex = list.getModel().getSize() - 1; - if (lastIndex < 0) { - return 0; - } - - final Rectangle bounds = list.getCellBounds(lastIndex, lastIndex); - final int lowestY = (int) (bounds.getY() + bounds.getHeight()); - if ((int) (e.getPoint().getY()) >= lowestY) { - return lastIndex + 1; - } - - final int listIndex = list.locationToIndex(e.getPoint()); - assert listIndex >= 0; // -1 is returned only if the list is empty, but this was already checked - return listIndex; - } - - /** * Return the currently selected GameObject within this list (currently selected MapSquare). * @return the currently selected GameObject */ @Nullable public GameObject getMapTileSelection() { - return (GameObject) list.getSelectedValue(); + return view.getMapTileSelection(); } /** @@ -279,38 +190,16 @@ return; } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown final GameObject temp = getMapTileSelection(); - final GameObject entry = (GameObject) model.getElementAt(index); + final GameObject entry = view.getListGameObject(index); if (entry != null) { mainControl.deleteMapArch(entry, currentSquare, MapModel.JOIN_ENABLE); setMapTileList(mainControl.getCurrentMap(), temp); } } - public int getTileArch(final int oldindex) { - final int index; - if (oldindex == -1) { - index = list.getFirstVisibleIndex(); - } else if (list.getModel().getSize() <= oldindex) { - index = oldindex; - } else { - index = -1; - } - if (index != -1 && list.getModel().getSize() > 0) { - list.setSelectedIndex(index); - } - return list.getSelectedIndex(); - } - public void refresh() { - final GameObject gameObject; - final GameObject sel = getMapTileSelection(); - if (sel != null) { - gameObject = getMapTileSelection(); - } else { - gameObject = null; - } - mainView.setMapTileList(mainControl.getCurrentMap(), gameObject); - repaint(); + setMapTileList(mainControl.getCurrentMap(), getMapTileSelection()); + view.repaint(); } /** @@ -319,166 +208,37 @@ * @param gameObject selected GameObject */ public void setMapTileList(final MapControl mapControl, final GameObject gameObject) { - list.setEnabled(false); - model.removeAllElements(); - if (mapControl == null) { - // mouse has been clicked outside the mapview - currentSquare = null; - getTileArch(-1); - list.setEnabled(true); - mainView.refreshMapArchPanel(); - return; - } + view.setMapTileList(mapControl, gameObject); - listCounter = 0; - currentSquare = mapControl.getMapCursor().getLocation(); - int postSelect = -1; - boolean foundSIndex = false; - int sIndex = 0; - - // Now go through the list backwards and put all arches - // on the panel in this order - if (currentSquare != null) { - for (final GameObject node : mapControl.getMapModel().getMapSquare(currentSquare).reverse()) { - // add the node - if (node == gameObject) { - postSelect = listCounter; - } - listCounter++; - model.addElement(node); - - // if view-settings are applied, mark topmost "visible" tile for selection - if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { - sIndex = listCounter - 1; // select this tile - foundSIndex = true; // this is it - don't select any other tile - } - - final int tmpSelect = addInvObjects(node.getHead(), gameObject); - if (postSelect == -1 && tmpSelect != -1) { - postSelect = tmpSelect; - } - } - } - - if (postSelect != -1) { - list.setSelectedIndex(postSelect); - } else { - // Per default, the topmost arch matching the view settings is selected. - // (With no view settings applied, the very topmost arch is selected.) - list.setSelectedIndex(sIndex); - } - // refresh the MapArchPanel to display the new arch mainView.refreshMapArchPanel(); - - list.setEnabled(true); } /** - * Add inventory objects to an arch in the MapTileList recursively. - * @param node the arch where the inventory gets added - * @param gameObject selected GameObject - * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch + * Return the view for this controller. + * + * @return the view for this controller */ - private int addInvObjects(final GameObject node, final GameObject gameObject) { - int selListCounter = -1; - for (final GameObject invObject : node.getHead()) { - if (invObject == gameObject) { - selListCounter = listCounter; - } - listCounter++; - model.addElement(invObject); - - final int tmpListCounter = addInvObjects(invObject, gameObject); - if (tmpListCounter != -1) { - selListCounter = tmpListCounter; - } - } - return selListCounter; + public MapTileListView getMapTileListView() { + return view; } - /** {@inheritDoc} */ - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - if (e.getSource().isActive()) { - // Position changed - setMapTileList(mainControl.getCurrentMap(), null); - } else { - // Cursor was disabled - setMapTileList(null, null); - } + /** + * Return the currently selected MapSquare. + * + * @return the currently selected MapSquare + */ + @Nullable Point getCurrentSquare() { + return currentSquare; } - /** {@inheritDoc} */ - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // A mode change can be ignored + /** + * Set the currently selected MapSquare. + * + * @param point the selected MapSquare + */ + void setCurrentSquare(@Nullable Point point) { + currentSquare = point; } - /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ - private final class MyCellRenderer extends DefaultListCellRenderer { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - GameObject arch = (GameObject) value; - - // arch == null should not happen, but it *can* happen when the active - // window gets changed by user and java is still blitting here - if (arch != null) { - arch = arch.getHead(); - - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.getFaceFlag()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else if (arch.getFaceNr() == -1) { - setIcon(CMainControl.getUnknownTileIcon()); - } else { - setIcon(mainControl.getFace(arch.getFaceNr())); - } - - // In the map-tile-window the object names are displayed - // next to the icons - if (arch.getObjName() != null && arch.getObjName().length() > 0) { - setText(arch.getObjName()); // special name - } else { - final String defname; - if (arch.hasArchetype()) { - defname = arch.getArchetype().getObjName(); - } else { - defname = null; - } - - if (defname != null && defname.length() > 0) { - setText(defname); // default name - } else { - setText(arch.getArchetypeName()); // arch name - } - } - } else { - setIcon(CMainControl.getUnknownTileIcon()); - setText("?"); - } - - int indent = 0; - for (;;) { - final GameObjectContainer<GameObject> env = arch.getContainer(); - if (env == null || !(env instanceof GameObject)) { - break; - } - arch = (GameObject) env; - indent++; - } - if (indent > 1) { - setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation - } - - return this; - } - - } // class MyCellRenderer - } // class MapTileListControl Copied: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java (from rev 1219, trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -0,0 +1,407 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.gui.maptilelist; + +import cfeditor.CFancyButton; +import cfeditor.CMainControl; +import cfeditor.IGUIConstants; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import javax.swing.BorderFactory; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; +import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; +import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; +import javax.swing.SwingConstants; +import static javax.swing.JViewport.SIMPLE_SCROLL_MODE; +import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The panel that displays the arches of the currently selected map square. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + */ +public final class MapTileListView extends JPanel implements MapCursorListener { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** The controller for this view. */ + @NotNull final MapTileListControl control; + + /** The main control for this view. */ + @NotNull final CMainControl mainControl; + + /** The "Import..." button. */ + private final JList list; + + private final DefaultListModel model; + + private int listCounter = 0; + + /** + * Create a new instance. + * + * @param control the controller for this view + * + * @param mainControl the main controller for this view + * + * @param mapTileListBottom set if the map tile list should be at the + * bottom or on the top of the main view + */ + MapTileListView(@NotNull final MapTileListControl control, @NotNull final CMainControl mainControl, final boolean mapTileListBottom) { + this.control = control; + this.mainControl = mainControl; + + setLayout(new BorderLayout()); + + model = new DefaultListModel(); + list = new JList(model); + list.setCellRenderer(new MyCellRenderer()); + list.setBackground(Color.lightGray); + final JScrollPane scrollPane = new JScrollPane(list); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scrollPane.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); + add(scrollPane, BorderLayout.CENTER); + + final JPanel arrows = new JPanel(); + if (mapTileListBottom) { + arrows.setLayout(new GridLayout(2, 1)); + } + final JScrollPane scrollPane2 = new JScrollPane(arrows); + scrollPane2.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_NEVER); + scrollPane2.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); + scrollPane2.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); + if (!mapTileListBottom) { + add(scrollPane2, BorderLayout.SOUTH); // put up/down buttons south + } else { + add(scrollPane2, BorderLayout.WEST); // put up/down buttons west + scrollPane2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); // don't show the border + } + + final CFancyButton buttonDown = new CFancyButton(null, "Move Tile Position Down", + IGUIConstants.MOVE_DOWN_ICON, + control.getButtonDownActionListener()); + buttonDown.setVerticalTextPosition(SwingConstants.BOTTOM); + buttonDown.setHorizontalTextPosition(SwingConstants.CENTER); + if (!mapTileListBottom) { + arrows.add(buttonDown, BorderLayout.EAST); + } + + final CFancyButton buttonUp = new CFancyButton(null, "Move Tile Position Up", + IGUIConstants.MOVE_UP_ICON, + control.getButtonUpActionListener()); + buttonUp.setVerticalTextPosition(SwingConstants.BOTTOM); + buttonUp.setHorizontalTextPosition(SwingConstants.CENTER); + if (!mapTileListBottom) { + arrows.add(buttonUp, BorderLayout.WEST); + } else { + arrows.add(buttonUp); + arrows.add(buttonDown); + } + + list.addListSelectionListener(control.getListSelectionListener()); + + /** + * listen for mouse events in the panel + */ + list.addMouseListener(control.getMouseListener()); + } + + /** + * Determine the list index for a given mouse event. This function differs + * from <code>list.locationTopIndex(e.getPoint())</code> in that it always + * returns a valid list index, or the list size (i.e., one element past the + * last list index) if the point is after the end of the list. + * + * @param e the mouse event containing the position to check + * + * @return the selected list index + */ + int getListIndex(final MouseEvent e) { + final int lastIndex = getModelSize() - 1; + if (lastIndex < 0) { + return 0; + } + + final Rectangle bounds = list.getCellBounds(lastIndex, lastIndex); + final int lowestY = (int) (bounds.getY() + bounds.getHeight()); + if ((int) (e.getPoint().getY()) >= lowestY) { + return lastIndex + 1; + } + + final int listIndex = list.locationToIndex(e.getPoint()); + assert listIndex >= 0; // -1 is returned only if the list is empty, but this was already checked + return listIndex; + } + + /** + * Return the currently selected GameObject within this list (currently selected MapSquare). + * @return the currently selected GameObject + */ + @Nullable public GameObject getMapTileSelection() { + return (GameObject) list.getSelectedValue(); + } + + private int getTileArch(final int oldindex) { + final int index; + if (oldindex == -1) { + index = list.getFirstVisibleIndex(); + } else if (getModelSize() <= oldindex) { + index = oldindex; + } else { + index = -1; + } + if (index != -1 && getModelSize() > 0) { + list.setSelectedIndex(index); + } + return list.getSelectedIndex(); + } + + /** + * Set the display to the currently selected map tile. + * @param mapControl Map to get display for (includes selection information) + * @param gameObject selected GameObject + */ + void setMapTileList(final MapControl mapControl, final GameObject gameObject) { + list.setEnabled(false); + model.removeAllElements(); + if (mapControl == null) { + // mouse has been clicked outside the mapview + control.setCurrentSquare(null); + getTileArch(-1); + list.setEnabled(true); + return; + } + + listCounter = 0; + control.setCurrentSquare(mapControl.getMapCursor().getLocation()); + int postSelect = -1; + boolean foundSIndex = false; + int sIndex = 0; + + // Now go through the list backwards and put all arches + // on the panel in this order + if (control.getCurrentSquare() != null) { + for (final GameObject node : mapControl.getMapModel().getMapSquare(control.getCurrentSquare()).reverse()) { + // add the node + if (node == gameObject) { + postSelect = listCounter; + } + listCounter++; + model.addElement(node); + + // if view-settings are applied, mark topmost "visible" tile for selection + if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { + sIndex = listCounter - 1; // select this tile + foundSIndex = true; // this is it - don't select any other tile + } + + final int tmpSelect = addInvObjects(node.getHead(), gameObject); + if (postSelect == -1 && tmpSelect != -1) { + postSelect = tmpSelect; + } + } + } + + if (postSelect != -1) { + list.setSelectedIndex(postSelect); + } else { + // Per default, the topmost arch matching the view settings is selected. + // (With no view settings applied, the very topmost arch is selected.) + list.setSelectedIndex(sIndex); + } + + list.setEnabled(true); + } + + /** + * Add inventory objects to an arch in the MapTileListView recursively. + * @param node the arch where the inventory gets added + * @param gameObject selected GameObject + * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch + */ + private int addInvObjects(final GameObject node, final GameObject gameObject) { + int selListCounter = -1; + for (final GameObject invObject : node.getHead()) { + if (invObject == gameObject) { + selListCounter = listCounter; + } + listCounter++; + model.addElement(invObject); + + final int tmpListCounter = addInvObjects(invObject, gameObject); + if (tmpListCounter != -1) { + selListCounter = tmpListCounter; + } + } + return selListCounter; + } + + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + if (e.getSource().isActive()) { + // Position changed + setMapTileList(mainControl.getCurrentMap(), null); + } else { + // Cursor was disabled + setMapTileList(null, null); + } + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // A mode change can be ignored + } + + /** + * Return a game object from the list. + * + * @param index the index in the list + * + * @return the game object, or <code>null</code> if the index is invalid + */ + @Nullable GameObject getListGameObject(final int index) { + return (GameObject) model.getElementAt(index); + } + + /** + * Return the number of currently shown game objects. + * + * @return the number of currently shown game objects + */ + int getModelSize() { + return model.getSize(); + } + + /** + * Return the currently selected list index. + * + * @return the currently selected list index + */ + int getSelectedIndex() { + return list.getSelectedIndex(); + } + + /** + * Set the currently selected list index. If an invalid index is given, the + * nearest valid index is used instead. + * + * @param index the index to select + */ + void setSelectedIndex(final int index) { + if (index < 0) { + list.setSelectedIndex(0); + } else if (index >= getModelSize()) { + list.setSelectedIndex(Math.max(0, getModelSize() - 1)); + } else { + list.setSelectedIndex(index); + } + } + + /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ + private final class MyCellRenderer extends DefaultListCellRenderer { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** {@inheritDoc} */ + @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + GameObject arch = (GameObject) value; + + // arch == null should not happen, but it *can* happen when the active + // window gets changed by user and java is still blitting here + if (arch != null) { + arch = arch.getHead(); + + if (!arch.hasArchetype()) { + setIcon(CMainControl.getNoarchTileIcon()); + } else if (arch.getFaceFlag()) { + setIcon(CMainControl.getNofaceTileIcon()); + } else if (arch.getFaceNr() == -1) { + setIcon(CMainControl.getUnknownTileIcon()); + } else { + setIcon(mainControl.getFace(arch.getFaceNr())); + } + + // In the map-tile-window the object names are displayed + // next to the icons + if (arch.getObjName() != null && arch.getObjName().length() > 0) { + setText(arch.getObjName()); // special name + } else { + final String defname; + if (arch.hasArchetype()) { + defname = arch.getArchetype().getObjName(); + } else { + defname = null; + } + + if (defname != null && defname.length() > 0) { + setText(defname); // default name + } else { + setText(arch.getArchetypeName()); // arch name + } + } + } else { + setIcon(CMainControl.getUnknownTileIcon()); + setText("?"); + } + + int indent = 0; + for (;;) { + final GameObjectContainer<GameObject> env = arch.getContainer(); + if (env == null || !(env instanceof GameObject)) { + break; + } + arch = (GameObject) env; + indent++; + } + if (indent > 1) { + setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation + } + + return this; + } + + } // class MyCellRenderer + +} // class MapTileListView Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -225,11 +225,11 @@ mapArchPanel = new CMapArchPanel(mainControl, this); if (mapTileListBottom) { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl); + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl.getMapTileListView()); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, mapDesktop, splitRightPane); } else { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileListControl); + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileListControl.getMapTileListView()); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, splitRightPane, mapArchPanel); } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -124,7 +124,7 @@ mapCursor = new MapCursor(mapGrid); mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl()); + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl().getMapTileListView()); mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java 2006-12-23 09:53:58 UTC (rev 1219) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -3,6 +3,7 @@ * Copyright (C) 2000 Michael Toennies * Copyright (C) 2001 Andreas Vogl * Copyright (C) 2005 Christian Hujer + * Copyright (C) 2006 The Gridarta Developers * * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) * @@ -33,33 +34,15 @@ import daieditor.IGUIConstants; import daieditor.gameobject.GameObject; import daieditor.map.MapControl; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.Insets; import java.awt.Point; -import java.awt.Rectangle; import static java.awt.event.InputEvent.SHIFT_MASK; import java.awt.event.MouseEvent; import static java.awt.event.MouseEvent.BUTTON1; import static java.awt.event.MouseEvent.BUTTON2; import static java.awt.event.MouseEvent.BUTTON3; import java.awt.event.MouseListener; -import javax.swing.DefaultListCellRenderer; -import javax.swing.DefaultListModel; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JViewport; -import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -73,29 +56,19 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @todo turn this into a tree */ -public final class MapTileListControl extends JPanel implements ListSelectionListener, MouseListener, MapCursorListener { +public final class MapTileListControl implements ListSelectionListener, MouseListener { - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** Controller of this subview. */ private final CMainControl mainControl; private final CMainView mainView; - /** The "Import..." button. */ - private final JList list; - - private final DefaultListModel model; - - private int listCounter = 0; - /** The currently selected MapSquare. */ private transient MapSquare<GameObject> currentSquare; + /** The view for this controller. */ + private final MapTileListView view; + /** * Create a MapTileListControl. * @param mainControl MainControl, used for icons @@ -104,35 +77,8 @@ public MapTileListControl(final CMainControl mainControl, final CMainView mainView) { this.mainControl = mainControl; this.mainView = mainView; - setLayout(new BorderLayout()); - model = new DefaultListModel(); - list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); - list.setBackground(Color.lightGray); - final JScrollPane scrollPane = new JScrollPane(list); - scrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - add(scrollPane, BorderLayout.CENTER); - - final JPanel arrows = new JPanel(); - if (mainView.isMapTileListBottom()) { - arrows.setLayout(new GridLayout(4, 1)); - add(arrows, BorderLayout.WEST); // put up/down buttons west - } else { - add(arrows, BorderLayout.SOUTH); // put up/down buttons south - } - for (final String keyPostfix : new String[] { "Top", "Up", "Down", "Bottom" }) { - final JButton button = new JButton(ACTION_FACTORY.createAction(true, "moveTile" + keyPostfix, this)); - arrows.add(button); - button.setMargin(new Insets(0, 0, 0, 0)); - } - final JPanel compass = new JPanel(); - compass.add(new JLabel(CGUIUtils.getSysIcon(IGUIConstants.TILE_NORTH))); - add(compass, BorderLayout.NORTH); - list.addListSelectionListener(this); - list.addMouseListener(this); - list.setFocusable(false); // XXX Workaround for Mantis #0000154 This is not clean and should be removed as soon as cut/copy/paste of arches is possible + view = new MapTileListView(this, mainControl, mainView.isMapTileListBottom()); } /** {@inheritDoc} */ @@ -185,14 +131,11 @@ } public void selectArchBelow() { - list.setSelectedIndex(list.getSelectedIndex() + 1); + view.setSelectedIndex(view.getSelectedIndex() + 1); } public void selectArchAbove() { - final int index = list.getSelectedIndex(); - if (index > 0) { - list.setSelectedIndex(index - 1); - } + view.setSelectedIndex(view.getSelectedIndex() - 1); } /** {@inheritDoc} */ @@ -217,11 +160,11 @@ } } - final int listIndex = getListIndex(e); - if (listIndex >= list.getModel().getSize()) { + final int listIndex = view.getListIndex(e); + if (listIndex >= view.getModelSize()) { mainControl.insertArchToMap(newarch, archname, null, new Point(currentSquare.getMapX(), currentSquare.getMapY())); } else { - final GameObject entry = (GameObject) model.getElementAt(listIndex); + final GameObject entry = view.getListGameObject(listIndex); mainControl.insertArchToMap(newarch, archname, entry, new Point(currentSquare.getMapX(), currentSquare.getMapY())); } @@ -231,8 +174,8 @@ setMapTileList(mainControl.getCurrentMap(), null); } else if (e.getButton() == BUTTON2 || (e.getModifiers() & SHIFT_MASK) == SHIFT_MASK && e.getButton() == BUTTON3) { // MMB // --- middle mouse button: delete arch --- - final int listIndex = getListIndex(e); - if (listIndex < list.getModel().getSize()) { + final int listIndex = view.getListIndex(e); + if (listIndex < view.getModelSize()) { deleteIndexFromList(listIndex); } } @@ -259,38 +202,11 @@ } /** - * Determine the list index for a given mouse event. This function differs - * from <code>list.locationTopIndex(e.getPoint())</code> in that it always - * returns a valid list index, or the list size (i.e., one element past the - * last list index) if the point is after the end of the list. - * - * @param e the mouse event containing the position to check - * - * @return the selected list index - */ - private int getListIndex(final MouseEvent e) { - final int lastIndex = list.getModel().getSize() - 1; - if (lastIndex < 0) { - return 0; - } - - final Rectangle bounds = list.getCellBounds(lastIndex, lastIndex); - final int lowestY = (int) (bounds.getY() + bounds.getHeight()); - if ((int) (e.getPoint().getY()) >= lowestY) { - return lastIndex + 1; - } - - final int listIndex = list.locationToIndex(e.getPoint()); - assert listIndex >= 0; // -1 is returned only if the list is empty, but this was already checked - return listIndex; - } - - /** * Return the currently selected GameObject within this list (currently selected MapSquare). * @return the currently selected GameObject */ @Nullable public GameObject getMapTileSelection() { - return (GameObject) list.getSelectedValue(); + return view.getMapTileSelection(); } /** @@ -302,7 +218,7 @@ return; } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown final GameObject temp = getMapTileSelection(); - final GameObject entry = (GameObject) model.getElementAt(index); + final GameObject entry = view.getListGameObject(index); if (entry != null) { entry.remove(); // TODO: refresh map @@ -310,24 +226,9 @@ } } - public int getTileArch(final int oldindex) { - final int index; - if (oldindex == -1) { - index = list.getFirstVisibleIndex(); - } else if (list.getModel().getSize() <= oldindex) { - index = oldindex; - } else { - index = -1; - } - if (index != -1 && list.getModel().getSize() > 0) { - list.setSelectedIndex(index); - } - return list.getSelectedIndex(); - } - public void refresh() { setMapTileList(mainControl.getCurrentMap(), getMapTileSelection()); - repaint(); + view.repaint(); } /** @@ -336,150 +237,37 @@ * @param gameObject selected GameObject */ public void setMapTileList(final MapControl mapControl, final GameObject gameObject) { - list.setEnabled(false); - model.removeAllElements(); - if (mapControl == null) { - // mouse has been clicked outside the mapview - currentSquare = null; - getTileArch(-1); - list.setEnabled(true); - mainView.refreshMapArchPanel(); - return; - } + view.setMapTileList(mapControl, gameObject); - listCounter = 0; - currentSquare = mapControl.getMapModel().getMouseRightPosObject(); - int postSelect = -1; - boolean foundSIndex = false; - int sIndex = 0; - - // Now go through the list backwards and put all arches - // on the panel in this order - if (currentSquare != null) { - for (final GameObject node : currentSquare.reverse()) { - // add the node - if (node == gameObject) { - postSelect = listCounter; - } - listCounter++; - model.addElement(node); - - // if view-settings are applied, mark topmost "visible" tile for selection - if (mainControl.isTileEditSet() && !foundSIndex && mainControl.isTileEdit(node.getEditType())) { - sIndex = listCounter - 1; // select this tile - foundSIndex = true; // this is it - don't select any other tile - } - - final int tmpSelect = addInvObjects(node.getHead(), gameObject); - if (postSelect == -1 && tmpSelect != -1) { - postSelect = tmpSelect; - } - } - } - - if (postSelect != -1) { - list.setSelectedIndex(postSelect); - } else { - // Per default, the topmost arch matching the view settings is selected. - // (With no view settings applied, the very topmost arch is selected.) - list.setSelectedIndex(sIndex); - } - // refresh the MapArchPanel to display the new arch mainView.refreshMapArchPanel(); - - list.setEnabled(true); } /** - * Add inventory objects to an arch in the MapTileListControl recursively. - * @param node the arch where the inventory gets added - * @param gameObject selected GameObject - * @return <code>-1</code> if <var>selArch</var> was found, else <var>listCounter</var> of the arch + * Return the view for this controller. + * + * @return the view for this controller */ - private int addInvObjects(final GameObject node, final GameObject gameObject) { - int selListCounter = -1; - for (final GameObject invObject : node.reverse()) { - if (invObject == gameObject) { - selListCounter = listCounter; - } - listCounter++; - model.addElement(invObject); - - final int tmpListCounter = addInvObjects(invObject, gameObject); - if (tmpListCounter != -1) { - selListCounter = tmpListCounter; - } - } - return selListCounter; + public MapTileListView getMapTileListView() { + return view; } - /** {@inheritDoc} */ - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - if (e.getSource().isActive()) { - // Position changed - setMapTileList(mainControl.getCurrentMap(), null); - } else { - // Cursor was disabled - setMapTileList(null, null); - } + /** + * Return the currently selected MapSquare. + * + * @return the currently selected MapSquare + */ + @Nullable MapSquare<GameObject> getCurrentSquare() { + return currentSquare; } - /** {@inheritDoc} */ - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // A mode change can be ignored + /** + * Set the currently selected MapSquare. + * + * @param mapSquare the selected MapSquare + */ + void setCurrentSquare(@Nullable MapSquare<GameObject> mapSquare) { + currentSquare = mapSquare; } - /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ - private final class MyCellRenderer extends DefaultListCellRenderer { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - GameObject arch = (GameObject) value; - - // arch == null should not happen, but it *can* happen when the active - // window gets changed by user and java is still blitting here - if (arch != null) { - arch = arch.getHead(); - - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.hasFaceObject()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else { - final String faceObjName = arch.getFaceObjName(); - final ImageIcon icon = faceObjName != null ? mainControl.getArchetypeSet().getFace(faceObjName) : null; - setIcon(icon != null ? icon : CMainControl.getUnknownTileIcon()); - } - - // In the map-tile-window the object names are displayed - // next to the icons - if (arch.getObjName() != null && arch.getObjName().length() > 0) { - setText(arch.getObjName()); // special name - } else { - final String defname; - if (arch.hasArchetype()) { - defname = arch.getArchetype().getObjName(); - } else { - defname = null; - } - - if (defname != null && defname.length() > 0) { - setText(defname); // default name - } else { - setText(arch.getArchetypeName()); // arch name - } - } - } - - return this; - } - - } // class MyCellRenderer - } // class MapTileListControl Copied: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java (from rev 1219, trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java) =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:26:23 UTC (rev 1220) @@ -0,0 +1,384 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2005 Christian Hujer + * Copyright (C) 2006 The Gridarta Developers + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package daieditor.gui.maptilelist; + +import daieditor.CopyBuffer; +import daieditor.CGUIUtils; +import daieditor.CMainControl; +import daieditor.CPickmapPanel; +import daieditor.IGUIConstants; +import daieditor.gameobject.GameObject; +import daieditor.map.MapControl; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.Insets; +import java.awt.Rectangle; +import static java.awt.event.InputEvent.SHIFT_MASK; +import java.awt.event.MouseEvent; +import static java.awt.event.MouseEvent.BUTTON1; +import static java.awt.event.MouseEvent.BUTTON2; +import static java.awt.event.MouseEvent.BUTTON3; +import java.awt.event.MouseListener; +import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JViewport; +import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.map.MapSquare; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The panel that displays the arches of the currently selected map square. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christia... [truncated message content] |