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. Android studio 使用NDK工具实现JNI编程

    前言: Android开发中常常会使用到第三方的.so库.在使用.so库的时候就要用到JNI编程.JNI是Java Native Interface的缩写.它提供了若干的API实现了Java和其它语言 ...

  2. 上传一个 游戏server架构图

  3. 调用oracle 各种报错总结---待续

    ORA-01747: user.table.column, table.column 或列说明无效 原因之一是sql语句拼接错误,多了逗点:二是使用到了oracle的关键字所致 ORA-02449: ...

  4. HTML DOM的总结

    DOM 是 Document Object Model(文档对象模型)的缩写,是 W3C(万维网联盟)的标准 W3C DOM 标准被分为 3 个不同的部分: 1.核心 DOM - 针对任何结构化文档的 ...

  5. Mybatis里Mapper映射sql文件里insert的主键返回selectKey使用

    有时候新增一条数据,知道新增成功即可,但是有时候,需要这条新增数据的主键,以便逻辑使用,再将其查询出来明显不符合要求,效率也变低了. 这时候,通过一些设置,mybatis可以将insert的数据的主键 ...

  6. C# 遍历枚举(枚举是目的,遍历(获取)是手段)

    C# 遍历枚举   C#中,如何获取(遍历)枚举中所有的值: public enum Suits { Spades, Hearts, Clubs, Diamonds, NumSuits } priva ...

  7. 关于Solr6.0中solrj使用简单例子

    solr6.0的solrJ接口有部分变化,下面列出了简单的使用实例,有需要的朋友可以参考下. package com.ailk.solr6; import java.io.IOException; i ...

  8. 编写Spark的WordCount程序并提交到集群运行[含scala和java两个版本]

    编写Spark的WordCount程序并提交到集群运行[含scala和java两个版本] 1. 开发环境 Jdk 1.7.0_72 Maven 3.2.1 Scala 2.10.6 Spark 1.6 ...

  9. CSocket类网络编程 MFC

    Visual C++的MFC提供了CSocket类用来实现网络通信. 下面介绍VC++在Windows 95中实现Socket的 CSocket 类相关成员函数(这些成员函数实际上是从CAsyncSo ...

  10. 使用conda 对gcc进行升级 (sonicparanoid)

    由于要是用python 3.6版本的一个包sonicparanoid,但是系统的gcc比较老,所以先用conda创建python环境,在该环境下尽心gcc的安装和升级 conda create --n ...