private void setTexturedIcon(Component c, BufferedImage textureImage, float angle)
{
// Paint plan icon in an image
BufferedImage image = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB);
final Graphics2D imageGraphics = (Graphics2D) image.getGraphics();
imageGraphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
PieceOfFurniturePlanIcon.super.paintIcon(c, imageGraphics, 0, 0);
// Fill the pixels of plan icon with texture image
imageGraphics
.setPaint(new TexturePaint(textureImage,
new Rectangle2D.Float(0, 0,
-getIconWidth() / this.pieceWidth * this.pieceTexture.getWidth(),
-getIconHeight() / this.pieceDepth * this.pieceTexture.getHeight())));
imageGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN));
imageGraphics.rotate(angle);
float maxDimension = Math.max(image.getWidth(), image.getHeight());
imageGraphics.fill(new Rectangle2D.Float(-maxDimension, -maxDimension, 3 * maxDimension, 3 * maxDimension));
imageGraphics.fillRect(0, 0, getIconWidth(), getIconHeight());
imageGraphics.dispose();
setIcon(new ImageIcon(image));
}
PlanComponent.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:SweetHome3D
作者:
评论列表
文章目录