There are two ways to draw basic shapes like circles, ovals, lines, arcs, squares, rectangles, rounded rectangles, and polygons. The first is to use specific drawing methods like Graphics.drawOval(). This example uses these methods. The second is to construct a shape and then use Graphics2D.draw() to draw the shape. See the java.awt.geom package for examples that create shapes.

    // See e575 The Quintessential Drawing Program
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D)g; g2d.drawLine(x1, y1, x2, y2);
g2d.drawOval(x, y, w, h);
g2d.drawRect(x, y, w, h); // A start angle of 0 represents a 3 o'clock position, 90 represents a 12 o'clock position,
// and -90 (or 270) represents a 6 o'clock position
int startAngle = 45;
int arcAngle = -60;
g2d.drawArc(x, y, w, h, startAngle, arcAngle); g2d.drawRoundRect(x, y, w, h, arcWidth, arcHeight); Polygon polygon = new Polygon();
polygon.addPoint(x, y);
// Add more points...
g2d.drawPolygon(polygon);
}
Related Examples

e586. Drawing Simple Shapes的更多相关文章

  1. LightOJ 1285 - Drawing Simple Polygon (几何,极角排序)

    1285 - Drawing Simple Polygon   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...

  2. e591. Drawing Simple Text

    See also e575 The Quintessential Drawing Program. public void paint(Graphics g) { // Set the desired ...

  3. Drawing Simple Polygon(Create Simple Polygon from unordered points by angle sorting)

    Keywords: 极角排序, Simple Polygon Generation Given set of points in the plane, your task is to draw a p ...

  4. LightOj1285 - Drawing Simple Polygon(连接多边形各点)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1285 题意:给你一些点,然后把它们用一条线把它们连起来,构成一个多边形,不能有相交,必 ...

  5. e575. The Quintessential Drawing Program

    To draw on the screen, it is first necessary to subclass a JComponent and override its paint() metho ...

  6. e577. Enabling Antialiasing

    // See e575 The Quintessential Drawing Program public void paint(Graphics g) { // Retrieve the graph ...

  7. python编程学习--Pygame - Python游戏编程入门(0)---转载

    原文地址:https://www.cnblogs.com/wuzhanpeng/p/4261015.html 引言 博客刚开,想把最近学习的东西记录下来,算是一种笔记.最近打算开始学习Python,因 ...

  8. Pygame - Python游戏编程入门(0) 转

    博客刚开,想把最近学习的东西记录下来,算是一种笔记.最近打算开始学习Python,因为我感觉Python是一门很有意思的语言,很早以前就想学了(碍于懒),它的功能很强大,你可以用它来做科学运算,或者数 ...

  9. Pygame - Python游戏编程入门

    >>> import pygame>>> print(pygame.ver)1.9.2a0 如果没有报错,应该是安装好了~ 如果报错找不到模块,很可能是安装版本的问 ...

随机推荐

  1. 统计学习方法:支撑向量机(SVM)

    作者:桂. 时间:2017-05-13  21:52:14 链接:http://www.cnblogs.com/xingshansi/p/6850684.html 前言 主要记录SVM的相关知识,参考 ...

  2. 深入浅出Node.js--数据通讯,NET模块运行机制

    互联网的运作,最根本的驱动就是信息的交互,NodeJS 在数据交互这一块做的很带感,异步编程让人很惬意,关于 NodeJS 的数据通信,最基础的两个模块是 NET 和 HTTP,前者是基于 TCP 的 ...

  3. Nginx+mysql+php(待补全)

    先安装 Nginx 通过源码安装可以指定目录(/usr/local/Nginx/) yum或源码安装Mysql yum或源码安装php(记得命令一定要全,别忘了安装php-fpm) 待补全

  4. Windows上怎么安装ELK

    In this guide I will show that it is also possible to run Logstash on a Windows Server 2012 machine ...

  5. Linux服务器开发初步

      服务器开发需要考虑的内容很多,比如服务器的架构.稳定性.性能以及负载能力等等. 事实上,在开发服务器的过程中,需要综合考虑各种因素,比如就客户端连接时间较短却又比较频繁的服务器(例如HTTP服务器 ...

  6. A simple case to use Celery:

    Prerequisites:   1: Install RabbitMQ as it would be used as message broker for Celery. In windows, i ...

  7. 正则表达式入门(c#)

    本文是对该教程的学习练习 http://www.jb51.net/tools/zhengze.html 注:正则符号转义和普通的转义一样,加反斜杠,比如[ 变成 \[ 正则表达式符号和转义符号最好用+ ...

  8. Linux虚拟内存系统常用参数说明

    1.admin_reserve_kbytes    给有cap_sys_admin权限的用户保留的内存数量,默认值是min(free pages * 3%, 8MB).这些内存是为了给管理员登录和杀死 ...

  9. no link present

    今天装linux 系统.然后:service network restart的时候提演示样例如以下的错误: .............................................. ...

  10. ny17 单调递增最长子序列

    单调递增最长子序列时间限制:3000 ms  |  内存限制:65535 KB难度:4 描述    求一个字符串的最长递增子序列的长度    如:dabdbf最长递增子序列就是abdf,长度为4 输入 ...