From: <aki...@us...> - 2006-12-22 19:53:37
|
Revision: 1204 http://svn.sourceforge.net/gridarta/?rev=1204&view=rev Author: akirschbaum Date: 2006-12-22 11:53:34 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Properly update connection view when the current map changes. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/gui/ConnectionView.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-22 19:43:29 UTC (rev 1203) +++ trunk/crossfire/ChangeLog 2006-12-22 19:53:34 UTC (rev 1204) @@ -1,5 +1,7 @@ 2006-12-22 Andreas Kirschbaum + * Properly update connection view when the current map changes. + * Remove support for loading maps with invalid width/height specifications. Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-22 19:43:29 UTC (rev 1203) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-22 19:53:34 UTC (rev 1204) @@ -230,6 +230,8 @@ updateFont(true); document = archEdit.getDocument(); + + mainControl.addMainControlListener(connectionView); } /** Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-22 19:43:29 UTC (rev 1203) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-22 19:53:34 UTC (rev 1204) @@ -304,10 +304,7 @@ return mapFile; } - /** - * Returns model (= map data of this level). - * @return model (= map data of this level) - */ + /** {@inheritDoc} */ public MapModel getMapModel() { return mapModel; } Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-12-22 19:43:29 UTC (rev 1203) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-12-22 19:53:34 UTC (rev 1204) @@ -250,6 +250,8 @@ updateFont(true); document = archEdit.getDocument(); + + mainControl.addMainControlListener(connectionView); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-22 19:43:29 UTC (rev 1203) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-22 19:53:34 UTC (rev 1204) @@ -383,10 +383,7 @@ return mapFile; } - /** - * Returns model (= map data of this level). - * @return model (= map data of this level) - */ + /** {@inheritDoc} */ public MapModel getMapModel() { return mapModel; } Modified: trunk/src/app/net/sf/gridarta/gui/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-22 19:43:29 UTC (rev 1203) +++ trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-22 19:53:34 UTC (rev 1204) @@ -29,12 +29,15 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import net.sf.gridarta.MainControlListener; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; +import org.jetbrains.annotations.Nullable; /** * A Panel that holds information about the connections of the selected arch on the selected map. @@ -46,7 +49,7 @@ * @todo attach * @serial exclude */ -public final class ConnectionView extends JPanel implements MapModelListener { +public final class ConnectionView extends JPanel implements MainControlListener, MapModelListener { /** The conections. */ private final Map<Integer, List<GameObject>> connections = new TreeMap<Integer, List<GameObject>>(); @@ -75,6 +78,11 @@ scanMapForConnections(e.getMapModel()); } + /** {@inheritDoc} */ + public void currentMapChanged(@Nullable final MapControl mapControl) { + scanMapForConnections(mapControl.getMapModel()); + } + /** * Scans a map for the contained connections. * @param model Model of map to scan Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-22 19:43:29 UTC (rev 1203) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-22 19:53:34 UTC (rev 1204) @@ -3,6 +3,7 @@ /** * Currently nothing more than a marker interface for unification. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum */ public interface MapControl { @@ -12,4 +13,10 @@ */ boolean isPickmap(); + /** + * Returns model (= map data of this level). + * @return model (= map data of this level) + */ + MapModel getMapModel(); + } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:12:20
|
Revision: 1210 http://svn.sourceforge.net/gridarta/?rev=1210&view=rev Author: akirschbaum Date: 2006-12-22 13:12:21 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CFTreasureListTree.java Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-22 21:07:13 UTC (rev 1209) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-22 21:12:21 UTC (rev 1210) @@ -59,6 +59,7 @@ import javax.swing.tree.TreePath; import net.sf.gridarta.help.Help; import net.sf.gridarta.io.IOUtils; +import net.sf.japi.util.EnumerationIterator; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -244,8 +245,8 @@ // set accurate type of treausrelist (one/multi) node.getTreasureObj().setType(realNode.getTreasureObj().getType()); - for (Enumeration clist = realNode.children(); clist != null && clist.hasMoreElements();) { - node.add(((TreasureTreeNode) clist.nextElement()).getClone()); + for (final TreasureTreeNode ttn : new EnumerationIterator<TreasureTreeNode>(realNode.children())) { + node.add(ttn.getClone()); } } } Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-22 21:07:13 UTC (rev 1209) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-22 21:12:21 UTC (rev 1210) @@ -233,12 +233,9 @@ // set accurate type of treausrelist (one/multi) node.getTreasureObj().setType(realNode.getTreasureObj().getType()); - for (TreasureTreeNode ttn : new EnumerationIterator<TreasureTreeNode>(realNode.children())) { + for (final TreasureTreeNode ttn : new EnumerationIterator<TreasureTreeNode>(realNode.children())) { node.add(ttn.getClone()); } -// for (Enumeration clist = realNode.children(); clist != null & clist.hasMoreElements();) { -// node.add(((TreasureTreeNode) clist.nextElement()).getClone()); -// } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 09:53:58
|
Revision: 1219 http://svn.sourceforge.net/gridarta/?rev=1219&view=rev Author: akirschbaum Date: 2006-12-23 01:53:58 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Rename *editor.CMapTileList to *editor.gui.maptilelist.MapTileListControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/map/MapCursorControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/maptilelist/ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/daimonin/src/daieditor/gui/maptilelist/ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/CMapTileList.java trunk/daimonin/src/daieditor/CMapTileList.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -587,7 +587,7 @@ mainView.showArchPanelQuickObject(gameObject); } - boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { + public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return currentMap.insertArchToMap(newarch, archname, next, pos, join); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -25,6 +25,7 @@ package cfeditor; import cfeditor.gameobject.GameObject; +import cfeditor.gui.maptilelist.MapTileListControl; import cfeditor.map.MapControl; import cfeditor.menu.AggregateMenuLocation; import cfeditor.menu.MenuManager; @@ -139,7 +140,7 @@ private final List<MapViewIFrame> mapViews = new ArrayList<MapViewIFrame>(); /** List of objects on map (right side). */ - private CMapTileList mapTileList; + private MapTileListControl mapTileListControl; /** Attributes panel (bottom). */ private CMapArchPanel mapArchPanel; @@ -219,12 +220,12 @@ // Build the placeholder for tile palette archPanel = new CArchPanel(mainControl); - mapTileList = new CMapTileList(mainControl, this); + mapTileListControl = new MapTileListControl(mainControl, this); mapDesktop = new JDesktopPane(); if (!mapTileListBottom) { // the map tile list is on the right side - splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, mapTileList); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapDesktop, mapTileListControl); splitRightPane.setDividerLocation(divLocationRight); splitRightPane.setDividerSize(BORDER_SIZE); @@ -247,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, mapTileList); + splitRightPane = new GSplitPane(JSplitPane.HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl); splitRightPane.setDividerLocation(divLocationRight); splitRightPane.setDividerSize(BORDER_SIZE); @@ -375,15 +376,15 @@ // access mape tile list ... public void setMapTileList(final MapControl map, final GameObject gameObject) { - mapTileList.setMapTileList(map, gameObject); + mapTileListControl.setMapTileList(map, gameObject); } public void refreshMapTileList() { - mapTileList.refresh(); + mapTileListControl.refresh(); } public GameObject getMapTileSelection() { - return mapTileList.getMapTileSelection(); + return mapTileListControl.getMapTileSelection(); } /** @@ -466,7 +467,7 @@ */ void refreshMenusAndToolbars() { archPanel.refresh(); - mapTileList.refresh(); + mapTileListControl.refresh(); mapArchPanel.refresh(); statusBar.refresh(); @@ -474,7 +475,7 @@ } /** Refresh the map arch panel (bottom window). */ - void refreshMapArchPanel() { + public void refreshMapArchPanel() { mapArchPanel.refresh(); } @@ -517,7 +518,7 @@ // set bounds to maximum size if (!mapTileListBottom) { - mapView.setBounds(0, 0, mapTileList.getX() - BORDER_SIZE - 2, mapArchPanel.getY() - BORDER_SIZE - 4); + mapView.setBounds(0, 0, mapTileListControl.getX() - BORDER_SIZE - 2, mapArchPanel.getY() - BORDER_SIZE - 4); } else { mapView.setBounds(0, 0, mapDesktop.getWidth() - 2, mapDesktop.getHeight() - 2); } @@ -941,8 +942,8 @@ MenuManager.getMenuManager().addMenuLocation(currentmapLocation); } - public CMapTileList getMapTileList() { - return mapTileList; + public MapTileListControl getMapTileListControl() { + return mapTileListControl; } private final class LookAndFeelAction extends AbstractAction { Deleted: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -1,479 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (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; - -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.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; - -/** - * 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 CMapTileList extends JPanel implements MapCursorListener { - - /** 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. - */ - private long lastClick = -1; - - private GameObject lastClickGameObject = null; - - /** The currently selected MapSquare. */ - private transient Point currentSquare = null; - - /** - * Create a CMapTileList. - * @param mainControl MainControl, used for icons - * @param mainView MainView, used for updating UI - */ - public CMapTileList(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); - - 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(); - } - } - }); - 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(); - } - } - }); - 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()); - } - }); - - /** - * listen for mouse events in the panel - */ - list.addMouseListener(new MouseAdapter() { - @Override public void mousePressed(final MouseEvent e) { - if (e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown()) { - // --- left mouse button: select arch --- - // first, check if this is a doubleclick - final long thisClick = (new Date()).getTime(); - if (thisClick - lastClick < IGUIConstants.DOUBLECLICK_MS && lastClickGameObject != null && lastClickGameObject == getMapTileSelection()) { - // doubleclick: open attribute window - mainControl.openAttrDialog(getMapTileSelection()); - } else { - // single click: now make this arch selected - mainView.setMapArchPanelObject(getMapTileSelection()); - } - - // save values for next click - lastClick = thisClick; - lastClickGameObject = getMapTileSelection(); - } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.isShiftDown())) { - // --- right mouse button: insert arch --- - - if (currentSquare != null && mainControl.getArchPanelHighlight() != null) { - mainControl.getCurrentMap().getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N - final int listIndex = getListIndex(e); - if (listIndex >= list.getModel().getSize()) { - mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), null, currentSquare, MapModel.JOIN_ENABLE); - } else { - final GameObject entry = (GameObject) model.getElementAt(listIndex); - mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), entry, currentSquare, MapModel.JOIN_ENABLE); - } - mainControl.getCurrentMap().getMapModel().endTransaction(); - - // refresh - mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified - mainControl.getMainView().refreshMapTileList(); // update tile window - } - } else { - // --- middle mouse button: delete arch --- - final int listIndex = getListIndex(e); - if (listIndex < list.getModel().getSize()) { - mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N - deleteIndexFromList(listIndex); - mainControl.getCurrentMap().getMapModel().endTransaction(); - } - } - } - }); - } - - public void selectArchBelow() { - list.setSelectedIndex(list.getSelectedIndex() + 1); - } - - public void selectArchAbove() { - final int index = list.getSelectedIndex(); - if (index > 0) { - list.setSelectedIndex(index - 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(); - } - - /** - * Delete an GameObject with a specific list index. - * @param index List index of GameObject - */ - private void deleteIndexFromList(final int index) { - if (index < 0) { - return; - } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown - final GameObject temp = getMapTileSelection(); - final GameObject entry = (GameObject) model.getElementAt(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(); - } - - void refresh() { - final GameObject gameObject; - final GameObject sel = getMapTileSelection(); - if (sel != null) { - gameObject = getMapTileSelection(); - } else { - gameObject = null; - } - mainView.setMapTileList(mainControl.getCurrentMap(), gameObject); - repaint(); - } - - /** - * Set the display to the currently selected map tile. - * @param mapControl Map to get display for (includes selection information) - * @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; - } - - 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 - */ - 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 - } - - /** 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 CMapTileList Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -128,7 +128,7 @@ mapCursor = new MapCursor(mapGrid); mapCursor.addMapCursorListener(this); if (!mapControl.isPickmap()) { - mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileList()); + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileListControl()); mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); mapCursor.addMapCursorListener(mainControl.getMapCursorControl()); } Modified: trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -23,9 +23,9 @@ import cfeditor.CMainControl; import cfeditor.CMainView; -import cfeditor.CMapTileList; import cfeditor.IGUIConstants; import cfeditor.gameobject.GameObject; +import cfeditor.gui.maptilelist.MapTileListControl; import cfeditor.map.MapControl; import java.awt.Point; import javax.swing.Action; @@ -161,9 +161,9 @@ if (mapCursor.isActive()) { final CMainView mainView = mainControl.getMainView(); assert mainView != null; - final CMapTileList mapTileList = mainView.getMapTileList(); - assert mapTileList != null; - final GameObject arch = mapTileList.getMapTileSelection(); + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; + final GameObject arch = mapTileListControl.getMapTileSelection(); if (arch != null) { final Point pos = mapCursor.getLocation(); assert pos != null; @@ -216,12 +216,12 @@ if (getMapCursor().isActive()) { final CMainView mainView = mainControl.getMainView(); assert mainView != null; - final CMapTileList mapTileList = mainView.getMapTileList(); - assert mapTileList != null; + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; if (above) { - mapTileList.selectArchAbove(); + mapTileListControl.selectArchAbove(); } else { - mapTileList.selectArchBelow(); + mapTileListControl.selectArchBelow(); } } } @@ -230,9 +230,9 @@ if (getMapCursor().isActive()) { final CMainView mainView = mainControl.getMainView(); assert mainView != null; - final CMapTileList mapTileList = mainView.getMapTileList(); - assert mapTileList != null; - final GameObject arch = mapTileList.getMapTileSelection(); + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; + final GameObject arch = mapTileListControl.getMapTileSelection(); if (arch != null) { mainControl.openAttrDialog(arch); } Copied: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java (from rev 1218, trunk/crossfire/src/cfeditor/CMapTileList.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -0,0 +1,484 @@ +/* + * 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.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.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; + +/** + * 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 MapTileListControl extends JPanel implements MapCursorListener { + + /** 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. + */ + private long lastClick = -1; + + private GameObject lastClickGameObject = null; + + /** The currently selected MapSquare. */ + private transient Point currentSquare = null; + + /** + * Create a MapTileListControl. + * @param mainControl MainControl, used for icons + * @param mainView MainView, used for updating UI + */ + 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); + + 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(); + } + } + }); + 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(); + } + } + }); + 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()); + } + }); + + /** + * listen for mouse events in the panel + */ + list.addMouseListener(new MouseAdapter() { + @Override public void mousePressed(final MouseEvent e) { + if (e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown()) { + // --- left mouse button: select arch --- + // first, check if this is a doubleclick + final long thisClick = (new Date()).getTime(); + if (thisClick - lastClick < IGUIConstants.DOUBLECLICK_MS && lastClickGameObject != null && lastClickGameObject == getMapTileSelection()) { + // doubleclick: open attribute window + mainControl.openAttrDialog(getMapTileSelection()); + } else { + // single click: now make this arch selected + mainView.setMapArchPanelObject(getMapTileSelection()); + } + + // save values for next click + lastClick = thisClick; + lastClickGameObject = getMapTileSelection(); + } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.isShiftDown())) { + // --- right mouse button: insert arch --- + + if (currentSquare != null && mainControl.getArchPanelHighlight() != null) { + mainControl.getCurrentMap().getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N + final int listIndex = getListIndex(e); + if (listIndex >= list.getModel().getSize()) { + mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), null, currentSquare, MapModel.JOIN_ENABLE); + } else { + final GameObject entry = (GameObject) model.getElementAt(listIndex); + mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), entry, currentSquare, MapModel.JOIN_ENABLE); + } + mainControl.getCurrentMap().getMapModel().endTransaction(); + + // refresh + mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified + mainControl.getMainView().refreshMapTileList(); // update tile window + } + } else { + // --- middle mouse button: delete arch --- + final int listIndex = getListIndex(e); + if (listIndex < list.getModel().getSize()) { + mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N + deleteIndexFromList(listIndex); + mainControl.getCurrentMap().getMapModel().endTransaction(); + } + } + } + }); + } + + public void selectArchBelow() { + list.setSelectedIndex(list.getSelectedIndex() + 1); + } + + public void selectArchAbove() { + final int index = list.getSelectedIndex(); + if (index > 0) { + list.setSelectedIndex(index - 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(); + } + + /** + * Delete an GameObject with a specific list index. + * @param index List index of GameObject + */ + private void deleteIndexFromList(final int index) { + if (index < 0) { + return; + } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown + final GameObject temp = getMapTileSelection(); + final GameObject entry = (GameObject) model.getElementAt(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(); + } + + /** + * Set the display to the currently selected map tile. + * @param mapControl Map to get display for (includes selection information) + * @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; + } + + 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 + */ + 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 + } + + /** 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 Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -783,7 +783,7 @@ mainView.showArchPanelQuickObject(gameObject); } - boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { + public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { return currentMap.getMapModel().insertArchToMap(newarch, archname, next, point); } @@ -1012,7 +1012,7 @@ level.levelCloseNotify(); } else { // Notify the level about the closing - mainView.getMapTileList().setMapTileList(null, null); + mainView.getMapTileListControl().setMapTileList(null, null); level.levelCloseNotify(); while (level.getMapViewFrame() != null) { level.closeView(level.getMapViewFrame()); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -26,6 +26,7 @@ import daieditor.gameobject.GameObject; import daieditor.gui.AboutDialog; +import daieditor.gui.maptilelist.MapTileListControl; import daieditor.map.MapControl; import daieditor.map.validation.ErrorCollector; import daieditor.map.validation.ErrorHandler; @@ -141,7 +142,7 @@ private final List<MapViewIFrame> mapViews = synchronizedList(new ArrayList<MapViewIFrame>()); /** List of objects on map (right side). */ - private CMapTileList mapTileList; + private MapTileListControl mapTileListControl; /** Attributes panel (bottom). */ private CMapArchPanel mapArchPanel; @@ -219,16 +220,16 @@ statusBar = new CMainStatusbar(mainControl); archPanel = new CArchPanel(mainControl); - mapTileList = new CMapTileList(mainControl, this); + mapTileListControl = new MapTileListControl(mainControl, this); mapDesktop = new JDesktopPane(); mapArchPanel = new CMapArchPanel(mainControl, this); if (mapTileListBottom) { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileList); + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapArchPanel, mapTileListControl); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, mapDesktop, splitRightPane); } else { - splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileList); + splitRightPane = new GSplitPane(HORIZONTAL_SPLIT, mapDesktop, mapTileListControl); splitRightPane.setDividerLocation(divLocationRight); splitDownPane = new GSplitPane(VERTICAL_SPLIT, splitRightPane, mapArchPanel); } @@ -351,21 +352,21 @@ } // show a arch in the arch map panel - void setMapArchPanelObject(final GameObject arch) { + public void setMapArchPanelObject(final GameObject arch) { mapArchPanel.setMapArchPanelObject(arch); } // access mape tile list ... public void setMapTileList(final MapControl map, final GameObject gameObject) { - mapTileList.setMapTileList(map, gameObject); + mapTileListControl.setMapTileList(map, gameObject); } public void refreshMapTileList() { - mapTileList.refresh(); + mapTileListControl.refresh(); } public GameObject getMapTileSelection() { - return mapTileList.getMapTileSelection(); + return mapTileListControl.getMapTileSelection(); } /** @@ -447,7 +448,7 @@ */ void refreshMenusAndToolbars() { archPanel.refresh(); - //mapTileList.refresh(); + //mapTileListControl.refresh(); mapArchPanel.refresh(); statusBar.refresh(); @@ -455,7 +456,7 @@ } /** Refresh the map arch panel (bottom window). */ - void refreshMapArchPanel() { + public void refreshMapArchPanel() { mapArchPanel.refresh(); } @@ -827,8 +828,8 @@ return statusBar; } - public CMapTileList getMapTileList() { - return mapTileList; + public MapTileListControl getMapTileListControl() { + return mapTileListControl; } /** {@inheritDoc} */ Deleted: trunk/daimonin/src/daieditor/CMapTileList.java =================================================================== --- trunk/daimonin/src/daieditor/CMapTileList.java 2006-12-22 22:24:55 UTC (rev 1218) +++ trunk/daimonin/src/daieditor/CMapTileList.java 2006-12-23 09:53:58 UTC (rev 1219) @@ -1,479 +0,0 @@ -/* - * Daimonin Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * Copyright (C) 2005 Christian Hujer - * - * (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; - -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; -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...">Christian Hujer</a> - * @todo turn this into a tree - */ -public final class CMapTileList extends JPanel implements ListSelectionListener, MouseListener, MapCursorListener { - - /** 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; - - /** - * Create a CMapTileList. - * @param mainControl MainControl, used for icons - * @param mainView MainView, used for updating UI - */ - public CMapTileList(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 - } - - /** {@inheritDoc} */ - public void valueChanged(final ListSelectionEvent e) { - mainView.setMapArchPanelObject(getMapTileSelection()); - } - - /** - * Action method for moving an arch topmost within its tile. - */ - @ActionMethod public void moveTileTop() { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveTop(); - } - refresh(); - } - - /** - * Action method for moving an arch up within its tile. - */ - @ActionMethod public void moveTileUp() { - final GameObject arch = getMapTileSelection(); - if (arch != null) { - arch.moveUp(); - } - refresh(); - } - - /** - * Action method for moving an arch down within its tile. - */ - @ActionMethod public void moveTileDown() { - final GameObject a... [truncated message content] |
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] |
From: <aki...@us...> - 2006-12-23 12:45:27
|
Revision: 1221 http://svn.sourceforge.net/gridarta/?rev=1221&view=rev Author: akirschbaum Date: 2006-12-23 04:45:27 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Remove unused import statements. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -25,7 +25,6 @@ package cfeditor; -import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import java.awt.BorderLayout; import java.awt.Component; @@ -46,7 +45,6 @@ import javax.swing.event.ListSelectionListener; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * @author unknown Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -25,17 +25,12 @@ package cfeditor.gameobject; import cfeditor.CMainControl; -import cfeditor.IGUIConstants; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; -import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -39,11 +39,8 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Date; -import javax.swing.JList; -import javax.swing.JPanel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -25,7 +25,6 @@ package cfeditor.map; import cfeditor.CMainControl; -import cfeditor.CMapViewBasic; import cfeditor.IGUIConstants; import cfeditor.MapViewIFrame; import cfeditor.gameobject.GameObject; Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -25,7 +25,6 @@ package daieditor; -import daieditor.gameobject.ArchetypeSet; import daieditor.gameobject.GameObject; import java.awt.BorderLayout; import java.awt.Component; @@ -51,7 +50,6 @@ import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * @author unknown Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListControl.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -27,11 +27,9 @@ package daieditor.gui.maptilelist; import daieditor.CopyBuffer; -import daieditor.CGUIUtils; import daieditor.CMainControl; import daieditor.CMainView; import daieditor.CPickmapPanel; -import daieditor.IGUIConstants; import daieditor.gameobject.GameObject; import daieditor.map.MapControl; import java.awt.Point; @@ -44,9 +42,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; 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; /** Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:26:23 UTC (rev 1220) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:45:27 UTC (rev 1221) @@ -26,10 +26,8 @@ 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; @@ -39,12 +37,7 @@ 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; @@ -55,13 +48,9 @@ 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 13:09:46
|
Revision: 1222 http://svn.sourceforge.net/gridarta/?rev=1222&view=rev Author: akirschbaum Date: 2006-12-23 05:09:46 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Move cell renderer class of MapTileListView into separate java file. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java Added: trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java 2006-12-23 13:09:46 UTC (rev 1222) @@ -0,0 +1,110 @@ +/* + * Gridarta Java Editor. + * 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.CMainControl; +import cfeditor.gameobject.ArchetypeSet; +import cfeditor.gameobject.GameObject; +import java.awt.Component; +import javax.swing.BorderFactory; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; +import net.sf.gridarta.gameobject.GameObjectContainer; +import org.jetbrains.annotations.NotNull; + +/** + * CellRenderer for rendering ArchObjects on a certain map tile in a list. + */ +public final class CellRenderer extends DefaultListCellRenderer { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** The archetype set. */ + @NotNull private final ArchetypeSet archetypeSet; + + public CellRenderer(@NotNull final ArchetypeSet archetypeSet) { + this.archetypeSet = archetypeSet; + } + + /** {@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(archetypeSet.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 CellRenderer Property changes on: trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:45:27 UTC (rev 1221) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 13:09:46 UTC (rev 1222) @@ -32,12 +32,10 @@ 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; @@ -94,7 +92,7 @@ model = new DefaultListModel(); list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); + list.setCellRenderer(new CellRenderer(mainControl.getArchetypeSet())); list.setBackground(Color.lightGray); final JScrollPane scrollPane = new JScrollPane(list); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); @@ -336,72 +334,4 @@ } } - /** 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 Added: trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java 2006-12-23 13:09:46 UTC (rev 1222) @@ -0,0 +1,93 @@ +/* + * Gridarta Java Editor. + * 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.CMainControl; +import daieditor.gameobject.ArchetypeSet; +import daieditor.gameobject.GameObject; +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.ImageIcon; +import javax.swing.JList; +import org.jetbrains.annotations.NotNull; + +/** + * CellRenderer for rendering ArchObjects on a certain map tile in a list. + */ +public final class CellRenderer extends DefaultListCellRenderer { + + /** Serial Version UID. */ + private static final long serialVersionUID = 1L; + + /** The archetype set. */ + @NotNull private final ArchetypeSet archetypeSet; + + public CellRenderer(@NotNull final ArchetypeSet archetypeSet) { + this.archetypeSet = archetypeSet; + } + + /** {@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 ? archetypeSet.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 CellRenderer Property changes on: trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 12:45:27 UTC (rev 1221) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 13:09:46 UTC (rev 1222) @@ -33,14 +33,11 @@ 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 java.awt.event.MouseEvent; -import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; -import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; @@ -100,7 +97,7 @@ model = new DefaultListModel(); list = new JList(model); - list.setCellRenderer(new MyCellRenderer()); + list.setCellRenderer(new CellRenderer(mainControl.getArchetypeSet())); list.setBackground(Color.lightGray); final JScrollPane scrollPane = new JScrollPane(list); scrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); @@ -318,56 +315,4 @@ } } - /** 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 MapTileListView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 14:07:07
|
Revision: 1224 http://svn.sourceforge.net/gridarta/?rev=1224&view=rev Author: akirschbaum Date: 2006-12-23 06:07:07 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Add isPointValid() to common MapControl interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 13:36:24 UTC (rev 1223) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 14:07:07 UTC (rev 1224) @@ -520,12 +520,7 @@ } } - /** - * Check if the coordinates posx, posy are valid (located within the - * borders of the map). - * @param pos coordinate to check - * @return true if this point is located within the map boundaries - */ + /* {@inheritDoc} */ public boolean isPointValid(final Point pos) { return mapModel.isPointValid(pos); } Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 13:36:24 UTC (rev 1223) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 14:07:07 UTC (rev 1224) @@ -268,13 +268,7 @@ return mapModel.getMapSize(); } - /** - * Check if the coordinates posx, posy are valid (located within the - * borders of the map). - * @param pos the x-coordinate - * @return <code>true</code> if this point is located within the map - * boundaries - */ + /** {@inheritDoc} */ public boolean isPointValid(final Point pos) { return mapModel.isPointValid(pos); } Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 13:36:24 UTC (rev 1223) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 14:07:07 UTC (rev 1224) @@ -1,5 +1,7 @@ package net.sf.gridarta.map; +import java.awt.Point; + /** * Currently nothing more than a marker interface for unification. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> @@ -19,4 +21,13 @@ */ MapModel getMapModel(); + /** + * Check if the coordinate is valid (located within the borders of the + * map). + * @param pos the coordinate to check + * @return <code>true</code> if this point is located within the map + * boundaries + */ + boolean isPointValid(final Point pos); + } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 15:14:36
|
Revision: 1226 http://svn.sourceforge.net/gridarta/?rev=1226&view=rev Author: akirschbaum Date: 2006-12-23 07:14:35 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Add getMapCursor() to common MapControl interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 15:14:13 UTC (rev 1225) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 15:14:35 UTC (rev 1226) @@ -298,6 +298,7 @@ return mapModel; } + /** {@inheritDoc} */ public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 15:14:13 UTC (rev 1225) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 15:14:35 UTC (rev 1226) @@ -382,6 +382,7 @@ return mapModel; } + /** {@inheritDoc} */ public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 15:14:13 UTC (rev 1225) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 15:14:35 UTC (rev 1226) @@ -1,6 +1,8 @@ package net.sf.gridarta.map; import java.awt.Point; +import net.sf.gridarta.gui.map.MapCursor; +import org.jetbrains.annotations.NotNull; /** * Currently nothing more than a marker interface for unification. @@ -30,4 +32,10 @@ */ boolean isPointValid(final Point pos); + /** + * Return the map cursor of this map. + * @return the map cursor of this map + */ + @NotNull MapCursor getMapCursor(); + } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 15:39:24
|
Revision: 1227 http://svn.sourceforge.net/gridarta/?rev=1227&view=rev Author: christianhujer Date: 2006-12-23 07:39:22 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Fixed javadoc and similar issues. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java trunk/daimonin/src/test/daieditor/map/validation/AbstractValidatorTest.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java trunk/src/test/net/sf/gridarta/gui/HideFileFilterProxyTest.java Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -47,6 +47,7 @@ import org.jetbrains.annotations.NotNull; /** + * Panel for Archetypes. * @author unknown * @author Andreas Kirschbaum */ @@ -80,7 +81,7 @@ private final CArchPanel archPanel; /** - * Comparator used to sort entries shown in {@link archList}. + * Comparator used to sort entries shown in {@link #archList}. */ private static final Comparator<GameObject> archComparator = new Comparator<GameObject>() { Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -623,7 +623,7 @@ * * @deprecated this has nothing to do with MainControl and should be refactored */ - public void addArchPanelArchetype(@NotNull final String panelName, @NotNull final String folderName, @NotNull final GameObject arch) { + @Deprecated public void addArchPanelArchetype(@NotNull final String panelName, @NotNull final String folderName, @NotNull final GameObject arch) { mainView.addArchPanelArchetype(panelName, folderName, arch); } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -196,9 +196,9 @@ } /** - * This method loads the arches & faces recursively by looping through - * the arch folder, collecting all the trash. + * Loads all archetypes and faces by recursing through the <code>arch/</code> directory tree. * @param f file path where we currently are + * @param folderLevel level of the folder * @param panelName the panel to add archetypes to * @param folderName the folder to add archetypes to */ Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -34,6 +34,7 @@ /** * CellRenderer for rendering ArchObjects on a certain map tile in a list. + * @author Andreas Kirschbaum */ public final class CellRenderer extends DefaultListCellRenderer { Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -52,6 +52,7 @@ import org.jetbrains.annotations.NotNull; /** + * Panel for Archetypes. * @author unknown * @author Andreas Kirschbaum */ @@ -92,7 +93,7 @@ private final CArchPanel archPanel; /** - * Comparator used to sort entries shown in {@link archList}. + * Comparator used to sort entries shown in {@link #archList}. */ private static final Comparator<GameObject> archComparator = new Comparator<GameObject>() { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -314,11 +314,12 @@ private File currentFile; /** - * This method loads the arches & faces recursively by looping through - * the arch folder, collecting all the face, arc and png files.. - * @param f file path where we currently are - * @param index counter for arches - * @param noPanel if <var>true</var> no arch panels will be generated + * Loads all archetypes and faces by recursing through the <code>arch/</code> directory tree. + * @param f file path where we currently are + * @param folderLevel level of the folder + * @param panelName the panel to add archetypes to + * @param folderName the folder to add archetypes to + * @param noPanel set this to true if the file should be omitted from the panel. */ private void loadArchFromFiles(final File f, final int folderLevel, @NotNull final String panelName, @NotNull final String folderName, final boolean noPanel) { final String name = f.getName(); @@ -369,7 +370,7 @@ /** * This method loads animations that are separately defined by looping * through all files that were previously collected by {@link - * #loadArchFromFiles(File,int,boolean)}. Do not invoke this method if + * #loadArchFromFiles(File, int, String, String, boolean)}. Do not invoke this method if * loadArchFromFiles() wasn't invoked. */ private void loadAnimsFromFiles() { Modified: trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/daieditor/gui/maptilelist/CellRenderer.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -33,6 +33,7 @@ /** * CellRenderer for rendering ArchObjects on a certain map tile in a list. + * @author Andreas Kirschbaum */ public final class CellRenderer extends DefaultListCellRenderer { Modified: trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -182,7 +182,7 @@ testEvents(0, 0); } - @Test public void isOnGrid() { + @Test public void testIsOnGrid() { final Point p = new Point(); for (int j = -2; j < gridSize.getHeight() + 2; j++) { for (int i = -2; i < gridSize.getWidth() + 2; i++) { @@ -197,7 +197,7 @@ assertFalse("Null should not be on the grid.", cursor.isOnGrid(null)); } - @Test public void go() { + @Test public void testGoTo() { for (int dir = 0; dir < 8; dir++) { assertFalse("go(" + dir + ") should return false.", cursor.goTo(dir)); testEvents(0, 0); @@ -407,6 +407,8 @@ /** * Test if number of events fired is correct. + * @param nPos number of position events. + * @param nMode number of mode events. */ private void testEvents(final int nPos, final int nMode) { assertEquals("Position change event", nPos, changedPosCounter); Modified: trunk/daimonin/src/test/daieditor/map/validation/AbstractValidatorTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/map/validation/AbstractValidatorTest.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/daimonin/src/test/daieditor/map/validation/AbstractValidatorTest.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -47,7 +47,7 @@ } /** Test case for {@link AbstractValidator#setEnabled(boolean)}. */ - public void testEnabled() throws Exception { + public void testEnabled() { oUT.setEnabled(false); assertFalse(oUT.isEnabled()); oUT.setEnabled(true); Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -53,7 +53,7 @@ GameObject parseArchetypeFromStream(BufferedReader in, @Nullable G prototype, @Nullable String line, @Nullable String archName, @NotNull String panelName, @NotNull String folderName, String fname) throws IOException; /** - * Short form of {@link #parseArchetypeFromStream(BufferedReader, GameObject, String, String, int, String)}. + * Short form of {@link #parseArchetypeFromStream(BufferedReader, GameObject, String, String, String, String, String)}. * @param in <code>BufferedReader</code> file stream of archetype data * @param panelName the panel name to add the archetype to * @param folderName the folder name to add the archetype to Modified: trunk/src/test/net/sf/gridarta/gui/HideFileFilterProxyTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/HideFileFilterProxyTest.java 2006-12-23 15:14:35 UTC (rev 1226) +++ trunk/src/test/net/sf/gridarta/gui/HideFileFilterProxyTest.java 2006-12-23 15:39:22 UTC (rev 1227) @@ -16,17 +16,17 @@ private HideFileFilterProxy oUT; /** Test case for {@link HideFileFilterProxy#HideFileFilterProxy(AbstractFileFilter)}. */ - @Test public void testHideFileFilterProxy() throws Exception { + @Test public void testHideFileFilterProxy() { fail("Test is not implemented"); // TODO: Test goes here... } /** Test case for {@link HideFileFilterProxy#getDescription()}. */ - @Test public void testGetDescription() throws Exception { + @Test public void testGetDescription() { fail("Test is not implemented"); // TODO: Test goes here... } /** Test case for {@link HideFileFilterProxy#accept(File)}. */ - @Test public void testAccept() throws Exception { + @Test public void testAccept() { fail("Test is not implemented"); // TODO: Test goes here... } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 19:09:38
|
Revision: 1228 http://svn.sourceforge.net/gridarta/?rev=1228&view=rev Author: akirschbaum Date: 2006-12-23 11:09:38 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Return the newly inserted game object from MapModel.insertArchToMap(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -587,7 +587,7 @@ mainView.showArchPanelQuickObject(gameObject); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return currentMap.insertArchToMap(newarch, archname, next, pos, join); } Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -245,12 +245,13 @@ /** * {@inheritDoc} */ - public boolean insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos, final boolean join) { // map coords must be valid if (!isPointValid(pos)) { - return false; + return null; } + final GameObject newGameObject; if (next == null || !next.isInContainer()) { // put arch on the map @@ -261,7 +262,7 @@ } // insert a new instance of the default arch (number 'archName') if (!addArchToMap(archName, pos, true, join, false)) { - return false; + return null; } } else { // insert the given 'newObject' (multis not allowed here yet - sorry) @@ -269,11 +270,11 @@ newObject = newObject.createClone(pos.x, pos.y); // create a clone addGameObjectToMap(newObject, false); // insert it to the map } else { - return false; // tried to insert multi (probably from pickmap) + return null; // tried to insert multi (probably from pickmap) } } - final GameObject node = mapGrid[pos.x][pos.y].getLast(); + newGameObject = mapGrid[pos.x][pos.y].getLast(); int position = 0; for (final GameObject search : mapGrid[pos.x][pos.y].reverse()) { if (search == next) { @@ -282,33 +283,32 @@ position++; } for(int i = 0; i < position - 1; i++) { - node.moveDown(); + newGameObject.moveDown(); } } else { // insert the new arch into the inventory of a map arch - final GameObject invnew; // new arch to be inserted if (newObject == null || newObject.isArchetype()) { if (newObject != null && newObject.isArchetype()) { archName = newObject.getArchetypeName(); } // create a new copy of a default arch - invnew = getArchetype(archName).createArch(); + newGameObject = getArchetype(archName).createArch(); } else { // create clone from a pickmap if (!newObject.isMulti()) { - invnew = newObject.createClone(pos.x, pos.y); + newGameObject = newObject.createClone(pos.x, pos.y); } else { - return false; + return null; } } - next.getContainer().addLast(invnew); - mainControl.getArchetypeParser().postParseGameObject(invnew, mapControl.getActiveEditType()); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); + next.getContainer().addLast(newGameObject); + mainControl.getArchetypeParser().postParseGameObject(newGameObject, mapControl.getActiveEditType()); + mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), newGameObject); } setLevelChangedFlag(); // the map has been modified - return true; + return newGameObject; } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -202,7 +202,7 @@ return addArchToMap(archname, pos, allowDouble, join, false); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return mapModel.insertArchToMap(newarch, archname, next, pos, join); } Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -61,9 +61,9 @@ * -> 'next' must be an arch from the map! (or null) * @param pos map position to insert the new arch * @param join if set to JOIN_ENABLE auto-joining is supported - * @return true if insertion was successful + * @return the inserted game object, or <code>null</code> if an error occurred */ - boolean insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos, boolean join); + @Nullable GameObject insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos, boolean join); /** * Delete an existing arch from the map. (If the specified arch doesn't Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -783,7 +783,7 @@ mainView.showArchPanelQuickObject(gameObject); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { return currentMap.getMapModel().insertArchToMap(newarch, archname, next, point); } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -172,12 +172,13 @@ * {@inheritDoc} * @xxx I'm too complex */ - public boolean insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos) { + @Nullable public GameObject insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos) { // map coords must be valid if (!isPointValid(pos)) { - return false; + return null; } + final GameObject newGameObject; if (next == null || !next.isInContainer()) { // put arch on the map @@ -188,7 +189,7 @@ } // insert a new instance of the default arch (number 'archName') if (!addArchToMap(archName, pos, true, false)) { - return false; + return null; } } else { // insert the given 'newObject' (multis not allowed here yet - sorry) @@ -196,11 +197,11 @@ newObject = newObject.createClone(pos.x, pos.y); // create a clone addGameObjectToMap(newObject, false); // insert it to the map } else { - return false; // tried to insert multi (probably from pickmap) + return null; // tried to insert multi (probably from pickmap) } } - final GameObject node = mapGrid[pos.x][pos.y].getLast(); + newGameObject = mapGrid[pos.x][pos.y].getLast(); int position = 0; for (final GameObject search : mapGrid[pos.x][pos.y].reverse()) { // This is okay because next is on the desired square. @@ -211,33 +212,32 @@ position++; } for(int i = 0; i < position - 1; i++) { - node.moveDown(); + newGameObject.moveDown(); } } else { // insert the new arch into the inventory of a map arch - final GameObject invnew; // new arch to be inserted if (newObject == null || newObject.isArchetype()) { if (newObject != null && newObject.isArchetype()) { archName = newObject.getArchetypeName(); } // create a new copy of a default arch - invnew = getArchetype(archName).createArch(); + newGameObject = getArchetype(archName).createArch(); } else { // create clone from a pickmap if (!newObject.isMulti()) { - invnew = newObject.createClone(pos.x, pos.y); + newGameObject = newObject.createClone(pos.x, pos.y); } else { - return false; + return null; } } - next.getContainer().addLast(invnew); - invnew.setObjectFace(); - mainControl.getArchetypeParser().postParseGameObject(invnew, mapControl.getActiveEditType()); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); + next.getContainer().addLast(newGameObject); + newGameObject.setObjectFace(); + mainControl.getArchetypeParser().postParseGameObject(newGameObject, mapControl.getActiveEditType()); + mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), newGameObject); } - return true; + return newGameObject; } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/MapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/map/MapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -61,9 +61,9 @@ * ('next'==null) the arch gets inserted at bottom * -> 'next' must be an arch from the map! (or null) * @param pos map position to insert the new arch - * @return true if insertion was successful + * @return the inserted game object, or <code>null</code> if an error occurred */ - boolean insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos); + @Nullable GameObject insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos); /** * Get the first exit on the MapSquare described by <var>hspot</var>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 20:27:07
|
Revision: 1229 http://svn.sourceforge.net/gridarta/?rev=1229&view=rev Author: christianhujer Date: 2006-12-23 12:26:58 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Documented some Nullability. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -1537,7 +1537,7 @@ } /** {@inheritDoc} */ - public void removeMainControlListener(final MainControlListener listener) { + public void removeMainControlListener(@NotNull final MainControlListener listener) { listenerList.remove(MainControlListener.class, listener); } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -104,9 +104,9 @@ private boolean gridVisible = false; - private MapCursor mapCursor; + @NotNull private final MapCursor mapCursor; - private MapGrid mapGrid; + @NotNull private final MapGrid mapGrid; // interface for the mapview frame private final MapView frame; @@ -186,7 +186,7 @@ * Get MapCursor of this view. * @return MapCursor of this view. */ - public MapCursor getMapCursor() { + @NotNull public MapCursor getMapCursor() { return mapCursor; } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -299,12 +299,12 @@ } /** {@inheritDoc} */ - public MapCursor getMapCursor() { + @NotNull public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); } - public MapGrid getMapGrid() { + @NotNull public MapGrid getMapGrid() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapGrid(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -1723,7 +1723,7 @@ } /** {@inheritDoc} */ - public void removeMainControlListener(final MainControlListener listener) { + public void removeMainControlListener(@NotNull final MainControlListener listener) { listenerList.remove(MainControlListener.class, listener); } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -101,9 +101,9 @@ /** The tile palette renderer. */ private final DefaultLevelRenderer renderer; - private MapCursor mapCursor; + @NotNull private final MapCursor mapCursor; - private MapGrid mapGrid; + @NotNull private final MapGrid mapGrid; /** The MapSquares that are known to contain errors. */ private Map<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError> erraneousMapSquares = new HashMap<MapSquare<? extends net.sf.gridarta.gameobject.GameObject>, ValidationError>(); @@ -161,7 +161,7 @@ * Get MapGrid of this view. * @return MapGrid of this view. */ - public MapGrid getMapGrid() { + @NotNull public MapGrid getMapGrid() { return mapGrid; } @@ -169,7 +169,7 @@ * Get MapCursor of this view. * @return MapCursor of this view. */ - public MapCursor getMapCursor() { + @NotNull public MapCursor getMapCursor() { return mapCursor; } Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -129,7 +129,7 @@ * Get the background music that is attached to the map name. * @return background music or <code>null</code> if no background music */ - public String getBackgroundMusic() { + @Nullable public String getBackgroundMusic() { final int t1 = getMapName().indexOf("§"); final int t2 = getMapName().indexOf("|"); return t1 > 0 && t2 > t1 ? getMapName().substring(t1 + 1, t2) : null; Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -55,6 +55,7 @@ import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * The <code>MapControl</code>. @@ -383,12 +384,12 @@ } /** {@inheritDoc} */ - public MapCursor getMapCursor() { + @NotNull public MapCursor getMapCursor() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapCursor(); } - public MapGrid getMapGrid() { + @NotNull public MapGrid getMapGrid() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapGrid(); } Modified: trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java =================================================================== --- trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java 2006-12-23 19:09:38 UTC (rev 1228) +++ trunk/daimonin/src/test/daieditor/gui/map/MapCursorTest.java 2006-12-23 20:26:58 UTC (rev 1229) @@ -261,27 +261,18 @@ offset.width = p.x - start.x; offset.height = p.y - start.y; assertEquals("Wrong offset", offset, cursor.getDragOffset()); - checkPreSelection(start, p); + assertPreSelection(start, p); } - private void checkPreSelection(final Point start, final Point end) { - final int minX, maxX, minY, maxY; - if (start.x < end.x) { - minX = start.x; - maxX = end.x; - } else { - minX = end.x; - maxX = start.x; - } - if (start.y < end.y) { - minY = start.y; - maxY = end.y; - } else { - minY = end.y; - maxY = start.y; - } - for (int j = 0; j < gridSize.getHeight(); j++) { - for (int i = 0; i < gridSize.getWidth(); i++) { + private void assertPreSelection(final Point start, final Point end) { + final int minX = Math.min(start.x, end.x); + final int maxX = Math.max(start.x, end.x); + final int minY = Math.min(start.y, end.y); + final int maxY = Math.max(start.y, end.y); + final int height = gridSize.getHeight(); + final int width = gridSize.getWidth(); + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { if (i < minX || i > maxX || j < minY || j > maxY) { //Not preselected assertFalse("Preselection", (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTING) > 0); @@ -294,22 +285,11 @@ } } - private void checkSelection(final Point start, final Point end, final boolean flag) { - final int minX, maxX, minY, maxY; - if (start.x < end.x) { - minX = start.x; - maxX = end.x; - } else { - minX = end.x; - maxX = start.x; - } - if (start.y < end.y) { - minY = start.y; - maxY = end.y; - } else { - minY = end.y; - maxY = start.y; - } + private void assertSelection(final Point start, final Point end, final boolean flag) { + final int minX = Math.min(start.x, end.x); + final int maxX = Math.max(start.x, end.x); + final int minY = Math.min(start.y, end.y); + final int maxY = Math.max(start.y, end.y); for (int j = minY; j <= maxY; j++) { for (int i = minX; i <= maxX; i++) { assertSame("Selection", flag, (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTION) > 0); @@ -351,12 +331,12 @@ cursor.dragTo(end); testEvents(1, 0); assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); - checkSelection(new Point(0, 0), gridMaxIndex, false); + assertSelection(new Point(0, 0), gridMaxIndex, false); cursor.dragSelect(MapGrid.SelectionMode.ADD); testEvents(0, 1); - checkSelection(start, end, true); + assertSelection(start, end, true); //Check if nothing is preselected - checkPreSelection(new Point(-1, -1), new Point(-1, -1)); + assertPreSelection(new Point(-1, -1), new Point(-1, -1)); cursor.setLocation(start); testEvents(1, 0); cursor.dragStart(); @@ -365,7 +345,7 @@ testEvents(1, 0); cursor.dragSelect(MapGrid.SelectionMode.SUB); testEvents(0, 1); - checkSelection(new Point(0, 0), gridMaxIndex, false); + assertSelection(new Point(0, 0), gridMaxIndex, false); cursor.setLocation(start); testEvents(1, 0); cursor.dragStart(); @@ -374,7 +354,7 @@ testEvents(1, 0); cursor.dragSelect(MapGrid.SelectionMode.FLIP); testEvents(0, 1); - checkSelection(start, end, true); + assertSelection(start, end, true); start.setLocation(3, 4); end.setLocation(5, 1); cursor.setLocation(start); @@ -385,12 +365,12 @@ testEvents(1, 0); cursor.dragSelect(MapGrid.SelectionMode.FLIP); testEvents(0, 1); - checkSelection(start, new Point(4, 4), false); - checkSelection(new Point (3, 2), end, true); - checkSelection(new Point (5, 3), new Point (5, 4), true); + assertSelection(start, new Point(4, 4), false); + assertSelection(new Point (3, 2), end, true); + assertSelection(new Point (5, 3), new Point (5, 4), true); cursor.deactivate(); testEvents(1, 1); - checkSelection(new Point(0, 0), gridMaxIndex, false); + assertSelection(new Point(0, 0), gridMaxIndex, false); } @AfterClass public static void deleteCursor() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 20:54:33
|
Revision: 1231 http://svn.sourceforge.net/gridarta/?rev=1231&view=rev Author: christianhujer Date: 2006-12-23 12:54:30 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Unified CFArchAttrib. Also fixes a bug in cfeditor.CFArchAttrib. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchAttrib.java trunk/daimonin/src/daieditor/CFArchAttrib.java Modified: trunk/crossfire/src/cfeditor/CFArchAttrib.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-23 20:49:43 UTC (rev 1230) +++ trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-23 20:54:30 UTC (rev 1231) @@ -153,7 +153,7 @@ dataType = ArchAttribType.FLOAT; } else if (atype.equalsIgnoreCase("string")) { dataType = ArchAttribType.STRING; - } else if (atype.equalsIgnoreCase("text")) { + } else if (atype.equalsIgnoreCase("facename")) { dataType = ArchAttribType.FACENAME; } else if (atype.equalsIgnoreCase("animname")) { dataType = ArchAttribType.ANIMNAME; Modified: trunk/daimonin/src/daieditor/CFArchAttrib.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchAttrib.java 2006-12-23 20:49:43 UTC (rev 1230) +++ trunk/daimonin/src/daieditor/CFArchAttrib.java 2006-12-23 20:54:30 UTC (rev 1231) @@ -128,9 +128,9 @@ } // which type of attribute is it? - if ("bool".equalsIgnoreCase(atype)) { + if (atype.equalsIgnoreCase("bool")) { dataType = ArchAttribType.BOOL; // normal bool - } else if ("bool_special".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("bool_special")) { // customized boolean type: dataType = ArchAttribType.BOOL_SPEC; @@ -140,24 +140,24 @@ if (a1 == null || a2 == null) { log.error("In '" + IGUIConstants.TYPEDEF_FILE + "': Type " + typeName + " has bool_special attribute missing 'true' or 'false' value."); return false; - } else { - misc = new String[2]; // 'misc' string contains the values - misc[0] = a1.getValue().trim(); // string for true - misc[1] = a2.getValue().trim(); // string for false } - } else if ("int".equalsIgnoreCase(atype)) { + + misc = new String[2]; // 'misc' string contains the values + misc[0] = a1.getValue().trim(); // string for true + misc[1] = a2.getValue().trim(); // string for false + } else if (atype.equalsIgnoreCase("int")) { dataType = ArchAttribType.INT; - } else if ("long".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("long")) { dataType = ArchAttribType.LONG; - } else if ("float".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("float")) { dataType = ArchAttribType.FLOAT; - } else if ("string".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("string")) { dataType = ArchAttribType.STRING; - } else if ("facename".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("facename")) { dataType = ArchAttribType.FACENAME; - } else if ("animname".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("animname")) { dataType = ArchAttribType.ANIMNAME; - } else if ("text".equalsIgnoreCase(atype)) { + } else if (atype.equalsIgnoreCase("text")) { dataType = ArchAttribType.TEXT; // for text data, the terminating string has to be read too if ((a1 = root.getAttributeNode(XML_KEY_ARCH_BEGIN)) != null) { @@ -222,7 +222,7 @@ log.error(key); } } - } else if (atype.startsWith("doublelist")) { + } else if ("doublelist".startsWith(atype)) { // got a doublelist attribute final String listNames = atype.substring(11).trim(); final int seppos = listNames.indexOf(','); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 21:08:19
|
Revision: 1232 http://svn.sourceforge.net/gridarta/?rev=1232&view=rev Author: akirschbaum Date: 2006-12-23 13:08:19 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Use event callbacks to update map tile panel (cfeditor only). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControlListener.java trunk/src/app/net/sf/gridarta/gui/ConnectionView.java trunk/src/app/net/sf/gridarta/map/MapControl.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/maptilelist/ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/ChangeLog 2006-12-23 21:08:19 UTC (rev 1232) @@ -1,3 +1,7 @@ +2006-12-23 Andreas Kirschbaum + + * Properly update map tile panel after changes. + 2006-12-22 Andreas Kirschbaum * Use bold font for top-level entries in treasure list viewer. Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -587,14 +587,6 @@ mainView.showArchPanelQuickObject(gameObject); } - @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { - return currentMap.insertArchToMap(newarch, archname, next, pos, join); - } - - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { - currentMap.deleteMapArch(gameObject, pos, join); - } - public GameObject getMapArch(final GameObject gameObject, final Point pos) { return currentMap.getMapArch(gameObject, pos); } @@ -721,6 +713,7 @@ // Create a new level control and set the level view from that final MapControl map = new MapControl(this, objects, maparch, false, initial); + fireMapCreatedEvent(map); if (view) { map.addMapGridListener(mainActions); map.addMapCursorListener(mainActions); @@ -841,13 +834,14 @@ } } + fireMapClosingEvent(level); + if (level.isPickmap()) { // special case: close a pickmap CPickmapPanel.getInstance().closePickmap(level); level.levelCloseNotify(); } else { // Notify the level about the closing - mainView.setMapTileList(null, null); level.levelCloseNotify(); mainView.removeLevelView(level.getMapViewFrame()); levels.remove(level); @@ -1519,6 +1513,34 @@ } /** + * Notify all listeners about a created map. + * + * @param mapControl the created map + */ + private void fireMapCreatedEvent(@NotNull final MapControl mapControl) { + final Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + //noinspection ObjectEquality + if (listeners[i] == MainControlListener.class) { + ((MainControlListener) listeners[i + 1]).mapCreated(mapControl); + } + } + } + + /** + * Notify all listeners about a map to be closed. + */ + private void fireMapClosingEvent(@NotNull final MapControl mapControl) { + final Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + //noinspection ObjectEquality + if (listeners[i] == MainControlListener.class) { + ((MainControlListener) listeners[i + 1]).mapClosing(mapControl); + } + } + } + + /** * Notify all listeners about a changed current map. */ private void fireCurrentMapChangedEvent() { @@ -1615,10 +1637,6 @@ void appExitNotify() { mainView.appExitNotify(); // notify main view - if (currentMap != null) { - mainView.setMapTileList(null, null); - } - // save settings CSettings.getInstance(IGUIConstants.APP_NAME).saveSettings(); } @@ -1893,6 +1911,16 @@ } /** {@inheritDoc} */ + public void mapCreated(@NotNull final net.sf.gridarta.map.MapControl mapControl) { + // ignore: a current map changed event will be generated + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final net.sf.gridarta.map.MapControl mapControl) { + // ignore: a current map changed event will be generated + } + + /** {@inheritDoc} */ public void mapGridChanged(@NotNull final MapGridEvent e) { refreshMenus(); // selection state may have changed } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -374,15 +374,6 @@ return mapArchPanel.getMapArchPanelObject(); } - // access mape tile list ... - public void setMapTileList(final MapControl map, final GameObject gameObject) { - mapTileListControl.setMapTileList(map, gameObject); - } - - public void refreshMapTileList() { - mapTileListControl.refresh(); - } - public GameObject getMapTileSelection() { return mapTileListControl.getMapTileSelection(); } @@ -467,7 +458,6 @@ */ void refreshMenusAndToolbars() { archPanel.refresh(); - mapTileListControl.refresh(); mapArchPanel.refresh(); statusBar.refresh(); Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -281,20 +281,10 @@ mainControl.getArchetypeParser().postParseGameObject(invnew, 0); inv.addLast(invnew); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv); mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified } public void updateMapTileList() { - GameObject inv = mainView.getMapTileSelection(); - if (inv == null) { - return; - } - - // if this is a multi-tail, we put the new arch into the head's inv. - inv = inv.getHead(); - - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv); mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified } @@ -445,7 +435,6 @@ updateMapTileList(); // if needed (due to face changes), we also redraw the map - mainControl.getMainView().refreshMapTileList(); if (needRedraw) { mainControl.getCurrentMap().repaint(); } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -385,10 +385,6 @@ if (!(selChange == mapCursor.isActive())) { CMainControl.getInstance().getMainView().refreshMenus(); } - - if (!e.isShiftDown() && !e.isControlDown()) { - selectTile(mapLoc); - } } else { // middle mouse button: delete arch // (I intenionally used "else" here. BUTTON2_MASK seems not to work for some systems) @@ -397,7 +393,6 @@ } } else { mapCursor.setLocation(mapLoc); - mainControl.getMainView().setMapTileList(null, null); // for secure... } /* UndoAndRedo.getInstance(mapControl).add(new CPaintOp(previewRect, aOrigData, (short)mapControl.getSelectedTile())); @@ -456,9 +451,7 @@ mapCursor.setLocation(temp); // Right Mouse Button: Arches get inserted all the way - if (temp == null) { - mainControl.getMainView().setMapTileList(null, null); - } else { + if (temp != null) { mapControl.insertSelArchToMap(temp, false); } } else { @@ -466,9 +459,7 @@ // Middle Mouse Button: Arches get deleted all the way - if (temp == null) { - mainControl.getMainView().setMapTileList(null, null); - } else { + if (temp != null) { // delete the topmost arch (matching the view settings) // on that square and redraw the map GameObject tmpArch = null; @@ -521,24 +512,10 @@ } else { insertArchName = "nothing"; } - - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } } } - private void selectTile(final Point mapLoc) { - if (mapLoc.x == -1 || mapLoc.y == -1) { - if (!mapControl.isPickmap()) { - mainControl.getMainView().setMapTileList(null, null); - } - } else { - if (!mapControl.isPickmap()) { - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); - } - } - } - private void deleteObject(final Point mapLoc) { if (mapLoc.x != -1 && mapLoc.y != -1) { // delete the topmost arch (matching the view settings) on that square @@ -554,9 +531,6 @@ if (tmpArch != null) { mapControl.calcArchRedraw(tmpArch); // get redraw info mapControl.deleteMapArch(tmpArch, mapLoc, MapModel.JOIN_ENABLE); - - // update mapArch panel - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } } } @@ -730,4 +704,12 @@ mapCursor.addMapCursorListener(listener); } + /** + * Unregister a MapCursorListener. + * @param listener MapCursorListener to unregister + */ + public void removeMapCursorListener(final MapCursorListener listener) { + mapCursor.removeMapCursorListener(listener); + } + } // class CMapViewBasic Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -223,9 +223,6 @@ } } mapControl.getMapModel().endTransaction(); - - // now the toolbars must be redrawn - mainControl.getMainView().refreshMapTileList(); } /** @@ -256,7 +253,6 @@ addArchToMap(mapControl, gameObject, p, false, fillBelow); } mapControl.getMapModel().endTransaction(); - mainControl.getMainView().refreshMapTileList(); } /** @@ -282,7 +278,6 @@ mapControl.getMapModel().beginTransaction("Floodfill"); // TODO: I18N/L10N floodfill(mapControl, cursor.x, cursor.y, arch); mapControl.getMapModel().endTransaction(); - mainControl.getMainView().refreshMapTileList(); } /** Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -39,6 +39,7 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGridListener; import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; /** * The <code>MapViewIFrame</code> is mainly a wrapper class which creates a @@ -231,10 +232,18 @@ * Register a MapCursorListener. * @param listener MapCursorListener to register */ - public void addMapCursorListener(final MapCursorListener listener) { + public void addMapCursorListener(@NotNull final MapCursorListener listener) { view.addMapCursorListener(listener); } + /** + * Unregister a MapCursorListener. + * @param listener MapCursorListener to unregister + */ + public void removeMapCursorListener(@NotNull final MapCursorListener listener) { + view.removeMapCursorListener(listener); + } + /** Action class for selecting this window. */ public final class WindowAction extends AbstractAction { Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -336,7 +336,6 @@ } mapControl.getMapModel().endTransaction(); - mainControl.getMainView().refreshMapTileList(); return replaceCount; } Modified: trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -143,35 +143,19 @@ } public void insertArch() { - final MapControl mapControl = mainControl.getCurrentMap(); - assert mapControl != null; - final MapCursor mapCursor = mapControl.getMapCursor(); - assert mapCursor != null; - if (mapCursor.isActive()) { - mapControl.insertSelArchToMap(mapCursor.getLocation(), true); - mainControl.getMainView().setMapTileList(mapControl, null); - } + final CMainView mainView = mainControl.getMainView(); + assert mainView != null; + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; + mapTileListControl.insertGameObjectFromArchPanel(); } public void deleteArch() { - final MapControl mapControl = mainControl.getCurrentMap(); - assert mapControl != null; - final MapCursor mapCursor = mapControl.getMapCursor(); - assert mapCursor != null; - if (mapCursor.isActive()) { - final CMainView mainView = mainControl.getMainView(); - assert mainView != null; - final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); - assert mapTileListControl != null; - final GameObject arch = mapTileListControl.getMapTileSelection(); - if (arch != null) { - final Point pos = mapCursor.getLocation(); - assert pos != null; - arch.remove(); - // TODO: re-select next object after the removed one - mainControl.getMainView().setMapTileList(mapControl, null); - } - } + final CMainView mainView = mainControl.getMainView(); + assert mainView != null; + final MapTileListControl mapTileListControl = mainView.getMapTileListControl(); + assert mapTileListControl != null; + mapTileListControl.deleteSelection(); } private void selectTile(final MapGrid.SelectionMode mode) { Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -41,6 +41,7 @@ import java.util.Date; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.Nullable; /** @@ -63,9 +64,6 @@ private GameObject lastClickGameObject = null; - /** The currently selected MapSquare. */ - private transient Point currentSquare = null; - /** The view for this controller. */ private final MapTileListView view; @@ -87,7 +85,6 @@ final GameObject arch = getMapTileSelection(); if (arch != null) { arch.moveDown(); - refresh(); } } }; @@ -99,7 +96,6 @@ final GameObject arch = getMapTileSelection(); if (arch != null) { arch.moveUp(); - refresh(); } } }; @@ -133,30 +129,10 @@ lastClickGameObject = getMapTileSelection(); } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.isShiftDown())) { // --- right mouse button: insert arch --- - - if (currentSquare != null && mainControl.getArchPanelHighlight() != null) { - mainControl.getCurrentMap().getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N - 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 = view.getListGameObject(listIndex); - mainControl.insertArchToMap(mainControl.getArchPanelHighlight(), mainControl.getPanelArchName(), entry, currentSquare, MapModel.JOIN_ENABLE); - } - mainControl.getCurrentMap().getMapModel().endTransaction(); - - // refresh - mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified - mainControl.getMainView().refreshMapTileList(); // update tile window - } + insertGameObjectFromArchPanel(view.getListIndex(e)); } else { // --- middle mouse button: delete arch --- - final int listIndex = view.getListIndex(e); - if (listIndex < view.getModelSize()) { - mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N - deleteIndexFromList(listIndex); - mainControl.getCurrentMap().getMapModel().endTransaction(); - } + deleteIndex(view.getListIndex(e)); } } }; @@ -179,33 +155,96 @@ } /** + * Delete the currently selected game object. + */ + public void deleteSelection() { + deleteIndex(view.getSelectedIndex()); + } + + /** * Delete an GameObject with a specific list index. * @param index List index of GameObject */ - private void deleteIndexFromList(final int index) { - if (index < 0) { + private void deleteIndex(final int index) { + if (index < 0 || index >= view.getModelSize()) { return; - } // index is -1 for empty lists, so an IndexOutOfBoundsException would be thrown - final GameObject temp = getMapTileSelection(); + } + + final MapControl mapControl = view.getCurrentMapControl(); + if (mapControl == null) { + return; + } + + final MapSquare<GameObject> mapSquare = view.getCurrentMapSquare(); + if (mapSquare == null) { + return; + } + + mapControl.getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N final GameObject entry = view.getListGameObject(index); if (entry != null) { - mainControl.deleteMapArch(entry, currentSquare, MapModel.JOIN_ENABLE); - setMapTileList(mainControl.getCurrentMap(), temp); + mapControl.deleteMapArch(entry, new Point(mapSquare.getMapX(), mapSquare.getMapY()), MapModel.JOIN_ENABLE); + + if (index + 1 < view.getModelSize()) { + view.setSelectedGameObject(view.getListGameObject(index + 1)); + } else if (index > 0) { + view.setSelectedGameObject(view.getListGameObject(index - 1)); + } else { + view.setSelectedGameObject(null); + } } + mapControl.getMapModel().endTransaction(); } - public void refresh() { - setMapTileList(mainControl.getCurrentMap(), getMapTileSelection()); - view.repaint(); + /** + * Insert a new game object. + */ + public void insertGameObjectFromArchPanel() { + insertGameObjectFromArchPanel(view.getSelectedIndex()); } /** + * Insert a new game object. + * + * @param index the list index to insert at + */ + public void insertGameObjectFromArchPanel(final int index) { + final GameObject gameObject = mainControl.getArchPanelHighlight(); + if (gameObject == null) { + return; + } + + final MapControl currentMapControl = view.getCurrentMapControl(); + if (currentMapControl == null) { + return; + } + + final MapSquare<GameObject> currentMapSquare = view.getCurrentMapSquare(); + if (currentMapSquare == null) { + return; + } + + currentMapControl.getMapModel().beginTransaction("Insert"); // TODO; I18N/L10N + final GameObject insertedGameObject; + if (index >= view.getModelSize()) { + insertedGameObject = currentMapControl.insertArchToMap(gameObject, mainControl.getPanelArchName(), null, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); + } else { + final GameObject entry = view.getListGameObject(index); + insertedGameObject = currentMapControl.insertArchToMap(gameObject, mainControl.getPanelArchName(), entry, new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY()), MapModel.JOIN_ENABLE); + } + view.setSelectedGameObject(insertedGameObject); + currentMapControl.getMapModel().endTransaction(); + + // refresh + currentMapControl.setLevelChangedFlag(); // the map has been modified + } + + /** * Set the display to the currently selected map tile. * @param mapControl Map to get display for (includes selection information) * @param gameObject selected GameObject */ public void setMapTileList(final MapControl mapControl, final GameObject gameObject) { - view.setMapTileList(mapControl, gameObject); // refresh the MapArchPanel to display the new arch mainView.refreshMapArchPanel(); @@ -220,22 +259,4 @@ return view; } - /** - * Return the currently selected MapSquare. - * - * @return the currently selected MapSquare - */ - @Nullable Point getCurrentSquare() { - return currentSquare; - } - - /** - * Set the currently selected MapSquare. - * - * @param point the selected MapSquare - */ - void setCurrentSquare(@Nullable Point point) { - currentSquare = point; - } - } // class MapTileListControl Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -33,6 +33,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; +import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseEvent; import javax.swing.BorderFactory; @@ -45,9 +46,15 @@ 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.MainControlListener; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.maptilelist.MapTileSelection; +import net.sf.gridarta.gui.maptilelist.MapTileSelectionCache; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; +import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -56,13 +63,13 @@ * @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 { +public final class MapTileListView extends JPanel implements MainControlListener<MapControl>, MapCursorListener, MapModelListener<GameObject> { /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** The controller for this view. */ - @NotNull final MapTileListControl control; + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(MapTileListView.class); /** The main control for this view. */ @NotNull final CMainControl mainControl; @@ -75,6 +82,16 @@ private int listCounter = 0; /** + * The cache to store selections for each map control. + */ + @NotNull private final MapTileSelectionCache<GameObject, MapControl> mapTileSelectionCache = new MapTileSelectionCache<GameObject, MapControl>(); + + /** + * The currently selected map tile. + */ + @Nullable private MapTileSelection<GameObject, MapControl> selectedMapTile = null; + + /** * Create a new instance. * * @param control the controller for this view @@ -85,7 +102,6 @@ * 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()); @@ -137,9 +153,31 @@ * listen for mouse events in the panel */ list.addMouseListener(control.getMouseListener()); + + mainControl.addMainControlListener(this); } /** + * Return the currently selected map control. + * + * @return the currently selected map control, or <code>null</code> if no + * tile is selected + */ + @Nullable public MapControl getCurrentMapControl() { + return selectedMapTile == null ? null : selectedMapTile.getMapControl(); + } + + /** + * Return the currently selected map square. + * + * @return the currently selected map square, or <code>null</code> if no + * tile is selected + */ + @Nullable public MapSquare<GameObject> getCurrentMapSquare() { + return selectedMapTile == null ? null : selectedMapTile.getMapSquare(); + } + + /** * 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 @@ -171,50 +209,51 @@ * @return the currently selected GameObject */ @Nullable public GameObject getMapTileSelection() { - return (GameObject) list.getSelectedValue(); - } + final GameObject gameObject = (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 (selectedMapTile != null) { + selectedMapTile.setGameObject(gameObject); + selectedMapTile.setIndex(list.getSelectedIndex()); } - if (index != -1 && getModelSize() > 0) { - list.setSelectedIndex(index); - } - return list.getSelectedIndex(); + + return gameObject; } /** - * Set the display to the currently selected map tile. - * @param mapControl Map to get display for (includes selection information) - * @param gameObject selected GameObject + * Re-display the map tile panel for {@link #selectedMapTile}. Possibly updates + * information in <code>selectedMapTile</code>. */ - void setMapTileList(final MapControl mapControl, final GameObject gameObject) { + private void refresh() { + final MapControl mapControl; + final MapSquare<GameObject> mapSquare; + final GameObject gameObject; + if (selectedMapTile == null) { + mapControl = null; + mapSquare = null; + gameObject = null; + } else { + mapControl = selectedMapTile.getMapControl(); + mapSquare = selectedMapTile.getMapSquare(); + gameObject = selectedMapTile.getGameObject(); + } + list.setEnabled(false); model.removeAllElements(); if (mapControl == null) { - // mouse has been clicked outside the mapview - control.setCurrentSquare(null); - getTileArch(-1); + list.setSelectedIndex(0); list.setEnabled(true); return; } listCounter = 0; - control.setCurrentSquare(mapControl.getMapCursor().getLocation()); int postSelect = -1; boolean foundSIndex = false; - int sIndex = 0; + int sIndex = -1; // 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()) { + if (mapSquare != null) { + for (final GameObject node : mapSquare.reverse()) { // add the node if (node == gameObject) { postSelect = listCounter; @@ -236,11 +275,16 @@ } if (postSelect != -1) { - list.setSelectedIndex(postSelect); - } else { + setSelectedIndex(postSelect); + } else if (sIndex != -1) { // 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); + setSelectedIndex(sIndex); + } else if (selectedMapTile != null){ + // use last known good index + setSelectedIndex(selectedMapTile.getIndex()); + } else { + setSelectedIndex(0); } list.setEnabled(true); @@ -250,7 +294,7 @@ * 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 + * @return <code>listCounter</code> for <var>gameObject</var>, or <code>-1</code> if not found */ private int addInvObjects(final GameObject node, final GameObject gameObject) { int selListCounter = -1; @@ -270,22 +314,124 @@ } /** {@inheritDoc} */ + public void currentMapChanged(@Nullable final MapControl mapControl) { + if (setSelectedMapTile(mapTileSelectionCache.findOrCreate(mapControl))) { + refresh(); + } + } + + /** {@inheritDoc} */ + public void mapCreated(@NotNull final MapControl mapControl) { + mapControl.addMapCursorListener(this); + mapControl.addMapModelListener(this); + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final MapControl mapControl) { + mapControl.removeMapModelListener(this); + mapControl.removeMapCursorListener(this); + + final MapTileSelection<GameObject, MapControl> closedMapTile = mapTileSelectionCache.find(mapControl); + if (selectedMapTile != null && selectedMapTile == closedMapTile) { + if (setSelectedMapTile(null)) { + refresh(); + } + } + } + + /** {@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); + if (selectedMapTile == null) { + return; } + + final MapControl mapControl = selectedMapTile.getMapControl(); + + final Point cursorPos = e.getSource().getLocation(); + if (cursorPos == null || !mapControl.isPointValid(cursorPos)) { + if (setSelectedMapSquare(null)) { + refresh(); + } + return; + } + + final MapSquare mapSquare = mapControl.getMapModel().getMapSquare(cursorPos); + if (setSelectedMapSquare(mapSquare)) { + refresh(); + } } /** {@inheritDoc} */ public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // A mode change can be ignored + // ignore } + /** {@inheritDoc} */ + public void mapSizeChanged(final MapModelEvent<GameObject> e) { + if (selectedMapTile != null && selectedMapTile.getMapControl().getMapModel() == e.getMapModel() && selectedMapTile.validateMapSquare()) { + refresh(); + } + } + + /** {@inheritDoc} */ + public void mapSquaresChanged(final MapModelEvent<GameObject> e) { + if (selectedMapTile == null) { + return; + } + + for (final MapSquare mapSquare : e.getSquares()) { + if (selectedMapTile.checkForChangedMapSquare(mapSquare)) { + refresh(); + break; + } + } + } + + /** {@inheritDoc} */ + public void mapObjectsChanged(final MapModelEvent<GameObject> e) { + if (selectedMapTile == null) { + return; + } + + for (final GameObject gameObject : e.getGameObjects()) { + final MapSquare mapSquare = gameObject.getMapSquare(); + if (mapSquare != null && selectedMapTile.checkForChangedMapSquare(mapSquare)) { + refresh(); + break; + } + } + } + /** + * Set a map tile selection. + * + * @return <code>true</code> if the selected map tile has changed + */ + private boolean setSelectedMapTile(@Nullable final MapTileSelection<GameObject, MapControl> mapTileSelection) { + if (mapTileSelection == selectedMapTile) { + return false; + } + + selectedMapTile = mapTileSelection; + return true; + } + + /** + * Set the currently selected map square. + * + * @param mapSquare the selected map square + * + * @return <code>true</code> if the state has changed + */ + private boolean setSelectedMapSquare(@Nullable final MapSquare mapSquare) { + if (selectedMapTile == null) { + return false; + } + + return selectedMapTile.setMapSquare(mapSquare); + } + + /** * Return a game object from the list. * * @param index the index in the list @@ -293,7 +439,8 @@ * @return the game object, or <code>null</code> if the index is invalid */ @Nullable GameObject getListGameObject(final int index) { - return (GameObject) model.getElementAt(index); + final int actualIndex = getValidIndex(index); + return actualIndex < model.getSize() ? (GameObject) model.getElementAt(actualIndex) : null; } /** @@ -306,6 +453,33 @@ } /** + * Set the selected game object. + * + * @param gameObject the game object to select, or <code>null</code> to + * unselect it + */ + void setSelectedGameObject(@Nullable final GameObject gameObject) { + if (selectedMapTile == null) { + return; + } + + if (gameObject != null) { + final MapSquare<GameObject> mapSquare = gameObject.getTopContainer().getMapSquare(); + if (mapSquare == null) { + log.warn("setSelectedGameObject: gameObject " + gameObject + " is not part of a map"); + return; + } + if (selectedMapTile.getMapControl().getMapModel() != mapSquare.getModel()) { + return; + } + + setSelectedMapSquare(mapSquare); + } + + selectedMapTile.setGameObject(gameObject); + } + + /** * Return the currently selected list index. * * @return the currently selected list index @@ -321,13 +495,28 @@ * @param index the index to select */ void setSelectedIndex(final int index) { + final int actualIndex = getValidIndex(index); + list.setSelectedIndex(actualIndex); + if (selectedMapTile != null) { + selectedMapTile.setIndex(actualIndex); + } + } + + /** + * Determine a valid list index near a given index. + * + * @param index the index to look up + * + * @return a valid index, or 0 if the list is empty + */ + private int getValidIndex(final int index) { if (index < 0) { - list.setSelectedIndex(0); - } else if (index >= getModelSize()) { - list.setSelectedIndex(Math.max(0, getModelSize() - 1)); - } else { - list.setSelectedIndex(index); + return 0; } + if (index >= getModelSize()) { + return Math.max(0, getModelSize() - 1); + } + return index; } } // class MapTileListView Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -304,7 +304,6 @@ next.getContainer().addLast(newGameObject); mainControl.getArchetypeParser().postParseGameObject(newGameObject, mapControl.getActiveEditType()); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), newGameObject); } setLevelChangedFlag(); // the map has been modified @@ -383,7 +382,7 @@ } /** {@inheritDoc} */ - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { + public void deleteMapArch(final GameObject gameObject, @NotNull final Point pos, final boolean join) { // first, try to find the tile we had selected for (final GameObject node : getMapSquare(pos)) { if (node == gameObject) { Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -36,6 +36,7 @@ import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridListener; +import net.sf.gridarta.map.MapModelListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,7 +45,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class MapControl implements net.sf.gridarta.map.MapControl { +public final class MapControl implements net.sf.gridarta.map.MapControl<GameObject, MapArchObject> { /** * The main controller of this subcontroller. @@ -214,7 +215,7 @@ mapModel.addGameObjectToMap(arch, false); } - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { + public void deleteMapArch(final GameObject gameObject, @NotNull final Point pos, final boolean join) { mapModel.deleteMapArch(gameObject, pos, join); } @@ -612,8 +613,32 @@ * Register a MapCursorListener. * @param listener MapCursorListener to register */ - public void addMapCursorListener(final MapCursorListener listener) { + public void addMapCursorListener(@NotNull final MapCursorListener listener) { mapViewFrame.addMapCursorListener(listener); } + /** + * Unregister a MapCursorListener. + * @param listener MapCursorListener to unregister + */ + public void removeMapCursorListener(@NotNull final MapCursorListener listener) { + mapViewFrame.removeMapCursorListener(listener); + } + + /** + * Register a MapModelListener. + * @param listener MapModelListener to register + */ + public void addMapModelListener(@NotNull final MapModelListener listener) { + mapModel.addMapModelListener(listener); + } + + /** + * Unregister a MapModelListener. + * @param listener MapModelListener to unregister + */ + public void removeMapModelListener(@NotNull final MapModelListener listener) { + mapModel.removeMapModelListener(listener); + } + } // class MapControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -884,6 +884,7 @@ setStatusText("Creating new map " + maparch.getMapName()); } final MapControl map = new MapControl(this, objects, maparch, false, view); + fireMapCreatedEvent(map); levels.add(map); if (view) { map.addMapGridListener(mainActions); @@ -1006,6 +1007,8 @@ } } + fireMapClosingEvent(level); + if (level.isPickmap()) { // special case: close a pickmap CPickmapPanel.getInstance().closePickmap(level); @@ -1705,6 +1708,34 @@ } /** + * Notify all listeners about a created map. + * + * @param mapControl the created map + */ + private void fireMapCreatedEvent(@NotNull final MapControl mapControl) { + final Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + //noinspection ObjectEquality + if (listeners[i] == MainControlListener.class) { + ((MainControlListener) listeners[i + 1]).mapCreated(mapControl); + } + } + } + + /** + * Notify all listeners about a map to be closed. + */ + private void fireMapClosingEvent(@NotNull final MapControl mapControl) { + final Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + //noinspection ObjectEquality + if (listeners[i] == MainControlListener.class) { + ((MainControlListener) listeners[i + 1]).mapClosing(mapControl); + } + } + } + + /** * Notify all listeners about a changed current map. */ private void fireCurrentMapChangedEvent() { @@ -2189,6 +2220,16 @@ aSelectAll.setEnabled(isSelectAllEnabled()); } + /** {@inheritDoc} */ + public void mapCreated(@NotNull final net.sf.gridarta.map.MapControl mapControl) { + // ignore: a current map changed event will be generated + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final net.sf.gridarta.map.MapControl mapControl) { + // ignore: a current map changed event will be generated + } + /* {@inheritDoc} */ public void currentMapChanged(@Nullable final net.sf.gridarta.map.MapControl mapControl) { refreshMenus(); Modified: trunk/src/app/net/sf/gridarta/MainControlListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControlListener.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/src/app/net/sf/gridarta/MainControlListener.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -22,6 +22,7 @@ import java.util.EventListener; import net.sf.gridarta.map.MapControl; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -29,7 +30,7 @@ * * @author Andreas Kirschbaum */ -public interface MainControlListener extends EventListener { +public interface MainControlListener<C extends MapControl> extends EventListener { /** * This event handler is called when the current map has changed. @@ -37,6 +38,20 @@ * @param mapControl the new map control, or <code>null</code> if no opened * map exists */ - void currentMapChanged(@Nullable MapControl mapControl); + void currentMapChanged(@Nullable C mapControl); + /** + * This event handler is called when a map was created. + * + * @param mapControl the created map control + */ + void mapCreated(@NotNull C mapControl); + + /** + * This event handler is called when a map is to be closed. + * + * @param mapControl the map control that is to be closed + */ + void mapClosing(@NotNull C mapControl); + } Modified: trunk/src/app/net/sf/gridarta/gui/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -37,6 +37,7 @@ import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -87,6 +88,16 @@ scanMapForConnections(mapControl == null ? null : mapControl.getMapModel()); } + /** {@inheritDoc} */ + public void mapCreated(@NotNull final MapControl mapControl) { + // ignore: a current map changed event will be generated + } + + /** {@inheritDoc} */ + public void mapClosing(@NotNull final MapControl mapControl) { + // ignore: a current map changed event will be generated + } + /** * Scans a map for the contained connections. * @param model Model of map to scan Added: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -0,0 +1,194 @@ +/* + * Gridarta Java Editor. + * 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 net.sf.gridarta.gui.maptilelist; + +import java.awt.Point; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapSquare; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The class <code>MapTileSelection</code> holds the selection state for one + * {@link MapControl}. It consists of a {@link MapSquare}, a {@link GameObject} + * in this map square, and a selection index. + * + * <p/>The game object and the selection index is redundant. This redundancy is + * used to retain the selection when the map square changes. + * + * @author Andreas Kirschbaum + */ +public class MapTileSelection<G extends GameObject<G>, C extends MapControl> { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(MapTileSelection.class.getName()); + + /** + * The corresponding map control. + */ + @NotNull private final C mapControl; + + /** + * The currently selected map square. It is set to <code>null</code> if no + * map tile is selected. + */ + @Nullable private MapSquare<G> mapSquare = null; + + /** + * The currently selected game object. It is part of {@link #mapSquare}. It + * is set to <code>null</code> if not game object is selected (or if + * <code>mapSquare</code> is <code>null</code>). + */ + @Nullable private G gameObject = null; + + /** + * The index in the map tile list that corresponds to {@link gameObject}. + * It is set to zero if <code>gameObject</code> is <code>null</code>. + */ + private int index = 0; + + /** + * Create a new instance. + * + * @param mapControl the corresponding map control + */ + public MapTileSelection(@NotNull final C mapControl) { + this.mapControl = mapControl; + } + + /** + * Select a map square. If it is different from the previously selected map + * square, the state ({@link #gameObject} and {@link #index}) is reset. + * + * @param mapSquare the selected map square + * + * @return <code>true</code> if the state has changed + */ + public boolean setMapSquare(@Nullable MapSquare<G> mapSquare) { + if (this.mapSquare == mapSquare) { + return false; + } + + this.mapSquare = mapSquare; + gameObject = null; + index = 0; + return true; + } + + /** + * Validate that the selected map square is still valid. + * + * @return <code>true</code> if the state has changed + */ + public boolean validateMapSquare() { + if (mapSquare == null) { + return false; + } + + if (mapControl.isPointValid(new Point(mapSquare.getMapX(), mapSquare.getMapY()))) { + return false; + } + + return setMapSquare(null); + } + + /** + * Check if the currently selected map square is affected by a change in a + * given map square. + * + * @param changedMapSquare the map square that has changed + * + * @return <code>true</code> if the state was updated + */ + public boolean checkForChangedMapSquare(@NotNull final MapSquare<G> changedMapSquare) { + return mapSquare != null && mapSquare == changedMapSquare; + } + + /** + * Reset the state. + */ + private void reset() { + mapSquare = null; + gameObject = null; + index = 0; + } + + /** + * Return the associated map control. + * + * @return the associated map control. + */ + @NotNull public C getMapControl() { + return mapControl; + } + + /** + * Return the selected map square. + * + * @return the selected map square if any + */ + public @Nullable MapSquare<G> getMapSquare() { + return mapSquare; + } + + /** + * Return the selected game object. + * + * @return the selected game object if any + */ + public @Nullable G getGameObject() { + return gameObject; + } + + /** + * Set the selected game object. + * + * @param gameObject the selected game object, or <code>null</code> to + * unselect it + */ + public void setGameObject(@Nullable final G gameObject) { + this.gameObject = gameObject; + index = 0; + } + + /** + * Return the selected index. + * + * @return the selected index + */ + public int getIndex() { + return index; + } + + /** + * Set the selected index. + * + * @param index the selected index + */ + public void setIndex(final int index) { + this.index = index; + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -0,0 +1,70 @@ +/* $Id$ */ + +package net.sf.gridarta.gui.maptilelist; + +import java.util.Map; +import java.util.WeakHashMap; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapControl; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The class <code>MapTileSelectionCache</code> manages a cache that contains + * one {@link MapTileSelection} instance for each {@link MapControl} instance. + */ +public class MapTileSelectionCache<G extends GameObject<G>, C extends MapControl> { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(MapTileSelectionCache.class.getName()); + + /** + * The cache to map {@link MapControl} instances to {@link + * MapTileSelection} instances. + */ + @NotNull private final Map<C, MapTileSelection<G, C>> cache = new WeakHashMap<C, MapTileSelection<G, C>>(); + + /** + * Return the {@link MapTileSelection} instance associated to a {@link + * MapControl} instance. If no instance exists, a new one is created. + * + * @param mapControl the map control to look up; it may be + * <code>null</code> in which case <code>null</code> is returned + * + * @return the associated map tile selection instance, or <code>null</code> + * if <code>null</code> was passed in + */ + public MapTileSelection<G, C> findOrCreate(@Nullable final C mapControl) { + if (mapControl == null) { + return null; + } + + synchronized(cache) { + final MapTileSelection<G, C> existingMapTileSelection = cache.get(mapControl); + if (existingMapTileSelection != null) { + return existingMapTileSelection; + } + + final MapTileSelection<G, C> newMapTileSelection = new MapTileSelection(mapControl); + cache.put(mapControl, newMapTileSelection); + return newMapTileSelection; + } + } + + /** + * Return the {@link MapTileSelection} instance associated to a {@link + * MapControl} instance. + * + * @param mapControl the map control to look up + * + * @return the associated map tile selection instance, or <code>null</code> + * if no associated instance exists + */ + public MapTileSelection<G, C> find(@NotNull final C mapControl) { + synchronized(cache) { + return cache.get(mapControl); + } + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 20:54:30 UTC (rev 1231) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-23 21:08:19 UTC (rev 1232) @@ -1,6 +1,7 @@ package net.sf.gridarta.map; import java.awt.Point; +import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapCursor; import org.jetbrains.annotations.NotNull; @@ -9,7 +10,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public interface MapControl { +public interface MapControl<G extends GameObject<G>, A extends MapArchObject> { /** * Return flag that indicates whether this is a pickmap or not. @@ -21,7 +22,7 @@ * Returns model (= map data of this level). * @return model (= map data of this level) */ - MapModel getMapModel(); + MapModel<G, A> getMapModel(); /** * Check if the coordinate is valid (located within the borders of the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 21:56:49
|
Revision: 1237 http://svn.sourceforge.net/gridarta/?rev=1237&view=rev Author: christianhujer Date: 2006-12-23 13:56:49 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Fixed some documentation issues: Renamed parameter names to match overridden parameter names. Added missing @author tags. Fixed some javadoc links. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/CFancyButton.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CScriptView.java trunk/crossfire/src/cfeditor/CStartupScreen.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/daimonin/src/daieditor/MapViewIFrame.java trunk/daimonin/src/daieditor/ReplaceDialog.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java trunk/src/app/net/sf/gridarta/gameobject/NamedTreeNode.java trunk/src/app/net/sf/gridarta/gui/HideFileFilterProxy.java trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -602,7 +602,7 @@ // left right side buttons final JButton helpButton = new JButton("Help"); helpButton.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent event) { + public void actionPerformed(final ActionEvent e) { new Help(CMainControl.getInstance().getMainView(), "treasurelists.html").setVisible(true); } }); Modified: trunk/crossfire/src/cfeditor/CFancyButton.java =================================================================== --- trunk/crossfire/src/cfeditor/CFancyButton.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/CFancyButton.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -88,8 +88,8 @@ setIcon(normalIcon); } - @Override public void setEnabled(final boolean fEnabled) { - super.setEnabled(fEnabled); + @Override public void setEnabled(final boolean b) { + super.setEnabled(b); setRolloverIcon(rolloverIcon); setIcon(normalIcon); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -1529,6 +1529,7 @@ /** * Notify all listeners about a map to be closed. + * @param mapControl MapControl that's being closed. */ private void fireMapClosingEvent(@NotNull final MapControl mapControl) { final Object[] listeners = listenerList.getListenerList(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -174,7 +174,7 @@ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener( new WindowAdapter() { - @Override public void windowClosing(final WindowEvent event) { + @Override public void windowClosing(final WindowEvent e) { mainControl.exit(); } }); @@ -688,36 +688,36 @@ } /** {@inheritDoc} */ - public void internalFrameOpened(final InternalFrameEvent event) { + public void internalFrameOpened(final InternalFrameEvent e) { } /** {@inheritDoc} */ - public void internalFrameClosing(final InternalFrameEvent event) { - mainControl.closeView((MapViewIFrame) event.getInternalFrame()); + public void internalFrameClosing(final InternalFrameEvent e) { + mainControl.closeView((MapViewIFrame) e.getInternalFrame()); } /** {@inheritDoc} */ - public void internalFrameClosed(final InternalFrameEvent event) { + public void internalFrameClosed(final InternalFrameEvent e) { } /** {@inheritDoc} */ - public void internalFrameIconified(final InternalFrameEvent event) { - final MapViewIFrame view = (MapViewIFrame) event.getSource(); + public void internalFrameIconified(final InternalFrameEvent e) { + final MapViewIFrame view = (MapViewIFrame) e.getSource(); levelViewFocusLostNotify(view); } /** {@inheritDoc} */ - public void internalFrameDeiconified(final InternalFrameEvent event) { + public void internalFrameDeiconified(final InternalFrameEvent e) { } /** {@inheritDoc} */ - public void internalFrameActivated(final InternalFrameEvent event) { - final MapViewIFrame view = (MapViewIFrame) event.getSource(); + public void internalFrameActivated(final InternalFrameEvent e) { + final MapViewIFrame view = (MapViewIFrame) e.getSource(); levelViewFocusGainedNotify(view); } /** {@inheritDoc} */ - public void internalFrameDeactivated(final InternalFrameEvent event) { + public void internalFrameDeactivated(final InternalFrameEvent e) { } /** @@ -946,7 +946,7 @@ putValue(SHORT_DESCRIPTION, "Selects " + lafInfo.getName()); } - public void actionPerformed(final ActionEvent event) { + public void actionPerformed(final ActionEvent e) { mainControl.setLookNFeel(className); CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(CMainView.SELECTED_LNF_KEY, className); rebuildLookAndFeelMenuEntries(); Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -97,11 +97,11 @@ } /** {@inheritDoc} */ - @Override public void setSize(final Dimension size) { - if (size.width < getParent().getSize().width) { - size.width = getParent().getSize().width; + @Override public void setSize(final Dimension d) { + if (d.width < getParent().getSize().width) { + d.width = getParent().getSize().width; } - super.setSize(size); + super.setSize(d); } }; Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -401,14 +401,14 @@ } /** {@inheritDoc} */ - @Override public void mouseReleased(final MouseEvent event) { - final Point clickPoint = event.getPoint(); + @Override public void mouseReleased(final MouseEvent e) { + final Point clickPoint = e.getPoint(); final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); if (!mapCursor.isOnGrid(mapLoc)) { mapCursor.dragRelease(); - } else if (event.isShiftDown()) { + } else if (e.isShiftDown()) { mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); - } else if (event.isControlDown()) { + } else if (e.isControlDown()) { mapCursor.dragSelect(MapGrid.SelectionMode.SUB); } else { mapCursor.dragSelect(MapGrid.SelectionMode.ADD); @@ -416,9 +416,9 @@ final int buttonNr; // Number of released mouse button - if (event.getModifiers() == InputEvent.BUTTON1_MASK) { + if (e.getModifiers() == InputEvent.BUTTON1_MASK) { buttonNr = 0; // left button - } else if (event.getModifiers() == InputEvent.BUTTON3_MASK) { + } else if (e.getModifiers() == InputEvent.BUTTON3_MASK) { buttonNr = 2; // right button } else { buttonNr = 1; // middle @@ -426,28 +426,28 @@ } /** {@inheritDoc} */ - @Override public void mouseExited(final MouseEvent event) { + @Override public void mouseExited(final MouseEvent e) { // endFill(); } /** {@inheritDoc} */ - public void mouseMoved(final MouseEvent event) { + public void mouseMoved(final MouseEvent e) { // repaint(); // we should blt here with clipping... // this paints the whole map again, but we want only the marker } /** {@inheritDoc} */ - public void mouseDragged(final MouseEvent event) { + public void mouseDragged(final MouseEvent e) { changedFlagNotify(); - final Point dragPoint = event.getPoint(); // Mouse pointer + final Point dragPoint = e.getPoint(); // Mouse pointer final Point temp = renderer.getTileLocationAt(dragPoint, null); // tile under Mouse pointer - if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { + if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { // Left Mouse Button: Selected area gets highlighted mapCursor.dragTo(temp); - } else if ((event.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { mapCursor.setLocation(temp); // Right Mouse Button: Arches get inserted all the way Modified: trunk/crossfire/src/cfeditor/CScriptView.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptView.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/CScriptView.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -138,8 +138,8 @@ } } - public void actionPerformed(final ActionEvent ev) { - runPlugin((String) ev.getActionCommand()); + public void actionPerformed(final ActionEvent e) { + runPlugin((String) e.getActionCommand()); } public void runPlugin(final String script) { Modified: trunk/crossfire/src/cfeditor/CStartupScreen.java =================================================================== --- trunk/crossfire/src/cfeditor/CStartupScreen.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/CStartupScreen.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -80,7 +80,7 @@ setBounds(bounds); clickListener = new MouseAdapter() { - @Override public void mouseClicked(final MouseEvent event) { + @Override public void mouseClicked(final MouseEvent e) { close(); } }; @@ -108,10 +108,10 @@ /** * Overridden to paint the loaded startup image. - * @param grfx The graphics context to paint to. + * @param g The graphics context to paint to. */ - @Override public void paint(final Graphics grfx) { - image.paintIcon(this, grfx, 0, 0); + @Override public void paint(final Graphics g) { + image.paintIcon(this, g, 0, 0); //grfx.drawImage(pinga, 0, 0, null); } @@ -119,11 +119,11 @@ * Overridden to startup a timer that then closes this window after * a few seconds. */ - @Override public void setVisible(final boolean visible) { - if (visible) { + @Override public void setVisible(final boolean b) { + if (b) { super.setVisible(true); autoCloseTimer = new Timer(3000, new ActionListener() { - public void actionPerformed(final ActionEvent event) { + public void actionPerformed(final ActionEvent e) { close(); } }); Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -269,7 +269,7 @@ } /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent event) { + public void actionPerformed(final ActionEvent e) { mainControl.setCurrentLevelView(MapViewIFrame.this); } Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -343,9 +343,9 @@ private class ReplaceWithBoxItemListener implements ItemListener { /** {@inheritDoc} */ - public void itemStateChanged(final ItemEvent event) { + public void itemStateChanged(final ItemEvent e) { final int selectedIndex = replaceWithBox.getSelectedIndex(); - if (event.getStateChange() == ItemEvent.SELECTED && lastSelectedIndex != selectedIndex) { + if (e.getStateChange() == ItemEvent.SELECTED && lastSelectedIndex != selectedIndex) { switch (selectedIndex) { case 0: // replace with arch Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -170,11 +170,11 @@ return bufImage; } - @Override public void paintComponent(final Graphics grfx) { + @Override public void paintComponent(final Graphics g) { if (isPickmap) { - paintComponent(grfx, false); + paintComponent(g, false); } else { - paintFromBackbuffer(grfx, 0, 0, bufferedSize.width, bufferedSize.height); + paintFromBackbuffer(g, 0, 0, bufferedSize.width, bufferedSize.height); } } Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -81,7 +81,7 @@ ActionListener getButtonDownActionListener() { return new ActionListener() { - public void actionPerformed(final ActionEvent event) { + public void actionPerformed(final ActionEvent e) { final GameObject arch = getMapTileSelection(); if (arch != null) { arch.moveDown(); @@ -92,7 +92,7 @@ ActionListener getButtonUpActionListener() { return new ActionListener() { - public void actionPerformed(final ActionEvent event) { + public void actionPerformed(final ActionEvent e) { final GameObject arch = getMapTileSelection(); if (arch != null) { arch.moveUp(); Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -405,6 +405,8 @@ /** * Set a map tile selection. * + * @param mapTileSelection Selection that's made. + * * @return <code>true</code> if the selected map tile has changed */ private boolean setSelectedMapTile(@Nullable final MapTileSelection<GameObject, MapControl> mapTileSelection) { Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -281,8 +281,8 @@ if (f.isDirectory()) { // This is a directory -> only accept *.tl files and directories final String[] traverse = f.list(new FilenameFilter() { - public boolean accept(final File d, final String name) { - final File fullPath = new File(d, name); + public boolean accept(final File dir, final String name) { + final File fullPath = new File(dir, name); return ((fullPath.isDirectory() && !name.equalsIgnoreCase("cvs"))) || name.toLowerCase().endsWith(".tl"); } @@ -617,7 +617,7 @@ // left right side buttons final JButton helpButton = new JButton("Help"); helpButton.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent event) { + public void actionPerformed(final ActionEvent e) { new Help(CMainControl.getInstance().getMainView(), "treasurelists.html").setVisible(true); } }); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -1724,6 +1724,7 @@ /** * Notify all listeners about a map to be closed. + * @param mapControl MapControl that's being closed. */ private void fireMapClosingEvent(@NotNull final MapControl mapControl) { final Object[] listeners = listenerList.getListenerList(); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -640,36 +640,36 @@ } /** {@inheritDoc} */ - public void internalFrameOpened(final InternalFrameEvent event) { + public void internalFrameOpened(final InternalFrameEvent e) { } /** {@inheritDoc} */ - public void internalFrameClosing(final InternalFrameEvent event) { - mainControl.closeView((MapViewIFrame) event.getInternalFrame()); + public void internalFrameClosing(final InternalFrameEvent e) { + mainControl.closeView((MapViewIFrame) e.getInternalFrame()); } /** {@inheritDoc} */ - public void internalFrameClosed(final InternalFrameEvent event) { + public void internalFrameClosed(final InternalFrameEvent e) { } /** {@inheritDoc} */ - public void internalFrameIconified(final InternalFrameEvent event) { - final MapViewIFrame view = (MapViewIFrame) event.getSource(); + public void internalFrameIconified(final InternalFrameEvent e) { + final MapViewIFrame view = (MapViewIFrame) e.getSource(); levelViewFocusLostNotify(view); } /** {@inheritDoc} */ - public void internalFrameDeiconified(final InternalFrameEvent event) { + public void internalFrameDeiconified(final InternalFrameEvent e) { } /** {@inheritDoc} */ - public void internalFrameActivated(final InternalFrameEvent event) { - final MapViewIFrame view = (MapViewIFrame) event.getSource(); + public void internalFrameActivated(final InternalFrameEvent e) { + final MapViewIFrame view = (MapViewIFrame) e.getSource(); levelViewFocusGainedNotify(view); } /** {@inheritDoc} */ - public void internalFrameDeactivated(final InternalFrameEvent event) { + public void internalFrameDeactivated(final InternalFrameEvent e) { } /** Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -103,11 +103,11 @@ } /** {@inheritDoc} */ - @Override public void setSize(final Dimension size) { - if (size.width < getParent().getSize().width) { - size.width = getParent().getSize().width; + @Override public void setSize(final Dimension d) { + if (d.width < getParent().getSize().width) { + d.width = getParent().getSize().width; } - super.setSize(size); + super.setSize(d); } }; Modified: trunk/daimonin/src/daieditor/MapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -215,7 +215,7 @@ } /** {@inheritDoc} */ - public void actionPerformed(final ActionEvent event) { + public void actionPerformed(final ActionEvent e) { mainControl.setCurrentLevelView(MapViewIFrame.this); } Modified: trunk/daimonin/src/daieditor/ReplaceDialog.java =================================================================== --- trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -352,9 +352,9 @@ private class ReplaceWithBoxItemListener implements ItemListener { /** {@inheritDoc} */ - public void itemStateChanged(final ItemEvent event) { + public void itemStateChanged(final ItemEvent e) { final int selectedIndex = replaceWithBox.getSelectedIndex(); - if (event.getStateChange() == ItemEvent.SELECTED && lastSelectedIndex != selectedIndex) { + if (e.getStateChange() == ItemEvent.SELECTED && lastSelectedIndex != selectedIndex) { final int size; switch (selectedIndex) { case 0: Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -185,8 +185,8 @@ if (f.isDirectory()) { // This is a directory -> only accept *.art files and directories final String[] traverse = f.list(new FilenameFilter() { - public boolean accept(final File d, final String name) { - final File fullPath = new File(d, name); + public boolean accept(final File dir, final String name) { + final File fullPath = new File(dir, name); // TODO: Replace this with a proper FileFilter. return fullPath.isDirectory() && !name.equalsIgnoreCase("cvs") && !name.equalsIgnoreCase(".xvpics") && !name.equalsIgnoreCase(".svn") || name.toLowerCase().endsWith(".art"); Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -206,9 +206,9 @@ return bufImage; } - @Override public void paintComponent(final Graphics grfx) { + @Override public void paintComponent(final Graphics g) { final long start = System.currentTimeMillis(); - paintComponent2((Graphics2D) grfx); + paintComponent2((Graphics2D) g); final long lastPaint = System.currentTimeMillis() - start; mainControl.setStatusText("Sel: " + lastSelectionPaint + " Core: " + lastCorePaint + " All: " + lastPaint); } Modified: trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/gui/map/MapPreviewAccessory.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -273,14 +273,14 @@ private class MapFileView extends FileView { /** {@inheritDoc} */ - @Override public Icon getIcon(final File file) { + @Override public Icon getIcon(final File f) { final ImageIcon icon; - if (fileChooser.getCurrentDirectory().equals(file.getParentFile())) { - icon = getMapIcon(file); + if (fileChooser.getCurrentDirectory().equals(f.getParentFile())) { + icon = getMapIcon(f); } else { icon = null; } - return icon != null ? icon : super.getIcon(file); + return icon != null ? icon : super.getIcon(f); } } // class MapFileView Modified: trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -94,8 +94,8 @@ return bufImage; } - @Override protected void paintComponent(final Graphics grfx) { - paintComponent2((Graphics2D) grfx); + @Override protected void paintComponent(final Graphics g) { + paintComponent2((Graphics2D) g); } /** Modified: trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/daimonin/src/daieditor/gui/map/tools/ToolSelector.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -156,7 +156,7 @@ } /** {@inheritDoc} */ - public void actionPerformed(@NotNull final ActionEvent actionEvent) { + public void actionPerformed(@NotNull final ActionEvent e) { setSelectedTool(tool); } Modified: trunk/src/app/net/sf/gridarta/gameobject/NamedTreeNode.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/NamedTreeNode.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/src/app/net/sf/gridarta/gameobject/NamedTreeNode.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -229,8 +229,8 @@ } /** {@inheritDoc} */ - public int compareTo(final NamedTreeNode<T> other) { - return this.dir ^ !other.dir ? name.compareTo(other.name) : this.dir ? -1 : 1; + public int compareTo(final NamedTreeNode<T> o) { + return this.dir ^ !o.dir ? name.compareTo(o.name) : this.dir ? -1 : 1; } /** Modified: trunk/src/app/net/sf/gridarta/gui/HideFileFilterProxy.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/HideFileFilterProxy.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/src/app/net/sf/gridarta/gui/HideFileFilterProxy.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -66,6 +66,8 @@ * {@inheritDoc} * First checks whether the file should be hidden, if not, checks the other FileFilter. */ + // XXX suppression because parameter name depends on class loader search order. + @SuppressWarnings({"ParameterNameDiffersFromOverriddenParameter"}) @Override public boolean accept(final File pathname) { if (pathname.getName().startsWith(".")) { return false; Modified: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelection.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -64,7 +64,7 @@ @Nullable private G gameObject = null; /** - * The index in the map tile list that corresponds to {@link gameObject}. + * The index in the map tile list that corresponds to {@link #gameObject}. * It is set to zero if <code>gameObject</code> is <code>null</code>. */ private int index = 0; Modified: trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java 2006-12-23 21:46:21 UTC (rev 1236) +++ trunk/src/app/net/sf/gridarta/gui/maptilelist/MapTileSelectionCache.java 2006-12-23 21:56:49 UTC (rev 1237) @@ -13,6 +13,7 @@ /** * The class <code>MapTileSelectionCache</code> manages a cache that contains * one {@link MapTileSelection} instance for each {@link MapControl} instance. + * @author unknown */ public class MapTileSelectionCache<G extends GameObject<G>, C extends MapControl> { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 22:20:35
|
Revision: 1241 http://svn.sourceforge.net/gridarta/?rev=1241&view=rev Author: akirschbaum Date: 2006-12-23 14:20:36 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Make map tile panel a "single selection" list. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 22:15:32 UTC (rev 1240) +++ trunk/crossfire/ChangeLog 2006-12-23 22:20:36 UTC (rev 1241) @@ -1,5 +1,7 @@ 2006-12-23 Andreas Kirschbaum + * Make map tile panel a "single selection" list. + * Remove support for deleting/inserting with button 1 and shift/control. Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 22:15:32 UTC (rev 1240) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 22:20:36 UTC (rev 1241) @@ -41,6 +41,7 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; import javax.swing.ScrollPaneConstants; import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER; @@ -110,6 +111,7 @@ list = new JList(model); list.setCellRenderer(new CellRenderer(mainControl.getArchetypeSet())); list.setBackground(Color.lightGray); + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JScrollPane scrollPane = new JScrollPane(list); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.getViewport().setScrollMode(SIMPLE_SCROLL_MODE); Modified: trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 22:15:32 UTC (rev 1240) +++ trunk/daimonin/src/daieditor/gui/maptilelist/MapTileListView.java 2006-12-23 22:20:36 UTC (rev 1241) @@ -44,6 +44,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JViewport; +import javax.swing.ListSelectionModel; import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; @@ -99,6 +100,7 @@ list = new JList(model); list.setCellRenderer(new CellRenderer(mainControl.getArchetypeSet())); list.setBackground(Color.lightGray); + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JScrollPane scrollPane = new JScrollPane(list); scrollPane.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 22:27:39
|
Revision: 1245 http://svn.sourceforge.net/gridarta/?rev=1245&view=rev Author: christianhujer Date: 2006-12-23 14:27:35 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Added several performance issues to the error policy. Improved some code regarding performance. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchType.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/crossfire/src/cfeditor/CResourceLoader.java trunk/crossfire/src/cfeditor/JarResources.java trunk/crossfire/src/cfeditor/ScriptArchData.java trunk/crossfire/src/cfeditor/Spells.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/io/CMapWriter.java trunk/daimonin/src/daieditor/CFArchType.java trunk/daimonin/src/daieditor/CFArchTypeList.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/Spells.java trunk/daimonin/src/daieditor/gameobject/match/MutableOrGameObjectMatcher.java trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/UndoAndRedo.java Modified: trunk/crossfire/src/cfeditor/CFArchType.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -371,7 +371,7 @@ // parse attribute if (attrib.load(elem, tlist, typeName)) { // add this attribute to the list: - if (attrList.size() > 0) { + if (!attrList.isEmpty()) { attrList.get(attrList.size() - 1).setNext(attrib); } attrList.add(attrib); Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -197,7 +197,7 @@ throw new RuntimeException("In file '" + IGUIConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); } else { final List<?> list = parseListFromElement(elem); - if (list != null && list.size() > 0) { + if (list != null && !list.isEmpty()) { listTable.put(elem.getAttribute("name"), list); } } @@ -242,7 +242,7 @@ } } // now add the list vector to the ignoreListTable: - if (content.size() > 0) { + if (!content.isEmpty()) { ignoreListTable.put(lname, content); } } @@ -383,7 +383,7 @@ * @return <code>true</code> if this typelist contains no data, otherwise <code>false</code>. */ public boolean isEmpty() { - return archTypeList.size() == 0; + return archTypeList.isEmpty(); } /** Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -109,7 +109,7 @@ return; } } - if (inlist != null && infiles.size() > 0) { + if (inlist != null && !infiles.isEmpty()) { System.err.println("-filelist option and loading maps are mutually exclusive"); System.exit(1); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -650,7 +650,7 @@ SwingUtilities.updateComponentTreeUI(mainView); // update the look and feel for all open map views - if (levels.size() > 0) { + if (!levels.isEmpty()) { for (final MapControl level : levels) { level.getMapViewFrame().updateLookAndFeel(); if (log.isDebugEnabled()) { @@ -752,7 +752,7 @@ * @return <code>true</code> if all levels closed, <code>false</code> if user cancelled */ public boolean closeAll() { - while (levels.size() > 0) { + while (!levels.isEmpty()) { final MapControl mapToClose; if (currentMap == null) { mapToClose = levels.get(levels.size() - 1); @@ -846,7 +846,7 @@ mainView.removeLevelView(level.getMapViewFrame()); levels.remove(level); - if (levels.size() > 0) { + if (!levels.isEmpty()) { // get next open map we can find and set it to currentMap setCurrentLevel(levels.get(levels.size() - 1)); } else { Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -545,7 +545,7 @@ * @return All level windows */ @Nullable List<MapViewIFrame> getAllLevelWindows() { - if (mapViews != null && mapViews.size() > 0) { + if (mapViews != null && !mapViews.isEmpty()) { return Collections.unmodifiableList(mapViews); } @@ -736,7 +736,7 @@ final JMenu menuWindow = (JMenu) ACTION_FACTORY.find(getJMenuBar(), "window"); menuWindow.removeAll(); menuWindow.add(aCloseAll); - if (mapViews.size() != 0) { + if (!mapViews.isEmpty()) { menuWindow.addSeparator(); } int index = 0; Modified: trunk/crossfire/src/cfeditor/CPickmapPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -280,7 +280,7 @@ return; // for safety, shouldn't happen } - if (pickmaps.size() == 0) { + if (pickmaps.isEmpty()) { currentPickMap = null; return; } Modified: trunk/crossfire/src/cfeditor/CResourceLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/CResourceLoader.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/CResourceLoader.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -177,7 +177,7 @@ * application dir and the filename. */ public static String getHomeFileName(final String filename) { - final StringBuffer buf = new StringBuffer(128); + final StringBuilder buf = new StringBuilder(128); final String home = System.getProperty("user.home"); buf.append(home); buf.append(File.separator).append(IGUIConstants.APP_SETTINGS_DIR); Modified: trunk/crossfire/src/cfeditor/JarResources.java =================================================================== --- trunk/crossfire/src/cfeditor/JarResources.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/JarResources.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -167,7 +167,7 @@ * @return String with information on the supplied ZipEntry. */ private String dumpZipEntry(final ZipEntry ze) { - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); if (ze.isDirectory()) { sb.append("d "); } else { Modified: trunk/crossfire/src/cfeditor/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/ScriptArchData.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/ScriptArchData.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -170,7 +170,7 @@ * @return index of ScriptedEvent in 'eventList' if found, -1 if not found */ private int getScriptedEvent(final String eventType) { - if (eventList != null && eventList.size() > 0) { + if (eventList != null && !eventList.isEmpty()) { for (int i = 0; i < eventList.size(); i++) { final ScriptedEvent se = eventList.get(i); if (se.getEventType().equalsIgnoreCase(eventType)) { @@ -191,7 +191,7 @@ * events were invalid (and deleted) */ public boolean validateAllEvents() { - if (eventList != null && eventList.size() > 0) { + if (eventList != null && !eventList.isEmpty()) { int numEvents = eventList.size(); for (int i = 0; i < numEvents; i++) { @@ -208,7 +208,7 @@ } } - if (eventList.size() > 0) { + if (!eventList.isEmpty()) { return true; // there is at least one remaining valid event } } @@ -223,7 +223,7 @@ public String getMapArchEventData() { final StringBuilder buff = new StringBuilder(); - if (eventList != null && eventList.size() > 0) { + if (eventList != null && !eventList.isEmpty()) { for (final ScriptedEvent se : eventList) { buff.append(se.getMapArchText()); } @@ -252,7 +252,7 @@ * @return a cloned instance of this ScriptArchData object */ @Nullable public ScriptArchData getClone() { - if (eventList != null && eventList.size() > 0) { + if (eventList != null && !eventList.isEmpty()) { final ScriptArchData clone = new ScriptArchData(); // new instance for (int i = 0; i < eventList.size(); i++) { @@ -601,7 +601,7 @@ * @return <code>true</code> if this ScriptArchData contains no events, otherwise <code>false</code>. */ public boolean isEmpty() { - return eventList == null || eventList.size() == 0; + return eventList == null || eventList.isEmpty(); } /** Inner class which stores information about one scripted event. */ Modified: trunk/crossfire/src/cfeditor/Spells.java =================================================================== --- trunk/crossfire/src/cfeditor/Spells.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/Spells.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -161,7 +161,7 @@ } // --------- now write the "spells.def" file --------- - if (list != null && list.size() > 0) { + if (list != null && !list.isEmpty()) { final File dfile; // create new file for writing (replaces old one if existent) if (IGUIConstants.CONFIG_DIR != null && IGUIConstants.CONFIG_DIR.length() > 0) { @@ -260,7 +260,7 @@ // loading successful log.info("Loaded " + tmpSpellNames.size() + " defined spells from '" + IGUIConstants.SPELL_FILE + "'"); - if (tmpSpellNames.size() == 0) { + if (tmpSpellNames.isEmpty()) { log.warn("File '" + IGUIConstants.SPELL_FILE + "' has no content."); } else { tmpSpellNames.add(0, "<none>"); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -283,7 +283,7 @@ } final String elevation = arch.getAttributeString("elevation", false); - if (!elevation.equals("")) { + if (elevation.length() != 0) { setAttributeString("elevation", elevation); arch.removeAttribute("elevation"); } Modified: trunk/crossfire/src/cfeditor/io/CMapWriter.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapWriter.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/crossfire/src/cfeditor/io/CMapWriter.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -87,7 +87,7 @@ if (gameObject.isScripted()) { final String events = gameObject.getMapArchEventData(); - if (!events.equals("")) { + if (events.length() != 0) { final String[] tmp = events.split("\n"); for (final String aTmp : tmp) { final String[] line = aTmp.split(" +", 2); @@ -152,7 +152,7 @@ } final String text = gameObject.getObjectText(); - if (!text.equals("")) { + if (text.length() != 0) { final String[] tmp = text.split("\n"); for (final String aTmp : tmp) { final String[] line = aTmp.split(" +", 2); Modified: trunk/daimonin/src/daieditor/CFArchType.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchType.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/CFArchType.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -362,7 +362,7 @@ // parse attribute if (attrib.load(elem, tlist, typeName)) { // add this attribute to the list: - if (attrList.size() > 0) { + if (!attrList.isEmpty()) { attrList.get(attrList.size() - 1).setNext(attrib); } attrList.add(attrib); Modified: trunk/daimonin/src/daieditor/CFArchTypeList.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -201,7 +201,7 @@ throw new RuntimeException("In file '" + IGUIConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); } else { final List<?> list = parseListFromElement(elem); - if (list != null && list.size() > 0) { + if (list != null && !list.isEmpty()) { listTable.put(elem.getAttribute("name"), list); } } @@ -246,7 +246,7 @@ } } // now add the list vector to the ignoreListTable: - if (content.size() > 0) { + if (!content.isEmpty()) { ignoreListTable.put(lname, content); } } @@ -412,7 +412,7 @@ * @return <code>true</code> if this typelist contains no data, otherwise <code>false</code>. */ public boolean isEmpty() { - return archTypeList.size() == 0; + return archTypeList.isEmpty(); } /** Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -925,7 +925,7 @@ * @return <code>true</code> if all levels closed, <code>false</code> if user cancelled */ public boolean closeAll() { - while (levels.size() > 0) { + while (!levels.isEmpty()) { final MapControl mapToClose; if (currentMap == null) { mapToClose = levels.get(levels.size() - 1); @@ -1022,7 +1022,7 @@ } levels.remove(level); - if (levels.size() > 0) { + if (!levels.isEmpty()) { // get next open map we can find and set it to currentMap setCurrentLevel(levels.get(levels.size() - 1)); } else { @@ -1928,7 +1928,7 @@ /** Update wanted. */ public void update() { - if (levels.size() > 0) { + if (!levels.isEmpty()) { ACTION_FACTORY.showMessageDialog(mainView, "updateCloseMaps"); } else { Updater.update(mainView); Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -691,7 +691,7 @@ final JMenu menuWindow = (JMenu) ACTION_FACTORY.find(getJMenuBar(), "window"); menuWindow.removeAll(); menuWindow.add(aCloseAll); - if (mapViews.size() != 0) { + if (!mapViews.isEmpty()) { menuWindow.addSeparator(); } int index = 0; Modified: trunk/daimonin/src/daieditor/CPickmapPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/CPickmapPanel.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -306,7 +306,7 @@ return; // for safety, shouldn't happen } - if (pickmaps.size() == 0) { + if (pickmaps.isEmpty()) { currentPickMap = null; return; } Modified: trunk/daimonin/src/daieditor/CopyBuffer.java =================================================================== --- trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/CopyBuffer.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -243,7 +243,7 @@ final List<GameObject> archList; if (seed == null) { final List<GameObject> archPanelSelection = mainControl.getArchPanelSelection(); - if (archPanelSelection == null || archPanelSelection.size() == 0) { + if (archPanelSelection == null || archPanelSelection.isEmpty()) { return; } archList = archPanelSelection; @@ -254,7 +254,7 @@ } archList = getMapArchList(seed, seedSize); } - if (archList == null || archList.size() == 0) { + if (archList == null || archList.isEmpty()) { return; } @@ -332,7 +332,7 @@ mapSquares = mapControl.getAllSquares(); } else { final List<MapSquare<GameObject>> selectedMapSquares = mapViewIFrame.getView().getSelectedSquares(); - if (selectedMapSquares.size() == 0) { + if (selectedMapSquares.isEmpty()) { mapSquares = mapControl.getAllSquares(); } else { mapSquares = selectedMapSquares; @@ -346,7 +346,7 @@ } } } - return objects.size() == 0 ? null : objects; + return objects.isEmpty() ? null : objects; } /** @@ -365,7 +365,7 @@ } final List<GameObject> archList = mainControl.getArchPanelSelection(); - if (archList == null || archList.size() == 0) { + if (archList == null || archList.isEmpty()) { return; } Modified: trunk/daimonin/src/daieditor/Spells.java =================================================================== --- trunk/daimonin/src/daieditor/Spells.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/Spells.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -135,7 +135,7 @@ } // --------- now write the "spells.def" file --------- - if (spells.size() > 0) { + if (!spells.isEmpty()) { // FIXME: This should use DOM for writing the file. final File dfile; // create new file for writing (replaces old one if existent) @@ -231,7 +231,7 @@ // loading successful log.info("Loaded " + tmpSpellNames.size() + " defined spells from '" + IGUIConstants.SPELL_FILE + "'"); - if (tmpSpellNames.size() == 0) { + if (tmpSpellNames.isEmpty()) { log.warn("File '" + IGUIConstants.SPELL_FILE + "' has no content."); } else { tmpSpellNames.add(0, "<none>"); Modified: trunk/daimonin/src/daieditor/gameobject/match/MutableOrGameObjectMatcher.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/match/MutableOrGameObjectMatcher.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/gameobject/match/MutableOrGameObjectMatcher.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -50,7 +50,7 @@ /** {@inheritDoc} */ public boolean isMatching(final GameObject arch) { - if (gameObjectMatchers.size() == 0) { + if (gameObjectMatchers.isEmpty()) { return true; } for (final GameObjectMatcher gameObjectMatcher : gameObjectMatchers) { Modified: trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/daimonin/src/daieditor/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -51,7 +51,7 @@ blockers.add(gameObject); } } - if (blockers.size() > 0 && mobsOrSpawnPoints.size() > 0) { + if (!blockers.isEmpty() && !mobsOrSpawnPoints.isEmpty()) { errorCollector.collect(new BlockedMobOrSpawnPointError(mapSquare, new ArrayList<GameObject>(blockers), new ArrayList<GameObject>(mobsOrSpawnPoints))); } blockers.clear(); Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/gridarta.ipr 2006-12-23 22:27:35 UTC (rev 1245) @@ -494,7 +494,7 @@ <option name="m_ignoreExpressionsContainingConstants" value="false" /> </inspection_tool> <inspection_tool class="GwtInconsistentI18nInterface" level="ERROR" enabled="false" /> - <inspection_tool class="StringToString" level="WARNING" enabled="false" /> + <inspection_tool class="StringToString" level="ERROR" enabled="true" /> <inspection_tool class="AnalyzingStaticVariables" level="ERROR" enabled="true"> <option name="CHECKED_TYPES" value="javax.servlet.http.HttpSession;com.ulcjava.base.application.ULCProxy" /> </inspection_tool> @@ -529,7 +529,7 @@ </inspection_tool> <inspection_tool class="NoScrollPane" level="WARNING" enabled="false" /> <inspection_tool class="JSUnresolvedFunction" level="INFO" enabled="false" /> - <inspection_tool class="InstantiatingObjectToGetClassObject" level="WARNING" enabled="false" /> + <inspection_tool class="InstantiatingObjectToGetClassObject" level="ERROR" enabled="true" /> <inspection_tool class="ReturnFromFinallyBlockJS" level="WARNING" enabled="false" /> <inspection_tool class="UnusedAssignment" level="WARNING" enabled="true"> <option name="REPORT_PREFIX_EXPRESSIONS" value="true" /> @@ -546,7 +546,7 @@ <inspection_tool class="WebProperties" level="ERROR" enabled="false" /> <inspection_tool class="PointlessArithmeticExpressionJS" level="WARNING" enabled="false" /> <inspection_tool class="UnnecessaryConditionalExpression" level="WARNING" enabled="false" /> - <inspection_tool class="StringConcatenationInsideStringBufferAppend" level="WARNING" enabled="false" /> + <inspection_tool class="StringConcatenationInsideStringBufferAppend" level="ERROR" enabled="true" /> <inspection_tool class="AnalyzingJLSModifierOrder" level="WARNING" enabled="false" /> <inspection_tool class="AntDuplicateImportedTargetsInspection" level="WARNING" enabled="false" /> <inspection_tool class="UNUSED_SYMBOL" level="WARNING" enabled="false"> @@ -577,7 +577,7 @@ <inspection_tool class="PointlessArithmeticExpression" level="WARNING" enabled="false"> <option name="m_ignoreExpressionsContainingConstants" value="false" /> </inspection_tool> - <inspection_tool class="UnnecessaryTemporaryOnConversionToString" level="WARNING" enabled="false" /> + <inspection_tool class="UnnecessaryTemporaryOnConversionToString" level="ERROR" enabled="true" /> <inspection_tool class="UnnecessaryContinue" level="WARNING" enabled="false" /> <inspection_tool class="SameReturnValue" level="WARNING" enabled="false" /> <inspection_tool class="UnusedLabel" level="WARNING" enabled="false" /> @@ -588,7 +588,7 @@ <inspection_tool class="ReturnFromFinallyBlock" level="WARNING" enabled="false" /> <inspection_tool class="UnreachableCodeJS" level="WARNING" enabled="false" /> <inspection_tool class="CheckValidXmlInScriptTagBody" level="ERROR" enabled="false" /> - <inspection_tool class="ManualArrayCopy" level="WARNING" enabled="false" /> + <inspection_tool class="ManualArrayCopy" level="ERROR" enabled="true" /> <inspection_tool class="Weblogic" level="ERROR" enabled="false" /> <inspection_tool class="PersistenceDataSourceORMDomInspection" level="ERROR" enabled="false" /> <inspection_tool class="FallthroughInSwitchStatementJS" level="WARNING" enabled="false" /> @@ -672,7 +672,7 @@ <option name="m_ignoreImmediatelyReturnedVariables" value="false" /> <option name="m_ignoreAnnotatedVariables" value="false" /> </inspection_tool> - <inspection_tool class="UnnecessaryTemporaryOnConversionFromString" level="WARNING" enabled="false" /> + <inspection_tool class="UnnecessaryTemporaryOnConversionFromString" level="ERROR" enabled="true" /> <inspection_tool class="EmptyStatementBodyJS" level="WARNING" enabled="false"> <option name="m_reportEmptyBlocks" value="false" /> </inspection_tool> @@ -696,7 +696,7 @@ <option name="m_ignoreExpressionsContainingConstants" value="false" /> </inspection_tool> <inspection_tool class="SimplifiableIfStatement" level="WARNING" enabled="false" /> - <inspection_tool class="BooleanConstructor" level="WARNING" enabled="false" /> + <inspection_tool class="BooleanConstructor" level="ERROR" enabled="true" /> <inspection_tool class="ExtendsObject" level="WARNING" enabled="false" /> <inspection_tool class="RedundantArrayCreation" level="WARNING" enabled="false" /> <inspection_tool class="PersistenceQlInspection" level="ERROR" enabled="false" /> @@ -727,7 +727,7 @@ <inspection_tool class="AccessStaticViaInstance" level="WARNING" enabled="false" /> <inspection_tool class="UnusedParameters" level="WARNING" enabled="false" /> <inspection_tool class="DuplicateMnemonic" level="WARNING" enabled="false" /> - <inspection_tool class="StringConstructor" level="WARNING" enabled="false"> + <inspection_tool class="StringConstructor" level="ERROR" enabled="true"> <option name="ignoreSubstringArguments" value="false" /> </inspection_tool> <inspection_tool class="GWTRemoteServiceAsyncCheck" level="ERROR" enabled="false" /> @@ -942,10 +942,10 @@ <option name="ignoreSystemErrs" value="false" /> </inspection_tool> <inspection_tool class="AssertsWithoutMessages" level="WARNING" enabled="false" /> - <inspection_tool class="RandomDoubleForRandomInteger" level="WARNING" enabled="false" /> + <inspection_tool class="RandomDoubleForRandomInteger" level="ERROR" enabled="true" /> <inspection_tool class="TestMethodWithoutAssertion" level="WARNING" enabled="false" /> <inspection_tool class="SerialPersistentFieldsWithWrongSignature" level="WARNING" enabled="false" /> - <inspection_tool class="StringBufferReplaceableByStringBuilder" level="WARNING" enabled="false" /> + <inspection_tool class="StringBufferReplaceableByStringBuilder" level="ERROR" enabled="true" /> <inspection_tool class="UnterminatedStatementJS" level="WARNING" enabled="false" /> <inspection_tool class="CastToConcreteClass" level="WARNING" enabled="false" /> <inspection_tool class="EmptyFinallyBlockJS" level="WARNING" enabled="false" /> @@ -1223,7 +1223,7 @@ <inspection_tool class="StaticNonFinalField" level="WARNING" enabled="false" /> <inspection_tool class="DynamicallyGeneratedCodeJS" level="WARNING" enabled="false" /> <inspection_tool class="TimeToString" level="WARNING" enabled="false" /> - <inspection_tool class="SubstringZero" level="WARNING" enabled="false" /> + <inspection_tool class="SubstringZero" level="ERROR" enabled="true" /> <inspection_tool class="ObsoleteCollection" level="WARNING" enabled="false" /> <inspection_tool class="ClassWithoutNoArgConstructor" level="WARNING" enabled="false"> <option name="m_ignoreClassesWithNoConstructors" value="true" /> @@ -1281,7 +1281,7 @@ <inspection_tool class="AnnotationClass" level="WARNING" enabled="false" /> <inspection_tool class="TailRecursionJS" level="WARNING" enabled="false" /> <inspection_tool class="StringBufferMustHaveInitialCapacity" level="WARNING" enabled="false" /> - <inspection_tool class="MethodMayBeStatic" level="WARNING" enabled="false"> + <inspection_tool class="MethodMayBeStatic" level="WARNING" enabled="true"> <option name="m_onlyPrivateOrFinal" value="false" /> <option name="m_ignoreEmptyMethods" value="true" /> </inspection_tool> @@ -1354,11 +1354,11 @@ <inspection_tool class="AnonymousClassComplexity" level="WARNING" enabled="false"> <option name="m_limit" value="3" /> </inspection_tool> - <inspection_tool class="InnerClassMayBeStatic" level="WARNING" enabled="false" /> + <inspection_tool class="InnerClassMayBeStatic" level="WARNING" enabled="true" /> <inspection_tool class="RedundantFieldInitialization" level="WARNING" enabled="false" /> <inspection_tool class="StaticSuite" level="WARNING" enabled="false" /> - <inspection_tool class="StringBufferToStringInConcatenation" level="WARNING" enabled="false" /> - <inspection_tool class="ConstantStringIntern" level="WARNING" enabled="false" /> + <inspection_tool class="StringBufferToStringInConcatenation" level="ERROR" enabled="true" /> + <inspection_tool class="ConstantStringIntern" level="ERROR" enabled="true" /> <inspection_tool class="DuplicateBooleanBranch" level="WARNING" enabled="false" /> <inspection_tool class="MethodOverridesStaticMethod" level="WARNING" enabled="false" /> <inspection_tool class="DesignForExtension" level="WARNING" enabled="false" /> @@ -1399,7 +1399,7 @@ <inspection_tool class="MisorderedAssertEqualsParameters" level="WARNING" enabled="false" /> <inspection_tool class="UnnecessaryConstructor" level="WARNING" enabled="false" /> <inspection_tool class="MethodNameSameAsParentName" level="WARNING" enabled="false" /> - <inspection_tool class="JavaLangReflect" level="WARNING" enabled="false" /> + <inspection_tool class="JavaLangReflect" level="ERROR" enabled="true" /> <inspection_tool class="NestedAssignment" level="WARNING" enabled="false" /> <inspection_tool class="ThisEscapedInConstructor" level="WARNING" enabled="false" /> <inspection_tool class="WaitNotInSynchronizedContext" level="WARNING" enabled="false" /> @@ -1442,7 +1442,7 @@ <inspection_tool class="ChainedMethodCall" level="WARNING" enabled="false"> <option name="m_ignoreFieldInitializations" value="true" /> </inspection_tool> - <inspection_tool class="UseOfSunClasses" level="WARNING" enabled="false" /> + <inspection_tool class="UseOfSunClasses" level="WARNING" enabled="true" /> <inspection_tool class="PublicInnerClass" level="WARNING" enabled="false" /> <inspection_tool class="NotifyNotInSynchronizedContext" level="WARNING" enabled="false" /> <inspection_tool class="ForLoopReplaceableByWhileJS" level="WARNING" enabled="false"> @@ -1477,7 +1477,7 @@ <inspection_tool class="DoubleCheckedLocking" level="WARNING" enabled="false" /> <inspection_tool class="ContinueStatementJS" level="WARNING" enabled="false" /> <inspection_tool class="InstanceofChain" level="WARNING" enabled="false" /> - <inspection_tool class="StringBufferReplaceableByString" level="WARNING" enabled="false" /> + <inspection_tool class="StringBufferReplaceableByString" level="ERROR" enabled="true" /> <inspection_tool class="BooleanMethodNameMustStartWithQuestion" level="WARNING" enabled="false"> <option name="nameCheckString" value="is,can,has,should,could,will,shall,check,contains,equals,add,put,remove,startsWith,endsWith" /> </inspection_tool> @@ -1500,7 +1500,7 @@ <option name="m_minLength" value="4" /> <option name="m_maxLength" value="32" /> </inspection_tool> - <inspection_tool class="TrivialStringConcatenation" level="WARNING" enabled="false" /> + <inspection_tool class="TrivialStringConcatenation" level="WARNING" enabled="true" /> <inspection_tool class="EmptySynchronizedStatement" level="WARNING" enabled="false" /> <inspection_tool class="UnnecessaryDefault" level="WARNING" enabled="false" /> <inspection_tool class="UnnecessarySuperConstructor" level="WARNING" enabled="false" /> @@ -1558,7 +1558,7 @@ <inspection_tool class="AssignmentToMethodParameter" level="WARNING" enabled="false"> <option name="ignoreTransformationOfOriginalParameter" value="false" /> </inspection_tool> - <inspection_tool class="StringEqualsEmptyString" level="WARNING" enabled="false" /> + <inspection_tool class="StringEqualsEmptyString" level="ERROR" enabled="true" /> <inspection_tool class="MagicCharacter" level="WARNING" enabled="false" /> <inspection_tool class="ConnectionResource" level="WARNING" enabled="false" /> <inspection_tool class="StaticVariableInitialization" level="WARNING" enabled="false"> @@ -1576,7 +1576,7 @@ <option name="m_limit" value="30" /> </inspection_tool> <inspection_tool class="SynchronizeOnLock" level="WARNING" enabled="false" /> - <inspection_tool class="FieldMayBeStatic" level="WARNING" enabled="false" /> + <inspection_tool class="FieldMayBeStatic" level="WARNING" enabled="true" /> <inspection_tool class="ClassMayBeInterface" level="WARNING" enabled="false" /> <inspection_tool class="AbstractClassWithoutAbstractMethods" level="WARNING" enabled="false" /> <inspection_tool class="DefaultNotLastCaseInSwitch" level="WARNING" enabled="false" /> @@ -1595,7 +1595,7 @@ <inspection_tool class="PlatformDetectionJS" level="WARNING" enabled="false" /> <inspection_tool class="PublicFieldAccessedInSynchronizedContext" level="WARNING" enabled="false" /> <inspection_tool class="StaticMethodOnlyUsedInOneClass" level="WARNING" enabled="false" /> - <inspection_tool class="StringReplaceableByStringBuffer" level="WARNING" enabled="false" /> + <inspection_tool class="StringReplaceableByStringBuffer" level="WARNING" enabled="true" /> <inspection_tool class="JUnitTestClassNamingConvention" level="WARNING" enabled="false"> <option name="m_regex" value="[A-Z][A-Za-z\d]*Test" /> <option name="m_minLength" value="8" /> @@ -1630,7 +1630,7 @@ <inspection_tool class="EnumClass" level="WARNING" enabled="false" /> <inspection_tool class="FeatureEnvy" level="WARNING" enabled="false" /> <inspection_tool class="EmptyTryBlockJS" level="WARNING" enabled="false" /> - <inspection_tool class="SetReplaceableByEnumSet" level="WARNING" enabled="false" /> + <inspection_tool class="SetReplaceableByEnumSet" level="ERROR" enabled="true" /> <inspection_tool class="PublicMethodNotExposedInInterface" level="WARNING" enabled="false" /> <inspection_tool class="NonFinalStaticVariableUsedInClassInitialization" level="WARNING" enabled="false" /> <inspection_tool class="UnusedCatchParameterJS" level="WARNING" enabled="false"> @@ -1649,7 +1649,7 @@ </inspection_tool> <inspection_tool class="ArithmeticOnVolatileField" level="WARNING" enabled="false" /> <inspection_tool class="PublicStaticCollectionField" level="WARNING" enabled="false" /> - <inspection_tool class="SizeReplaceableByIsEmpty" level="WARNING" enabled="false" /> + <inspection_tool class="SizeReplaceableByIsEmpty" level="ERROR" enabled="true" /> <inspection_tool class="JavadocReference" level="ERROR" enabled="true" /> <inspection_tool class="UnaryPlus" level="WARNING" enabled="false" /> <inspection_tool class="IOResource" level="WARNING" enabled="false" /> @@ -1680,7 +1680,7 @@ </inspection_tool> <inspection_tool class="StandardVariableNames" level="WARNING" enabled="false" /> <inspection_tool class="UnusedProperty" level="WARNING" enabled="false" /> - <inspection_tool class="MapReplaceableByEnumMap" level="WARNING" enabled="false" /> + <inspection_tool class="MapReplaceableByEnumMap" level="ERROR" enabled="true" /> <inspection_tool class="IfStatementWithTooManyBranchesJS" level="WARNING" enabled="false"> <option name="m_limit" value="3" /> </inspection_tool> Modified: trunk/src/app/net/sf/gridarta/UndoAndRedo.java =================================================================== --- trunk/src/app/net/sf/gridarta/UndoAndRedo.java 2006-12-23 22:26:57 UTC (rev 1244) +++ trunk/src/app/net/sf/gridarta/UndoAndRedo.java 2006-12-23 22:27:35 UTC (rev 1245) @@ -101,7 +101,7 @@ * undone, <code>false</code> if not */ public boolean canUndo() { - return currentStack.undoStack.size() > 0 && currentStack.undoStack.get(currentStack.undoStack.size() - 1).isUndoable(); + return !currentStack.undoStack.isEmpty() && currentStack.undoStack.get(currentStack.undoStack.size() - 1).isUndoable(); } @@ -129,7 +129,7 @@ * redone, <code>false</code> if not */ public boolean canRedo() { - return currentStack.redoStack.size() > 0 && currentStack.redoStack.get(currentStack.redoStack.size() - 1).isRedoable(); + return !currentStack.redoStack.isEmpty() && currentStack.redoStack.get(currentStack.redoStack.size() - 1).isRedoable(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 22:29:52
|
Revision: 1246 http://svn.sourceforge.net/gridarta/?rev=1246&view=rev Author: christianhujer Date: 2006-12-23 14:29:52 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Hardened policy: No empty Strings for toString() conversion. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/gridarta.ipr Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 22:27:35 UTC (rev 1245) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-23 22:29:52 UTC (rev 1246) @@ -197,15 +197,15 @@ final int defheight = (int) (0.9 * screen.getHeight()); // define divider locations - final int divLocationRight = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY3, "" + (int) (defwidth * 0.62))); - final int divLocationDown = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY2, "" + (int) (defheight * 0.76))); - final int divLocation = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY, "" + (int) (defwidth * 0.17))); + final int divLocationRight = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY3, String.valueOf((int) (defwidth * 0.62)))); + final int divLocationDown = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY2, String.valueOf((int) (defheight * 0.76)))); + final int divLocation = Integer.parseInt(settings.getProperty(DIVIDER_LOCATION_KEY, String.valueOf((int) (defwidth * 0.17)))); // get the old location and size - final int x = Integer.parseInt(settings.getProperty(WINDOW_X, "" + (int) ((screen.getWidth() - defwidth) / 2.0))); - final int y = Integer.parseInt(settings.getProperty(WINDOW_Y, "" + (int) ((screen.getHeight() - defheight) / 2.0))); - final int width = Integer.parseInt(settings.getProperty(WINDOW_WIDTH, "" + defwidth)); - final int height = Integer.parseInt(settings.getProperty(WINDOW_HEIGHT, "" + defheight)); + final int x = Integer.parseInt(settings.getProperty(WINDOW_X, String.valueOf((int) ((screen.getWidth() - defwidth) / 2.0)))); + final int y = Integer.parseInt(settings.getProperty(WINDOW_Y, String.valueOf((int) ((screen.getHeight() - defheight) / 2.0)))); + final int width = Integer.parseInt(settings.getProperty(WINDOW_WIDTH, String.valueOf(defwidth))); + final int height = Integer.parseInt(settings.getProperty(WINDOW_HEIGHT, String.valueOf(defheight))); // Add all the subviews getContentPane().setLayout(new BorderLayout()); @@ -439,13 +439,13 @@ // Store the location and size final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); final Rectangle bounds = getBounds(); - settings.setProperty(WINDOW_X, "" + bounds.x); - settings.setProperty(WINDOW_Y, "" + bounds.y); - settings.setProperty(WINDOW_WIDTH, "" + bounds.width); - settings.setProperty(WINDOW_HEIGHT, "" + bounds.height); - settings.setProperty(DIVIDER_LOCATION_KEY, "" + splitPane.getDividerLocation()); - settings.setProperty(DIVIDER_LOCATION_KEY2, "" + splitDownPane.getDividerLocation()); - settings.setProperty(DIVIDER_LOCATION_KEY3, "" + splitRightPane.getDividerLocation()); + settings.setProperty(WINDOW_X, String.valueOf(bounds.x)); + settings.setProperty(WINDOW_Y, String.valueOf(bounds.y)); + settings.setProperty(WINDOW_WIDTH, String.valueOf(bounds.width)); + settings.setProperty(WINDOW_HEIGHT, String.valueOf(bounds.height)); + settings.setProperty(DIVIDER_LOCATION_KEY, String.valueOf(splitPane.getDividerLocation())); + settings.setProperty(DIVIDER_LOCATION_KEY2, String.valueOf(splitDownPane.getDividerLocation())); + settings.setProperty(DIVIDER_LOCATION_KEY3, String.valueOf(splitRightPane.getDividerLocation())); archPanel.appExitNotify(); mapArchPanel.appExitNotify(); Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-23 22:27:35 UTC (rev 1245) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-23 22:29:52 UTC (rev 1246) @@ -224,7 +224,7 @@ // calculate default value in case there is no settings file final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - splitPane.setDividerLocation(Integer.parseInt(settings.getProperty(MAPARCHPANEL_LOCATION_KEY, "" + (int) (0.49 * screen.getWidth())))); + splitPane.setDividerLocation(Integer.parseInt(settings.getProperty(MAPARCHPANEL_LOCATION_KEY, String.valueOf((int) (0.49 * screen.getWidth()))))); add(splitPane, BorderLayout.CENTER); updateFont(true); @@ -597,7 +597,7 @@ void appExitNotify() { final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - settings.setProperty(MAPARCHPANEL_LOCATION_KEY, "" + splitPane.getDividerLocation()); + settings.setProperty(MAPARCHPANEL_LOCATION_KEY, String.valueOf(splitPane.getDividerLocation())); } void refresh() { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-12-23 22:27:35 UTC (rev 1245) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-12-23 22:29:52 UTC (rev 1246) @@ -292,7 +292,7 @@ log.warn("Duplicate Animation " + animName, e); } } else { - animText = "" + animText + thisLine + "\n"; + animText = animText + thisLine + "\n"; } } Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2006-12-23 22:27:35 UTC (rev 1245) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2006-12-23 22:29:52 UTC (rev 1246) @@ -574,36 +574,36 @@ mapDescription.setText(map.getText()); mapLore.setText(map.getLore()); mapName.setText(map.getMapName()); - mapRegion.setText("" + map.getMapRegion()); + mapRegion.setText(map.getMapRegion()); final Size2D mapSize = map.getMapSize(); levelWidthField.setText(String.valueOf(mapSize.getWidth())); levelHeightField.setText(String.valueOf(mapSize.getHeight())); - fieldEnterX.setText("" + map.getEnterX()); - fieldEnterY.setText("" + map.getEnterY()); - fieldSwapTime.setText("" + map.getSwapTime()); - fieldResetTimeout.setText("" + map.getResetTimeout()); - fieldDarkness.setText("" + map.getDarkness()); - fieldDifficulty.setText("" + map.getDifficulty()); + fieldEnterX.setText(String.valueOf(map.getEnterX())); + fieldEnterY.setText(String.valueOf(map.getEnterY())); + fieldSwapTime.setText(String.valueOf(map.getSwapTime())); + fieldResetTimeout.setText(String.valueOf(map.getResetTimeout())); + fieldDarkness.setText(String.valueOf(map.getDarkness())); + fieldDifficulty.setText(String.valueOf(map.getDifficulty())); checkboxUnique.setSelected(map.isUnique()); checkboxOutdoor.setSelected(map.isOutdoor()); checkboxFixedReset.setSelected(map.isFixedReset()); checkboxNosmooth.setSelected(map.isNosmooth()); - fieldShopitems.setText("" + map.getShopItems()); - fieldShoprace.setText("" + map.getShopRace()); - fieldShopmax.setText("" + map.getShopMax()); - fieldShopmin.setText("" + map.getShopMin()); - fieldShopgreed.setText("" + map.getShopGreed()); - fieldTemperature.setText("" + map.getTemp()); - fieldPressure.setText("" + map.getPressure()); - fieldHumidity.setText("" + map.getHumid()); - fieldWindspeed.setText("" + map.getWindspeed()); - fieldWindDirection.setText("" + map.getWinddir()); - fieldSkySetting.setText("" + map.getSky()); + fieldShopitems.setText(map.getShopItems()); + fieldShoprace.setText(map.getShopRace()); + fieldShopmax.setText(String.valueOf(map.getShopMax())); + fieldShopmin.setText(String.valueOf(map.getShopMin())); + fieldShopgreed.setText(String.valueOf(map.getShopGreed())); + fieldTemperature.setText(String.valueOf(map.getTemp())); + fieldPressure.setText(String.valueOf(map.getPressure())); + fieldHumidity.setText(String.valueOf(map.getHumid())); + fieldWindspeed.setText(String.valueOf(map.getWindspeed())); + fieldWindDirection.setText(String.valueOf(map.getWinddir())); + fieldSkySetting.setText(String.valueOf(map.getSky())); for (int i = 0; i < 4; i++) { - fieldTilePath[i].setText("" + map.getTilePath(i)); + fieldTilePath[i].setText(map.getTilePath(i)); } } Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2006-12-23 22:27:35 UTC (rev 1245) +++ trunk/gridarta.ipr 2006-12-23 22:29:52 UTC (rev 1246) @@ -1500,7 +1500,7 @@ <option name="m_minLength" value="4" /> <option name="m_maxLength" value="32" /> </inspection_tool> - <inspection_tool class="TrivialStringConcatenation" level="WARNING" enabled="true" /> + <inspection_tool class="TrivialStringConcatenation" level="ERROR" enabled="true" /> <inspection_tool class="EmptySynchronizedStatement" level="WARNING" enabled="false" /> <inspection_tool class="UnnecessaryDefault" level="WARNING" enabled="false" /> <inspection_tool class="UnnecessarySuperConstructor" level="WARNING" enabled="false" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-23 22:39:35
|
Revision: 1247 http://svn.sourceforge.net/gridarta/?rev=1247&view=rev Author: christianhujer Date: 2006-12-23 14:39:35 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Hardened policy: fields and inner classes that may be declared static must be declared static. Removed some unused fields. Made a field static. Made several inner classes static. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFilterControl.java trunk/crossfire/src/cfeditor/CGUIUtils.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CScriptModel.java trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java trunk/crossfire/src/cfeditor/parameter/MapParameterView.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/gridarta.ipr Modified: trunk/crossfire/src/cfeditor/CFilterControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CFilterControl.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/CFilterControl.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -47,8 +47,6 @@ public static final int MAX_HIGHLIGHT = 3; - private final boolean filterOut = false; - private static final NamedFilterList filterList = NamedFilterList.getDefaultList(); private final NamedFilterConfig filterOutConfig; Modified: trunk/crossfire/src/cfeditor/CGUIUtils.java =================================================================== --- trunk/crossfire/src/cfeditor/CGUIUtils.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/CGUIUtils.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -161,7 +161,7 @@ } /** Grayscale filter to make grayscaled images. */ - private final class CGrayScaleFilter extends RGBImageFilter { + private static final class CGrayScaleFilter extends RGBImageFilter { /** * Converts a single input pixel in the default RGB ColorModel Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -613,7 +613,7 @@ // ignore } - public final class CPaintOp implements EditOperation { + public static final class CPaintOp implements EditOperation { final Rectangle fillRect; Modified: trunk/crossfire/src/cfeditor/CScriptModel.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptModel.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/CScriptModel.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -56,7 +56,7 @@ this.ctrl = ctrl; } - private final class Parameter { + private static final class Parameter { private String name; Modified: trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -16,8 +16,6 @@ */ public class SimpleFilterConfig extends BasicFilterConfig { - private final boolean enabled = true; - private Map<String, Object> properties = new HashMap<String, Object>(); public void setProperty(final String name, final Object value) { Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -370,7 +370,7 @@ class MyCellRenderer extends DefaultListCellRenderer { - public final String sizeTester = "**Sizetester**"; + public static final String SIZE_TESTER = "**Sizetester**"; private static final long serialVersionUID = 1L; @@ -383,7 +383,7 @@ final boolean isSelected, // is the cell selected final boolean cellHasFocus) { // the list and the cell have the focus - if (sizeTester.equals(value)) { + if (SIZE_TESTER.equals(value)) { return editor.getEditorComponent(); } /* The DefaultListCellRenderer class will take care of Modified: trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -124,7 +124,7 @@ * the idea for this class stems from limewire's CancelSearchIconProxy * class, thanks for going open source guys. */ - protected class ClosingIcon implements Icon { + protected static class ClosingIcon implements Icon { //--- Data field(s) --- Modified: trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -13,7 +13,7 @@ public class DoubleParameter extends PluginParameter { - private class DoubleConfig { + private static class DoubleConfig { /* we do not use the Double.MAX or JTextField will be *very* large. So * we fall back to [0, 1] range (useful for randoms)*/ Modified: trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -31,7 +31,7 @@ * since Java 5.0 but we need this workaround for java 4.x users. * @author tchize */ - private class TooltipSpinner extends JSpinner { + private static class TooltipSpinner extends JSpinner { private static final long serialVersionUID = 1L; Modified: trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -13,7 +13,7 @@ public class IntegerParameter extends PluginParameter { - private class IntegerConfig { + private static class IntegerConfig { int min = Integer.MIN_VALUE; Modified: trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -31,7 +31,7 @@ * since Java 5.0 but we need this workaround for java 4.x users. * @author tchize */ - private class TooltipSpinner extends JSpinner { + private static class TooltipSpinner extends JSpinner { private static final long serialVersionUID = -797350272052837471L; Modified: trunk/crossfire/src/cfeditor/parameter/MapParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/MapParameterView.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/crossfire/src/cfeditor/parameter/MapParameterView.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -71,7 +71,7 @@ return this.config; } - public class MyCellRenderer extends DefaultListCellRenderer { + public static class MyCellRenderer extends DefaultListCellRenderer { private static final long serialVersionUID = 1L; @@ -96,7 +96,7 @@ } } - public class MyComboBoxModel extends DefaultComboBoxModel { + public static class MyComboBoxModel extends DefaultComboBoxModel { private final Object currentMap = new Object(); Modified: trunk/daimonin/src/daieditor/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/ScriptArchData.java 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/daimonin/src/daieditor/ScriptArchData.java 2006-12-23 22:39:35 UTC (rev 1247) @@ -572,7 +572,7 @@ } /** Inner class which stores information about one scripted event. */ - private final class ScriptedEvent { + private static final class ScriptedEvent { private final GameObject event; // Our event object Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2006-12-23 22:29:52 UTC (rev 1246) +++ trunk/gridarta.ipr 2006-12-23 22:39:35 UTC (rev 1247) @@ -1354,7 +1354,7 @@ <inspection_tool class="AnonymousClassComplexity" level="WARNING" enabled="false"> <option name="m_limit" value="3" /> </inspection_tool> - <inspection_tool class="InnerClassMayBeStatic" level="WARNING" enabled="true" /> + <inspection_tool class="InnerClassMayBeStatic" level="ERROR" enabled="true" /> <inspection_tool class="RedundantFieldInitialization" level="WARNING" enabled="false" /> <inspection_tool class="StaticSuite" level="WARNING" enabled="false" /> <inspection_tool class="StringBufferToStringInConcatenation" level="ERROR" enabled="true" /> @@ -1576,7 +1576,7 @@ <option name="m_limit" value="30" /> </inspection_tool> <inspection_tool class="SynchronizeOnLock" level="WARNING" enabled="false" /> - <inspection_tool class="FieldMayBeStatic" level="WARNING" enabled="true" /> + <inspection_tool class="FieldMayBeStatic" level="ERROR" enabled="true" /> <inspection_tool class="ClassMayBeInterface" level="WARNING" enabled="false" /> <inspection_tool class="AbstractClassWithoutAbstractMethods" level="WARNING" enabled="false" /> <inspection_tool class="DefaultNotLastCaseInSwitch" level="WARNING" enabled="false" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 22:55:35
|
Revision: 1250 http://svn.sourceforge.net/gridarta/?rev=1250&view=rev Author: akirschbaum Date: 2006-12-23 14:55:29 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Add comment/@NotNull annotation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/daimonin/src/daieditor/CAttribDialog.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-23 22:46:34 UTC (rev 1249) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-23 22:55:29 UTC (rev 1250) @@ -92,6 +92,7 @@ import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -123,7 +124,8 @@ private JLabel imagePanel; // panel for object's face (png) - private final GameObject gameObject; + /** The game object being modified. */ + @NotNull private final GameObject gameObject; private final Archetype<GameObject> archetype; @@ -191,7 +193,7 @@ * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control */ - private CAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final CMainControl mainControl) { + private CAttribDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final CMainControl mainControl) { listNr = 0; this.mainControl = mainControl; // reference to the main control Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-12-23 22:46:34 UTC (rev 1249) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-12-23 22:55:29 UTC (rev 1250) @@ -92,6 +92,7 @@ import net.sf.japi.swing.ActionFactory; import static net.sf.japi.util.Arrays2.linearSearch; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -123,7 +124,8 @@ private JLabel imagePanel; // panel for object's face (png) - private final GameObject gameObject; + /** The game object being modified. */ + @NotNull private final GameObject gameObject; private final Archetype<GameObject> archetype; @@ -191,7 +193,7 @@ * @param gameObject the GameObject to be displayed by this dialog * @param mainControl main control */ - private CAttribDialog(final CFArchTypeList archTypeList, final GameObject gameObject, final CMainControl mainControl) { + private CAttribDialog(final CFArchTypeList archTypeList, @NotNull final GameObject gameObject, final CMainControl mainControl) { listNr = 0; this.mainControl = mainControl; // reference to the main control This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 23:25:24
|
Revision: 1252 http://svn.sourceforge.net/gridarta/?rev=1252&view=rev Author: akirschbaum Date: 2006-12-23 15:25:24 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Move code to determine the type of an game object to a separate function. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CFArchTypeList.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-23 23:17:35 UTC (rev 1251) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-23 23:25:24 UTC (rev 1252) @@ -203,66 +203,9 @@ this.gameObject = gameObject.getHead(); archetype = this.gameObject.getArchetype(); - // check if the type of the object is present in the definitions - //typeNr = 0; // for invalid types, we take "type 0" - boolean typeFound = false; - int i = 0; - type = null; - for (final CFArchType tmp : archTypeList) { - if (type == null) { - type = tmp; - } - if (tmp.getTypeNr() == this.gameObject.getArchTypNr()) { - if (tmp.getTypeAttr() == null) { - // no type-attributes, so we only compared type-numbers - typeFound = true; - } else { - // check if all the type-attributes match - final int numArgs = (int) (tmp.getTypeAttr().length / 2.0); - boolean match = true; + type = archTypeList.getType(gameObject); + listNr = archTypeList.getArchTypeIndex(type); - if (log.isDebugEnabled()) { - log.debug("# type: " + tmp.getTypeName()); - } - - for (int t = 0, l = numArgs * 2; t < l; t += 2) { - final String attrValue = this.gameObject.getAttributeString(tmp.getTypeAttr()[t]); - - if (log.isDebugEnabled()) { - log.debug(" arch: '" + attrValue + "', type: '" + tmp.getTypeAttr()[t + 1] + "'"); - } - - if (!attrValue.equals(tmp.getTypeAttr()[t + 1]) && !(tmp.getTypeAttr()[t + 1].equals("0") && attrValue.length() == 0)) { - match = false; - if (log.isDebugEnabled()) { - log.debug("-> attr: " + tmp.getTypeAttr()[t] + " NO match"); - } - } else { - if (log.isDebugEnabled()) { - log.debug("-> attr: " + tmp.getTypeAttr()[t] + " YES match"); - } - } - } - - // we've got a match after all - if (match) { - typeFound = true; - } - } - - // we found our type, now save all infos we need - if (typeFound) { - type = tmp; // save reference to the type-data - listNr = i; // save position in list - break; - } - } - i++; - } - - // get the type data - //type = archTypeList.getType(typeNr); - // first split top-left and -right final JComponent leftPane = buildHeader(); final JScrollPane rightPane = buildInv(); Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-23 23:17:35 UTC (rev 1251) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-23 23:25:24 UTC (rev 1252) @@ -47,6 +47,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This class handles all the CFArchTypes and makes them conveniently @@ -314,6 +316,10 @@ return archTypeList.get(n); } + public int getArchTypeIndex(@NotNull final CFArchType archType) { + return archTypeList.indexOf(archType); + } + /** * Lookup the name of an archtype. * @param typeNr type number @@ -401,4 +407,61 @@ return type == null ? archTypeList.get(0) : type; } + @Nullable public CFArchType getType(@NotNull final GameObject gameObject) { + CFArchType type = null; + boolean typeFound = false; + type = null; + for (final CFArchType tmp : archTypeList) { + if (type == null) { + type = tmp; + } + if (tmp.getTypeNr() == gameObject.getArchTypNr()) { + if (tmp.getTypeAttr() == null) { + // no type-attributes, so we only compared type-numbers + typeFound = true; + } else { + // check if all the type-attributes match + final int numArgs = (int) (tmp.getTypeAttr().length / 2.0); + boolean match = true; + + if (log.isDebugEnabled()) { + log.debug("# type: " + tmp.getTypeName()); + } + + for (int t = 0, l = numArgs * 2; t < l; t += 2) { + final String attrValue = gameObject.getAttributeString(tmp.getTypeAttr()[t]); + + if (log.isDebugEnabled()) { + log.debug(" arch: '" + attrValue + "', type: '" + tmp.getTypeAttr()[t + 1] + "'"); + } + + if (!attrValue.equals(tmp.getTypeAttr()[t + 1]) && !(tmp.getTypeAttr()[t + 1].equals("0") && attrValue.length() == 0)) { + match = false; + if (log.isDebugEnabled()) { + log.debug("-> attr: " + tmp.getTypeAttr()[t] + " NO match"); + } + } else { + if (log.isDebugEnabled()) { + log.debug("-> attr: " + tmp.getTypeAttr()[t] + " YES match"); + } + } + } + + // we've got a match after all + if (match) { + typeFound = true; + } + } + + // we found our type, now save all infos we need + if (typeFound) { + type = tmp; // save reference to the type-data + break; + } + } + } + + return type; + } + } // class CFArchTypeList Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-12-23 23:17:35 UTC (rev 1251) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-12-23 23:25:24 UTC (rev 1252) @@ -203,65 +203,9 @@ this.gameObject = gameObject.getHead(); archetype = this.gameObject.getArchetype(); - // check if the type of the object is present in the definitions - //typeNr = 0; // for invalid types, we take "type 0" - boolean typeFound = false; - int i = 0; - for (final CFArchType tmp : archTypeList) { - if (tmp.getTypeNr() == this.gameObject.getArchTypNr()) { - if (tmp.getTypeAttr() == null) { - // no type-attributes, so we only compared type-numbers - typeFound = true; - } else { - // check if all the type-attributes match - final int numArgs = (int) (tmp.getTypeAttr().length / 2.0); - boolean match = true; + type = archTypeList.getType(gameObject); + listNr = archTypeList.getArchTypeIndex(type); - if (log.isDebugEnabled()) { - log.debug("# type: " + tmp.getTypeName()); - } - - for (int t = 0, l = numArgs * 2; t < l; t += 2) { - final String attrValue = this.gameObject.getAttributeString(tmp.getTypeAttr()[t]); - - if (log.isDebugEnabled()) { - log.debug(" arch: '" + attrValue + "', type: '" + tmp.getTypeAttr()[t + 1] + "'"); - } - - if (!attrValue.equals(tmp.getTypeAttr()[t + 1]) && !(tmp.getTypeAttr()[t + 1].equals("0") && attrValue.length() == 0)) { - match = false; - if (log.isDebugEnabled()) { - log.debug("-> attr: " + tmp.getTypeAttr()[t] + " NO match"); - } - } else { - if (log.isDebugEnabled()) { - log.debug("-> attr: " + tmp.getTypeAttr()[t] + " YES match"); - } - } - } - - // we've got a match after all - if (match) { - typeFound = true; - } - } - - // we found our type, now save all infos we need - if (typeFound) { - type = tmp; // save reference to the type-data - listNr = i; // save position in list - break; - } - } - i++; - } - if (!typeFound) { - type = archTypeList.getArchType(0); - } - - // get the type data - //type = archTypeList.getType(typeNr); - // first split top-left and -right final JComponent leftPane = buildHeader(); final JScrollPane rightPane = buildInv(); Modified: trunk/daimonin/src/daieditor/CFArchTypeList.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-23 23:17:35 UTC (rev 1251) +++ trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-23 23:25:24 UTC (rev 1252) @@ -48,6 +48,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * This class handles all the CFArchTypes and makes them conveniently @@ -343,6 +345,10 @@ return archTypeList.get(n); } + public int getArchTypeIndex(@NotNull final CFArchType archType) { + return archTypeList.indexOf(archType); + } + /** * Lookup the name of an archtype. * @param typeNr type number @@ -430,4 +436,60 @@ return type == null ? archTypeList.get(0) : type; } + @Nullable public CFArchType getType(@NotNull final GameObject gameObject) { + CFArchType type = null; + boolean typeFound = false; + for (final CFArchType tmp : archTypeList) { + if (tmp.getTypeNr() == gameObject.getArchTypNr()) { + if (tmp.getTypeAttr() == null) { + // no type-attributes, so we only compared type-numbers + typeFound = true; + } else { + // check if all the type-attributes match + final int numArgs = (int) (tmp.getTypeAttr().length / 2.0); + boolean match = true; + + if (log.isDebugEnabled()) { + log.debug("# type: " + tmp.getTypeName()); + } + + for (int t = 0, l = numArgs * 2; t < l; t += 2) { + final String attrValue = gameObject.getAttributeString(tmp.getTypeAttr()[t]); + + if (log.isDebugEnabled()) { + log.debug(" arch: '" + attrValue + "', type: '" + tmp.getTypeAttr()[t + 1] + "'"); + } + + if (!attrValue.equals(tmp.getTypeAttr()[t + 1]) && !(tmp.getTypeAttr()[t + 1].equals("0") && attrValue.length() == 0)) { + match = false; + if (log.isDebugEnabled()) { + log.debug("-> attr: " + tmp.getTypeAttr()[t] + " NO match"); + } + } else { + if (log.isDebugEnabled()) { + log.debug("-> attr: " + tmp.getTypeAttr()[t] + " YES match"); + } + } + } + + // we've got a match after all + if (match) { + typeFound = true; + } + } + + // we found our type, now save all infos we need + if (typeFound) { + type = tmp; // save reference to the type-data + break; + } + } + } + if (!typeFound) { + type = getArchType(0); + } + + return type; + } + } // class CFArchTypeList This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 23:37:53
|
Revision: 1253 http://svn.sourceforge.net/gridarta/?rev=1253&view=rev Author: akirschbaum Date: 2006-12-23 15:37:52 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Move code to determine the type of an game object to a separate function. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFArchType.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/daimonin/src/daieditor/CFArchType.java trunk/daimonin/src/daieditor/CFArchTypeList.java Modified: trunk/crossfire/src/cfeditor/CFArchType.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-23 23:25:24 UTC (rev 1252) +++ trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-23 23:37:52 UTC (rev 1253) @@ -29,10 +29,12 @@ import java.util.List; import java.util.Map; import net.sf.gridarta.gameobject.ArchAttribType; +import net.sf.gridarta.gameobject.GameObject; import net.sf.japi.swing.ActionFactory; import net.sf.japi.xml.NodeListIterator; import static net.sf.japi.xml.NodeListIterator.getFirstChild; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.w3c.dom.Attr; import org.w3c.dom.Element; import static org.w3c.dom.Node.ELEMENT_NODE; @@ -433,4 +435,45 @@ return typeAttributes; } + public boolean matches(@NotNull final GameObject gameObject) { + if (getTypeNr() != gameObject.getArchTypNr()) { + return false; + } + + if (getTypeAttr() == null) { + // no type-attributes, so we only compared type-numbers + return true; + } + + // check if all the type-attributes match + final int numArgs = getTypeAttr().length / 2; + + if (log.isDebugEnabled()) { + log.debug("# type: " + getTypeName()); + } + + for (int t = 0, l = numArgs * 2; t < l; t += 2) { + final String attrValue = gameObject.getAttributeString(getTypeAttr()[t]); + + if (log.isDebugEnabled()) { + log.debug(" arch: '" + attrValue + "', type: '" + getTypeAttr()[t + 1] + "'"); + } + + if (!attrValue.equals(getTypeAttr()[t + 1]) && !(getTypeAttr()[t + 1].equals("0") && attrValue.length() == 0)) { + if (log.isDebugEnabled()) { + log.debug("-> attr: " + getTypeAttr()[t] + " NO match"); + } + + return false; + } + + if (log.isDebugEnabled()) { + log.debug("-> attr: " + getTypeAttr()[t] + " YES match"); + } + } + + // we've got a match after all + return true; + } + } // class CFArchType Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-23 23:25:24 UTC (rev 1252) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-23 23:37:52 UTC (rev 1253) @@ -408,60 +408,17 @@ } @Nullable public CFArchType getType(@NotNull final GameObject gameObject) { - CFArchType type = null; - boolean typeFound = false; - type = null; - for (final CFArchType tmp : archTypeList) { - if (type == null) { - type = tmp; + CFArchType result = null; + for (final CFArchType type : archTypeList) { + if (result == null) { + result = type; } - if (tmp.getTypeNr() == gameObject.getArchTypNr()) { - if (tmp.getTypeAttr() == null) { - // no type-attributes, so we only compared type-numbers - typeFound = true; - } else { - // check if all the type-attributes match - final int numArgs = (int) (tmp.getTypeAttr().length / 2.0); - boolean match = true; - - if (log.isDebugEnabled()) { - log.debug("# type: " + tmp.getTypeName()); - } - - for (int t = 0, l = numArgs * 2; t < l; t += 2) { - final String attrValue = gameObject.getAttributeString(tmp.getTypeAttr()[t]); - - if (log.isDebugEnabled()) { - log.debug(" arch: '" + attrValue + "', type: '" + tmp.getTypeAttr()[t + 1] + "'"); - } - - if (!attrValue.equals(tmp.getTypeAttr()[t + 1]) && !(tmp.getTypeAttr()[t + 1].equals("0") && attrValue.length() == 0)) { - match = false; - if (log.isDebugEnabled()) { - log.debug("-> attr: " + tmp.getTypeAttr()[t] + " NO match"); - } - } else { - if (log.isDebugEnabled()) { - log.debug("-> attr: " + tmp.getTypeAttr()[t] + " YES match"); - } - } - } - - // we've got a match after all - if (match) { - typeFound = true; - } - } - - // we found our type, now save all infos we need - if (typeFound) { - type = tmp; // save reference to the type-data - break; - } + if (type.matches(gameObject)) { + return type; } } - return type; + return result; } } // class CFArchTypeList Modified: trunk/daimonin/src/daieditor/CFArchType.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchType.java 2006-12-23 23:25:24 UTC (rev 1252) +++ trunk/daimonin/src/daieditor/CFArchType.java 2006-12-23 23:37:52 UTC (rev 1253) @@ -29,10 +29,12 @@ import java.util.List; import java.util.Map; import net.sf.gridarta.gameobject.ArchAttribType; +import net.sf.gridarta.gameobject.GameObject; import net.sf.japi.swing.ActionFactory; import net.sf.japi.xml.NodeListIterator; import static net.sf.japi.xml.NodeListIterator.getFirstChild; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.w3c.dom.Attr; import org.w3c.dom.Element; import static org.w3c.dom.Node.ELEMENT_NODE; @@ -424,4 +426,45 @@ return typeAttributes; } + public boolean matches(@NotNull final GameObject gameObject) { + if (getTypeNr() != gameObject.getArchTypNr()) { + return false; + } + + if (getTypeAttr() == null) { + // no type-attributes, so we only compared type-numbers + return true; + } + + // check if all the type-attributes match + final int numArgs = getTypeAttr().length / 2; + + if (log.isDebugEnabled()) { + log.debug("# type: " + getTypeName()); + } + + for (int t = 0, l = numArgs * 2; t < l; t += 2) { + final String attrValue = gameObject.getAttributeString(getTypeAttr()[t]); + + if (log.isDebugEnabled()) { + log.debug(" arch: '" + attrValue + "', type: '" + getTypeAttr()[t + 1] + "'"); + } + + if (!attrValue.equals(getTypeAttr()[t + 1]) && !(getTypeAttr()[t + 1].equals("0") && attrValue.length() == 0)) { + if (log.isDebugEnabled()) { + log.debug("-> attr: " + getTypeAttr()[t] + " NO match"); + } + + return false; + } + + if (log.isDebugEnabled()) { + log.debug("-> attr: " + getTypeAttr()[t] + " YES match"); + } + } + + // we've got a match after all + return true; + } + } // class CFArchType Modified: trunk/daimonin/src/daieditor/CFArchTypeList.java =================================================================== --- trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-23 23:25:24 UTC (rev 1252) +++ trunk/daimonin/src/daieditor/CFArchTypeList.java 2006-12-23 23:37:52 UTC (rev 1253) @@ -437,59 +437,13 @@ } @Nullable public CFArchType getType(@NotNull final GameObject gameObject) { - CFArchType type = null; - boolean typeFound = false; - for (final CFArchType tmp : archTypeList) { - if (tmp.getTypeNr() == gameObject.getArchTypNr()) { - if (tmp.getTypeAttr() == null) { - // no type-attributes, so we only compared type-numbers - typeFound = true; - } else { - // check if all the type-attributes match - final int numArgs = (int) (tmp.getTypeAttr().length / 2.0); - boolean match = true; - - if (log.isDebugEnabled()) { - log.debug("# type: " + tmp.getTypeName()); - } - - for (int t = 0, l = numArgs * 2; t < l; t += 2) { - final String attrValue = gameObject.getAttributeString(tmp.getTypeAttr()[t]); - - if (log.isDebugEnabled()) { - log.debug(" arch: '" + attrValue + "', type: '" + tmp.getTypeAttr()[t + 1] + "'"); - } - - if (!attrValue.equals(tmp.getTypeAttr()[t + 1]) && !(tmp.getTypeAttr()[t + 1].equals("0") && attrValue.length() == 0)) { - match = false; - if (log.isDebugEnabled()) { - log.debug("-> attr: " + tmp.getTypeAttr()[t] + " NO match"); - } - } else { - if (log.isDebugEnabled()) { - log.debug("-> attr: " + tmp.getTypeAttr()[t] + " YES match"); - } - } - } - - // we've got a match after all - if (match) { - typeFound = true; - } - } - - // we found our type, now save all infos we need - if (typeFound) { - type = tmp; // save reference to the type-data - break; - } + for (final CFArchType type : archTypeList) { + if (type.matches(gameObject)) { + return type; } } - if (!typeFound) { - type = getArchType(0); - } - return type; + return getArchType(0); } } // class CFArchTypeList This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 23:44:45
|
Revision: 1254 http://svn.sourceforge.net/gridarta/?rev=1254&view=rev Author: akirschbaum Date: 2006-12-23 15:44:43 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Fix #1613729 (Monsters appear as "weak wall (0)"). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CArchQuickView.java trunk/daimonin/src/daieditor/CArchQuickView.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 23:37:52 UTC (rev 1253) +++ trunk/crossfire/ChangeLog 2006-12-23 23:44:43 UTC (rev 1254) @@ -1,3 +1,7 @@ +2006-12-24 Andreas Kirschbaum + + * Fix #1613729 (Monsters appear as "weak wall (0)"). + 2006-12-23 Andreas Kirschbaum * Reorder inventory items in map tile panel to make "move up/down" Modified: trunk/crossfire/src/cfeditor/CArchQuickView.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-12-23 23:37:52 UTC (rev 1253) +++ trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-12-23 23:44:43 UTC (rev 1254) @@ -124,7 +124,8 @@ archArchNameText.setText(headObject.getArchetypeName()); - archTypeText.setText(mainControl.getTypeList().getArchTypeName(headObject.getArchTypNr()) + " (" + headObject.getArchTypNr() + ')'); + final CFArchType archType = mainControl.getTypeList().getType(headObject); + archTypeText.setText(archType.getTypeName() + " (" + archType.getTypeNr() + ')'); if (headObject.isMulti()) { archTileText.setText("<html><span style=\"color:green;\"> multi</span> (" + headObject.getMultiRefCount() + " parts) (" + headObject.getSizeX() + ',' + headObject.getSizeY() + ")</html>"); Modified: trunk/daimonin/src/daieditor/CArchQuickView.java =================================================================== --- trunk/daimonin/src/daieditor/CArchQuickView.java 2006-12-23 23:37:52 UTC (rev 1253) +++ trunk/daimonin/src/daieditor/CArchQuickView.java 2006-12-23 23:44:43 UTC (rev 1254) @@ -129,7 +129,8 @@ archArchNameText.setText(headObject.getArchetypeName()); - archTypeText.setText(mainControl.getTypeList().getArchTypeName(headObject.getArchTypNr()) + " (" + headObject.getArchTypNr() + ')'); + final CFArchType archType = mainControl.getTypeList().getType(headObject); + archTypeText.setText(archType.getTypeName() + " (" + archType.getTypeNr() + ')'); if (headObject.isMulti()) { archTileText.setText("<html><span style=\"color:green;\"> multi</span> (" + headObject.getMultiRefCount() + " parts) (" + headObject.getSizeX() + ',' + headObject.getSizeY() + ")</html>"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-24 00:07:04
|
Revision: 1256 http://svn.sourceforge.net/gridarta/?rev=1256&view=rev Author: akirschbaum Date: 2006-12-23 16:07:05 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Prevent possible use of null filename. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 23:46:46 UTC (rev 1255) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-24 00:07:05 UTC (rev 1256) @@ -1172,13 +1172,12 @@ // there is no map open (should not happen due to disabled menus) ACTION_FACTORY.showMessageDialog(mainView, "createImgNoMap"); } else { - String filename = null; - try { - if (strImageDir == null) { - strImageDir = mapDir.getAbsolutePath(); - } + if (strImageDir == null) { + strImageDir = mapDir.getAbsolutePath(); + } - filename = strImageDir + File.separator + mapControl.getMapFileName() + ".png"; + String filename = strImageDir + File.separator + mapControl.getMapFileName() + ".png"; + try { final JFileChooser fileChooser = new JFileChooser(strImageDir); fileChooser.setDialogTitle("Save Image As"); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 23:46:46 UTC (rev 1255) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-24 00:07:05 UTC (rev 1256) @@ -1398,13 +1398,12 @@ // there is no map open (should not happen due to disabled menus) ACTION_FACTORY.showMessageDialog(mainView, "createImgNoMap"); } else { - String filename = null; - try { - if (strImageDir == null) { - strImageDir = mapDir.getAbsolutePath(); - } + if (strImageDir == null) { + strImageDir = mapDir.getAbsolutePath(); + } - filename = strImageDir + File.separator + mapControl.getMapFileName() + ".png"; + String filename = strImageDir + File.separator + mapControl.getMapFileName() + ".png"; + try { final JFileChooser fileChooser = new JFileChooser(strImageDir); fileChooser.setDialogTitle("Save Image As"); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-24 10:41:35
|
Revision: 1264 http://svn.sourceforge.net/gridarta/?rev=1264&view=rev Author: akirschbaum Date: 2006-12-24 02:41:35 -0800 (Sun, 24 Dec 2006) Log Message: ----------- Split ConnectionView class into view/controller; move code to register listeners to connection view implementation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/src/app/net/sf/gridarta/gui/ConnectionView.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -724,7 +724,6 @@ setCurrentLevel(map); refreshMenusAndToolbars(); } - map.getMapModel().addMapModelListener(mainView.getMapArchPanel().getConnectionView()); return map; } Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -56,7 +56,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; -import net.sf.gridarta.gui.ConnectionView; +import net.sf.gridarta.gui.ConnectionControl; import net.sf.gridarta.gui.GSplitPane; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -126,9 +126,6 @@ private final JPanel animationPanel; - /** The JPanel holding the connection information. */ - private final ConnectionView connectionView = new ConnectionView(); - /** Arch text field. */ private final JTextArea archTextArea = new JTextArea(4, 25); @@ -173,6 +170,8 @@ final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); setLayout(new BorderLayout()); + final ConnectionControl connectionControl = new ConnectionControl(mainControl); + // scrollPane2 contains the document for archtext editing final JScrollPane scrollPane2 = new JScrollPane(archEdit); scrollPane2.setBackground(archEdit.getBackground()); @@ -219,7 +218,7 @@ panelDesktop.add(createScriptPanel(), "Scripts"); panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(connectionView, "Connection"); + panelDesktop.add(connectionControl.getView(), "Connection"); // calculate default value in case there is no settings file final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); @@ -230,8 +229,6 @@ updateFont(true); document = archEdit.getDocument(); - - mainControl.addMainControlListener(connectionView); } /** @@ -905,12 +902,4 @@ aRemove.setEnabled(removeButton); } - /** - * Get the ConnectionView. - * @return ConnectionView - */ - public ConnectionView getConnectionView() { - return connectionView; - } - } // class CMapArchPanel Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -893,7 +893,6 @@ refreshMenusAndToolbars(); } map.getMapModel().addMapModelListener(this); - map.getMapModel().addMapModelListener(mainView.getMapArchPanel().getConnectionView()); return map; } Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -61,7 +61,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; -import net.sf.gridarta.gui.ConnectionView; +import net.sf.gridarta.gui.ConnectionControl; import net.sf.gridarta.gui.GSplitPane; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; @@ -148,9 +148,6 @@ private final JPanel animationPanel; - /** The JPanel holding the connection information. */ - private final ConnectionView connectionView = new ConnectionView(); - /** The JPanel holding the error information. */ private final ErrorListView errorListView = new ErrorListView(); @@ -192,6 +189,8 @@ mainView = view; setLayout(new BorderLayout()); + final ConnectionControl connectionControl = new ConnectionControl(mainControl); + // scrollPane2 contains the document for archtext editing final JScrollPane scrollPane2 = new JScrollPane(archEdit); scrollPane2.setBackground(archEdit.getBackground()); @@ -238,7 +237,7 @@ panelDesktop.add(createScriptPanel(), "Scripts"); panelDesktop.add(animationPanel, "Animation"); - panelDesktop.add(connectionView, "Connection"); + panelDesktop.add(connectionControl.getView(), "Connection"); panelDesktop.add(errorListView, "Errors"); // calculate default value in case there is no settings file @@ -250,8 +249,6 @@ updateFont(true); document = archEdit.getDocument(); - - mainControl.addMainControlListener(connectionView); } /** {@inheritDoc} */ @@ -1043,12 +1040,4 @@ aRemove.setEnabled(removeButton); } - /** - * Get the ConnectionView. - * @return ConnectionView - */ - public ConnectionView getConnectionView() { - return connectionView; - } - } // class CMapArchPanel Added: trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -0,0 +1,58 @@ +/* + * Gridarta Java Editor. + * Copyright (C) 2006 The Gridarta Developers + * + * 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 net.sf.gridarta.gui; + +import net.sf.gridarta.MainControl; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * The controller for the connection view. + * + * @author Andreas Kirschbaum + */ +public class ConnectionControl { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(ConnectionControl.class); + + /** The view for this controller. */ + @NotNull private final ConnectionView view; + + /* + * Create a new instance. + * + * @param mainControl the main control to use + */ + public ConnectionControl(@NotNull final MainControl mainControl) { + view = new ConnectionView(mainControl); + } + + /** + * Return the view for this controller. + * + * @return the view for this controller + */ + @NotNull public ConnectionView getView() { + return view; + } + +} // class ConnectionControl Property changes on: trunk/src/app/net/sf/gridarta/gui/ConnectionControl.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/ConnectionView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-24 09:58:17 UTC (rev 1263) +++ trunk/src/app/net/sf/gridarta/gui/ConnectionView.java 2006-12-24 10:41:35 UTC (rev 1264) @@ -1,6 +1,7 @@ /* * Gridarta Java Editor. * Copyright (C) 2005 Christian Hujer + * Copyright (C) 2006 The Gridarta Developers * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,7 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. - * */ package net.sf.gridarta.gui; @@ -29,6 +29,7 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import net.sf.gridarta.MainControl; import net.sf.gridarta.MainControlListener; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; @@ -44,6 +45,7 @@ * A Panel that holds information about the connections of the selected arch on the selected map. * It is unfinished. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum * @todo more user interface features * @todo make this a MapHighlightModel * @todo better react on changes, don't always scan the whole map @@ -62,9 +64,10 @@ private MapControl mapControl = null; /** Create a ConnectionPanel. */ - public ConnectionView() { + public ConnectionView(@NotNull final MainControl mainControl) { setLayout(new BorderLayout()); add(new JScrollPane(connectionList)); + mainControl.addMainControlListener(this); } /** {@inheritDoc} */ @@ -90,12 +93,12 @@ /** {@inheritDoc} */ public void mapCreated(@NotNull final MapControl mapControl) { - // ignore: a current map changed event will be generated + mapControl.getMapModel().addMapModelListener(this); } /** {@inheritDoc} */ public void mapClosing(@NotNull final MapControl mapControl) { - // ignore: a current map changed event will be generated + mapControl.getMapModel().removeMapModelListener(this); } /** @@ -123,4 +126,4 @@ connectionList.setListData(connections.keySet().toArray()); } -} // class ConnectionPanel +} // class ConnectionView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-24 11:53:24
|
Revision: 1265 http://svn.sourceforge.net/gridarta/?rev=1265&view=rev Author: akirschbaum Date: 2006-12-24 03:53:19 -0800 (Sun, 24 Dec 2006) Log Message: ----------- Add getMapGrid() to common MapControl interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/map/MapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-24 10:41:35 UTC (rev 1264) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-24 11:53:19 UTC (rev 1265) @@ -305,6 +305,7 @@ return mapViewFrame.getBasicView().getMapCursor(); } + /** {@inheritDoc} */ @NotNull public MapGrid getMapGrid() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapGrid(); Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-24 10:41:35 UTC (rev 1264) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-24 11:53:19 UTC (rev 1265) @@ -389,6 +389,7 @@ return mapViewFrame.getBasicView().getMapCursor(); } + /** {@inheritDoc} */ @NotNull public MapGrid getMapGrid() { assert mapViewFrame != null; return mapViewFrame.getBasicView().getMapGrid(); Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-24 10:41:35 UTC (rev 1264) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2006-12-24 11:53:19 UTC (rev 1265) @@ -3,6 +3,7 @@ import java.awt.Point; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapGrid; import org.jetbrains.annotations.NotNull; /** @@ -39,4 +40,10 @@ */ @NotNull MapCursor getMapCursor(); + /** + * Return the map grid of this map. + * @return the map grid of this map + */ + @NotNull MapGrid getMapGrid(); + } // interface MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |