From: Erik V. <ev...@us...> - 2009-11-02 23:30:46
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29771/rails/ui/swing/hexmap Modified Files: GUIHex.java EWHexMap.java GUITile.java HexMap.java NSHexMap.java Log Message: More rationalising of static method usage Index: NSHexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/NSHexMap.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NSHexMap.java 31 Oct 2009 17:08:27 -0000 1.8 --- NSHexMap.java 2 Nov 2009 23:30:36 -0000 1.9 *************** *** 5,10 **** import java.util.ArrayList; ! import rails.game.*; ! import rails.ui.swing.*; /** --- 5,10 ---- import java.util.ArrayList; ! import rails.game.MapHex; ! import rails.ui.swing.Scale; /** *************** *** 16,30 **** public NSHexMap() { - setupHexes(); cx = 0; cy = -scale / 2; } ! protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); scale = Scale.get(); ! hexArray = MapManager.getInstance().getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; --- 16,30 ---- public NSHexMap() { cx = 0; cy = -scale / 2; } ! @Override ! protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); scale = Scale.get(); ! hexArray = mapManager.getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; Index: EWHexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/EWHexMap.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EWHexMap.java 31 Oct 2009 17:08:27 -0000 1.9 --- EWHexMap.java 2 Nov 2009 23:30:36 -0000 1.10 *************** *** 5,9 **** import java.util.ArrayList; ! import rails.game.*; /** --- 5,9 ---- import java.util.ArrayList; ! import rails.game.MapHex; /** *************** *** 15,27 **** public EWHexMap() { - setupHexes(); cx = scale / 2; cy = 0; } ! protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); ! hexArray = MapManager.getInstance().getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; --- 15,27 ---- public EWHexMap() { cx = scale / 2; cy = 0; } ! @Override ! protected void setupHexesGUI() { hexes = new ArrayList<GUIHex>(); ! hexArray = mapManager.getHexes(); MapHex mh; h = new GUIHex[hexArray.length][hexArray[0].length]; Index: HexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/HexMap.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** HexMap.java 31 Oct 2009 17:08:27 -0000 1.17 --- HexMap.java 2 Nov 2009 23:30:36 -0000 1.18 *************** *** 4,8 **** import java.awt.*; import java.awt.event.*; - import java.awt.geom.Point2D; import java.util.*; import java.util.List; --- 4,7 ---- *************** *** 12,21 **** import org.apache.log4j.Logger; ! import rails.game.MapHex; ! import rails.game.MapManager; ! import rails.game.PhaseI; import rails.game.action.*; ! import rails.ui.swing.ORUIManager; ! import rails.ui.swing.Scale; /** --- 11,17 ---- import org.apache.log4j.Logger; ! import rails.game.*; import rails.game.action.*; ! import rails.ui.swing.*; /** *************** *** 30,34 **** protected ORUIManager orUIManager; ! //protected MapManager mapManager; // Abstract Methods --- 26,30 ---- protected ORUIManager orUIManager; ! protected MapManager mapManager; // Abstract Methods *************** *** 40,48 **** protected MapHex[][] hexArray; protected Map<String, GUIHex> hexesByName = new HashMap<String, GUIHex>(); ! protected static ArrayList<GUIHex> hexes; protected int scale = 2 * Scale.get(); protected int cx; protected int cy; ! protected static GUIHex selectedHex = null; protected Dimension preferredSize; --- 36,44 ---- protected MapHex[][] hexArray; protected Map<String, GUIHex> hexesByName = new HashMap<String, GUIHex>(); ! protected ArrayList<GUIHex> hexes; protected int scale = 2 * Scale.get(); protected int cx; protected int cy; ! protected GUIHex selectedHex = null; protected Dimension preferredSize; *************** *** 63,69 **** protected boolean bonusTokenLayingEnabled = false; ! public void setORUIManager(ORUIManager orUIManager) { this.orUIManager = orUIManager; ! //this.mapManager = orUIManager.getGameUIManager().getGameManager().getMapManager(); } --- 59,66 ---- protected boolean bonusTokenLayingEnabled = false; ! public void init(ORUIManager orUIManager, MapManager mapManager) { this.orUIManager = orUIManager; ! this.mapManager = mapManager; ! setupHexes(); } *************** *** 74,91 **** } - /** - * Return the GUIBattleHex that contains the given point, or null if none - * does. - */ - GUIHex getHexContainingPoint(Point2D.Double point) { - for (GUIHex hex : hexes) { - if (hex.contains(point)) { - return hex; - } - } - - return null; - } - GUIHex getHexContainingPoint(Point point) { for (GUIHex hex : hexes) { --- 71,74 ---- *************** *** 294,304 **** public PhaseI getPhase () { if (orUIManager != null) { ! return orUIManager.getGameUIManager().getGameManager().getPhaseManager().getCurrentPhase(); ! } else { ! return null; } } ! public void mouseClicked(MouseEvent arg0) { Point point = arg0.getPoint(); GUIHex clickedHex = getHexContainingPoint(point); --- 277,294 ---- public PhaseI getPhase () { if (orUIManager != null) { ! //return orUIManager.getGameUIManager().getGameManager().getPhaseManager().getCurrentPhase(); ! GameUIManager u = orUIManager.getGameUIManager(); ! GameManagerI g = u.getGameManager(); ! PhaseManager p = g.getPhaseManager(); ! return p.getCurrentPhase(); } + return null; } ! public MapManager getMapManager() { ! return mapManager; ! } ! ! public void mouseClicked(MouseEvent arg0) { Point point = arg0.getPoint(); GUIHex clickedHex = getHexContainingPoint(point); Index: GUITile.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUITile.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** GUITile.java 6 Sep 2009 16:16:56 -0000 1.16 --- GUITile.java 2 Nov 2009 23:30:36 -0000 1.17 *************** *** 55,59 **** private void initialise() { ! if (MapManager.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; } else { --- 55,59 ---- private void initialise() { ! if (hex.getTileOrientation() == MapHex.EW) { baseRotation = 0.5 * DEG60; } else { *************** *** 68,73 **** /** ! * Rotate right (clockwise) until a valid orientation is found. ! * * @param initial: First rotation to try. Should be 0 for the initial tile * drop, and 1 at subsequent rotation attempts. --- 68,73 ---- /** ! * Rotate right (clockwise) until a valid orientation is found. ! * * @param initial: First rotation to try. Should be 0 for the initial tile * drop, and 1 at subsequent rotation attempts. *************** *** 140,152 **** oldTrack.getEndPoint(prevTileSide)); } else { ! // Assume there are only two exits ! // (this is the only known case for downgrading: // #3->#7, #4->#9, #58->#8). // Find the other new exit int otherNewEndPoint = newTracks.get(0).getEndPoint(tempTileSide); ! // Calculate the corresponding old tile side number int otherOldEndPoint = (otherNewEndPoint + tempRot - prevTileRotation + 6) % 6; // That old tile side must have track too ! if (prevTile.getTracksPerSide(otherOldEndPoint) == null || prevTile.getTracksPerSide(otherOldEndPoint).isEmpty()) { continue rot; --- 140,152 ---- oldTrack.getEndPoint(prevTileSide)); } else { ! // Assume there are only two exits ! // (this is the only known case for downgrading: // #3->#7, #4->#9, #58->#8). // Find the other new exit int otherNewEndPoint = newTracks.get(0).getEndPoint(tempTileSide); ! // Calculate the corresponding old tile side number int otherOldEndPoint = (otherNewEndPoint + tempRot - prevTileRotation + 6) % 6; // That old tile side must have track too ! if (prevTile.getTracksPerSide(otherOldEndPoint) == null || prevTile.getTracksPerSide(otherOldEndPoint).isEmpty()) { continue rot; Index: GUIHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUIHex.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** GUIHex.java 29 Oct 2009 19:41:27 -0000 1.22 --- GUIHex.java 2 Nov 2009 23:30:35 -0000 1.23 *************** *** 85,89 **** this.hexMap = hexMap; ! if (MapManager.getTileOrientation() == MapHex.EW) { len = scale; xVertex[0] = cx + SQRT3 / 2 * scale; --- 85,89 ---- this.hexMap = hexMap; ! if (hexMap.getMapManager().getTileOrientation() == MapHex.EW) { len = scale; xVertex[0] = cx + SQRT3 / 2 * scale; |