DrawingAttributes.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:passage 作者:
/**
 * Get the Paint for these attributes, and scale it for the scale compared to
 * the base scale set if the fill Paint is a TexturePattern. If the base
 * scale equals NONE, or if the Paint is not a TexturePaint, it's the same as
 * getFillPaint().
 * 
 * @param scale scale to compare to the base scale.
 * @return a Paint object to use for the fill, scaled if necessary.
 */
public Paint getFillPaintForScale(float scale) {
   if (fillPattern != null) {
      if (baseScale != NONE) {
         BufferedImage bi = fillPattern.getImage();
         float scaleFactor = scale / baseScale;
         Image image =
               bi.getScaledInstance((int) (bi.getWidth() * scaleFactor), (int) (bi.getHeight() * scaleFactor),
                                    Image.SCALE_SMOOTH);
         try {
            bi = BufferedImageHelper.getBufferedImage(image, 0, 0, -1, -1);

            return new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
         } catch (InterruptedException ie) {
            if (logger.isLoggable(Level.FINE)) {
               logger.warning("DrawingAttributes: Interrupted Exception scaling texture paint");
            }
         }
      }
      return fillPattern;
   } else {
      return fillPaint;
   }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号