@Override public String toString() { StringBuilder msg = new StringBuilder("Edges:"); HexLine[] edges = getEdges(); for (int i = 0; i < edges.length; i++) { if (i != 0) { msg.append("; "); } if (edges[i] == null) { msg.append("null"); } else { msg.append(edges[i].toString()); } } return msg.toString(); }
/** * Returns a vertex, with zero starting at the upper left of the hex */ public Coords getVertexNum(int i) { final String METHOD_NAME = "getVertexNum(int)"; owner.methodBegin(getClass(), METHOD_NAME); try { HexLine[] edges = getEdges(); if (edges[i] == null || edges[(i + 1) % 6] == null) { System.err.println(new IllegalStateException("Edge[" + i + "] is NULL.")); return null; } return edges[i].getIntersection(edges[(i + 1) % 6]); } finally { owner.methodEnd(getClass(), METHOD_NAME); } }
/** * returns true if a point is inside the area * false if it is not */ public boolean contains(Coords c) { final String METHOD_NAME = "contains(Coords)"; owner.methodBegin(getClass(), METHOD_NAME); try { HexLine[] edges = getEdges(); if (edges[0] == null) { return false; } for (int i = 0; i < 6; i++) { if (edges[i].judgePoint(c) > 0) { return false; } } return true; } finally { owner.methodEnd(getClass(), METHOD_NAME); } }
Coords closest = null; int closest_dist = 0; HexLine[] edges = getEdges(); for (int i = 0; i < 6; i++) { if (edges[i] == null) {
HexLine[] edges = a.getEdges(); if ((edges[getDirection()] == null) || (edges[(getDirection() + 3) % 6] == null)) { System.err.println(new IllegalStateException("Detection of NULL edges in ConvexBoardArea :: " +
/** * expands the board area to include point onc */ void expandToInclude(Coords onc) { final String METHOD_NAME = "expandToInclude(Coords)"; owner.methodBegin(getClass(), METHOD_NAME); try { HexLine[] edges = getEdges(); for (int i = 0; i < 6; i++) { if ((edges[i] == null) || (edges[i].judgePoint(onc) > 0)) { edges[i] = new HexLine(onc, i, owner); } } setEdges(edges); } finally { owner.methodEnd(getClass(), METHOD_NAME); } }