@Test public void testCreateErrorImage() { BufferedImage img = this.tile.createErrorImage("Failed:" + this.tile.getId()); Assert.assertNotNull(img); Assert.assertEquals(256, img.getHeight()); Assert.assertEquals(256, img.getWidth()); }
protected BufferedImage createErrorImage(final String message) { BufferedImage buffImage = null; final int size = getTileSize(); buffImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = buffImage.createGraphics(); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.5)); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, size, size); graphics.setColor(Color.RED); graphics.drawLine(0, 0, size, size); graphics.drawLine(0, size, size, 0); int mesgWidth = graphics.getFontMetrics().stringWidth(message); graphics.drawString(message, (size - mesgWidth) / 2, size / 2); graphics.dispose(); return buffImage; }
Tile implements ImageLoader { protected BufferedImage createErrorImage(final String message) { BufferedImage buffImage = null; final int size = getTileSize(); buffImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = buffImage.createGraphics(); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.5)); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, size, size); graphics.setColor(Color.RED); graphics.drawLine(0, 0, size, size); graphics.drawLine(0, size, size, 0); int mesgWidth = graphics.getFontMetrics().stringWidth(message); graphics.drawString(message, (size - mesgWidth) / 2, size / 2); graphics.dispose(); return buffImage; } }
Tile implements ImageLoader { protected BufferedImage createErrorImage(final String message) { BufferedImage buffImage = null; final int size = getTileSize(); buffImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = buffImage.createGraphics(); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.5)); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, size, size); graphics.setColor(Color.RED); graphics.drawLine(0, 0, size, size); graphics.drawLine(0, size, size, 0); int mesgWidth = graphics.getFontMetrics().stringWidth(message); graphics.drawString(message, (size - mesgWidth) / 2, size / 2); graphics.dispose(); return buffImage; } Tile(TileIdentifier tileId, ReferencedEnvelope env, int tileSize); }
Tile implements ImageLoader { protected BufferedImage createErrorImage(final String message) { BufferedImage buffImage = null; final int size = getTileSize(); buffImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = buffImage.createGraphics(); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.5)); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, size, size); graphics.setColor(Color.RED); graphics.drawLine(0, 0, size, size); graphics.drawLine(0, size, size, 0); int mesgWidth = graphics.getFontMetrics().stringWidth(message); graphics.drawString(message, (size - mesgWidth) / 2, size / 2); graphics.dispose(); return buffImage; } Tile(TileIdentifier tileId, ReferencedEnvelope env, int tileSize); void setImageLoader(ImageLoader imageLoader); void setStateChangedListener(TileStateChangedListener listener); void dispose(); BufferedImage getBufferedImage(); @Override BufferedImage loadImageTileImage(Tile tile); int getTileSize(); ReferencedEnvelope getExtent(); void setRenderState(RenderState newState); RenderState getRenderState(); ContextState getContextState(); void setContextState(ContextState newState); ScreenState getScreenState(); void setScreenState(ScreenState newState); ValidatedState getTileState(); void setTileState(ValidatedState newState); String getId(); TileIdentifier getTileIdentifier(); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); abstract URL getUrl(); }
Tile implements ImageLoader { protected BufferedImage createErrorImage(final String message) { BufferedImage buffImage = null; final int size = getTileSize(); buffImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = buffImage.createGraphics(); graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.5)); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, size, size); graphics.setColor(Color.RED); graphics.drawLine(0, 0, size, size); graphics.drawLine(0, size, size, 0); int mesgWidth = graphics.getFontMetrics().stringWidth(message); graphics.drawString(message, (size - mesgWidth) / 2, size / 2); graphics.dispose(); return buffImage; } Tile(TileIdentifier tileId, ReferencedEnvelope env, int tileSize); void setImageLoader(ImageLoader imageLoader); void setStateChangedListener(TileStateChangedListener listener); void dispose(); BufferedImage getBufferedImage(); @Override BufferedImage loadImageTileImage(Tile tile); int getTileSize(); ReferencedEnvelope getExtent(); void setRenderState(RenderState newState); RenderState getRenderState(); ContextState getContextState(); void setContextState(ContextState newState); ScreenState getScreenState(); void setScreenState(ScreenState newState); ValidatedState getTileState(); void setTileState(ValidatedState newState); String getId(); TileIdentifier getTileIdentifier(); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); abstract URL getUrl();  }