From: Stefan F. <ste...@us...> - 2010-04-20 19:45:48
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv8480/rails/ui/swing/hexmap Modified Files: GUIHex.java HexMap.java Log Message: First implementation to visualize revenue runs on the map Index: GUIHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUIHex.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** GUIHex.java 11 Apr 2010 15:49:47 -0000 1.41 --- GUIHex.java 20 Apr 2010 19:45:40 -0000 1.42 *************** *** 181,184 **** --- 181,199 ---- } + public Point2D getCityPoint2D(City city){ + Point tokenPoint = getTokenCenter(0, 1, 0, city.getNumber() - 1); + return new Point2D.Double(tokenPoint.getX(), tokenPoint.getY()); + } + + public Point2D getSidePoint2D(int side){ + side = (5-side); + return new Point2D.Double((xVertex[side] + xVertex[(side+1)%6])/2, + (yVertex[side] + yVertex[(side+1)%6])/2); + } + + public Point2D getCenterPoint2D() { + return center; + } + public void setHexModel(MapHex model) { this.model = model; Index: HexMap.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/HexMap.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** HexMap.java 11 Mar 2010 20:38:00 -0000 1.23 --- HexMap.java 20 Apr 2010 19:45:40 -0000 1.24 *************** *** 4,7 **** --- 4,8 ---- import java.awt.*; import java.awt.event.*; + import java.awt.geom.GeneralPath; import java.util.*; import java.util.List; *************** *** 65,69 **** protected boolean bonusTokenLayingEnabled = false; ! public void init(ORUIManager orUIManager, MapManager mapManager) { this.orUIManager = orUIManager; --- 66,75 ---- protected boolean bonusTokenLayingEnabled = false; ! ! /** list of generalpath elements to indicate train runs */ ! protected List<GeneralPath> trainPaths; ! protected Color[] trainColors = new Color[]{Color.CYAN, Color.PINK, Color.ORANGE, Color.GRAY}; ! protected Stroke trainStroke = new BasicStroke(5, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); ! public void init(ORUIManager orUIManager, MapManager mapManager) { this.orUIManager = orUIManager; *************** *** 142,145 **** --- 148,160 ---- } } + + // paint train paths + Graphics2D g2 = (Graphics2D) g; + g2.setStroke(trainStroke); + int color = 0; + for (GeneralPath path:trainPaths) { + g2.setColor(trainColors[color++ % trainColors.length]); + g2.draw(path); + } } catch (NullPointerException ex) { *************** *** 338,341 **** --- 353,360 ---- } + public void setTrainPaths(List<GeneralPath> trainPaths) { + this.trainPaths = trainPaths; + } + /** * Off-board tiles must be able to retrieve the current phase. |