当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

北京理工大学:《Java导论与Java开发环境》课程教学资源(PPT课件讲稿)第十三讲 图形程序设计

资源类别:文库,文档格式:PPT,文档页数:48,文件大小:610.5KB,团购合买
一、 Java的绘图能力: 二、 绘制2维图形,3维图形需要附加的支持包 三、控制颜色
点击下载完整版文档(PPT)

第十三讲 Java图形程序设计 北京理工大学计算机系金旭亮

Java图形程序设计 北京理工大学计算机系金旭亮 第十三讲

Java绘图功能简介 Java的绘图能力: 绘制2维图形,3维图形需要附加的支持包 ■控制颜色 ■选择字体 Java 2D API ■提供大量的2维图形绘制和填充功能 2021/2/24 北京理工大学计算机系(共48页)

2021/2/24 北京理工大学计算机系(共48页) 2 Java绘图功能简介 ◼ Java的绘图能力: ◼ 绘制2维图形,3维图形需要附加的支持包 ◼ 控制颜色 ◼ 选择字体 ◼ Java 2D API ◼ 提供大量的2维图形绘制和填充功能

绘图的第一步 小 裸体”窗体: Simpleframe Test java 回回区 窗体是一个对象,从 frame类中派生出来。 2021/2/24 北京理工大学计算机系(共48页)

2021/2/24 北京理工大学计算机系(共48页) 3 绘图的第一步 ◼ 显示一个“裸体”窗体:SimpleFrameTest.java 窗体是一个对象,从JFrame类中派生出来

设定窗体行为 ■实例: Centered FrameTest 1.自定义图标 自动居中。 CenteredFrane 巴回囟 2021/2/24 北京理工大学计算机系(共48页)

2021/2/24 北京理工大学计算机系(共48页) 4 设定窗体行为 ◼ 实例:CenteredFrameTest 1. 自定义图标 2. 自动居中

Java窗体和面板继承树 Ob ject Component Conta iner JComponent Window PAne rame JFrame 2021/2/24 5

2021/2/24 北京理工大学计算机系(共48页) 5 Java窗体和面板继承树

向窗体中加入面板 将一个Pnel对象加入到窗体中,在其上绘 实例: Othello world java 量 OthE11oor1d 回囟 Not a Hello, World program 2021/2/24 北京理工大学计算机系(共48页)

2021/2/24 北京理工大学计算机系(共48页) 6 向窗体中加入面板 ◼ 将一个JPanel对象加入到窗体中,在其上绘 图 ◼ 实例:NotHelloWorld.java

Java4标系统 (0,0) Xaxis Y axis 2021/2/24 北京理工大学计算机系(共48页) 7

2021/2/24 北京理工大学计算机系(共48页) 7 Java坐标系统

图形上下文与图形对象 Graphics context(图形上下文) 用于在屏幕上绘图 Graphics对象管理图形上下文 Graphics类是一个抽象基类,必须派生出具 体子类以实现绘图功能。 类 Component有一个 paint方法,采用一个 Graphics对象作为参数 public void paint( Graphics g 通过调用类 Component的 repaint方法来调用 paInt 2021/2/24 北京理工大学计算机系(共48页)

2021/2/24 北京理工大学计算机系(共48页) 8 图形上下文与图形对象 ◼ Graphics context(图形上下文) ◼ 用于在屏幕上绘图 ◼ Graphics对象管理图形上下文 ◼ Graphics类是一个抽象基类,必须派生出具 体子类以实现绘图功能。 ◼ 类Component 有一个 paint方法,采用一个 Graphics 对象作为参数 public void paint( Graphics g ) ◼ 通过调用类Component的repaint方法来调用 paint

颜色控制 类co1or用于处理颜色 三原色原理: R-Red:0~255 G-Green: 0-255 B-Blue: 0-255 2021/2/24 北京理工大学计算机系(共48页)

2021/2/24 北京理工大学计算机系(共48页) 9 颜色控制 ◼ 类 Color用于处理颜色 ◼ 三原色原理: R-Red: 0~255 G-Green: 0~255 B-Blue: 0~255

颜色常数 Color constant Color RGBvalue public final static Color orange orange 2552000 public final static color pink nk 255.175.175 public final static Color cyan cyan 0.255.255 public final static color magenta magenta public final static color yellow rello 255,255,0 public final static Color black black 0,0,0 public final static Color white white 255,255,255 public final static color gray 128.128.128 public final static Color lightGray light gray 192.192.192 public final static Color darkGray dark gray64,64,64 public final static Color red re 255,0,0 public final static color green green public final static color blue blue 0,0,255 Fig.11.3 Color class static constants and RGB values 2021/2/24 北京理工大学计算机系(共48页) 10

2021/2/24 北京理工大学计算机系(共48页) 10 颜色常数 Color Constant Color RGB value public final static Color orange orange 255, 200, 0 public final static Color pink pink 255, 175, 175 public final static Color cyan cyan 0, 255, 255 public final static Color magenta magenta 255, 0, 255 public final static Color yellow yellow 255, 255, 0 public final static Color black black 0, 0, 0 public final static Color white white 255, 255, 255 public final static Color gray gray 128, 128, 128 public final static Color lightGray light gray 192, 192, 192 public final static Color darkGray dark gray 64, 64, 64 public final static Color red red 255, 0, 0 public final static Color green green 0, 255, 0 public final static Color blue blue 0, 0, 255 Fig. 11.3 Color c lass static c onstants and RGB values

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共48页,可试读16页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有