This example demonstrates how to set a clipping area using a shape. The example sets an oval for the clipping area and then draws and image. Only those pixels of the image that fall within the oval are displayed.

    // See e575 The Quintessential Drawing Program
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g; // Create an oval shape that's as large as the component
float fx = 0;
float fy = 0;
float fw = getSize().width-1;
float fh = getSize().height-1;
Shape shape = new java.awt.geom.Ellipse2D.Float(fx, fy, fw, fh); // Set the clipping area
g2d.setClip(shape); // Draw an image
int x = 0;
int y = 0;
g2d.drawImage(image, x, y, this);
}
Related Examples

e578. Setting the Clipping Area with a Shape的更多相关文章

  1. 动态计算area位置

    window.onresize = adjuest; function adjuest(){ var picw = $(".imgbox img").width(); var pi ...

  2. YTU 2915: Shape系列-1

    2915: Shape系列-1 时间限制: 1 Sec  内存限制: 128 MB 提交: 283  解决: 221 题目描述 小强开始迷恋彩色的Shape,于是决定做一个Shape类.Shape类有 ...

  3. area热点区域

    <area>标记:主要用于图像地图,通过该标记可以在图像地图中设定作用区域(又称为热点),这样当用户的鼠标移到指定的作用区域点击时,会自动链接到预先设定好的页面.其基本语法结构如下: &l ...

  4. area标签的使用,图片中某一个部分可以点击跳转,太阳系中点击某个行星查看具体信息

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. html|Area

    http://tomys.win/   HTML图片热区Area map的用法只是在上学的时候学习到过,在实际工作中一直没用过,如果 不是这次紧急任务,可能永远都不会想起这个功能.在一些特殊的html ...

  6. Using SetWindowRgn

    Using SetWindowRgn Home Back To Tips Page Introduction There are lots of interesting reasons for cre ...

  7. PHP7函数大全(4553个函数)

    转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...

  8. Paths_Quartz2D

    Paths中的几个重要元素 Points void CGContextMoveToPoint (    CGContextRef c,    CGFloat x,    CGFloat y ); 指定 ...

  9. Paths(转载)

    Paths中的几个重要元素 Points void CGContextMoveToPoint ( CGContextRef c, CGFloat x, CGFloat y ); 指定一个点成为curr ...

随机推荐

  1. 分享Memcached shell启动停止脚本

    注意:要使用这个shell,必须先成功建立memcache环境 1>建立memcached文件和权限 [root@luozhonghua ~]# touch /etc/init.d/memcac ...

  2. SVN版本控制业务流程详解

    http://blog.sina.com.cn/s/blog_56d8ea900100y9cf.html http://jingyan.baidu.com/article/fa4125acbf509e ...

  3. 利用eChart绘制网页图表

    首先,最好的教程在这里:eCchart eChart所需JS: echarts.min.js china.js echarts.js 页面代码如下: 一.图表 <!DOCTYPE html> ...

  4. Firefox清空缓存的快捷键

    有时候调试网页,需要清空缓存,常用的firefox清空缓存的快捷键: Shift+Ctrl+Delete

  5. WIN2008中部署网站后样式及JS加载不了

    今天在一台刚刚装好的WIN2008上部署一个问题,一切按流程来:① 控制面板加IIS,把.NET 3.5打勾② 装.NET 4.0框架③ 装MSSQL2012④ IIS中部署网站⑤ 修改web.con ...

  6. markdown 语法简要备忘

    标题 # 一级标题 ## 二级标题 ### 三级标题 无序列表 前面加 - 或 * 即可变为 有序列表 直接用数字即可 1. 2. 3. 添加引用 > 图片与链接 插入链接与插入图片的语法很像, ...

  7. UTF8字符串在lua的截取和字数统计【转载】

    转载自:GitHub:pangliang/pangliang.github.com 需求 按字面个数来截取 函数(字符串, 开始位置, 截取长度) utf8sub(,) = 好1世界哈 utf8sub ...

  8. Ubuntu下安装JDK1.7

    Ubuntu操作系统下如何手动安装JDK1.7呢?本文是我经历的全过程. Ubuntu版本:12.04 LTS JDK版本:1.7.0_04 安装目录:/usr/local/development/j ...

  9. Python中的相对文件路径的调用

    先让我们来看看一个用到相对文件路径的函数调用的问题.假设现在有两个脚本文件main.py和func.py,他们的路径关系是: . |--dir1 |--main.py |--dir2 |--func. ...

  10. Makefile学习之路——4

    变量的类别有递归扩展变量和简单扩展变量.只用一个“=”符号定义的变量被称为递归扩展变量.通过下面例子观察递归扩展变量的特点. .PHONY: all foo=$(bar) bar=$(ugh) ugh ...