10.5 处理2D信息
来源:互联网 发布:苍南县网络问政平台 编辑:程序博客网 时间:2024/06/16 14:49
import java.awt.*;import java.awt.geom.*;import javax.swing.*;/** * @version 1.33 2007-05-12 * @author Cay Horstmann */public class DrawTest{ public static void main(String[] args) { EventQueue.invokeLater(() -> { JFrame frame = new DrawFrame(); frame.setTitle("DrawTest"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }); }}/** * A frame that contains a panel with drawings */class DrawFrame extends JFrame{ public DrawFrame() { add(new DrawComponent()); pack(); }}/** * A component that displays rectangles and ellipses. */class DrawComponent extends JComponent{ private static final int DEFAULT_WIDTH = 400; private static final int DEFAULT_HEIGHT = 400; public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // draw a rectangle double leftX = 100; double topY = 100; double width = 200; double height = 150; Rectangle2D rect = new Rectangle2D.Double(leftX, topY, width, height); g2.draw(rect); // draw the enclosed ellipse Ellipse2D ellipse = new Ellipse2D.Double(); ellipse.setFrame(rect); g2.draw(ellipse); // draw a diagonal line g2.draw(new Line2D.Double(leftX, topY, leftX + width, topY + height)); // draw a circle with the same center double centerX = rect.getCenterX(); double centerY = rect.getCenterY(); double radius = 150; Ellipse2D circle = new Ellipse2D.Double(); circle.setFrameFromCenter(centerX, centerY, centerX + radius, centerY + radius); g2.draw(circle); } public Dimension getPreferredSize() { return new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT); }}
0 0
- 10.5 处理2D信息
- 图形学 Direct3D的3D模型处理2 - 邻接三角形的信息及优化
- Android 2D,3D处理
- 2D图像处理:斜切
- java 2d图片处理
- 处理信息
- 2D图像处理框架-目录
- java图形处理-Java 2D
- java图形处理-Java 2D
- java图形处理-Java 2D
- java gui处理2D图形
- java 处理2D图形 及代码
- Chapter 2 信息的表示和处理
- 2章 信息的表示和处理
- unity3d 角色头顶信息3D&2D遮挡解决方案(一)
- unity3d 角色头顶信息3D&2D遮挡解决方案(二)
- 3D 图像处理
- D网络与信息安全
- 使用C#邮件发送需要邮箱开通smtp功能
- Hibernate报错问题解决
- QT--base_20161202控件
- c语言之变参函数、calloc和布尔类型bool
- Spring学习笔记(四)
- 10.5 处理2D信息
- 计算机科学(Computer Science)到底学什么?
- FJNU第二十届低年级程序设计竞赛(正式赛)-Problem C-汪老司机(简单DP)
- 10.6 使用颜色
- Borda count
- 延时执行的方法
- SoapUi负载测试
- cmd命令编译运行时添加多个依赖包的问题
- 10.7 使用特殊的文本字体