e591. Drawing Simple Text
See also e575 The Quintessential Drawing Program.
public void paint(Graphics g) {
// Set the desired font if different from default font
String family = "Serif";
int style = Font.PLAIN;
int size = 12;
Font font = new Font(family, style, size);
g.setFont(font);
// Draw a string such that its base line is at x, y
int x = 10;
int y = 10;
g.drawString("aString", x, y);
// Draw a string such that the top-left corner is at x, y
x = 10;
y = 30;
FontMetrics fontMetrics = g.getFontMetrics();
g.drawString("aString", x, y+fontMetrics.getAscent());
}
| Related Examples |
e591. Drawing Simple Text的更多相关文章
- LightOJ 1285 - Drawing Simple Polygon (几何,极角排序)
1285 - Drawing Simple Polygon PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- Html5: Drawing with text
<!DOCTYPE html> <html> <head> <meta name="viewport" content="wid ...
- e586. Drawing Simple Shapes
There are two ways to draw basic shapes like circles, ovals, lines, arcs, squares, rectangles, round ...
- reactjs simple text editor
import React, { Component } from 'react' import PubSub from 'pubsub' import GlobalVars from 'globalV ...
- 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 ...
- LightOj1285 - Drawing Simple Polygon(连接多边形各点)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1285 题意:给你一些点,然后把它们用一条线把它们连起来,构成一个多边形,不能有相交,必 ...
- e577. Enabling Antialiasing
// See e575 The Quintessential Drawing Program public void paint(Graphics g) { // Retrieve the graph ...
- html5 canvas simple drawing
var c = canvas.getContext("2d");//get canvas 2d context canvas including a proposed 3D con ...
- [OpenCV] Samples 01: drawing
基本的几何图形,标注功能. commondLineParser的使用参见:http://blog.csdn.net/u010305560/article/details/8941365 #includ ...
随机推荐
- ubuntu的apt-get提示资源被锁定
一.错误提示 E: Could not : Resource temporarily unavailable) E: Unable to lock the administration directo ...
- winfrom 窗口起始位置为屏幕中央
窗口起始位置为屏幕中央 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 获取鼠标触发事件光标位置 t ...
- oracle递归层级查询 start with connect by prior
递归层级查询:start with connect by prior 以部门表作为解析 表结构:dept{id:'主键',name:'部门名称',parent_id:'父亲id'} select * ...
- STORM在线业务实践-集群空闲CPU飙高问题排查(转)
最近将公司的在线业务迁移到Storm集群上,上线后遇到低峰期CPU耗费严重的情况.在解决问题的过程中深入了解了storm的内部实现原理,并且解决了一个storm0.9-0.10版本一直存在的严重bug ...
- 【转】在ASP.NET应用启动的时候初始化的几种方法
ASP.NET 4.0 之前,有两种方法:通过Global.asax 中的 Application_Start 事件启动,或者通过定义在 App_Code 文件夹中任意类中的AppInitialize ...
- 分享下今天研究的流量上限DDos攻击分析和解决方式
分享下今天研究的流量上限DDos攻击分析和解决方式 常常听到或者碰到某个站点被攻击.一般都是流量攻击.今天自己写了个程序測下相关的上限,程序仅仅简单做了个get html操作(不包括图片等资源文件). ...
- Probability Concepts
Probability Concepts Unconditional probability and Conditional Probability Unconditional Probability ...
- 利用yacc和lex制作一个小的计算器
买了本<自制编程语言>,这本书有点难,目前只是看前两章,估计后面的章节,最近一段时间是不会看了,真的是好难啊!! 由于本人是身处弱校,学校的课程没有编译原理这一门课,所以就想看这两章,了解 ...
- angular学习笔记(三)-视图绑定数据的两种方式
绑定数据有两种方式: <!DOCTYPE html> <html ng-app> <head> <title>2.2显示文本</title> ...
- JSON数据乱码问题
http://ifeve.com/json-code-problem/ ***************************** 背景 程序员一提到编码应该都不陌生,像gbk.utf-8.ascii ...