/** * Specifies the squareSize of the squares. By default, it is 8. A squareSize of <= * 0 will cause an IllegalArgumentException to be thrown. * * @param squareSize the squareSize of one side of a square tile. Must be > 0. */ public void setSquareSize(double squareSize) { if (squareSize <= 0) { throw new IllegalArgumentException("Length must be > 0"); } double old = getSquareSize(); this.squareSize = squareSize; checkerPaint = null; setDirty(true); firePropertyChange("squareSize", old, getSquareSize()); }
/** * Specifies the squareSize of the squares. By default, it is 8. A squareSize of <= * 0 will cause an IllegalArgumentException to be thrown. * * @param squareSize the squareSize of one side of a square tile. Must be > 0. */ public void setSquareSize(double squareSize) { if (squareSize <= 0) { throw new IllegalArgumentException("Length must be > 0"); } double old = getSquareSize(); this.squareSize = squareSize; checkerPaint = null; setDirty(true); firePropertyChange("squareSize", old, getSquareSize()); }
/** * Specifies the squareSize of the squares. By default, it is 8. A squareSize of <= * 0 will cause an IllegalArgumentException to be thrown. * * @param squareSize the squareSize of one side of a square tile. Must be > 0. */ public void setSquareSize(double squareSize) { if (squareSize <= 0) { throw new IllegalArgumentException("Length must be > 0"); } double old = getSquareSize(); this.squareSize = squareSize; checkerPaint = null; setDirty(true); firePropertyChange("squareSize", old, getSquareSize()); }
/** * Specifies the squareSize of the squares. By default, it is 8. A squareSize of <= * 0 will cause an IllegalArgumentException to be thrown. * * @param squareSize the squareSize of one side of a square tile. Must be > 0. */ public void setSquareSize(double squareSize) { if (squareSize <= 0) { throw new IllegalArgumentException("Length must be > 0"); } double old = getSquareSize(); this.squareSize = squareSize; checkerPaint = null; setDirty(true); firePropertyChange("squareSize", old, getSquareSize()); }
double sqlength = getSquareSize(); int length = (int)(sqlength * 2); BufferedImage image = new BufferedImage(length, length, BufferedImage.TYPE_INT_ARGB);
/** * Helper method that creates and returns the Paint that incorporates the * sizes and light and dark Paints in one TexturePaint. I may want to cache * this value in the future for performance reasons */ private Paint getCheckerPaint(Object c) { if (checkerPaint == null) { Paint p1 = PainterUtils.getForegroundPaint(getLightPaint(), c); Paint p2 = PainterUtils.getBackgroundPaint(getDarkPaint(), c); checkerPaint = PaintUtils.getCheckerPaint(p1, p2, (int)(getSquareSize() * 2)); } return checkerPaint; }
/** * Helper method that creates and returns the Paint that incorporates the * sizes and light and dark Paints in one TexturePaint. I may want to cache * this value in the future for performance reasons */ private Paint getCheckerPaint(Object c) { if (checkerPaint == null) { Paint p1 = PainterUtils.getForegroundPaint(getLightPaint(), c); Paint p2 = PainterUtils.getBackgroundPaint(getDarkPaint(), c); checkerPaint = PaintUtils.getCheckerPaint(p1, p2, (int)(getSquareSize() * 2)); } return checkerPaint; }
/** * Helper method that creates and returns the Paint that incorporates the * sizes and light and dark Paints in one TexturePaint. I may want to cache * this value in the future for performance reasons */ private Paint getCheckerPaint(Object c) { if (checkerPaint == null) { Paint p1 = PainterUtils.getForegroundPaint(getLightPaint(), c); Paint p2 = PainterUtils.getBackgroundPaint(getDarkPaint(), c); checkerPaint = PaintUtils.getCheckerPaint(p1, p2, (int)(getSquareSize() * 2)); } return checkerPaint; }
@Test @Override public void testDefaults() { super.testDefaults(); CheckerboardPainter cp = (CheckerboardPainter) p; assertThat(cp.getDarkPaint(), CoreMatchers.<Paint>is(new Color(204, 204, 204))); assertThat(cp.getLightPaint(), CoreMatchers.<Paint>is(Color.WHITE)); assertThat(cp.getSquareSize(), is(8d)); } }