/* * Copyright (c) 2014 tabletoptool.com team. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * rptools.com team - initial implementation * tabletoptool.com team - further development */ package com.t3.client.ui; import java.awt.TexturePaint; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import com.t3.model.Asset; import com.t3.util.ImageManager; public class AssetPaint extends TexturePaint { private Asset asset; public AssetPaint(Asset asset) { this(ImageManager.getImageAndWait(asset.getId())); this.asset = asset; } // Only used to avoid a bunch of calls to getImageAndWait() that the compiler may // not be able to optimize (method calls may not be optimizable when side effects // of the method are not known to the compiler). private AssetPaint(BufferedImage img) { super(img, new Rectangle2D.Float(0, 0, img.getWidth(), img.getHeight())); } public Asset getAsset() { return asset; } }