From: Stefan F. <ste...@us...> - 2010-04-20 20:18:02
|
Update of /cvsroot/rails/18xx/rails/ui/swing/hexmap In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv12106/rails/ui/swing/hexmap Modified Files: GUIHex.java Log Message: Changed highlighting for selectable hexes Index: GUIHex.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/hexmap/GUIHex.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** GUIHex.java 20 Apr 2010 19:45:40 -0000 1.42 --- GUIHex.java 20 Apr 2010 20:17:51 -0000 1.43 *************** *** 23,26 **** --- 23,27 ---- public static final double SQRT3 = Math.sqrt(3.0); public static double NORMAL_SCALE = 1.0; + public static double SELECTABLE_SCALE = 0.9; public static double SELECTED_SCALE = 0.8; *************** *** 34,44 **** public static void setScale(double scale) { NORMAL_SCALE = scale; SELECTED_SCALE = 0.8 * scale; } protected MapHex model; ! protected GeneralPath innerHexagon; protected static final Color highlightColor = Color.red; ! protected static final Color upgradableColor = Color.magenta; protected Point center; /** x and y coordinates on the map */ --- 35,47 ---- public static void setScale(double scale) { NORMAL_SCALE = scale; + SELECTABLE_SCALE = 0.9 * scale; SELECTED_SCALE = 0.8 * scale; } protected MapHex model; ! protected GeneralPath innerHexagonSelected; ! protected GeneralPath innerHexagonSelectable; protected static final Color highlightColor = Color.red; ! protected static final Color selectableColor = Color.red; protected Point center; /** x and y coordinates on the map */ *************** *** 154,161 **** (yVertex[0] + yVertex[3]) / 2.0); ! final double innerScale = 0.8; AffineTransform at = AffineTransform.getScaleInstance(innerScale, innerScale); ! innerHexagon = (GeneralPath) hexagon.createTransformedShape(at); // Translate innerHexagon to make it concentric. --- 157,169 ---- (yVertex[0] + yVertex[3]) / 2.0); ! innerHexagonSelected = defineInnerHexagon(0.8, center2D); ! innerHexagonSelectable = defineInnerHexagon(0.9, center2D); ! } ! ! private GeneralPath defineInnerHexagon(double innerScale, Point2D.Double center2D) { ! AffineTransform at = AffineTransform.getScaleInstance(innerScale, innerScale); ! GeneralPath innerHexagon = (GeneralPath) hexagon.createTransformedShape(at); // Translate innerHexagon to make it concentric. *************** *** 171,174 **** --- 179,194 ---- innerHexagon.transform(at); + return innerHexagon; + } + + /** + * returns point that corresponds to the definition as networkvertex + */ + public Point getHexPoint(int side){ + if (side >= 0) { // side + return new Point((int) xVertex[side],(int) yVertex[side]); + } else { // station + return getTokenCenter(0, 0, 0, -side); + } } *************** *** 254,258 **** this.selectable = selectable; if (selectable) { ! currentGUITile.setScale(SELECTED_SCALE); } else { currentGUITile.setScale(NORMAL_SCALE); --- 274,278 ---- this.selectable = selectable; if (selectable) { ! currentGUITile.setScale(SELECTABLE_SCALE); } else { currentGUITile.setScale(NORMAL_SCALE); *************** *** 327,342 **** Color terrainColor = Color.WHITE; ! if (isSelected() || isSelectable()) { ! if (isSelected()) ! g2.setColor(highlightColor); ! else ! g2.setColor(upgradableColor); g2.fill(hexagon); g2.setColor(terrainColor); ! g2.fill(innerHexagon); g2.setColor(Color.black); ! g2.draw(innerHexagon); } --- 347,368 ---- Color terrainColor = Color.WHITE; ! if (isSelected()) { ! g2.setColor(highlightColor); g2.fill(hexagon); g2.setColor(terrainColor); ! g2.fill(innerHexagonSelected); g2.setColor(Color.black); ! g2.draw(innerHexagonSelected); ! } else if (isSelectable()) { ! g2.setColor(selectableColor); ! g2.fill(hexagon); ! ! g2.setColor(terrainColor); ! g2.fill(innerHexagonSelectable); ! ! g2.setColor(Color.black); ! g2.draw(innerHexagonSelectable); } |