You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2011-10-15 21:41:33
|
Revision: 9035 http://gridarta.svn.sourceforge.net/gridarta/?rev=9035&view=rev Author: akirschbaum Date: 2011-10-15 21:41:26 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Move DefaultMapViewBasic.mapCursorTracker to DefaultMapView. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 21:38:31 UTC (rev 9034) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 21:41:26 UTC (rev 9035) @@ -102,6 +102,12 @@ private final ErroneousMapSquares<G, A, R> erroneousMapSquares; /** + * The erroneous {@link MapSquare MapSquares}. + */ + @NotNull + private final MapCursorTracker<G, A, R> mapCursorTracker; + + /** * The {@link MapModelListener} used to detect changes in the map model that * should be reflected in the window title. */ @@ -201,6 +207,7 @@ this.renderer = renderer; final MapModel<G, A, R> mapModel = mapControl.getMapModel(); erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); + mapCursorTracker = new MapCursorTracker<G, A, R>(mapCursor, renderer); mapModel.addMapModelListener(mapModelListener); mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); mapControl.addMapControlListener(mapControlListener); @@ -217,6 +224,7 @@ public void closeNotify() { internalFrame.getContentPane().remove(mapViewBasic.getScrollPane()); mapViewBasic.closeNotify(); + mapCursorTracker.closeNotify(); erroneousMapSquares.closeNotify(); renderer.closeNotify(); mapControl.removeMapControlListener(mapControlListener); Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:38:31 UTC (rev 9034) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:41:26 UTC (rev 9035) @@ -19,16 +19,14 @@ package net.sf.gridarta.gui.map.mapview; +import java.awt.Component; import java.awt.Point; import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.ScrollPaneConstants; -import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapcursor.MapCursor; -import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,12 +39,6 @@ public class DefaultMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapViewBasic<G, A, R> { /** - * The erroneous {@link MapSquare MapSquares}. - */ - @NotNull - private final MapCursorTracker<G, A, R> mapCursorTracker; - - /** * The {@link JScrollPane} for this instance. */ @NotNull @@ -59,12 +51,9 @@ * corner * @param xScrollDistance the x distance when scrolling * @param yScrollDistance the y distance when scrolling - * @param mapCursor the map cursor for this instance * @param renderer the map renderer for rendering the map model */ - public DefaultMapViewBasic(final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final MapCursor mapCursor, @NotNull final AbstractMapRenderer<G, A, R> renderer) { - mapCursorTracker = new MapCursorTracker<G, A, R>(mapCursor, renderer); - + public DefaultMapViewBasic(final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final Component renderer) { scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); if (isPickmap) { scrollPane.setBackground(CommonConstants.BG_COLOR); @@ -87,7 +76,6 @@ @Override public void closeNotify() { scrollPane.setViewportView(null); - mapCursorTracker.closeNotify(); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 21:38:31 UTC (rev 9034) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 21:41:26 UTC (rev 9035) @@ -92,7 +92,7 @@ final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); final AbstractMapRenderer<G, A, R> renderer = mapControl.isPickmap() ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); renderer.setFocusable(true); - final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, new MapCursor(mapGrid), renderer), pathManager, mapGrid, new MapCursor(mapGrid), renderer); + final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, renderer), pathManager, mapGrid, new MapCursor(mapGrid), renderer); mapView.getInternalFrame().setJMenuBar(ACTION_BUILDER.createMenuBar(false, "mapwindow")); return mapView; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 21:38:37
|
Revision: 9034 http://gridarta.svn.sourceforge.net/gridarta/?rev=9034&view=rev Author: akirschbaum Date: 2011-10-15 21:38:31 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Move DefaultMapViewBasic.erroneousMapSquares to DefaultMapView. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 21:34:32 UTC (rev 9033) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 21:38:31 UTC (rev 9034) @@ -96,6 +96,12 @@ private final AbstractMapRenderer<G, A, R> renderer; /** + * The erroneous {@link MapSquare MapSquares}. + */ + @NotNull + private final ErroneousMapSquares<G, A, R> erroneousMapSquares; + + /** * The {@link MapModelListener} used to detect changes in the map model that * should be reflected in the window title. */ @@ -194,6 +200,7 @@ this.pathManager = pathManager; this.renderer = renderer; final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); mapModel.addMapModelListener(mapModelListener); mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); mapControl.addMapControlListener(mapControlListener); @@ -210,6 +217,7 @@ public void closeNotify() { internalFrame.getContentPane().remove(mapViewBasic.getScrollPane()); mapViewBasic.closeNotify(); + erroneousMapSquares.closeNotify(); renderer.closeNotify(); mapControl.removeMapControlListener(mapControlListener); final MapModel<G, A, R> mapModel = mapControl.getMapModel(); Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:34:32 UTC (rev 9033) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:38:31 UTC (rev 9034) @@ -28,8 +28,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcursor.MapCursor; -import net.sf.gridarta.model.mapgrid.MapGrid; -import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; @@ -46,12 +44,6 @@ * The erroneous {@link MapSquare MapSquares}. */ @NotNull - private final ErroneousMapSquares<G, A, R> erroneousMapSquares; - - /** - * The erroneous {@link MapSquare MapSquares}. - */ - @NotNull private final MapCursorTracker<G, A, R> mapCursorTracker; /** @@ -62,18 +54,15 @@ /** * Creates a new instance. - * @param mapModel the map model to use * @param isPickmap whether the map model belongs to a pickmap * @param initial the initial view position to show; null=show top left * corner * @param xScrollDistance the x distance when scrolling * @param yScrollDistance the y distance when scrolling - * @param mapGrid the map grid for this instance * @param mapCursor the map cursor for this instance * @param renderer the map renderer for rendering the map model */ - public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor, @NotNull final AbstractMapRenderer<G, A, R> renderer) { - erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); + public DefaultMapViewBasic(final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final MapCursor mapCursor, @NotNull final AbstractMapRenderer<G, A, R> renderer) { mapCursorTracker = new MapCursorTracker<G, A, R>(mapCursor, renderer); scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -99,7 +88,6 @@ public void closeNotify() { scrollPane.setViewportView(null); mapCursorTracker.closeNotify(); - erroneousMapSquares.closeNotify(); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 21:34:32 UTC (rev 9033) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 21:38:31 UTC (rev 9034) @@ -92,7 +92,7 @@ final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); final AbstractMapRenderer<G, A, R> renderer = mapControl.isPickmap() ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); renderer.setFocusable(true); - final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapModel, mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, mapGrid, new MapCursor(mapGrid), renderer), pathManager, mapGrid, new MapCursor(mapGrid), renderer); + final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, new MapCursor(mapGrid), renderer), pathManager, mapGrid, new MapCursor(mapGrid), renderer); mapView.getInternalFrame().setJMenuBar(ACTION_BUILDER.createMenuBar(false, "mapwindow")); return mapView; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 21:34:39
|
Revision: 9033 http://gridarta.svn.sourceforge.net/gridarta/?rev=9033&view=rev Author: akirschbaum Date: 2011-10-15 21:34:32 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Move MapViewBasic.getRenderer() to MapView. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViews.java trunk/src/app/net/sf/gridarta/gui/mapuserlistener/MapUserListenerManager.java trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -26,6 +26,8 @@ import java.util.Set; import javax.swing.JInternalFrame; import javax.swing.WindowConstants; +import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; +import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.gui.utils.MenuUtils; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -88,6 +90,12 @@ private final PathManager pathManager; /** + * The {@link AbstractMapRenderer} for rendering the map model. + */ + @NotNull + private final AbstractMapRenderer<G, A, R> renderer; + + /** * The {@link MapModelListener} used to detect changes in the map model that * should be reflected in the window title. */ @@ -175,14 +183,16 @@ * @param pathManager the path manager for converting path names * @param mapGrid the map grid for this map view * @param mapCursor the map cursor for this map view + * @param renderer the map renderer for rendering the map model */ - public DefaultMapView(@NotNull final MapControl<G, A, R> mapControl, final int number, @NotNull final MapViewBasic<G, A, R> mapViewBasic, @NotNull final PathManager pathManager, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { + public DefaultMapView(@NotNull final MapControl<G, A, R> mapControl, final int number, @NotNull final MapViewBasic<G, A, R> mapViewBasic, @NotNull final PathManager pathManager, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor, final AbstractMapRenderer<G, A, R> renderer) { super(mapControl.getMapModel(), mapGrid, mapCursor); internalFrame = new JInternalFrame(getWindowTitle(mapControl, number, pathManager), true, true, true, true); this.mapControl = mapControl; this.number = number; this.mapViewBasic = mapViewBasic; this.pathManager = pathManager; + this.renderer = renderer; final MapModel<G, A, R> mapModel = mapControl.getMapModel(); mapModel.addMapModelListener(mapModelListener); mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); @@ -200,6 +210,7 @@ public void closeNotify() { internalFrame.getContentPane().remove(mapViewBasic.getScrollPane()); mapViewBasic.closeNotify(); + renderer.closeNotify(); mapControl.removeMapControlListener(mapControlListener); final MapModel<G, A, R> mapModel = mapControl.getMapModel(); mapModel.getMapArchObject().removeMapArchObjectListener(mapArchObjectListener); @@ -288,4 +299,13 @@ return internalFrame; } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapRenderer getRenderer() { + return renderer; + } + } // class MapView Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -24,8 +24,6 @@ import javax.swing.JViewport; import javax.swing.ScrollPaneConstants; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; -import net.sf.gridarta.gui.map.renderer.MapRenderer; -import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -57,12 +55,6 @@ private final MapCursorTracker<G, A, R> mapCursorTracker; /** - * The {@link AbstractMapRenderer} for rendering the map model. - */ - @NotNull - private final AbstractMapRenderer<G, A, R> renderer; - - /** * The {@link JScrollPane} for this instance. */ @NotNull @@ -76,14 +68,11 @@ * corner * @param xScrollDistance the x distance when scrolling * @param yScrollDistance the y distance when scrolling - * @param rendererFactory the renderer factory to use * @param mapGrid the map grid for this instance * @param mapCursor the map cursor for this instance + * @param renderer the map renderer for rendering the map model */ - public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { - renderer = isPickmap ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); - renderer.setFocusable(true); - + public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor, @NotNull final AbstractMapRenderer<G, A, R> renderer) { erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); mapCursorTracker = new MapCursorTracker<G, A, R>(mapCursor, renderer); @@ -111,7 +100,6 @@ scrollPane.setViewportView(null); mapCursorTracker.closeNotify(); erroneousMapSquares.closeNotify(); - renderer.closeNotify(); } /** @@ -119,15 +107,6 @@ */ @NotNull @Override - public MapRenderer getRenderer() { - return renderer; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override public JScrollPane getScrollPane() { return scrollPane; } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -20,6 +20,7 @@ package net.sf.gridarta.gui.map.mapview; import java.awt.Point; +import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -89,7 +90,9 @@ public MapView<G, A, R> newMapView(@NotNull final MapControl<G, A, R> mapControl, @Nullable final Point viewPosition, final int viewCounter) { final MapModel<G,A,R> mapModel = mapControl.getMapModel(); final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); - final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapModel, mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, rendererFactory, mapGrid, new MapCursor(mapGrid)), pathManager, mapGrid, new MapCursor(mapGrid)); + final AbstractMapRenderer<G, A, R> renderer = mapControl.isPickmap() ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); + renderer.setFocusable(true); + final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapModel, mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, mapGrid, new MapCursor(mapGrid), renderer), pathManager, mapGrid, new MapCursor(mapGrid), renderer); mapView.getInternalFrame().setJMenuBar(ACTION_BUILDER.createMenuBar(false, "mapwindow")); return mapView; } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -22,6 +22,7 @@ import java.awt.Component; import java.util.List; import javax.swing.JInternalFrame; +import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -124,4 +125,11 @@ @NotNull MapCursor getMapCursor(); + /** + * Returns the {@link MapRenderer} for this view. + * @return the map renderer + */ + @NotNull + MapRenderer getRenderer(); + } // interface MapView Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -20,7 +20,6 @@ package net.sf.gridarta.gui.map.mapview; import javax.swing.JScrollPane; -import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -40,13 +39,6 @@ void closeNotify(); /** - * Returns the {@link MapRenderer} for this view. - * @return the map renderer - */ - @NotNull - MapRenderer getRenderer(); - - /** * Returns the {@link JScrollPane} of this map view basic. * @return the scroll pane */ Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViews.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViews.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViews.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -115,7 +115,7 @@ listener.mapViewCreated(mapView); } if (viewPosition == null && centerSquare != null) { - final Rectangle squareBounds = mapView.getMapViewBasic().getRenderer().getSquareBounds(centerSquare); + final Rectangle squareBounds = mapView.getRenderer().getSquareBounds(centerSquare); final JScrollPane scrollPane = mapView.getMapViewBasic().getScrollPane(); final Dimension extentSize = scrollPane.getViewport().getExtentSize(); final Point centerPoint = new Point(Math.max(0, squareBounds.x + squareBounds.width / 2 - extentSize.width / 2), Math.max(0, squareBounds.y + squareBounds.height / 2 - extentSize.height / 2)); @@ -187,7 +187,7 @@ */ public void repaintAllViews() { for (final MapView<G, A, R> mapView : mapViews) { - mapView.getMapViewBasic().getRenderer().forceRepaint(); + mapView.getRenderer().forceRepaint(); } } Modified: trunk/src/app/net/sf/gridarta/gui/mapuserlistener/MapUserListenerManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapuserlistener/MapUserListenerManager.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/app/net/sf/gridarta/gui/mapuserlistener/MapUserListenerManager.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -99,7 +99,7 @@ /** {@inheritDoc} */ @Override public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { - final MapUserListener<G, A, R> mapUserListener = new MapUserListener<G, A, R>(mapView.getMapViewBasic().getRenderer(), toolPalette, mapView); + final MapUserListener<G, A, R> mapUserListener = new MapUserListener<G, A, R>(mapView.getRenderer(), toolPalette, mapView); mapUserListeners.put(mapView, mapUserListener); } Modified: trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -396,14 +396,14 @@ private void setCurrentMapView(@Nullable final MapView<G, A, R> mapView) { if (this.mapView != null) { this.mapView.getMapCursor().removeMapCursorListener(mapCursorListener); - this.mapView.getMapViewBasic().getRenderer().removeMouseMotionListener(mouseMotionListener); + this.mapView.getRenderer().removeMouseMotionListener(mouseMotionListener); } this.mapView = mapView; if (this.mapView != null) { this.mapView.getMapCursor().addMapCursorListener(mapCursorListener); - this.mapView.getMapViewBasic().getRenderer().addMouseMotionListener(mouseMotionListener); + this.mapView.getRenderer().addMouseMotionListener(mouseMotionListener); } mapCursorChanged(mapView == null ? null : mapView.getMapCursor()); Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.List; import javax.swing.JInternalFrame; +import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; @@ -140,4 +141,13 @@ throw new AssertionError(); } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapRenderer getRenderer() { + throw new AssertionError(); + } + } // class TestMapView Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 21:22:37 UTC (rev 9032) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 21:34:32 UTC (rev 9033) @@ -20,7 +20,6 @@ package net.sf.gridarta.gui.map.mapview; import javax.swing.JScrollPane; -import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; @@ -44,15 +43,6 @@ */ @NotNull @Override - public MapRenderer getRenderer() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override public JScrollPane getScrollPane() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 21:22:45
|
Revision: 9032 http://gridarta.svn.sourceforge.net/gridarta/?rev=9032&view=rev Author: akirschbaum Date: 2011-10-15 21:22:37 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Reorder code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:14:38 UTC (rev 9031) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:22:37 UTC (rev 9032) @@ -81,6 +81,12 @@ * @param mapCursor the map cursor for this instance */ public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { + renderer = isPickmap ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); + renderer.setFocusable(true); + + erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); + mapCursorTracker = new MapCursorTracker<G, A, R>(mapCursor, renderer); + scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); if (isPickmap) { scrollPane.setBackground(CommonConstants.BG_COLOR); @@ -89,18 +95,11 @@ // set the pixel increment scrolling for clicking once on a scroll bar arrow scrollPane.getVerticalScrollBar().setUnitIncrement(yScrollDistance); scrollPane.getHorizontalScrollBar().setUnitIncrement(xScrollDistance); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - - renderer = isPickmap ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); scrollPane.setViewportView(renderer); if (initial != null) { scrollPane.getViewport().setViewPosition(initial); } - - erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); - mapCursorTracker = new MapCursorTracker<G, A, R>(mapCursor, renderer); - renderer.setFocusable(true); scrollPane.setFocusable(true); } @@ -109,10 +108,10 @@ */ @Override public void closeNotify() { - renderer.closeNotify(); - mapCursorTracker.closeNotify(); scrollPane.setViewportView(null); + mapCursorTracker.closeNotify(); erroneousMapSquares.closeNotify(); + renderer.closeNotify(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 21:14:45
|
Revision: 9031 http://gridarta.svn.sourceforge.net/gridarta/?rev=9031&view=rev Author: akirschbaum Date: 2011-10-15 21:14:38 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Fix ClassCastException when opening maps. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/mapdesktop/MapDesktop.java Modified: trunk/src/app/net/sf/gridarta/gui/mapdesktop/MapDesktop.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapdesktop/MapDesktop.java 2011-10-15 21:04:55 UTC (rev 9030) +++ trunk/src/app/net/sf/gridarta/gui/mapdesktop/MapDesktop.java 2011-10-15 21:14:38 UTC (rev 9031) @@ -119,6 +119,13 @@ private final Map<MapView<G, A, R>, WindowAction<G, A, R>> windowActions = new IdentityHashMap<MapView<G, A, R>, WindowAction<G, A, R>>(); /** + * The {@link MapViewFrameListener MapViewFrameListeners} associated with + * {@link MapView MapViews}. Maps map view to listener. + */ + @NotNull + private final Map<MapView<G, A, R>, MapViewFrameListener> mapViewFrameListeners = new IdentityHashMap<MapView<G, A, R>, MapViewFrameListener>(); + + /** * The {@link MapManagerListener} attached to {@link #mapManager}. */ @NotNull @@ -172,65 +179,6 @@ }; /** - * The listener attached to map views. - */ - @NotNull - private final InternalFrameListener internalFrameListener = new InternalFrameListener() { - - /** {@inheritDoc} */ - @Override - public void internalFrameActivated(@NotNull final InternalFrameEvent e) { - //InternalFrameEvent does not use type parameters - @SuppressWarnings("unchecked") - final MapView<G, A, R> mapView = (MapView<G, A, R>) e.getSource(); - mapViewFocusGainedNotify(mapView); - } - - /** {@inheritDoc} */ - @Override - public void internalFrameClosed(@NotNull final InternalFrameEvent e) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void internalFrameClosing(@NotNull final InternalFrameEvent e) { - //InternalFrameEvent does not use type parameters - @SuppressWarnings("unchecked") - final MapView<G, A, R> mapView = (MapView<G, A, R>) e.getInternalFrame(); - mapViewsManager.closeMapView(mapView); - } - - /** {@inheritDoc} */ - @Override - public void internalFrameDeactivated(@NotNull final InternalFrameEvent e) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void internalFrameDeiconified(@NotNull final InternalFrameEvent e) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void internalFrameIconified(@NotNull final InternalFrameEvent e) { - //InternalFrameEvent does not use type parameters - @SuppressWarnings("unchecked") - final MapView<G, A, R> mapView = (MapView<G, A, R>) e.getSource(); - mapViewFocusLostNotify(mapView); - } - - /** {@inheritDoc} */ - @Override - public void internalFrameOpened(@NotNull final InternalFrameEvent e) { - // ignore - } - - }; - - /** * The {@link MapImageCacheListener} registered to {@link #mapImageCache}. */ @NotNull @@ -293,7 +241,7 @@ */ private void removeMapView(@NotNull final MapView<G, A, R> mapView) { final JInternalFrame internalFrame = mapView.getInternalFrame(); - internalFrame.removeInternalFrameListener(internalFrameListener); + internalFrame.removeInternalFrameListener(mapViewFrameListeners.remove(mapView)); mapViewManager.removeMapView(mapView); if (windowActions.remove(mapView) == null) { assert false; @@ -322,7 +270,11 @@ updateFrameIcon(mapView); final JInternalFrame internalFrame = mapView.getInternalFrame(); - internalFrame.addInternalFrameListener(internalFrameListener); + final MapViewFrameListener mapViewFrameListener = new MapViewFrameListener(mapView); + if (mapViewFrameListeners.put(mapView, mapViewFrameListener) != null) { + assert false; + } + internalFrame.addInternalFrameListener(mapViewFrameListener); add(internalFrame); mapViewManager.addMapView(mapView); setCurrentMapView(mapView); @@ -480,4 +432,84 @@ return true; } + /** + * The listener attached to map views. + */ + private class MapViewFrameListener implements InternalFrameListener { + + /** + * The associated {@link MapView}. + */ + @NotNull + private final MapView<G, A, R> mapView; + + /** + * Creates a new instance. + * @param mapView the associated map view + */ + private MapViewFrameListener(@NotNull final MapView<G, A, R> mapView) { + this.mapView = mapView; + } + + /** + * {@inheritDoc} + */ + @Override + public void internalFrameActivated(@NotNull final InternalFrameEvent e) { + mapViewFocusGainedNotify(mapView); + } + + /** + * {@inheritDoc} + */ + @Override + public void internalFrameClosed(@NotNull final InternalFrameEvent e) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void internalFrameClosing(@NotNull final InternalFrameEvent e) { + mapViewsManager.closeMapView(mapView); + } + + /** + * {@inheritDoc} + */ + @Override + public void internalFrameDeactivated(@NotNull final InternalFrameEvent e) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void internalFrameDeiconified(@NotNull final InternalFrameEvent e) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + public void internalFrameIconified(@NotNull final InternalFrameEvent e) { + //InternalFrameEvent does not use type parameters + @SuppressWarnings("unchecked") + final MapView<G, A, R> mapView = (MapView<G, A, R>) e.getSource(); + mapViewFocusLostNotify(mapView); + } + + /** + * {@inheritDoc} + */ + @Override + public void internalFrameOpened(@NotNull final InternalFrameEvent e) { + // ignore + } + + } + } // class MapDesktop This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 21:05:01
|
Revision: 9030 http://gridarta.svn.sourceforge.net/gridarta/?rev=9030&view=rev Author: akirschbaum Date: 2011-10-15 21:04:55 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Make sure the map cursor is always visible. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2011-10-15 21:02:25 UTC (rev 9029) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2011-10-15 21:04:55 UTC (rev 9030) @@ -20,7 +20,6 @@ package net.sf.gridarta.gui.map.mapview; import java.awt.Point; -import java.awt.Rectangle; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -59,12 +58,7 @@ /** {@inheritDoc} */ @Override public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - final MapCursor mapCursor = e.getSource(); - final Point cursorLocation = mapCursor.getLocation(); - if (cursorLocation != null) { - final Rectangle rectangle = renderer.getSquareBounds(cursorLocation); - renderer.scrollRectToVisible(rectangle); - } + ensureVisibleMapCursor(); } /** {@inheritDoc} */ @@ -84,6 +78,7 @@ this.mapCursor = mapCursor; this.renderer = renderer; this.mapCursor.addMapCursorListener(mapCursorListener); + ensureVisibleMapCursor(); } /** @@ -94,4 +89,14 @@ mapCursor.removeMapCursorListener(mapCursorListener); } + /** + * Makes sure the {@link #mapCursor} is visible. + */ + private void ensureVisibleMapCursor() { + final Point cursorLocation = mapCursor.getLocation(); + if (cursorLocation != null) { + renderer.scrollRectToVisible(renderer.getSquareBounds(cursorLocation)); + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 21:02:32
|
Revision: 9029 http://gridarta.svn.sourceforge.net/gridarta/?rev=9029&view=rev Author: akirschbaum Date: 2011-10-15 21:02:25 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Extract MapCursorTracker from DefaultMapViewBasic. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:52:10 UTC (rev 9028) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:02:25 UTC (rev 9029) @@ -20,7 +20,6 @@ package net.sf.gridarta.gui.map.mapview; import java.awt.Point; -import java.awt.Rectangle; import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.ScrollPaneConstants; @@ -31,8 +30,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcursor.MapCursor; -import net.sf.gridarta.model.mapcursor.MapCursorEvent; -import net.sf.gridarta.model.mapcursor.MapCursorListener; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; @@ -48,16 +45,16 @@ public class DefaultMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapViewBasic<G, A, R> { /** - * The {@link MapCursor} of this view. + * The erroneous {@link MapSquare MapSquares}. */ @NotNull - private final MapCursor mapCursor; + private final ErroneousMapSquares<G, A, R> erroneousMapSquares; /** * The erroneous {@link MapSquare MapSquares}. */ @NotNull - private final ErroneousMapSquares<G, A, R> erroneousMapSquares; + private final MapCursorTracker<G, A, R> mapCursorTracker; /** * The {@link AbstractMapRenderer} for rendering the map model. @@ -72,31 +69,6 @@ private final JScrollPane scrollPane; /** - * The {@link MapCursorListener} attached to {@link #mapCursor}. - */ - @NotNull - private final MapCursorListener mapCursorListener = new MapCursorListener() { - - /** {@inheritDoc} */ - @Override - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - final MapCursor mapCursor = e.getSource(); - final Point cursorLocation = mapCursor.getLocation(); - if (cursorLocation != null) { - final Rectangle rectangle = renderer.getSquareBounds(cursorLocation); - renderer.scrollRectToVisible(rectangle); - } - } - - /** {@inheritDoc} */ - @Override - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - // Ignore mode change events - } - - }; - - /** * Creates a new instance. * @param mapModel the map model to use * @param isPickmap whether the map model belongs to a pickmap @@ -109,7 +81,6 @@ * @param mapCursor the map cursor for this instance */ public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { - this.mapCursor = mapCursor; scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); if (isPickmap) { scrollPane.setBackground(CommonConstants.BG_COLOR); @@ -120,7 +91,6 @@ scrollPane.getHorizontalScrollBar().setUnitIncrement(xScrollDistance); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - mapCursor.addMapCursorListener(mapCursorListener); renderer = isPickmap ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); scrollPane.setViewportView(renderer); @@ -129,6 +99,7 @@ } erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); + mapCursorTracker = new MapCursorTracker<G, A, R>(mapCursor, renderer); renderer.setFocusable(true); scrollPane.setFocusable(true); } @@ -139,7 +110,7 @@ @Override public void closeNotify() { renderer.closeNotify(); - mapCursor.removeMapCursorListener(mapCursorListener); + mapCursorTracker.closeNotify(); scrollPane.setViewportView(null); erroneousMapSquares.closeNotify(); } Added: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2011-10-15 21:02:25 UTC (rev 9029) @@ -0,0 +1,97 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map.mapview; + +import java.awt.Point; +import java.awt.Rectangle; +import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapcursor.MapCursorEvent; +import net.sf.gridarta.model.mapcursor.MapCursorListener; +import org.jetbrains.annotations.NotNull; + +/** + * Tracks the {@link MapCursor} of map and scrolls the {@link + * AbstractMapRenderer} so that the map cursor remains visible. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class MapCursorTracker<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The {@link MapCursor} to track. + */ + @NotNull + private final MapCursor mapCursor; + + /** + * The {@link AbstractMapRenderer} to update. + */ + @NotNull + private final AbstractMapRenderer<G, A, R> renderer; + + /** + * The {@link MapCursorListener} attached to {@link #mapCursor}. + */ + @NotNull + private final MapCursorListener mapCursorListener = new MapCursorListener() { + + /** {@inheritDoc} */ + @Override + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + final MapCursor mapCursor = e.getSource(); + final Point cursorLocation = mapCursor.getLocation(); + if (cursorLocation != null) { + final Rectangle rectangle = renderer.getSquareBounds(cursorLocation); + renderer.scrollRectToVisible(rectangle); + } + } + + /** {@inheritDoc} */ + @Override + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // Ignore mode change events + } + + }; + + /** + * Creates a new instance. + * @param mapCursor the map cursor to track + * @param renderer the map renderer to update + */ + public MapCursorTracker(@NotNull final MapCursor mapCursor, @NotNull final AbstractMapRenderer<G, A, R> renderer) { + this.mapCursor = mapCursor; + this.renderer = renderer; + this.mapCursor.addMapCursorListener(mapCursorListener); + } + + /** + * Must be called when this instance is not used anymore. It un-registers + * all listeners. + */ + public void closeNotify() { + mapCursor.removeMapCursorListener(mapCursorListener); + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 20:52:17
|
Revision: 9028 http://gridarta.svn.sourceforge.net/gridarta/?rev=9028&view=rev Author: akirschbaum Date: 2011-10-15 20:52:10 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Extract ErroneousMapSquares from DefaultMapViewBasic. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/mapview/ErroneousMapSquares.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:24:20 UTC (rev 9027) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:52:10 UTC (rev 9028) @@ -21,10 +21,6 @@ import java.awt.Point; import java.awt.Rectangle; -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; import javax.swing.JScrollPane; import javax.swing.JViewport; import javax.swing.ScrollPaneConstants; @@ -32,7 +28,6 @@ import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcursor.MapCursor; @@ -40,12 +35,8 @@ import net.sf.gridarta.model.mapcursor.MapCursorListener; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapmodel.MapModelListener; import net.sf.gridarta.model.mapmodel.MapSquare; -import net.sf.gridarta.model.validation.ErrorCollector; -import net.sf.gridarta.model.validation.errors.ValidationError; import net.sf.gridarta.utils.CommonConstants; -import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,34 +45,22 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public class DefaultMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapViewBasic<G,A,R> { +public class DefaultMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapViewBasic<G, A, R> { /** - * The {@link MapGrid} of this view. - */ - @NotNull - private final MapGrid mapGrid; - - /** * The {@link MapCursor} of this view. */ @NotNull private final MapCursor mapCursor; /** - * The {@link MapModel} to display. - */ - @NotNull - private final MapModel<G, A, R> mapModel; - - /** * The erroneous {@link MapSquare MapSquares}. */ @NotNull - private final Map<MapSquare<G, A, R>, ValidationError<G, A, R>> erroneousMapSquares = new HashMap<MapSquare<G, A, R>, ValidationError<G, A, R>>(); + private final ErroneousMapSquares<G, A, R> erroneousMapSquares; /** - * The {@link AbstractMapRenderer} for rendering {@link #mapModel}. + * The {@link AbstractMapRenderer} for rendering the map model. */ @NotNull private final AbstractMapRenderer<G, A, R> renderer; @@ -118,50 +97,6 @@ }; /** - * The {@link MapModelListener} attached to {@link #mapModel}. - */ - @NotNull - private final MapModelListener<G, A, R> mapModelListener = new MapModelListener<G, A, R>() { - - /** {@inheritDoc} */ - @Override - public void mapSizeChanged(@NotNull final Size2D newSize) { - mapGrid.resize(newSize); - } - - /** {@inheritDoc} */ - @Override - public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { - DefaultMapViewBasic.this.errorsChanged(errors); - } - - /** {@inheritDoc} */ - @Override - public void mapFileChanged(@Nullable final File oldMapFile) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void modifiedChanged() { - // ignore - } - - }; - - /** * Creates a new instance. * @param mapModel the map model to use * @param isPickmap whether the map model belongs to a pickmap @@ -174,9 +109,7 @@ * @param mapCursor the map cursor for this instance */ public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { - this.mapGrid = mapGrid; this.mapCursor = mapCursor; - this.mapModel = mapModel; scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); if (isPickmap) { scrollPane.setBackground(CommonConstants.BG_COLOR); @@ -195,9 +128,7 @@ scrollPane.getViewport().setViewPosition(initial); } - mapModel.addMapModelListener(mapModelListener); - - renderer.setErroneousMapSquares(erroneousMapSquares); + erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); renderer.setFocusable(true); scrollPane.setFocusable(true); } @@ -210,7 +141,7 @@ renderer.closeNotify(); mapCursor.removeMapCursorListener(mapCursorListener); scrollPane.setViewportView(null); - mapModel.removeMapModelListener(mapModelListener); + erroneousMapSquares.closeNotify(); } /** @@ -231,28 +162,4 @@ return scrollPane; } - /** - * Updates the erroneous map squares. - * @param errors the errors to display - */ - private void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { - erroneousMapSquares.clear(); - mapGrid.beginTransaction(); - try { - mapGrid.clearErrors(); - for (final ValidationError<G, A, R> validationError : errors.getErrors()) { - for (final MapSquare<G, A, R> mapSquare : validationError.getMapSquares()) { - erroneousMapSquares.put(mapSquare, validationError); - mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); - } - for (final G gameObject : validationError.getGameObjects()) { - final BaseObject<G, A, R, ?> topContainer = gameObject.getTopContainer(); - mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); - } - } - } finally { - mapGrid.endTransaction(); - } - } - } // class DefaultMapViewBasic Added: trunk/src/app/net/sf/gridarta/gui/map/mapview/ErroneousMapSquares.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/ErroneousMapSquares.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/ErroneousMapSquares.java 2011-10-15 20:52:10 UTC (rev 9028) @@ -0,0 +1,164 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map.mapview; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapgrid.MapGrid; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapModelListener; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.model.validation.ErrorCollector; +import net.sf.gridarta.model.validation.errors.ValidationError; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Tracks a {@link MapModel} for changed erroneous map squares and updates a + * {@link MapGrid} and an {@link AbstractMapRenderer} accordingly. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class ErroneousMapSquares<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The {@link MapModel} to track. + */ + @NotNull + private final MapModel<G, A, R> mapModel; + + /** + * The {@link MapGrid} to mark. + */ + @NotNull + private final MapGrid mapGrid; + + /** + * The {@link AbstractMapRenderer} to notify. + */ + @NotNull + private final AbstractMapRenderer<G, A, R> renderer; + + /** + * The erroneous {@link MapSquare MapSquares}. + */ + @NotNull + private final Map<MapSquare<G, A, R>, ValidationError<G, A, R>> erroneousMapSquares = new HashMap<MapSquare<G, A, R>, ValidationError<G, A, R>>(); + + /** + * The {@link MapModelListener} attached to {@link #mapModel}. + */ + @NotNull + private final MapModelListener<G, A, R> mapModelListener = new MapModelListener<G, A, R>() { + + /** {@inheritDoc} */ + @Override + public void mapSizeChanged(@NotNull final Size2D newSize) { + mapGrid.resize(newSize); + } + + /** {@inheritDoc} */ + @Override + public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { + ErroneousMapSquares.this.errorsChanged(errors); + } + + /** {@inheritDoc} */ + @Override + public void mapFileChanged(@Nullable final File oldMapFile) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void modifiedChanged() { + // ignore + } + + }; + + /** + * Creates a new instance. + * @param mapModel the map model to track + * @param mapGrid the map grid to mark + * @param renderer the renderer to notify + */ + public ErroneousMapSquares(@NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid, @NotNull final AbstractMapRenderer<G, A, R> renderer) { + this.mapModel = mapModel; + this.mapGrid = mapGrid; + this.renderer = renderer; + this.renderer.setErroneousMapSquares(erroneousMapSquares); + this.mapModel.addMapModelListener(mapModelListener); + } + + /** + * Must be called when this instance is not used anymore. It un-registers + * all listeners. + */ + public void closeNotify() { + mapModel.removeMapModelListener(mapModelListener); + } + + /** + * Updates the erroneous map squares. + * @param errors the errors to display + */ + public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { + erroneousMapSquares.clear(); + mapGrid.beginTransaction(); + try { + mapGrid.clearErrors(); + for (final ValidationError<G, A, R> validationError : errors.getErrors()) { + for (final MapSquare<G, A, R> mapSquare : validationError.getMapSquares()) { + erroneousMapSquares.put(mapSquare, validationError); + mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); + } + for (final G gameObject : validationError.getGameObjects()) { + final BaseObject<G, A, R, ?> topContainer = gameObject.getTopContainer(); + mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); + } + } + } finally { + mapGrid.endTransaction(); + } + renderer.setErroneousMapSquares(erroneousMapSquares); + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/map/mapview/ErroneousMapSquares.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 20:24:28
|
Revision: 9027 http://gridarta.svn.sourceforge.net/gridarta/?rev=9027&view=rev Author: akirschbaum Date: 2011-10-15 20:24:20 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Move MapViewBasic.getMapGrid() and getMapCursor() to MapView. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFile.java trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java trunk/src/app/net/sf/gridarta/gui/panel/connectionview/Control.java trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserView.java trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java Modified: trunk/src/app/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -163,7 +163,7 @@ gbcField.gridwidth = GridBagConstraints.REMAINDER; coordinatesPanel.setBorder(new CompoundBorder(new TitledBorder(new EtchedBorder()), GUIConstants.DIALOG_BORDER)); - final Point point = mapView.getMapViewBasic().getMapCursor().getLocation(); + final Point point = mapView.getMapCursor().getLocation(); coordinatesPanel.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "goLocationX"), gbcLabel); xCoordinateField.setText(point == null ? "0" : Integer.toString(point.x)); @@ -222,7 +222,7 @@ return false; } - mapView.getMapViewBasic().getMapCursor().setLocation(point); + mapView.getMapCursor().setLocation(point); return true; } Modified: trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -615,7 +615,7 @@ final boolean deleteOnly = replaceWithBox.getSelectedIndex() == REPLACE_WITH_NOTHING; final boolean entireMap = replaceEntireBox.getSelectedIndex() == REPLACE_ON_MAP; - if (!entireMap && mapView.getMapViewBasic().getMapGrid().getSelectedRec() == null) { + if (!entireMap && mapView.getMapGrid().getSelectedRec() == null) { // user selected "replace highlighted" but nothing is highlighted ACTION_BUILDER.showMessageDialog(this, "replaceMapNoSelection", mapView.getMapControl().getMapModel().getMapArchObject().getMapName()); return false; Modified: trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -23,7 +23,6 @@ import javax.swing.Action; import net.sf.gridarta.actions.ExitConnectorActions; import net.sf.gridarta.gui.map.mapview.MapView; -import net.sf.gridarta.gui.map.mapview.MapViewBasic; import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; import net.sf.gridarta.model.archetype.Archetype; @@ -207,11 +206,11 @@ */ private void setCurrentMapView(@Nullable final MapView<G, A, R> currentMapView) { if (this.currentMapView != null) { - this.currentMapView.getMapViewBasic().getMapCursor().removeMapCursorListener(mapCursorListener); + this.currentMapView.getMapCursor().removeMapCursorListener(mapCursorListener); } this.currentMapView = currentMapView; if (this.currentMapView != null) { - this.currentMapView.getMapViewBasic().getMapCursor().addMapCursorListener(mapCursorListener); + this.currentMapView.getMapCursor().addMapCursorListener(mapCursorListener); } refreshActions(); } @@ -237,8 +236,7 @@ return false; } - final MapViewBasic<G, A, R> mapViewBasic = mapView.getMapViewBasic(); - final MapCursor mapCursor = mapViewBasic.getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); if (!mapCursor.isActive()) { // no active cursor ==> no location to remember return false; @@ -260,7 +258,7 @@ return false; } - final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); if (!mapCursor.isActive()) { return false; } @@ -280,7 +278,7 @@ return false; } - final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); if (!mapCursor.isActive()) { return false; } Modified: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -93,7 +93,7 @@ public MouseOpEvent(@NotNull final MapView<G, A, R> mapView) { super(""); this.mapView = mapView; - mapCursor = mapView.getMapViewBasic().getMapCursor(); + mapCursor = mapView.getMapCursor(); mapControl = mapView.getMapControl(); } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -179,7 +179,7 @@ return; } - mapView.getMapViewBasic().getMapCursor().setLocation(point2); + mapView.getMapCursor().setLocation(point2); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -312,13 +312,13 @@ @Override public void activeMapViewChanged(@Nullable final MapView<G, A, R> mapView) { if (currentMapView != null) { - currentMapView.getMapViewBasic().getMapCursor().removeMapCursorListener(mapCursorListener); + currentMapView.getMapCursor().removeMapCursorListener(mapCursorListener); assert currentMapView != null; currentMapView.getMapControl().getMapModel().getMapArchObject().removeMapArchObjectListener(mapArchObjectListener); } currentMapView = mapView; if (currentMapView != null) { - currentMapView.getMapViewBasic().getMapCursor().addMapCursorListener(mapCursorListener); + currentMapView.getMapCursor().addMapCursorListener(mapCursorListener); assert currentMapView != null; currentMapView.getMapControl().getMapModel().getMapArchObject().addMapArchObjectListener(mapArchObjectListener); } @@ -410,7 +410,7 @@ mapViewManager.addMapViewManagerListener(mapViewManagerListener); currentMapView = mapViewManager.getActiveMapView(); if (currentMapView != null) { - currentMapView.getMapViewBasic().getMapCursor().addMapCursorListener(mapCursorListener); + currentMapView.getMapCursor().addMapCursorListener(mapCursorListener); assert currentMapView != null; currentMapView.getMapControl().getMapModel().getMapArchObject().addMapArchObjectListener(mapArchObjectListener); } @@ -576,7 +576,7 @@ * @param direction the direction to search */ private void selectExit(@NotNull final MapView<G, A, R> mapView, final int xStart, final int yStart, final int direction) { - final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int width = mapSize.getWidth(); @@ -848,7 +848,7 @@ final GameObject<G, A, R> exit; final GameObject<G, A, R> selectedExit = exitMatcher.getValidExit(selectedSquareModel.getSelectedGameObject()); if (selectedExit == null) { - final GameObject<G, A, R> cursorExit = exitMatcher.getValidExit(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getMapCursor().getLocation()); + final GameObject<G, A, R> cursorExit = exitMatcher.getValidExit(mapView.getMapControl().getMapModel(), mapView.getMapCursor().getLocation()); if (cursorExit == null) { return false; } @@ -879,7 +879,7 @@ } if (performAction) { - final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); final Point cursorLocation = mapCursor.getLocation(); if (cursorLocation == null) { selectExit(mapView, -1, 0, 1); @@ -903,7 +903,7 @@ } if (performAction) { - final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); final Point cursorLocation = mapCursor.getLocation(); if (cursorLocation == null) { final Size2D mapSize = mapView.getMapControl().getMapModel().getMapArchObject().getMapSize(); Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -26,6 +26,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; @@ -52,13 +53,21 @@ private final MapGrid mapGrid; /** + * The {@link MapCursor} of this map view. + */ + @NotNull + private final MapCursor mapCursor; + + /** * Creates a new instance. * @param mapModel the map model of this map view * @param mapGrid the map grid of this map view + * @param mapCursor the map cursor of this map view */ - protected AbstractMapView(@NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid) { + protected AbstractMapView(@NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { this.mapModel = mapModel; this.mapGrid = mapGrid; + this.mapCursor = mapCursor; } /** @@ -112,4 +121,22 @@ return objects.get(RandomUtils.rnd.nextInt(objects.size())); } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapGrid getMapGrid() { + return mapGrid; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapCursor getMapCursor() { + return mapCursor; + } + } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -35,6 +35,8 @@ import net.sf.gridarta.model.mapcontrol.DefaultMapControl; import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapcontrol.MapControlListener; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapModelListener; import net.sf.gridarta.model.mapmodel.MapSquare; @@ -171,9 +173,11 @@ * @param number each view of a map will get a number * @param mapViewBasic the underlying map view object * @param pathManager the path manager for converting path names + * @param mapGrid the map grid for this map view + * @param mapCursor the map cursor for this map view */ - public DefaultMapView(@NotNull final MapControl<G, A, R> mapControl, final int number, @NotNull final MapViewBasic<G, A, R> mapViewBasic, @NotNull final PathManager pathManager) { - super(mapControl.getMapModel(), mapViewBasic.getMapGrid()); + public DefaultMapView(@NotNull final MapControl<G, A, R> mapControl, final int number, @NotNull final MapViewBasic<G, A, R> mapViewBasic, @NotNull final PathManager pathManager, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { + super(mapControl.getMapModel(), mapGrid, mapCursor); internalFrame = new JInternalFrame(getWindowTitle(mapControl, number, pathManager), true, true, true, true); this.mapControl = mapControl; this.number = number; Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -126,7 +126,7 @@ /** {@inheritDoc} */ @Override public void mapSizeChanged(@NotNull final Size2D newSize) { - getMapGrid().resize(newSize); + mapGrid.resize(newSize); } /** {@inheritDoc} */ @@ -255,22 +255,4 @@ } } - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapGrid getMapGrid() { - return mapGrid; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapCursor getMapCursor() { - return mapCursor; - } - } // class DefaultMapViewBasic Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -89,7 +89,7 @@ public MapView<G, A, R> newMapView(@NotNull final MapControl<G, A, R> mapControl, @Nullable final Point viewPosition, final int viewCounter) { final MapModel<G,A,R> mapModel = mapControl.getMapModel(); final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); - final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapModel, mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, rendererFactory, mapGrid, new MapCursor(mapGrid)), pathManager); + final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapModel, mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, rendererFactory, mapGrid, new MapCursor(mapGrid)), pathManager, mapGrid, new MapCursor(mapGrid)); mapView.getInternalFrame().setJMenuBar(ACTION_BUILDER.createMenuBar(false, "mapwindow")); return mapView; } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -26,6 +26,8 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapSquare; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -108,4 +110,18 @@ @NotNull List<MapSquare<G, A, R>> getSelectedSquares(); + /** + * Returns the {@link MapGrid} of this view. + * @return the map grid of this view + */ + @NotNull + MapGrid getMapGrid(); + + /** + * Returns the {@link MapCursor} of this view. + * @return the map cursor of this view + */ + @NotNull + MapCursor getMapCursor(); + } // interface MapView Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -24,8 +24,6 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapcursor.MapCursor; -import net.sf.gridarta.model.mapgrid.MapGrid; import org.jetbrains.annotations.NotNull; /** @@ -36,20 +34,6 @@ public interface MapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { /** - * Returns the {@link MapGrid} of this view. - * @return the map grid of this view - */ - @NotNull - MapGrid getMapGrid(); - - /** - * Returns the {@link MapCursor} of this view. - * @return the map cursor of this view - */ - @NotNull - MapCursor getMapCursor(); - - /** * Must be called when this renderer is not used anymore. It un-registers * all listeners. */ Modified: trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -171,13 +171,13 @@ /** {@inheritDoc} */ @Override public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { - mapView.getMapViewBasic().getMapCursor().addMapCursorListener(mapCursorListener); + mapView.getMapCursor().addMapCursorListener(mapCursorListener); } /** {@inheritDoc} */ @Override public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) { - mapView.getMapViewBasic().getMapCursor().removeMapCursorListener(mapCursorListener); + mapView.getMapCursor().removeMapCursorListener(mapCursorListener); } }; @@ -409,7 +409,7 @@ */ @Nullable private MapCursor getActiveMapCursor(@NotNull final MapView<G, A, R> mapView) { - final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); return mapCursor.isActive() ? mapCursor : null; } Modified: trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFile.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFile.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFile.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -160,13 +160,26 @@ * file has not been loaded */ @Nullable - public MapViewBasic<G, A, R> getView() { + public MapViewBasic<G, A, R> getMapViewBasic() { synchronized (sync) { return pickmapView == null ? null : pickmapView.getMapViewBasic(); } } /** + * Returns the {@link MapView} instance for this pickmap. Returns + * <code>null</code> unless {@link #loadPickmap()} was successfully called. + * @return the <code>MapView</code> instance, or <code>null if the map file + * has not been loaded + */ + @Nullable + public MapView<G, A, R> getMapView() { + synchronized (sync) { + return pickmapView; + } + } + + /** * Loads the pickmap from the underlying map file. * @throws IOException if the map file cannot be loaded */ Modified: trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -111,7 +111,7 @@ * @return whether shifting is possible */ public boolean canShift(@NotNull final Direction dir) { - mapGrid = mapView.getMapViewBasic().getMapGrid(); + mapGrid = mapView.getMapGrid(); selRec = mapGrid.getSelectedRec(); if (selRec == null) { return false; Modified: trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -395,18 +395,18 @@ private void setCurrentMapView(@Nullable final MapView<G, A, R> mapView) { if (this.mapView != null) { - this.mapView.getMapViewBasic().getMapCursor().removeMapCursorListener(mapCursorListener); + this.mapView.getMapCursor().removeMapCursorListener(mapCursorListener); this.mapView.getMapViewBasic().getRenderer().removeMouseMotionListener(mouseMotionListener); } this.mapView = mapView; if (this.mapView != null) { - this.mapView.getMapViewBasic().getMapCursor().addMapCursorListener(mapCursorListener); + this.mapView.getMapCursor().addMapCursorListener(mapCursorListener); this.mapView.getMapViewBasic().getRenderer().addMouseMotionListener(mouseMotionListener); } - mapCursorChanged(mapView == null ? null : mapView.getMapViewBasic().getMapCursor()); + mapCursorChanged(mapView == null ? null : mapView.getMapCursor()); mouse.setText(""); } Modified: trunk/src/app/net/sf/gridarta/gui/panel/connectionview/Control.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/connectionview/Control.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/panel/connectionview/Control.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -105,7 +105,7 @@ return; } - final MapGrid mapGrid = mapView.getMapViewBasic().getMapGrid(); + final MapGrid mapGrid = mapView.getMapGrid(); mapGrid.unSelect(); final Point point = new Point(); Modified: trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -381,7 +381,7 @@ final MapView<G, A, R> mapView = mapViewsManager.getMapViewFrame(mapControl); if (mapView != null) { final ErrorCollector<G, A, R> errorCollector = mapControl.getMapModel().getErrors(); - setErrors(mapView.getMapViewBasic().getMapCursor(), errorCollector); + setErrors(mapView.getMapCursor(), errorCollector); return; } } Modified: trunk/src/app/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -30,7 +30,7 @@ import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import net.sf.gridarta.gui.map.mapview.MapViewBasic; +import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.mapfiles.MapFile; import net.sf.gridarta.gui.panel.objectchoicedisplay.ObjectChoiceDisplay; import net.sf.gridarta.gui.panel.pickmapchooser.PickmapChooserModel; @@ -109,10 +109,10 @@ private MapFile<G, A, R> activeMapFile = null; /** - * The map view of {@link #activeMapFile}. + * The {@link MapView} of {@link #activeMapFile}. */ @Nullable - private MapViewBasic<G, A, R> activePickmapView = null; + private MapView<G, A, R> activePickmapView = null; /** * The last reported selection. @@ -389,7 +389,7 @@ * Updates the display state after {@link #activeMapFile} has changed. */ private void updateActivePickmap() { - activePickmapView = activeMapFile != null ? activeMapFile.getView() : null; + activePickmapView = activeMapFile != null ? activeMapFile.getMapView() : null; updatePickmapInfo(activePickmapView == null ? null : activePickmapView.getMapCursor()); } Modified: trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserControl.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserControl.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -294,7 +294,7 @@ final MapFile<G, A, R> mapFile = getSelectedPickmap(); final MapControl<G, A, R> mapControl = mapFile == null ? null : mapFile.getPickmap(); if (mapControl != null) { - mapViewsManager.getMapViewFrame(mapControl).getMapViewBasic().getMapCursor().deactivate(); + mapViewsManager.getMapViewFrame(mapControl).getMapCursor().deactivate(); } pickmapChooserModel.fireActivePickmapChanged(mapFile); } Modified: trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserView.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserView.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -211,7 +211,7 @@ } final int index = pickmapChooserModel.addMapFile(mapFile); - final MapViewBasic<G, A, R> mapViewBasic = mapFile.getView(); + final MapViewBasic<G, A, R> mapViewBasic = mapFile.getMapViewBasic(); pickmapPanel.insertTab(getTitle(mapFile), null, mapViewBasic == null ? null : mapViewBasic.getScrollPane(), null, index); } @@ -237,7 +237,7 @@ return; } pickmapPanel.setTitleAt(index, getTitle(mapFile)); - final MapViewBasic<G, A, R> mapViewBasic = mapFile.getView(); + final MapViewBasic<G, A, R> mapViewBasic = mapFile.getMapViewBasic(); pickmapPanel.setComponentAt(index, mapViewBasic == null ? null : mapViewBasic.getScrollPane()); } Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -274,13 +274,13 @@ /** {@inheritDoc} */ @Override public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { - mapView.getMapViewBasic().getMapCursor().addMapCursorListener(mapCursorListener); + mapView.getMapCursor().addMapCursorListener(mapCursorListener); } /** {@inheritDoc} */ @Override public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) { - mapView.getMapViewBasic().getMapCursor().removeMapCursorListener(mapCursorListener); + mapView.getMapCursor().removeMapCursorListener(mapCursorListener); final MapSquareSelection<G, A, R> closedMapSquare = mapSquareSelectionCache.find(mapView); if (selectedSquareModel.getSelectedMapSquare() == closedMapSquare) { Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -33,7 +33,6 @@ import net.sf.gridarta.gui.copybuffer.CopyBuffer; import net.sf.gridarta.gui.dialog.replace.ReplaceDialogManager; import net.sf.gridarta.gui.map.mapview.MapView; -import net.sf.gridarta.gui.map.mapview.MapViewBasic; import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; import net.sf.gridarta.gui.misc.ShiftProcessor; @@ -534,15 +533,15 @@ /** {@inheritDoc} */ @Override public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { - mapView.getMapViewBasic().getMapGrid().addMapGridListener(mapGridListener); - mapView.getMapViewBasic().getMapCursor().addMapCursorListener(mapCursorListener); + mapView.getMapGrid().addMapGridListener(mapGridListener); + mapView.getMapCursor().addMapCursorListener(mapCursorListener); } /** {@inheritDoc} */ @Override public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) { - mapView.getMapViewBasic().getMapCursor().removeMapCursorListener(mapCursorListener); - mapView.getMapViewBasic().getMapGrid().removeMapGridListener(mapGridListener); + mapView.getMapCursor().removeMapCursorListener(mapCursorListener); + mapView.getMapGrid().removeMapGridListener(mapGridListener); } }; @@ -937,7 +936,7 @@ */ @Nullable private MapView<G, A, R> getSelection() { - return currentMapView != null && currentMapView.getMapViewBasic().getMapGrid().getSelectedRec() != null ? currentMapView : null; + return currentMapView != null && currentMapView.getMapGrid().getSelectedRec() != null ? currentMapView : null; } /** @@ -969,7 +968,7 @@ return false; } - final Rectangle selectedRec = mapView.getMapViewBasic().getMapGrid().getSelectedRec(); + final Rectangle selectedRec = mapView.getMapGrid().getSelectedRec(); if (selectedRec == null) { return false; } @@ -992,7 +991,7 @@ return false; } - final Rectangle selectedRec = mapView.getMapViewBasic().getMapGrid().getSelectedRec(); + final Rectangle selectedRec = mapView.getMapGrid().getSelectedRec(); if (selectedRec == null) { return false; } @@ -1015,7 +1014,7 @@ return false; } - final Rectangle selectedRec = mapView.getMapViewBasic().getMapGrid().getSelectedRec(); + final Rectangle selectedRec = mapView.getMapGrid().getSelectedRec(); if (selectedRec == null) { return false; } @@ -1038,7 +1037,7 @@ return false; } - final Point startLocation = mapView.getMapViewBasic().getMapCursor().getLocation(); + final Point startLocation = mapView.getMapCursor().getLocation(); if (startLocation == null) { return false; } @@ -1065,7 +1064,7 @@ return false; } - final Point startLocation = mapView.getMapViewBasic().getMapCursor().getLocation(); + final Point startLocation = mapView.getMapCursor().getLocation(); if (startLocation == null) { return false; } @@ -1079,14 +1078,14 @@ return false; } - final MapGrid mapGrid = mapView.getMapViewBasic().getMapGrid(); + final MapGrid mapGrid = mapView.getMapGrid(); final Rectangle selectedRec = mapGrid.getSelectedRec(); if (selectedRec == null) { return false; } if (performAction) { - final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); final Point cursorLocation = mapCursor.getLocation(); final Point origin = cursorLocation == null ? selectedRec.getLocation() : cursorLocation; copyBuffer.pasteTiled(mapView, selectedSquares, origin); @@ -1243,8 +1242,7 @@ return false; } - final MapViewBasic<G, A, R> mapViewBasic = mapView.getMapViewBasic(); - final MapCursor mapCursor = mapViewBasic.getMapCursor(); + final MapCursor mapCursor = mapView.getMapCursor(); final Point mapCursorLocation = mapCursor.getLocation(); if (mapCursorLocation == null) { return false; @@ -1268,7 +1266,7 @@ } if (performAction) { - currentMapView.getMapViewBasic().getMapGrid().selectAll(); + currentMapView.getMapGrid().selectAll(); } return true; @@ -1285,7 +1283,7 @@ } if (performAction) { - currentMapView.getMapViewBasic().getMapGrid().invertSelection(); + currentMapView.getMapGrid().invertSelection(); } return true; @@ -1315,7 +1313,7 @@ } if (performAction) { - final MapGrid mapGrid = mapView.getMapViewBasic().getMapGrid(); + final MapGrid mapGrid = mapView.getMapGrid(); final Map<MapSquare<G, A, R>, Void> newSelection = new IdentityHashMap<MapSquare<G, A, R>, Void>(); Map<MapSquare<G, A, R>, Void> todo = new IdentityHashMap<MapSquare<G, A, R>, Void>(); for (final MapSquare<G, A, R> mapSquare : selectedSquares) { @@ -1379,7 +1377,7 @@ } if (performAction) { - final MapGrid mapGrid = mapView.getMapViewBasic().getMapGrid(); + final MapGrid mapGrid = mapView.getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); @@ -1421,7 +1419,7 @@ } if (performAction) { - final MapGrid mapGrid = mapView.getMapViewBasic().getMapGrid(); + final MapGrid mapGrid = mapView.getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); Modified: trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -77,7 +77,7 @@ // select + cut final CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> copyBuffer = TestMapControlCreatorUtils.newCopyBuffer(testMapControlCreator); final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = TestMapControlCreatorUtils.newMapView(mapControl); - mapView.getMapViewBasic().getMapGrid().select(new Point(1, 1), new Point(1, 1), SelectionMode.ADD); + mapView.getMapGrid().select(new Point(1, 1), new Point(1, 1), SelectionMode.ADD); copyBuffer.cut(mapView, new Rectangle(1, 1, 1, 1)); TestMapModelHelper.checkMapContents(mapModel, "||", "||", "||"); Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -27,6 +27,8 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapgrid.MapGrid; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,9 +54,11 @@ * Creates a new instance. * @param mapControl the controller of this view * @param mapViewBasic the underlying map view object + * @param mapGrid the map grid for this map view + * @param mapCursor the map cursor for this map view */ - public TestMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @NotNull final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic) { - super(mapControl.getMapModel(), mapViewBasic.getMapGrid()); + public TestMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @NotNull final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { + super(mapControl.getMapModel(), mapGrid, mapCursor); this.mapControl = mapControl; this.mapViewBasic = mapViewBasic; } Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -24,8 +24,6 @@ import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.mapcursor.MapCursor; -import net.sf.gridarta.model.mapgrid.MapGrid; import org.jetbrains.annotations.NotNull; /** @@ -35,28 +33,6 @@ public class TestMapViewBasic implements MapViewBasic<TestGameObject,TestMapArchObject,TestArchetype> { /** - * The {@link MapGrid} of this view. - */ - @NotNull - private final MapGrid mapGrid; - - /** - * The {@link MapCursor} of this view. - */ - @NotNull - private final MapCursor mapCursor; - - /** - * Creates a new instance. - * @param mapGrid the map grid for this instance - * @param mapCursor the map cursor for this instance - */ - public TestMapViewBasic(@NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { - this.mapGrid = mapGrid; - this.mapCursor = mapCursor; - } - - /** * {@inheritDoc} */ @Override @@ -81,22 +57,4 @@ throw new AssertionError(); } - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapGrid getMapGrid() { - return mapGrid; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapCursor getMapCursor() { - return mapCursor; - } - } // class TestMapViewBasic Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -44,8 +44,8 @@ public MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @Nullable final Point viewPosition, final int viewCounter) { final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapGrid, new MapCursor(mapGrid)); - return new TestMapView(mapControl, mapViewBasic); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(); + return new TestMapView(mapControl, mapViewBasic, mapGrid, new MapCursor(mapGrid)); } } // class TestMapViewFactory Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 20:09:08 UTC (rev 9026) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 20:24:20 UTC (rev 9027) @@ -66,8 +66,8 @@ public static MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl) { final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapGrid, new MapCursor(mapGrid)); - return new TestMapView(mapControl, mapViewBasic); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(); + return new TestMapView(mapControl, mapViewBasic, mapGrid, new MapCursor(mapGrid)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 20:09:14
|
Revision: 9026 http://gridarta.svn.sourceforge.net/gridarta/?rev=9026&view=rev Author: akirschbaum Date: 2011-10-15 20:09:08 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Remove AbstractMapViewBasic. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java Deleted: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 20:05:20 UTC (rev 9025) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 20:09:08 UTC (rev 9026) @@ -1,74 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2011 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.map.mapview; - -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapcursor.MapCursor; -import net.sf.gridarta.model.mapgrid.MapGrid; -import org.jetbrains.annotations.NotNull; - -/** - * Abstract base class for {@link MapViewBasic} implementations. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @author Andreas Kirschbaum - */ -public abstract class AbstractMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapViewBasic<G, A, R> { - - /** - * The {@link MapGrid} of this view. - */ - @NotNull - private final MapGrid mapGrid; - - /** - * The {@link MapCursor} of this view. - */ - @NotNull - private final MapCursor mapCursor; - - /** - * Creates a new instance. - */ - protected AbstractMapViewBasic(@NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { - this.mapGrid = mapGrid; - this.mapCursor = mapCursor; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapGrid getMapGrid() { - return mapGrid; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public MapCursor getMapCursor() { - return mapCursor; - } - -} // class AbstractMapViewBasic Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:05:20 UTC (rev 9025) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:09:08 UTC (rev 9026) @@ -54,9 +54,21 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public class DefaultMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMapViewBasic<G, A, R> { +public class DefaultMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapViewBasic<G,A,R> { /** + * The {@link MapGrid} of this view. + */ + @NotNull + private final MapGrid mapGrid; + + /** + * The {@link MapCursor} of this view. + */ + @NotNull + private final MapCursor mapCursor; + + /** * The {@link MapModel} to display. */ @NotNull @@ -158,9 +170,12 @@ * @param xScrollDistance the x distance when scrolling * @param yScrollDistance the y distance when scrolling * @param rendererFactory the renderer factory to use + * @param mapGrid the map grid for this instance + * @param mapCursor the map cursor for this instance */ public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { - super(mapGrid, mapCursor); + this.mapGrid = mapGrid; + this.mapCursor = mapCursor; this.mapModel = mapModel; scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); if (isPickmap) { @@ -172,9 +187,9 @@ scrollPane.getHorizontalScrollBar().setUnitIncrement(xScrollDistance); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - getMapCursor().addMapCursorListener(mapCursorListener); + mapCursor.addMapCursorListener(mapCursorListener); - renderer = isPickmap ? rendererFactory.newPickmapRenderer(mapModel, getMapGrid()) : rendererFactory.newMapRenderer(mapModel, getMapGrid()); + renderer = isPickmap ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); scrollPane.setViewportView(renderer); if (initial != null) { scrollPane.getViewport().setViewPosition(initial); @@ -193,7 +208,7 @@ @Override public void closeNotify() { renderer.closeNotify(); - getMapCursor().removeMapCursorListener(mapCursorListener); + mapCursor.removeMapCursorListener(mapCursorListener); scrollPane.setViewportView(null); mapModel.removeMapModelListener(mapModelListener); } @@ -222,7 +237,6 @@ */ private void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { erroneousMapSquares.clear(); - final MapGrid mapGrid = getMapGrid(); mapGrid.beginTransaction(); try { mapGrid.clearErrors(); @@ -241,4 +255,22 @@ } } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapGrid getMapGrid() { + return mapGrid; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapCursor getMapCursor() { + return mapCursor; + } + } // class DefaultMapViewBasic Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 20:05:20 UTC (rev 9025) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 20:09:08 UTC (rev 9026) @@ -32,13 +32,28 @@ * A {@link MapViewBasic} implementation for regression tests. * @author Andreas Kirschbaum */ -public class TestMapViewBasic extends AbstractMapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> { +public class TestMapViewBasic implements MapViewBasic<TestGameObject,TestMapArchObject,TestArchetype> { /** + * The {@link MapGrid} of this view. + */ + @NotNull + private final MapGrid mapGrid; + + /** + * The {@link MapCursor} of this view. + */ + @NotNull + private final MapCursor mapCursor; + + /** * Creates a new instance. + * @param mapGrid the map grid for this instance + * @param mapCursor the map cursor for this instance */ public TestMapViewBasic(@NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { - super(mapGrid, mapCursor); + this.mapGrid = mapGrid; + this.mapCursor = mapCursor; } /** @@ -66,4 +81,22 @@ throw new AssertionError(); } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapGrid getMapGrid() { + return mapGrid; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapCursor getMapCursor() { + return mapCursor; + } + } // class TestMapViewBasic This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 20:05:27
|
Revision: 9025 http://gridarta.svn.sourceforge.net/gridarta/?rev=9025&view=rev Author: akirschbaum Date: 2011-10-15 20:05:20 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Move MapCursor creation out of AbstractMapViewBasic. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 20:02:23 UTC (rev 9024) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 20:05:20 UTC (rev 9025) @@ -48,9 +48,9 @@ /** * Creates a new instance. */ - protected AbstractMapViewBasic(@NotNull final MapGrid mapGrid) { + protected AbstractMapViewBasic(@NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { this.mapGrid = mapGrid; - mapCursor = new MapCursor(mapGrid); + this.mapCursor = mapCursor; } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:02:23 UTC (rev 9024) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:05:20 UTC (rev 9025) @@ -159,8 +159,8 @@ * @param yScrollDistance the y distance when scrolling * @param rendererFactory the renderer factory to use */ - public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid) { - super(mapGrid); + public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { + super(mapGrid, mapCursor); this.mapModel = mapModel; scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); if (isPickmap) { Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 20:02:23 UTC (rev 9024) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 20:05:20 UTC (rev 9025) @@ -26,6 +26,7 @@ import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.japi.swing.action.ActionBuilder; @@ -87,7 +88,8 @@ @Override public MapView<G, A, R> newMapView(@NotNull final MapControl<G, A, R> mapControl, @Nullable final Point viewPosition, final int viewCounter) { final MapModel<G,A,R> mapModel = mapControl.getMapModel(); - final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapModel, mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, rendererFactory, new MapGrid(mapModel.getMapArchObject().getMapSize())), pathManager); + final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); + final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapModel, mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, rendererFactory, mapGrid, new MapCursor(mapGrid)), pathManager); mapView.getInternalFrame().setJMenuBar(ACTION_BUILDER.createMenuBar(false, "mapwindow")); return mapView; } Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 20:02:23 UTC (rev 9024) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 20:05:20 UTC (rev 9025) @@ -24,6 +24,7 @@ import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import org.jetbrains.annotations.NotNull; @@ -36,8 +37,8 @@ /** * Creates a new instance. */ - public TestMapViewBasic(@NotNull final MapGrid mapGrid) { - super(mapGrid); + public TestMapViewBasic(@NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { + super(mapGrid, mapCursor); } /** Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 20:02:23 UTC (rev 9024) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 20:05:20 UTC (rev 9025) @@ -24,6 +24,7 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; @@ -42,7 +43,8 @@ @Override public MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @Nullable final Point viewPosition, final int viewCounter) { final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(new MapGrid(mapModel.getMapArchObject().getMapSize())); + final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapGrid, new MapCursor(mapGrid)); return new TestMapView(mapControl, mapViewBasic); } Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 20:02:23 UTC (rev 9024) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 20:05:20 UTC (rev 9025) @@ -39,6 +39,7 @@ import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapcontrol.TestMapControlCreator; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; @@ -64,7 +65,8 @@ @NotNull public static MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl) { final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(new MapGrid(mapModel.getMapArchObject().getMapSize())); + final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapGrid, new MapCursor(mapGrid)); return new TestMapView(mapControl, mapViewBasic); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 20:02:30
|
Revision: 9024 http://gridarta.svn.sourceforge.net/gridarta/?rev=9024&view=rev Author: akirschbaum Date: 2011-10-15 20:02:23 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 19:58:52 UTC (rev 9023) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 20:02:23 UTC (rev 9024) @@ -24,7 +24,6 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; -import net.sf.gridarta.model.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; /** @@ -48,9 +47,8 @@ /** * Creates a new instance. - * @param mapModel the map model to use */ - protected AbstractMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid) { + protected AbstractMapViewBasic(@NotNull final MapGrid mapGrid) { this.mapGrid = mapGrid; mapCursor = new MapCursor(mapGrid); } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 19:58:52 UTC (rev 9023) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 20:02:23 UTC (rev 9024) @@ -160,7 +160,7 @@ * @param rendererFactory the renderer factory to use */ public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid) { - super(mapModel, mapGrid); + super(mapGrid); this.mapModel = mapModel; scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); if (isPickmap) { Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 19:58:52 UTC (rev 9023) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 20:02:23 UTC (rev 9024) @@ -25,7 +25,6 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapgrid.MapGrid; -import net.sf.gridarta.model.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; /** @@ -36,10 +35,9 @@ /** * Creates a new instance. - * @param mapModel the map model to use */ - public TestMapViewBasic(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final MapGrid mapGrid) { - super(mapModel, mapGrid); + public TestMapViewBasic(@NotNull final MapGrid mapGrid) { + super(mapGrid); } /** Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 19:58:52 UTC (rev 9023) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 20:02:23 UTC (rev 9024) @@ -42,7 +42,7 @@ @Override public MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @Nullable final Point viewPosition, final int viewCounter) { final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapModel, new MapGrid(mapModel.getMapArchObject().getMapSize())); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(new MapGrid(mapModel.getMapArchObject().getMapSize())); return new TestMapView(mapControl, mapViewBasic); } Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 19:58:52 UTC (rev 9023) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 20:02:23 UTC (rev 9024) @@ -64,7 +64,7 @@ @NotNull public static MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl) { final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapModel, new MapGrid(mapModel.getMapArchObject().getMapSize())); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(new MapGrid(mapModel.getMapArchObject().getMapSize())); return new TestMapView(mapControl, mapViewBasic); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 19:58:59
|
Revision: 9023 http://gridarta.svn.sourceforge.net/gridarta/?rev=9023&view=rev Author: akirschbaum Date: 2011-10-15 19:58:52 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Move MapGrid creation out of AbstractMapViewBasic. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 19:50:20 UTC (rev 9022) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 19:58:52 UTC (rev 9023) @@ -50,8 +50,8 @@ * Creates a new instance. * @param mapModel the map model to use */ - protected AbstractMapViewBasic(@NotNull final MapModel<G, A, R> mapModel) { - mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); + protected AbstractMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid) { + this.mapGrid = mapGrid; mapCursor = new MapCursor(mapGrid); } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 19:50:20 UTC (rev 9022) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 19:58:52 UTC (rev 9023) @@ -159,8 +159,8 @@ * @param yScrollDistance the y distance when scrolling * @param rendererFactory the renderer factory to use */ - public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory) { - super(mapModel); + public DefaultMapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final MapGrid mapGrid) { + super(mapModel, mapGrid); this.mapModel = mapModel; scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); if (isPickmap) { Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 19:50:20 UTC (rev 9022) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 19:58:52 UTC (rev 9023) @@ -26,6 +26,8 @@ import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapgrid.MapGrid; +import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -84,7 +86,8 @@ @NotNull @Override public MapView<G, A, R> newMapView(@NotNull final MapControl<G, A, R> mapControl, @Nullable final Point viewPosition, final int viewCounter) { - final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapControl.getMapModel(), mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, rendererFactory), pathManager); + final MapModel<G,A,R> mapModel = mapControl.getMapModel(); + final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, new DefaultMapViewBasic<G, A, R>(mapModel, mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, rendererFactory, new MapGrid(mapModel.getMapArchObject().getMapSize())), pathManager); mapView.getInternalFrame().setJMenuBar(ACTION_BUILDER.createMenuBar(false, "mapwindow")); return mapView; } Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 19:50:20 UTC (rev 9022) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 19:58:52 UTC (rev 9023) @@ -24,6 +24,7 @@ import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; @@ -37,8 +38,8 @@ * Creates a new instance. * @param mapModel the map model to use */ - public TestMapViewBasic(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel) { - super(mapModel); + public TestMapViewBasic(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final MapGrid mapGrid) { + super(mapModel, mapGrid); } /** Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 19:50:20 UTC (rev 9022) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 19:58:52 UTC (rev 9023) @@ -24,6 +24,8 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapgrid.MapGrid; +import net.sf.gridarta.model.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,7 +41,8 @@ @NotNull @Override public MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @Nullable final Point viewPosition, final int viewCounter) { - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapControl.getMapModel()); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapModel, new MapGrid(mapModel.getMapArchObject().getMapSize())); return new TestMapView(mapControl, mapViewBasic); } Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 19:50:20 UTC (rev 9022) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 19:58:52 UTC (rev 9023) @@ -39,6 +39,8 @@ import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapcontrol.TestMapControlCreator; +import net.sf.gridarta.model.mapgrid.MapGrid; +import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; import org.jetbrains.annotations.NotNull; @@ -61,7 +63,8 @@ */ @NotNull public static MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl) { - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapControl.getMapModel()); + final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(mapModel, new MapGrid(mapModel.getMapArchObject().getMapSize())); return new TestMapView(mapControl, mapViewBasic); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 19:50:27
|
Revision: 9022 http://gridarta.svn.sourceforge.net/gridarta/?rev=9022&view=rev Author: akirschbaum Date: 2011-10-15 19:50:20 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Move MapViewBasic.getSelectedSquares() to MapView. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -153,7 +153,7 @@ mapModel2.beginTransaction("Cut / Clear"); // TODO: I18N/L10N try { final Collection<G> gameObjectsToDelete = new HashSet<G>(); - for (final MapSquare<G, A, R> square : mapView.getMapViewBasic().getSelectedSquares()) { + for (final MapSquare<G, A, R> square : mapView.getSelectedSquares()) { final int posX = square.getMapX() - selectedRec.x; final int posY = square.getMapY() - selectedRec.y; for (final G gameObject : square) { Modified: trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -290,7 +290,7 @@ colonLabel.setText(":"); } - if (mapView.getMapViewBasic().getSelectedSquares().size() > 1) { + if (mapView.getSelectedSquares().size() > 1) { replaceEntireBox.setSelectedIndex(REPLACE_ON_SELECTION); } else { replaceEntireBox.setSelectedIndex(REPLACE_ON_MAP); @@ -314,7 +314,7 @@ line1.add(Box.createVerticalStrut(3)); replaceEntireBox = new JComboBox(new String[] { ActionBuilderUtils.getString(ACTION_BUILDER, "replaceOnMap"), ActionBuilderUtils.getString(ACTION_BUILDER, "replaceOnSelection") }); replaceEntireBox.setToolTipText(ActionBuilderUtils.getString(ACTION_BUILDER, "replaceOn.shortdescription")); - if (mapView.getMapViewBasic().getSelectedSquares().size() > 1) { + if (mapView.getSelectedSquares().size() > 1) { replaceEntireBox.setSelectedIndex(REPLACE_ON_SELECTION); } else { replaceEntireBox.setSelectedIndex(REPLACE_ON_MAP); @@ -471,7 +471,7 @@ mapModel.beginTransaction("Replace"); // TODO: I18N/L10N try { int replaceCount = 0; - for (final MapSquare<G, A, R> square : entireMap ? mapModel : mapView.getMapViewBasic().getSelectedSquares()) { + for (final MapSquare<G, A, R> square : entireMap ? mapModel : mapView.getSelectedSquares()) { // Operate on a copy of the nodes to prevent ConcurrentModificationException // find objects to replace Added: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -0,0 +1,115 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map.mapview; + +import java.awt.Point; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapgrid.MapGrid; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.utils.RandomUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Abstract base class for {@link MapView} implementations. + * @author Andreas Kirschbaum + */ +public abstract class AbstractMapView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapView<G, A, R> { + + /** + * The {@link MapModel} of this map view. + */ + @NotNull + private final MapModel<G, A, R> mapModel; + + /** + * The {@link MapGrid} of this map view. + */ + @NotNull + private final MapGrid mapGrid; + + /** + * Creates a new instance. + * @param mapModel the map model of this map view + * @param mapGrid the map grid of this map view + */ + protected AbstractMapView(@NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid) { + this.mapModel = mapModel; + this.mapGrid = mapGrid; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public List<MapSquare<G, A, R>> getSelectedSquares() { + final Point[] selectedMapSquares = mapGrid.getSelection(); + final List<MapSquare<G, A, R>> selection = new ArrayList<MapSquare<G, A, R>>(); + for (final Point pos : selectedMapSquares) { + selection.add(mapModel.getMapSquare(pos)); + } + return selection; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public List<G> getSelectedGameObjects() { + final Collection<MapSquare<G, A, R>> selectedMapSquares = getSelectedSquares(); + if (selectedMapSquares.isEmpty()) { + return mapModel.getAllGameObjects(); + } + + final List<G> objects = new ArrayList<G>(); + for (final Iterable<G> mapSquare : selectedMapSquares) { + for (final GameObject<G, A, R> gameObject : mapSquare) { + objects.add(gameObject.getHead()); + } + } + return objects; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public G getSelectedGameObject() { + final List<G> objects = getSelectedGameObjects(); + final int objectSize = objects.size(); + if (objectSize == 0) { + return null; + } + if (objectSize == 1) { + return objects.get(0); + } + return objects.get(RandomUtils.rnd.nextInt(objects.size())); + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -19,16 +19,12 @@ package net.sf.gridarta.gui.map.mapview; -import java.awt.Point; -import java.util.ArrayList; -import java.util.List; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapmodel.MapSquare; import org.jetbrains.annotations.NotNull; /** @@ -39,12 +35,6 @@ public abstract class AbstractMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapViewBasic<G, A, R> { /** - * The {@link MapModel} to display. - */ - @NotNull - private final MapModel<G, A, R> mapModel; - - /** * The {@link MapGrid} of this view. */ @NotNull @@ -61,8 +51,7 @@ * @param mapModel the map model to use */ protected AbstractMapViewBasic(@NotNull final MapModel<G, A, R> mapModel) { - this.mapModel = mapModel; - mapGrid = new MapGrid(this.mapModel.getMapArchObject().getMapSize()); + mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); mapCursor = new MapCursor(mapGrid); } @@ -84,18 +73,4 @@ return mapCursor; } - /** - * {@inheritDoc} - */ - @NotNull - @Override - public List<MapSquare<G, A, R>> getSelectedSquares() { - final Point[] selectedMapSquares = mapGrid.getSelection(); - final List<MapSquare<G, A, R>> selection = new ArrayList<MapSquare<G, A, R>>(); - for (final Point pos : selectedMapSquares) { - selection.add(mapModel.getMapSquare(pos)); - } - return selection; - } - } // class AbstractMapViewBasic Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -23,11 +23,9 @@ import java.awt.Component; import java.beans.PropertyVetoException; import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; import java.util.Set; import javax.swing.JInternalFrame; +import javax.swing.WindowConstants; import net.sf.gridarta.gui.utils.MenuUtils; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -41,7 +39,6 @@ import net.sf.gridarta.model.mapmodel.MapModelListener; import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.model.validation.ErrorCollector; -import net.sf.gridarta.utils.RandomUtils; import net.sf.gridarta.utils.Size2D; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -52,7 +49,7 @@ * Default {@link MapView} implementation. * @author Andreas Kirschbaum */ -public class DefaultMapView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JInternalFrame implements MapView<G, A, R> { +public class DefaultMapView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMapView<G, A, R> { /** * The Logger for printing log messages. @@ -60,15 +57,16 @@ private static final Category log = Logger.getLogger(DefaultMapView.class); /** - * The serial version UID. + * The controller of this view. */ - private static final long serialVersionUID = 1L; + @NotNull + private final MapControl<G, A, R> mapControl; /** - * The controller of this view. + * The {@link JInternalFrame} instance associated with this map view. */ @NotNull - private final MapControl<G, A, R> mapControl; + private final JInternalFrame internalFrame; /** * View number. @@ -175,7 +173,8 @@ * @param pathManager the path manager for converting path names */ public DefaultMapView(@NotNull final MapControl<G, A, R> mapControl, final int number, @NotNull final MapViewBasic<G, A, R> mapViewBasic, @NotNull final PathManager pathManager) { - super(getWindowTitle(mapControl, number, pathManager), true, true, true, true); + super(mapControl.getMapModel(), mapViewBasic.getMapGrid()); + internalFrame = new JInternalFrame(getWindowTitle(mapControl, number, pathManager), true, true, true, true); this.mapControl = mapControl; this.number = number; this.mapViewBasic = mapViewBasic; @@ -184,10 +183,10 @@ mapModel.addMapModelListener(mapModelListener); mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); mapControl.addMapControlListener(mapControlListener); - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(mapViewBasic.getScrollPane(), BorderLayout.CENTER); - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - setAutoscrolls(true); + internalFrame.getContentPane().setLayout(new BorderLayout()); + internalFrame.getContentPane().add(mapViewBasic.getScrollPane(), BorderLayout.CENTER); + internalFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + internalFrame.setAutoscrolls(true); } /** @@ -195,58 +194,21 @@ */ @Override public void closeNotify() { - getContentPane().remove(mapViewBasic.getScrollPane()); + internalFrame.getContentPane().remove(mapViewBasic.getScrollPane()); mapViewBasic.closeNotify(); mapControl.removeMapControlListener(mapControlListener); final MapModel<G, A, R> mapModel = mapControl.getMapModel(); mapModel.getMapArchObject().removeMapArchObjectListener(mapArchObjectListener); mapModel.removeMapModelListener(mapModelListener); //mapFileActions.closeNotify(); - MenuUtils.disposeMenuElement(getJMenuBar()); + MenuUtils.disposeMenuElement(internalFrame.getJMenuBar()); } /** - * {@inheritDoc} - */ - @Nullable - @Override - public G getSelectedGameObject() { - final List<G> objects = getSelectedGameObjects(); - final int objectSize = objects.size(); - if (objectSize == 0) { - return null; - } - if (objectSize == 1) { - return objects.get(0); - } - return objects.get(RandomUtils.rnd.nextInt(objects.size())); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public List<G> getSelectedGameObjects() { - final Collection<MapSquare<G, A, R>> selectedMapSquares = mapViewBasic.getSelectedSquares(); - if (selectedMapSquares.isEmpty()) { - return mapControl.getMapModel().getAllGameObjects(); - } - - final List<G> objects = new ArrayList<G>(); - for (final Iterable<G> mapSquare : selectedMapSquares) { - for (final GameObject<G, A, R> gameObject : mapSquare) { - objects.add(gameObject.getHead()); - } - } - return objects; - } - - /** * Update the Map-Window Title (according to name and changeFlag). */ private void updateTitle() { - setTitle(getWindowTitle()); + internalFrame.setTitle(getWindowTitle()); } /** @@ -277,7 +239,7 @@ @NotNull @Override public Component getComponent() { - return this; + return internalFrame; } /** @@ -304,13 +266,13 @@ @Override public void activate() { try { - setSelected(true); + internalFrame.setSelected(true); } catch (final PropertyVetoException e) { log.warn("Unexpected exception", e); } - setVisible(true); - requestFocus(); - restoreSubcomponentFocus(); + internalFrame.setVisible(true); + internalFrame.requestFocus(); + internalFrame.restoreSubcomponentFocus(); } /** @@ -319,7 +281,7 @@ @NotNull @Override public JInternalFrame getInternalFrame() { - return this; + return internalFrame; } } // class MapView Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -26,6 +26,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapmodel.MapSquare; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -100,4 +101,11 @@ @NotNull JInternalFrame getInternalFrame(); + /** + * Returns the selected squares. + * @return the selected squares; the list may be modified by the caller + */ + @NotNull + List<MapSquare<G, A, R>> getSelectedSquares(); + } // interface MapView Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -19,7 +19,6 @@ package net.sf.gridarta.gui.map.mapview; -import java.util.List; import javax.swing.JScrollPane; import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.model.archetype.Archetype; @@ -27,7 +26,6 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; -import net.sf.gridarta.model.mapmodel.MapSquare; import org.jetbrains.annotations.NotNull; /** @@ -52,13 +50,6 @@ MapCursor getMapCursor(); /** - * Returns the selected squares. - * @return the selected squares; the list may be modified by the caller - */ - @NotNull - List<MapSquare<G, A, R>> getSelectedSquares(); - - /** * Must be called when this renderer is not used anymore. It un-registers * all listeners. */ Modified: trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -204,7 +204,7 @@ throw new AssertionError(); } final MapView<G, A, R> mapView = e.getMapView(); - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelectedSquares(), insertionMode, objectChooser.getSelections(), -1, false); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getSelectedSquares(), insertionMode, objectChooser.getSelections(), -1, false); } } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -1074,20 +1074,19 @@ return false; } - final MapViewBasic<G, A, R> mapViewBasic = mapView.getMapViewBasic(); - final List<MapSquare<G, A, R>> selectedSquares = mapViewBasic.getSelectedSquares(); + final List<MapSquare<G, A, R>> selectedSquares = mapView.getSelectedSquares(); if (selectedSquares.isEmpty()) { return false; } - final MapGrid mapGrid = mapViewBasic.getMapGrid(); + final MapGrid mapGrid = mapView.getMapViewBasic().getMapGrid(); final Rectangle selectedRec = mapGrid.getSelectedRec(); if (selectedRec == null) { return false; } if (performAction) { - final MapCursor mapCursor = mapViewBasic.getMapCursor(); + final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); final Point cursorLocation = mapCursor.getLocation(); final Point origin = cursorLocation == null ? selectedRec.getLocation() : cursorLocation; copyBuffer.pasteTiled(mapView, selectedSquares, origin); @@ -1304,7 +1303,7 @@ } boolean foundEmptySelectedSquare = false; - final List<MapSquare<G, A, R>> selectedSquares = mapView.getMapViewBasic().getSelectedSquares(); + final List<MapSquare<G, A, R>> selectedSquares = mapView.getSelectedSquares(); for (final MapSquare<G, A, R> selectedSquare : selectedSquares) { if (selectedSquare.isEmpty()) { foundEmptySelectedSquare = true; @@ -1374,14 +1373,13 @@ return false; } - final MapViewBasic<G, A, R> mapViewBasic = mapView.getMapViewBasic(); - final List<MapSquare<G, A, R>> selectedSquares = mapViewBasic.getSelectedSquares(); + final List<MapSquare<G, A, R>> selectedSquares = mapView.getSelectedSquares(); if (selectedSquares.isEmpty()) { return false; } if (performAction) { - final MapGrid mapGrid = mapViewBasic.getMapGrid(); + final MapGrid mapGrid = mapView.getMapViewBasic().getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); @@ -1417,14 +1415,13 @@ return false; } - final MapViewBasic<G, A, R> mapViewBasic = mapView.getMapViewBasic(); - final List<MapSquare<G, A, R>> selectedSquares = mapViewBasic.getSelectedSquares(); + final List<MapSquare<G, A, R>> selectedSquares = mapView.getSelectedSquares(); if (selectedSquares.isEmpty()) { return false; } if (performAction) { - final MapGrid mapGrid = mapViewBasic.getMapGrid(); + final MapGrid mapGrid = mapView.getMapViewBasic().getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); @@ -1553,7 +1550,7 @@ * @param insertionMode the insertion mode to use */ private void fill(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode<G, A, R> insertionMode) { - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelectedSquares(), insertionMode, objectChooser.getSelections(), -1, false); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getSelectedSquares(), insertionMode, objectChooser.getSelections(), -1, false); } /** @@ -1568,7 +1565,7 @@ final int fillDensity = randomFillDialog.getFillDensity(); final boolean noAdjacent = randomFillDialog.isRandomFillSkipAdjacentSquares(); - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelectedSquares(), insertionMode, objectChooser.getSelections(), fillDensity, noAdjacent); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getSelectedSquares(), insertionMode, objectChooser.getSelections(), fillDensity, noAdjacent); } } // class MainActions Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 19:32:30 UTC (rev 9021) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 19:50:20 UTC (rev 9022) @@ -34,7 +34,7 @@ * A {@link MapView} implementation for regression tests. * @author Andreas Kirschbaum */ -public class TestMapView implements MapView<TestGameObject, TestMapArchObject, TestArchetype> { +public class TestMapView extends AbstractMapView<TestGameObject, TestMapArchObject, TestArchetype> { /** * The controller of this view. @@ -54,6 +54,7 @@ * @param mapViewBasic the underlying map view object */ public TestMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @NotNull final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic) { + super(mapControl.getMapModel(), mapViewBasic.getMapGrid()); this.mapControl = mapControl; this.mapViewBasic = mapViewBasic; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 19:32:36
|
Revision: 9021 http://gridarta.svn.sourceforge.net/gridarta/?rev=9021&view=rev Author: akirschbaum Date: 2011-10-15 19:32:30 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Fix failing regression test. Modified Paths: -------------- trunk/utils/src/test/net/sf/gridarta/utils/TestActionBuilder.java Modified: trunk/utils/src/test/net/sf/gridarta/utils/TestActionBuilder.java =================================================================== --- trunk/utils/src/test/net/sf/gridarta/utils/TestActionBuilder.java 2011-10-15 19:24:37 UTC (rev 9020) +++ trunk/utils/src/test/net/sf/gridarta/utils/TestActionBuilder.java 2011-10-15 19:32:30 UTC (rev 9021) @@ -42,7 +42,7 @@ * The {@link Pattern} for matching validator keys for default values. */ @NotNull - private static final Pattern PATTERN_DEFAULT_KEY = Pattern.compile("Validator\\..*\\.default"); + private static final Pattern PATTERN_DEFAULT_KEY = Pattern.compile("Validator\\..*\\.default|MapValidator\\.All\\.default"); /** * Private constructor to prevent instantiation. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 19:24:44
|
Revision: 9020 http://gridarta.svn.sourceforge.net/gridarta/?rev=9020&view=rev Author: akirschbaum Date: 2011-10-15 19:24:37 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Remove some calls to MapGrid.getSelection(). Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2011-10-15 19:12:01 UTC (rev 9019) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2011-10-15 19:24:37 UTC (rev 9020) @@ -58,8 +58,8 @@ * @param noAdjacent whether squares are skipped if an adjacent squares is * not free */ - public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void fill(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point[] selection, @NotNull final InsertionMode<G, A, R> insertionMode, @NotNull final List<? extends BaseObject<G, A, R, ?>> gameObjects, final int density, final boolean noAdjacent) { - if (selection.length <= 0) { + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void fill(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Collection<MapSquare<G, A, R>> selection, @NotNull final InsertionMode<G, A, R> insertionMode, @NotNull final List<? extends BaseObject<G, A, R, ?>> gameObjects, final int density, final boolean noAdjacent) { + if (selection.isEmpty()) { return; } @@ -79,7 +79,7 @@ mapModel.beginTransaction("Fill"); // TODO; I18N/L10N try { - for (final Point p : selection) { + for (final MapSquare<G, A, R> mapSquare : selection) { if (density != -1 && density != 100 && density < RandomUtils.rnd.nextInt(100) + 1) { continue; } @@ -88,11 +88,11 @@ final Archetype<G, A, R> archetype = gameObject.getArchetype(); final int w = archetype.getSizeX(); final int h = archetype.getSizeY(); - if (containsArchetype(mapModel, archetypeNames, p, w, h)) { + if (containsArchetype(mapModel, archetypeNames, mapSquare, w, h)) { continue; } } - mapModel.insertBaseObject(gameObject, p, false, false, insertionMode); + mapModel.insertBaseObject(gameObject, new Point(mapSquare.getMapX(), mapSquare.getMapY()), false, false, insertionMode); } } finally { mapModel.endTransaction(); @@ -104,17 +104,17 @@ * archetype. * @param mapModel the map model to check * @param archetypeNames the archetype names to check for - * @param p the top left corner of the area to check + * @param topLeftMapSquare the top left corner of the area to check * @param w the width of the area to check * @param h the height of the area to check * @return whether a similar game object was found */ - private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> boolean containsArchetype(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Collection<String> archetypeNames, @NotNull final Point p, final int w, final int h) { + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> boolean containsArchetype(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Collection<String> archetypeNames, @NotNull final MapSquare<G, A, R> topLeftMapSquare, final int w, final int h) { final Point pos = new Point(); for (int dy = -1; dy < h + 1; dy++) { - pos.y = p.y + dy; + pos.y = topLeftMapSquare.getMapY() + dy; for (int dx = -1; dx < w + 1; dx++) { - pos.x = p.x + dx; + pos.x = topLeftMapSquare.getMapX() + dx; final MapSquare<G, A, R> mapSquare; try { mapSquare = mapModel.getMapSquare(pos); Modified: trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java 2011-10-15 19:12:01 UTC (rev 9019) +++ trunk/model/src/test/net/sf/gridarta/model/floodfill/FillUtilsTest.java 2011-10-15 19:24:37 UTC (rev 9020) @@ -21,6 +21,7 @@ import java.awt.Point; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetype.TestArchetype; @@ -29,6 +30,7 @@ import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapmodel.CannotInsertGameObjectException; import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; import net.sf.gridarta.model.mapmodel.TestMapModelHelper; import org.junit.Assert; @@ -41,7 +43,7 @@ public class FillUtilsTest { /** - * Checks that {@link FillUtils#fill(MapModel, Point[], + * Checks that {@link FillUtils#fill(MapModel, Collection, * net.sf.gridarta.model.mapmodel.InsertionMode, List, int, boolean)} works * correctly when skipping adjacent squares. * @throws DuplicateArchetypeException if the test fails @@ -69,7 +71,8 @@ mapModel.beginTransaction("TEST"); mapModelHelper.insertArchetype(mapModel, new Point(0, 2), head, false); - final Point[] selection = { new Point(2, 0), }; + final Collection<MapSquare<TestGameObject, TestMapArchObject, TestArchetype>> selection = new ArrayList<MapSquare<TestGameObject, TestMapArchObject, TestArchetype>>(); + selection.add(mapModel.getMapSquare(new Point(2, 0))); final List<TestGameObject> gameObjects = new ArrayList<TestGameObject>(); gameObjects.add(mapModelCreator.getGameObjectFactory().createGameObject(head)); Modified: trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java 2011-10-15 19:12:01 UTC (rev 9019) +++ trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java 2011-10-15 19:24:37 UTC (rev 9020) @@ -204,7 +204,7 @@ throw new AssertionError(); } final MapView<G, A, R> mapView = e.getMapView(); - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getMapGrid().getSelection(), insertionMode, objectChooser.getSelections(), -1, false); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelectedSquares(), insertionMode, objectChooser.getSelections(), -1, false); } } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 19:12:01 UTC (rev 9019) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 19:24:37 UTC (rev 9020) @@ -1553,7 +1553,7 @@ * @param insertionMode the insertion mode to use */ private void fill(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode<G, A, R> insertionMode) { - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getMapGrid().getSelection(), insertionMode, objectChooser.getSelections(), -1, false); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelectedSquares(), insertionMode, objectChooser.getSelections(), -1, false); } /** @@ -1568,8 +1568,7 @@ final int fillDensity = randomFillDialog.getFillDensity(); final boolean noAdjacent = randomFillDialog.isRandomFillSkipAdjacentSquares(); - final Point[] selection = mapView.getMapViewBasic().getMapGrid().getSelection(); - FillUtils.fill(mapView.getMapControl().getMapModel(), selection, insertionMode, objectChooser.getSelections(), fillDensity, noAdjacent); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelectedSquares(), insertionMode, objectChooser.getSelections(), fillDensity, noAdjacent); } } // class MainActions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 19:12:07
|
Revision: 9019 http://gridarta.svn.sourceforge.net/gridarta/?rev=9019&view=rev Author: akirschbaum Date: 2011-10-15 19:12:01 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 19:06:58 UTC (rev 9018) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 19:12:01 UTC (rev 9019) @@ -20,7 +20,6 @@ package net.sf.gridarta.gui.map.mapview; import java.awt.Point; -import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; import net.sf.gridarta.model.archetype.Archetype; @@ -91,17 +90,10 @@ @NotNull @Override public List<MapSquare<G, A, R>> getSelectedSquares() { + final Point[] selectedMapSquares = mapGrid.getSelection(); final List<MapSquare<G, A, R>> selection = new ArrayList<MapSquare<G, A, R>>(); - final Point pos = new Point(); - final Rectangle selectedRec = mapGrid.getSelectedRec(); - if (selectedRec != null) { - for (pos.x = selectedRec.x; pos.x < selectedRec.x + selectedRec.width; pos.x++) { - for (pos.y = selectedRec.y; pos.y < selectedRec.y + selectedRec.height; pos.y++) { - if ((mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0) { - selection.add(mapModel.getMapSquare(pos)); - } - } - } + for (final Point pos : selectedMapSquares) { + selection.add(mapModel.getMapSquare(pos)); } return selection; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 19:07:05
|
Revision: 9018 http://gridarta.svn.sourceforge.net/gridarta/?rev=9018&view=rev Author: akirschbaum Date: 2011-10-15 19:06:58 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Move MapViewBasic.getSelection() to MapGrid. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/mapgrid/MapGrid.java trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/model/src/app/net/sf/gridarta/model/mapgrid/MapGrid.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapgrid/MapGrid.java 2011-10-15 18:46:00 UTC (rev 9017) +++ trunk/model/src/app/net/sf/gridarta/model/mapgrid/MapGrid.java 2011-10-15 19:06:58 UTC (rev 9018) @@ -21,6 +21,8 @@ import java.awt.Point; import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -810,4 +812,25 @@ } } + /** + * Returns the selection. + * @return the selection + */ + @NotNull + public Point[] getSelection() { + final List<Point> selection = new ArrayList<Point>(); + calculateCachedSelectedRec(); + final Rectangle selectedRec = cachedSelectedRec; + if (selectedRec != null) { + for (int x = selectedRec.x; x < selectedRec.x + selectedRec.width; x++) { + for (int y = selectedRec.y; y < selectedRec.y + selectedRec.height; y++) { + if ((gridFlags[x][y] & GRID_FLAG_SELECTION) > 0) { + selection.add(new Point(x, y)); + } + } + } + } + return selection.toArray(new Point[selection.size()]); + } + } // class MapGrid Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 18:46:00 UTC (rev 9017) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapViewBasic.java 2011-10-15 19:06:58 UTC (rev 9018) @@ -90,27 +90,6 @@ */ @NotNull @Override - public Point[] getSelection() { - final List<Point> selection = new ArrayList<Point>(); - final Point pos = new Point(); - final Rectangle selectedRec = mapGrid.getSelectedRec(); - if (selectedRec != null) { - for (pos.x = selectedRec.x; pos.x < selectedRec.x + selectedRec.width; pos.x++) { - for (pos.y = selectedRec.y; pos.y < selectedRec.y + selectedRec.height; pos.y++) { - if ((mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0) { - selection.add((Point) pos.clone()); - } - } - } - } - return selection.toArray(new Point[selection.size()]); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override public List<MapSquare<G, A, R>> getSelectedSquares() { final List<MapSquare<G, A, R>> selection = new ArrayList<MapSquare<G, A, R>>(); final Point pos = new Point(); Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 18:46:00 UTC (rev 9017) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 19:06:58 UTC (rev 9018) @@ -19,7 +19,6 @@ package net.sf.gridarta.gui.map.mapview; -import java.awt.Point; import java.util.List; import javax.swing.JScrollPane; import net.sf.gridarta.gui.map.renderer.MapRenderer; @@ -53,13 +52,6 @@ MapCursor getMapCursor(); /** - * Returns the selection. - * @return the selection - */ - @NotNull - Point[] getSelection(); - - /** * Returns the selected squares. * @return the selected squares; the list may be modified by the caller */ Modified: trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java 2011-10-15 18:46:00 UTC (rev 9017) +++ trunk/src/app/net/sf/gridarta/gui/panel/tools/SelectionTool.java 2011-10-15 19:06:58 UTC (rev 9018) @@ -204,7 +204,7 @@ throw new AssertionError(); } final MapView<G, A, R> mapView = e.getMapView(); - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelection(), insertionMode, objectChooser.getSelections(), -1, false); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getMapGrid().getSelection(), insertionMode, objectChooser.getSelections(), -1, false); } } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 18:46:00 UTC (rev 9017) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 19:06:58 UTC (rev 9018) @@ -1553,7 +1553,7 @@ * @param insertionMode the insertion mode to use */ private void fill(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode<G, A, R> insertionMode) { - FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getSelection(), insertionMode, objectChooser.getSelections(), -1, false); + FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getMapViewBasic().getMapGrid().getSelection(), insertionMode, objectChooser.getSelections(), -1, false); } /** @@ -1568,7 +1568,7 @@ final int fillDensity = randomFillDialog.getFillDensity(); final boolean noAdjacent = randomFillDialog.isRandomFillSkipAdjacentSquares(); - final Point[] selection = mapView.getMapViewBasic().getSelection(); + final Point[] selection = mapView.getMapViewBasic().getMapGrid().getSelection(); FillUtils.fill(mapView.getMapControl().getMapModel(), selection, insertionMode, objectChooser.getSelections(), fillDensity, noAdjacent); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 18:46:06
|
Revision: 9017 http://gridarta.svn.sourceforge.net/gridarta/?rev=9017&view=rev Author: akirschbaum Date: 2011-10-15 18:46:00 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Do not export MapGridListener interface from MapCursor. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java Modified: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java 2011-10-15 18:44:24 UTC (rev 9016) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java 2011-10-15 18:46:00 UTC (rev 9017) @@ -39,7 +39,7 @@ * coordinates or state of MapCursor changes a {@link MapCursorEvent} is fired. * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> */ -public class MapCursor implements MapGridListener { +public class MapCursor { /** * Current cursor position. When cursor is active it is highlighted on the @@ -96,7 +96,31 @@ public MapCursor(final MapGrid mapGrid) { this.mapGrid = mapGrid; mapRec = mapGrid.getMapRec(); - mapGrid.addMapGridListener(this); + final MapGridListener mapGridListener = new MapGridListener() { + + @Override + public void mapGridChanged(@NotNull final MapGridEvent e) { + // We can ignore this event. Normally this MapCursor has caused it. + } + + @Override + public void mapGridResized(@NotNull final MapGridEvent e) { + // Test if drag start point is outside map -> move inside + if (dragging && !mapRec.contains(dragStart)) { + dragStart.x = Math.min(dragStart.x, mapRec.width - 1); + dragStart.y = Math.min(dragStart.y, mapRec.height - 1); + } + // Test if cursor position is outside map -> move inside + if (onMap && !mapRec.contains(pos)) { + pos.x = Math.min(pos.x, mapRec.width - 1); + pos.y = Math.min(pos.y, mapRec.height - 1); + mapGrid.setCursor(pos); + fireMapCursorChangedPosEvent(); + } + } + + }; + mapGrid.addMapGridListener(mapGridListener); deactivate(); } @@ -376,33 +400,6 @@ } /** - * {@inheritDoc} - */ - @Override - public void mapGridChanged(@NotNull final MapGridEvent e) { - // We can ignore this event. Normally this MapCursor has caused it. - } - - /** - * {@inheritDoc} - */ - @Override - public void mapGridResized(@NotNull final MapGridEvent e) { - // Test if drag start point is outside map -> move inside - if (dragging && !mapRec.contains(dragStart)) { - dragStart.x = Math.min(dragStart.x, mapRec.width - 1); - dragStart.y = Math.min(dragStart.y, mapRec.height - 1); - } - // Test if cursor position is outside map -> move inside - if (onMap && !mapRec.contains(pos)) { - pos.x = Math.min(pos.x, mapRec.width - 1); - pos.y = Math.min(pos.y, mapRec.height - 1); - mapGrid.setCursor(pos); - fireMapCursorChangedPosEvent(); - } - } - - /** * Start a new transaction. Transactions may be nested. Transactions serve * the purpose of firing events to the views when more changes are known to * come before the view is really required to update. Each invocation of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 18:44:30
|
Revision: 9016 http://gridarta.svn.sourceforge.net/gridarta/?rev=9016&view=rev Author: akirschbaum Date: 2011-10-15 18:44:24 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Disable warning. Modified Paths: -------------- trunk/gridarta.ipr Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2011-10-15 18:42:56 UTC (rev 9015) +++ trunk/gridarta.ipr 2011-10-15 18:44:24 UTC (rev 9016) @@ -510,10 +510,6 @@ <option name="m_minLength" value="1" /> <option name="m_maxLength" value="64" /> </inspection_tool> - <inspection_tool class="InstanceVariableUninitializedUse" enabled="true" level="WARNING" enabled_by_default="true"> - <option name="m_ignorePrimitives" value="false" /> - <option name="annotationNamesString" value="" /> - </inspection_tool> <inspection_tool class="InstanceofCatchParameter" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="InstanceofChain" enabled="true" level="WARNING" enabled_by_default="true"> <option name="ignoreInstanceofOnLibraryClasses" value="false" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 18:43:03
|
Revision: 9015 http://gridarta.svn.sourceforge.net/gridarta/?rev=9015&view=rev Author: akirschbaum Date: 2011-10-15 18:42:56 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Add assert statement. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 18:42:06 UTC (rev 9014) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 18:42:56 UTC (rev 9015) @@ -1503,6 +1503,7 @@ }; collector = new Collector(collectArches, resources, globalSettings.getCollectedDirectory()); + assert collector != null; collector.start(); aCollectArches.setEnabled(doCollectArches(false)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 18:42:13
|
Revision: 9014 http://gridarta.svn.sourceforge.net/gridarta/?rev=9014&view=rev Author: akirschbaum Date: 2011-10-15 18:42:06 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java Modified: trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2011-10-15 18:41:46 UTC (rev 9013) +++ trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2011-10-15 18:42:06 UTC (rev 9014) @@ -245,12 +245,8 @@ } final Point location = mapCursor.getLocation(); - if (location == null) { - // no active cursor ==> no location to remember - return false; - } - - return exitConnectorActions.doExitCopy(performAction, mapView.getMapControl(), location); + // no active cursor ==> no location to remember + return location != null && exitConnectorActions.doExitCopy(performAction, mapView.getMapControl(), location); } /** @@ -270,11 +266,7 @@ } final Point targetLocation = mapCursor.getLocation(); - if (targetLocation == null) { - return false; - } - - return exitConnectorActions.doExitPaste(performAction, mapView.getMapControl(), targetLocation); + return targetLocation != null && exitConnectorActions.doExitPaste(performAction, mapView.getMapControl(), targetLocation); } /** @@ -294,11 +286,7 @@ } final Point targetLocation = mapCursor.getLocation(); - if (targetLocation == null) { - return false; - } - - return exitConnectorActions.doExitConnect(performAction, mapView.getMapControl(), targetLocation); + return targetLocation != null && exitConnectorActions.doExitConnect(performAction, mapView.getMapControl(), targetLocation); } } // class ExitConnectorController Modified: trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java 2011-10-15 18:41:46 UTC (rev 9013) +++ trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java 2011-10-15 18:42:06 UTC (rev 9014) @@ -356,22 +356,23 @@ final String formatCursor; if (mapCursor == null) { formatCursor = ""; - } else if (mapCursor.isActive()) { + } else { final Point pos = mapCursor.getLocation(); - assert pos != null; - final int cursorX = pos.x; - final int cursorY = pos.y; - if (mapCursor.isDragging()) { - final Dimension offset = mapCursor.getDragOffset(); - assert offset != null; - final int offsetX = Math.abs(offset.width) + 1; - final int offsetY = Math.abs(offset.height) + 1; - formatCursor = ACTION_BUILDER.format("statusCursorDragging", cursorX, cursorY, offsetX, offsetY); + if (pos == null) { + formatCursor = ACTION_BUILDER.format("statusCursorInactive"); } else { - formatCursor = ACTION_BUILDER.format("statusCursorActive", cursorX, cursorY); + final int cursorX = pos.x; + final int cursorY = pos.y; + if (mapCursor.isDragging()) { + final Dimension offset = mapCursor.getDragOffset(); + assert offset != null; + final int offsetX = Math.abs(offset.width) + 1; + final int offsetY = Math.abs(offset.height) + 1; + formatCursor = ACTION_BUILDER.format("statusCursorDragging", cursorX, cursorY, offsetX, offsetY); + } else { + formatCursor = ACTION_BUILDER.format("statusCursorActive", cursorX, cursorY); + } } - } else { - formatCursor = ACTION_BUILDER.format("statusCursorInactive"); } cursor.setText(formatCursor); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 18:41:52
|
Revision: 9013 http://gridarta.svn.sourceforge.net/gridarta/?rev=9013&view=rev Author: akirschbaum Date: 2011-10-15 18:41:46 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Do not return internal state from MapCursor.getLocation(). Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java Modified: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java 2011-10-15 17:55:20 UTC (rev 9012) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java 2011-10-15 18:41:46 UTC (rev 9013) @@ -107,7 +107,7 @@ */ @Nullable public Point getLocation() { - return onMap ? pos : null; + return onMap ? new Point(pos) : null; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 17:55:27
|
Revision: 9012 http://gridarta.svn.sourceforge.net/gridarta/?rev=9012&view=rev Author: akirschbaum Date: 2011-10-15 17:55:20 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java Modified: trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-15 17:29:09 UTC (rev 9011) +++ trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-15 17:55:20 UTC (rev 9012) @@ -300,7 +300,6 @@ dialog.pack(); dialog.toFront(); - dialog.setVisible(true); } else { this.mapView = mapView; final JPanel mainPanel = new JPanel(); @@ -398,9 +397,9 @@ dialog.getRootPane().setDefaultButton(okButton); dialog.pack(); dialog.setLocationRelativeTo(parent); - dialog.setVisible(true); isBuilt = true; } + dialog.setVisible(true); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 17:29:15
|
Revision: 9011 http://gridarta.svn.sourceforge.net/gridarta/?rev=9011&view=rev Author: akirschbaum Date: 2011-10-15 17:29:09 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Remove redundant parameter from Archetype.setArtifact(). Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetype.java trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/model/src/app/net/sf/gridarta/model/archetype/Archetype.java Modified: trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetype.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetype.java 2011-10-15 17:26:43 UTC (rev 9010) +++ trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetype.java 2011-10-15 17:29:09 UTC (rev 9011) @@ -347,8 +347,8 @@ * {@inheritDoc} */ @Override - public void setArtifact(final boolean artifact) { - this.artifact = artifact; + public void setArtifact() { + artifact = true; } } // class AbstractArchetype Modified: trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2011-10-15 17:26:43 UTC (rev 9010) +++ trunk/model/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2011-10-15 17:29:09 UTC (rev 9011) @@ -225,7 +225,7 @@ archMore = false; if (archName != null) { - archetype.setArtifact(true); + archetype.setArtifact(); if (prototype != null) { archetype.addObjectText(AttributeListUtils.diffArchTextKeys(archetype, prototype)); } Modified: trunk/model/src/app/net/sf/gridarta/model/archetype/Archetype.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetype/Archetype.java 2011-10-15 17:26:43 UTC (rev 9010) +++ trunk/model/src/app/net/sf/gridarta/model/archetype/Archetype.java 2011-10-15 17:29:09 UTC (rev 9011) @@ -173,11 +173,9 @@ boolean isArtifact(); /** - * Sets whether this GameObject is an Artifact. - * @param artifact <code>true</code> if this GameObject is an Artifact, - * otherwise <code>false</code>. + * Converts this game object into an artifact. * @see #isArtifact() */ - void setArtifact(boolean artifact); + void setArtifact(); } // interface Archetype This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |