private void makePoly() { // make a polygon a = bv.getHexLocation(start); t = bv.getHexLocation(end); // OK, that is actually not good. I do not like hard coded figures. // HEX_W/2 - x distance in pixels from origin of hex bounding box to // the center of hex. // HEX_H/2 - y distance in pixels from origin of hex bounding box to // the center of hex. // 18 - is actually 36/2 - we do not want arrows to start and end // directly // in the centes of hex and hiding mek under. a.x = a.x + (int) ((BoardView1.HEX_W / 2) * bv.scale) + (int) Math.round(Math.cos(an) * (int) (18 * bv.scale)); t.x = (t.x + (int) ((BoardView1.HEX_W / 2) * bv.scale)) - (int) Math.round(Math.cos(an) * (int) (18 * bv.scale)); a.y = a.y + (int) ((BoardView1.HEX_H / 2) * bv.scale) + (int) Math.round(Math.sin(an) * (int) (18 * bv.scale)); t.y = (t.y + (int) ((BoardView1.HEX_H / 2) * this.bv.scale)) - (int) Math.round(Math.sin(an) * (int) (18 * bv.scale)); movePoly = new StraightArrowPolygon(a, t, (int) (4 * bv.scale), (int) (8 * bv.scale), false); }
attackPoly = new StraightArrowPolygon(a, t, (int) (8 * this.boardView1.scale), (int) (12 * this.boardView1.scale), true); } else { attackPoly = new StraightArrowPolygon(a, t, (int) (4 * this.boardView1.scale), (int) (8 * this.boardView1.scale), false);
/** * If we have build full arrow already with single attack and have got * counter attack from our target lately - lets change arrow to halved. */ public void rebuildToHalvedPolygon() { attackPoly = new StraightArrowPolygon(a, t, (int) (8 * this.boardView1.scale), (int) (12 * this.boardView1.scale), true); // set bounds bounds = new Rectangle(attackPoly.getBounds()); bounds.setSize(bounds.getSize().width + 1, bounds.getSize().height + 1); // move poly to upper right of image attackPoly.translate(-bounds.getLocation().x, -bounds.getLocation().y); }