[Picross-commit] SF.net SVN: picross: [30] trunk/src/picross/grid/GridUI.java
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2007-06-11 10:38:35
|
Revision: 30 http://picross.svn.sourceforge.net/picross/?rev=30&view=rev Author: yvan_norsa Date: 2007-06-11 03:38:34 -0700 (Mon, 11 Jun 2007) Log Message: ----------- changed blocks drawing Modified Paths: -------------- trunk/src/picross/grid/GridUI.java Modified: trunk/src/picross/grid/GridUI.java =================================================================== --- trunk/src/picross/grid/GridUI.java 2007-06-11 10:25:17 UTC (rev 29) +++ trunk/src/picross/grid/GridUI.java 2007-06-11 10:38:34 UTC (rev 30) @@ -364,70 +364,52 @@ private void initBlocks() { this.blocksLines = new ArrayList<Line2D>(); + this.blocksLines.add(new Line2D.Double(this.leftBoundary, + this.topBoundary, + this.leftBoundary, + this.bottomBoundary)); + this.blocksLines.add(new Line2D.Double(this.leftBoundary, + this.topBoundary, + this.rightBoundary, + this.topBoundary)); + this.blocksLines.add(new Line2D.Double(this.rightBoundary, + this.bottomBoundary, + this.leftBoundary, + this.bottomBoundary)); + this.blocksLines.add(new Line2D.Double(this.rightBoundary, + this.bottomBoundary, + this.rightBoundary, + this.topBoundary)); + + int boxWidth = GridUI.BLOCK_WIDTH * GridUI.BOX_WIDTH; int boxHeight = GridUI.BLOCK_HEIGHT * GridUI.BOX_HEIGHT; + + int i = 1; + int currentY = this.topBoundary + boxHeight; - int i = 0; - int currentY = this.topBoundary; + while ((i + GridUI.BLOCK_HEIGHT) < this.height) { + this.blocksLines.add(new Line2D.Double(this.leftBoundary, + currentY, + this.rightBoundary, + currentY)); - while (i < this.height) { - int j = 0; - int currentX = this.leftBoundary; - - while (j < this.width) { - if ((i + GridUI.BLOCK_HEIGHT) <= this.height) { - if ((j + GridUI.BLOCK_WIDTH <= this.width)) { - GridUI.addRectToLines(this.blocksLines, - currentX, currentY, - boxWidth, boxHeight); - } else { - GridUI.addRectToLines(this.blocksLines, - currentX, currentY, - (this.width - j) - * GridUI.BOX_WIDTH, - boxHeight); - } - } else { - if ((j + GridUI.BLOCK_WIDTH <= this.width)) { - GridUI.addRectToLines(this.blocksLines, - currentX, currentY, - boxWidth, - (this.height - i) - * GridUI.BOX_HEIGHT); - } else { - GridUI.addRectToLines(this.blocksLines, - currentX, currentY, - (this.width - j) - * GridUI.BOX_WIDTH, - (this.height - i) - * GridUI.BOX_HEIGHT); - } - } - - currentX += boxWidth; - j += GridUI.BLOCK_WIDTH; - } - currentY += boxHeight; i += GridUI.BLOCK_HEIGHT; } - } + + i = 1; + int currentX = this.leftBoundary + boxWidth; - /** - * Add a rectangle lines to a list. - * - * @param lines list to add the lines to - * @param x the x coordinate of the rectangle - * @param y the y coordinate of the rectangle - * @param width width of the rectangle - * @param height height of the retangle - */ - private static void addRectToLines(List<Line2D> lines, - int x, int y, int width, int height) { - lines.add(new Line2D.Double(x, y, x + width, y)); - lines.add(new Line2D.Double(x, y, x, y + height)); - lines.add(new Line2D.Double(x + width, y + height, x, y + height)); - lines.add(new Line2D.Double(x + width, y + height, x + width, y)); + while ((i + GridUI.BLOCK_WIDTH) < this.width) { + this.blocksLines.add(new Line2D.Double(currentX, + this.topBoundary, + currentX, + this.bottomBoundary)); + + currentX += boxWidth; + i += GridUI.BLOCK_WIDTH; + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |