[Picross-commit] SF.net SVN: picross:[120] branches/engine_split/android/src/picross/ specific/grid
Status: Pre-Alpha
Brought to you by:
yvan_norsa
|
From: <yva...@us...> - 2013-01-15 14:39:44
|
Revision: 120
http://sourceforge.net/p/picross/code/120
Author: yvan_norsa
Date: 2013-01-15 14:39:40 +0000 (Tue, 15 Jan 2013)
Log Message:
-----------
grid rendering
Modified Paths:
--------------
branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java
branches/engine_split/android/src/picross/specific/grid/ui/HintBoxInfos.java
branches/engine_split/android/src/picross/specific/grid/ui/UIBox.java
Modified: branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java
===================================================================
--- branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java 2013-01-15 14:25:07 UTC (rev 119)
+++ branches/engine_split/android/src/picross/specific/grid/ui/GridUI.java 2013-01-15 14:39:40 UTC (rev 120)
@@ -206,11 +206,9 @@
int[][] rowData,
CompletedHints completedHints,
GridController controller) {
- // FIXME
- //super(true);
+ GridUI.log.debug("GridUI(" + androidContext + ", " + width + ", " + height
+ + ", boxes, colData, rowData, completedhints, controller)");
- GridUI.log.debug("GridUI(" + androidContext + ", " + width + ", " + height + ", boxes, colData, rowData, completedhints, controller)");
-
if (androidContext == null) {
throw new IllegalArgumentException("\"androidContext\" cannot be null");
}
@@ -243,18 +241,18 @@
public void draw(Canvas c) {
c.drawColor(Color.WHITE);
- //Rectangle clipRect = newG.getClipBounds();
+ Rect clipRect = c.getClipBounds();
for (int i = 0; i < this.topHints.length; i++) {
- //if (this.topHints[i].intersects(clipRect)) {
+ if (this.topHints[i].intersect(clipRect)) {
this.drawTopHints(c, i);
- //}
+ }
}
for (int i = 0; i < this.leftHints.length; i++) {
- //if (this.leftHints[i].intersects(clipRect)) {
+ if (this.leftHints[i].intersect(clipRect)) {
this.drawLeftHints(c, i);
- //}
+ }
}
// Paints the boxes
@@ -262,11 +260,11 @@
for (int j = 0; j < this.height; j++) {
Rect currentRect = this.boxes[i][j].getRect();
- //if (currentRect.intersects(clipRect)) {
+ if (currentRect.intersect(clipRect)) {
c.drawBitmap(this.boxes[i][j].getIcon(),
currentRect.left,
currentRect.top, null);
- //}
+ }
}
}
@@ -290,31 +288,7 @@
public void init() throws FileNotFoundException {
GridUI.log.debug("init()");
- // FIXME
- /*
// Computes the size of a hint
- FontRenderContext frc = new FontRenderContext(null, true, true);
-
- // High hint (> 10)
- Rectangle2D textBounds =
- GridUI.HINT_FONT.getStringBounds(GridUI.HIGH_SAMPLE_HINT, frc);
- int hintHeight = (int) textBounds.getHeight();
- int highHintWidth = (int) textBounds.getWidth();
-
- // Low hint
- textBounds = GridUI.HINT_FONT.getStringBounds(GridUI.LOW_SAMPLE_HINT,
- frc);
- int lowHintWidth = (int) textBounds.getWidth();
- */
-
- /*
- Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
- //paint.setStyle(Paint.Style.FILL);
- //paint.setColor(color);
- paint.setTextAlign(Paint.Align.CENTER);
- paint.setTextSize(10);
- paint.setTypeface(GridUI.HINT_FONT);
- */
Paint paint = GridUI.getHintPaint();
Rect textBounds = new Rect();
@@ -327,14 +301,11 @@
GridUI.log.debug("highHintWidth = " + highHintWidth);
// Low hint
- //textBounds = new Rect();
paint.getTextBounds(GridUI.LOW_SAMPLE_HINT, 0, 1, textBounds);
int lowHintWidth = (int) textBounds.width();
GridUI.log.debug("lowHintWidth = " + lowHintWidth);
- // FIXME
- //this.hintBoxIcon = PicrossUIHelper.getImage(GridUI.HINT_BOX_ICON);
this.hintBoxIcon = PicrossUIHelper.getImage(this.context.getResources(), R.drawable.hint);
int hintBoxWidth = this.hintBoxIcon.getWidth();
@@ -363,20 +334,11 @@
for (int i = 0; i < this.topHints.length; i++) {
this.topHints[i] = new HintBoxInfos();
- /*
this.topHints[i].setRect(new Rect(this.leftBoundary
+ (i * GridUI.BOX_WIDTH), 0,
- GridUI.BOX_WIDTH,
- this.topBoundary));
- */
-
- this.topHints[i].setRect(new Rect(this.leftBoundary
- + (i * GridUI.BOX_WIDTH), 0,
this.leftBoundary
+ (i * GridUI.BOX_WIDTH) + GridUI.BOX_WIDTH,
this.topBoundary));
-
- //GridUI.log.debug("this.topHints[" + i + "].setRect(" + this.topHints[i].getRect() + ")");
}
this.leftHints = new HintBoxInfos[this.height];
@@ -384,16 +346,10 @@
for (int i = 0; i < this.leftHints.length; i++) {
this.leftHints[i] = new HintBoxInfos();
- /*
this.leftHints[i].setRect(new Rect(0, this.topBoundary
+ (i * GridUI.BOX_HEIGHT),
this.leftBoundary,
- GridUI.BOX_HEIGHT));
- */
- this.leftHints[i].setRect(new Rect(0, this.topBoundary
- + (i * GridUI.BOX_HEIGHT),
- this.leftBoundary,
-this.topBoundary
+ this.topBoundary
+ (i * GridUI.BOX_HEIGHT)
+ GridUI.BOX_HEIGHT));
}
@@ -420,22 +376,13 @@
* so we'll be able
* to redraw only what is needed
*/
- /*
this.boxes[i][j]
.setRect(new Rect(this.leftBoundary
+ (i * GridUI.BOX_WIDTH),
this.topBoundary
+ (j * GridUI.BOX_WIDTH),
- GridUI.BOX_WIDTH,
- GridUI.BOX_HEIGHT));
- */
- this.boxes[i][j]
- .setRect(new Rect(this.leftBoundary
- + (i * GridUI.BOX_WIDTH),
- this.topBoundary
- + (j * GridUI.BOX_WIDTH),
-this.leftBoundary
+ this.leftBoundary
+ (i * GridUI.BOX_WIDTH)+
GridUI.BOX_WIDTH,
@@ -517,25 +464,10 @@
* @param topHintsStart coordinate where the boxes begin
*/
private void initTopHints(int topHintsStart) {
- // FIXME
for (int k = 0; k < this.topHints.length; k++) {
- /*
- this.topHints[k].setBox(
- new BufferedImage(GridUI.BOX_WIDTH, this.topBoundary,
- BufferedImage.TYPE_INT_RGB));
- */
- //Bitmap b = Bitmap.createBitmap(GridUI.BOX_WIDTH, this.topBoundary, Bitmap.Config.ARGB_8888);
Picture b = new Picture();
- //this.topHints[k].setBox(b);
+ Canvas g2d = b.beginRecording(GridUI.BOX_WIDTH, this.topBoundary);
- //Canvas g2d = this.topHints[k].createBoxGraphics();
- Canvas g2d = b.beginRecording(GridUI.BOX_WIDTH, this.topBoundary);
- //g2d.drawColor(Color.WHITE);
- /*
- g2d.fillRect(0, 0,
- this.topHints[k].getWidth(),
- this.topHints[k].getHeight());
- */
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
@@ -548,7 +480,6 @@
// Column hints are in reverse order
for (int i = (this.colData[0].length - 1); i >= 0; i--) {
if (this.colData[k][i] != GridModel.EMPTY_HINT) {
- //this.hintBoxIcon.paintIcon(this, g2d, topHintsStart, y);
g2d.drawBitmap(this.hintBoxIcon, topHintsStart, y, null);
}
@@ -568,16 +499,9 @@
*/
private void initLeftHints(int leftHintsStart) {
for (int k = 0; k < this.leftHints.length; k++) {
- /*
- this.leftHints[k].setBox(
- new BufferedImage(this.leftBoundary, GridUI.BOX_HEIGHT,
- BufferedImage.TYPE_INT_RGB));
- */
Picture b = new Picture();
Canvas g2d = b.beginRecording(this.leftBoundary, GridUI.BOX_HEIGHT);
- //Graphics2D g2d = this.leftHints[k].createBoxGraphics();
- //g2d.setColor(Color.WHITE);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
@@ -590,7 +514,6 @@
for (int j = 0; j < this.rowData[k].length; j++) {
if (this.rowData[k][j] != GridModel.EMPTY_HINT) {
- //this.hintBoxIcon.paintIcon(this, g2d, x, leftHintsStart);
g2d.drawBitmap(this.hintBoxIcon, x, leftHintsStart, null);
}
@@ -609,18 +532,8 @@
* @param g the graphics context
*/
private void drawTopHints(Canvas c, int col) {
- /*
- g.drawImage(this.topHints[col].getBox(),
- this.topHints[col].getX(), this.topHints[col].getY(),
- null);
- */
-
- //this.topHints[col].getBox().draw(c);
c.drawPicture(this.topHints[col].getBox(), this.topHints[col].getRect());
- // FIXME
- //g.setFont(GridUI.HINT_FONT);
-
int x = this.topHintsX + (col * GridUI.BOX_WIDTH);
int y = 0;
@@ -640,16 +553,8 @@
* @param g the graphics context
*/
private void drawLeftHints(Canvas c, int row) {
- /*
- g.drawImage(this.leftHints[row].getBox(),
- this.leftHints[row].getX(), this.leftHints[row].getY(),
- null);
- */
c.drawPicture(this.leftHints[row].getBox(), this.leftHints[row].getRect());
- //FIXME
- //g.setFont(GridUI.HINT_FONT);
-
int y = this.leftHintsY + (row * GridUI.BOX_HEIGHT);
int x = 0;
@@ -675,19 +580,14 @@
boolean complete) {
//GridUI.log.debug("drawHint(c, " + value + ", " + x + ", " + y + ", " + complete + ")");
- //Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG);
Paint paint = GridUI.getHintPaint();
- if (complete) {
- paint.setColor(GridUI.COMPLETED_HINT_COLOR);
- } else {
- paint.setColor(GridUI.HINT_TEXT_COLOR);
- }
- /*
- paint.setTypeface(GridUI.HINT_FONT);
- paint.setTextAlign(Paint.Align.CENTER);
-paint.setTextSize(10);
- */
+ if (complete) {
+ paint.setColor(GridUI.COMPLETED_HINT_COLOR);
+ } else {
+ paint.setColor(GridUI.HINT_TEXT_COLOR);
+ }
+
y += this.centerHintHeight;
if (value < 10) {
@@ -702,7 +602,7 @@
private static Paint getHintPaint() {
Paint paint = new Paint(/*Paint.ANTI_ALIAS_FLAG | Paint.LINEAR_TEXT_FLAG*/);
paint.setTypeface(GridUI.HINT_FONT);
- paint.setTextAlign(Paint.Align.CENTER);
+ //paint.setTextAlign(Paint.Align.CENTER);
paint.setTextSize(10);
return paint;
Modified: branches/engine_split/android/src/picross/specific/grid/ui/HintBoxInfos.java
===================================================================
--- branches/engine_split/android/src/picross/specific/grid/ui/HintBoxInfos.java 2013-01-15 14:25:07 UTC (rev 119)
+++ branches/engine_split/android/src/picross/specific/grid/ui/HintBoxInfos.java 2013-01-15 14:39:40 UTC (rev 120)
@@ -49,7 +49,6 @@
private Rect rect = null;
/** Pre-rendered image of the box. */
- //private BufferedImage box = null;
private Picture box = null;
/*** Methods ***/
@@ -60,22 +59,11 @@
* @param rectangle the rectangle to test
* @return boolean indicating wether the two rectangles intersect
* with each other
- *//* boolean intersects(Rectangle rectangle) {
- return this.rect.intersects(rectangle);
- }*/
+ */ boolean intersect(Rect rectangle) {
+ return this.rect.intersect(rectangle);
+ }
/**
- * Creates and return a <code>Graphics2D</code> object corresponding
- * to the box.
- *
- * @return graphical object corresponding to the box
- */
- /*
- Canvas createBoxGraphics() {
- return new Canvas(this.box);
- }
- */
- /**
* Returns the rectangle's width.
*
* @return width of the box's rectangle
Modified: branches/engine_split/android/src/picross/specific/grid/ui/UIBox.java
===================================================================
--- branches/engine_split/android/src/picross/specific/grid/ui/UIBox.java 2013-01-15 14:25:07 UTC (rev 119)
+++ branches/engine_split/android/src/picross/specific/grid/ui/UIBox.java 2013-01-15 14:39:40 UTC (rev 120)
@@ -59,9 +59,6 @@
public final class UIBox extends Box {
/*** Constants ***/
- /** Index of the normal icon. */
- //private static final int ICON_INDEX = 0;
-
/** Images files extension. */
private static final String IMAGES_EXT = ".png";
@@ -73,7 +70,6 @@
/*** Field ***/
/** Rectangle occupied by the box. */
- //private Rectangle rect;
private Rect rect;
/*** Static block ***/
@@ -88,17 +84,6 @@
UIBox.images = new HashMap<BoxState, Bitmap>(4);
try {
- /*
- for (BoxState state : BoxState.values()) {
- ImageIcon[] img = new ImageIcon[1];
-
- String stateImageName = state.toString().toLowerCase();
- img[UIBox.ICON_INDEX] =
- PicrossUIHelper.getImage(stateImageName + UIBox.IMAGES_EXT);
- UIBox.images.put(state, img);
- }
- */
-
UIBox.images.put(BoxState.EMPTY, PicrossUIHelper.getImage(res, R.drawable.empty));
UIBox.images.put(BoxState.CHECKED, PicrossUIHelper.getImage(res, R.drawable.checked));
UIBox.images.put(BoxState.CROSSED, PicrossUIHelper.getImage(res, R.drawable.crossed));
@@ -141,12 +126,6 @@
*
* @return icon of the state of the box
*/
- /*
- ImageIcon getIcon() {
- return UIBox.images.get(this.state)[UIBox.ICON_INDEX];
- }
- */
-
Bitmap getIcon() {
return UIBox.images.get(this.state);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|