Commit a960afa0 authored by erreiip's avatar erreiip
Browse files

Refacto Summary

parent dfaca21b
Loading
Loading
Loading
Loading
+16 −15
Changes for jeuAssemblage/src/view/component/GameSummary.java: 16 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class GameSummary extends JPanel {
        int xEnd   = areaInformation[2];
        int yEnd   = areaInformation[3];

        double componentSize = Math.min(
        int componentSize = (int) Math.min(
                getHeightTimesPourcent(this, 0.95f) / ((yEnd - yBegin) * 1d),
                getWidthTimesPourcent(this, 0.95f) / ((xEnd - xBegin)  * 1d)
        );
@@ -53,31 +53,32 @@ public class GameSummary extends JPanel {
        g2d.setColor(Color.WHITE);
        int[][] matrices = this.controller.getPlayBoard();

        ArrayList<Piece> alreadyDraw = new ArrayList<Piece>();
        for ( int i = yBegin; i < yEnd; i++) {
            double y = (i - yBegin) * componentSize + paddingHeight/2;

            int y = (i - yBegin) * componentSize + (int) paddingHeight / 2;

            for ( int j = xBegin; j < xEnd; j++) {
                double x = (j - xBegin) * componentSize + paddingWidth/2;

                int x = (j - xBegin) * componentSize + (int) paddingWidth / 2;
                Rectangle2D shape = new Rectangle2D.Double(x,y, componentSize, componentSize);

                if (matrices[i][j] != 0) {

                    Piece p = this.controller.getPieceById(matrices[i][j]);
                    if (!alreadyDraw.contains(p)) {
                        // TODO rotate the image if needed
                        Image img = this.controller.getImageById(p.getInstanceId());

                        g2d.drawImage(img,
                                (int) Math.ceil(x),
                                (int) Math.ceil(y),
                                (int) Math.floor(componentSize * 3),
                                (int) Math.floor(componentSize * 3),
                                null);
					Image img = this.controller.getImageById(p.getInstanceId());

                        alreadyDraw.add(p);
					g2d.drawImage(
						img,
						x + 1,
						y + 1,
						componentSize,
						componentSize,
						null
					);
                } 
                } else {
				else {

                    g2d.draw(shape);
                }
            }
+2 −2
Changes for jeuAssemblage/src/view/component/board/Grid.java: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -62,11 +62,11 @@ public class Grid extends JPanel {

        for ( int i = 0; i < matrices.length; i++) {

            int y = i * (int) componentSize + (int) paddingHeight / 2;
            int y = i * componentSize + (int) paddingHeight / 2;

            for ( int j = 0; j < matrices[i].length; j++) {

                int x = j * (int) componentSize + (int) paddingWidth / 2;
                int x = j * componentSize + (int) paddingWidth / 2;
                Rectangle2D shape = new Rectangle2D.Double(x,y, componentSize, componentSize);

                if (matrices[i][j] != 0) {