Welcome![Sign In][Sign Up]
Location:
Search - DrawString

Search list

[WEB Code细分时钟刻度算法.txt

Description: import java.awt.*; import javax.swing.*; public class Exercise8_12 extends JFrame { // Main method with three auguments: // args[0]: hour // args[1]: minute // args[2]: second public static void main(String[] args) { // Declare hour, minute, and second values int hour = 0; int minute = 0; int second = 0; // Check usage and get hour, minute, second if (args.length > 3) { System.out.println( "Usage: java DisplayClock hour minute second"); System.exit(0); } else if (args.length == 3) { hour = new Integer(args[0]).intValue(); minute = new Integer(args[1]).intValue(); second = new Integer(args[2]).intValue(); } else if (args.length == 2) { hour = new Integer(args[0]).intValue(); minute = new Integer(args[1]).intValue(); } else if (args.length == 1) { hour = new Integer(args[0]).intValue(); } // Create a frame to hold the clock Exercise8_12 frame = new Exercise8_12(); frame.setTitle("Exercise 8.12: Display Clock"); frame.getContentPane().add(new DrawClock(hour, minute, second)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 350); frame.setVisible(true); } } class DrawClock extends JPanel { private int hour; private int minute; private int second; protected int xCenter, yCenter; protected int clockRadius; // Construct a clock panel public DrawClock(int hour, int minute, int second) { this.hour = hour; this.minute = minute; this.second = second; } // Draw the clock public void paintComponent(Graphics g) { super.paintComponent(g); // Initialize clock parameters clockRadius = (int)(Math.min(getSize().width, getSize().height)*0.7*0.5); xCenter = (getSize().width)/2; yCenter = (getSize().height)/2; // Draw circle g.setColor(Color.black); g.drawOval(xCenter - clockRadius,yCenter - clockRadius, 2*clockRadius, 2*clockRadius); g.drawString("12",xCenter-5, yCenter-clockRadius); g.drawString("9",xCenter-clockRadius-10,yCenter+3); g.drawString("3",xCenter+clockRadius,yCenter+3); g.drawString("6",xCenter-3,yCenter+clockRadius+10); // Draw second hand int sLength = (int)(clockRadius*0.85); int xSecond = (int)(xCenter + sLength*Math.sin(second*(2*Math.PI/60))); int ySecond = (int)(yCenter - sLength*Math.cos(second*(2*Math.PI/60))); g.setColor(Color.red); g.drawLine(xCenter, yCenter, xSecond, ySecond); // Draw minute hand int mLength = (int)(clockRadius*0.75); int xMinute = (int)(xCenter + mLength*Math.sin(minute*(2*Math.PI/60))); int yMinute = (int)(yCenter - mLength*Math.cos(minute*(2*Math.PI/60))); g.setColor(Color.blue); g.drawLine(xCenter, yCenter, xMinute, yMinute); // Draw hour hand int hLength = (int)(clockRadius*0.6); int xHour = (int)(xCenter + hLength*Math.sin((hour+minute/60.0)*(2*Math.PI/12))); int yHour = (int)(yCenter - hLength*Math.cos((hour+minute/60.0)*(2*Math.PI/12))); g.setColor(Color.green); g.drawLine(xCenter, yCenter, xHour, yHour); // Display current time in string g.setColor(Color.red); String time = "Hour: " + hour + " Minute: " + minute + " Second: " + second; FontMetrics fm = g.getFontMetrics(); g.drawString(time, (getSize().width - fm.stringWidth(time))/2, yCenter+clockRadius+30); // Display more details on the clock for (int i=0; i<60; i++) { double percent; if (i%5 == 0) { percent = 0.9; } else { percent = 0.95; } //细分时钟刻度 int xOuter = (int)(xCenter + clockRadius*Math.sin(i*(2*Math.PI/60))); int yOuter = (int)(yCenter - clockRadius*Math.cos(i*(2*Math.PI/60))); int xInner = (int)(xCenter + percent*clockRadius*Math.sin(i*(2*Math.PI/60))); int yInner = (int)(yCenter - percent*clockRadius*Math.cos(i*(2*Math.PI/60))); g.drawLine(xOuter, yOuter, xInner, yInner); } } }
Platform: | Size: 4270 | Author: hellosoft010@sina.com | Hits:

[.netDrawString

Description: 使用DrawString 方法在指定的位置绘制文本,用于VB.net编程-Drawstring methods used in mapping the location of the designated text for VB.net Programming
Platform: | Size: 4096 | Author: 王军 | Hits:

[JSP/Javajava

Description: 了解Java语言的发展历史和Java平台的应用划分。 了解Java语言的特点及其实际应用领域。 了解Java开发环境及开发工具,掌握如何设置开发环境及如何编译和运行Java程序。 熟悉几种不同类型的Java程序-import java.applet.* import java.awt.* public class FirstApplet extends Applet { public void paint(Graphics g) { g.drawString("Hello World!",25,50) }
Platform: | Size: 452608 | Author: yuhailong | Hits:

[Windows DevelopDrawString

Description: 使用MFC进行文字的输出处理,可以设置字体,颜色和方向-The use of MFC to handle the output of text, you can set fonts, colors and directions, etc.
Platform: | Size: 78848 | Author: zhangcht | Hits:

[J2MEDrawString

Description: Java ME 在手机屏幕是绘制字符的方法-Java ME the method of drawing characters on the phone screen is
Platform: | Size: 3072 | Author: ecnujyjs | Hits:

[Windows Develophanoicx

Description: 汉诺塔源码C# nt width = (int)((panelHanoi.Width / 3 - offset)*((float)hanoiData.diskList[key][j]/hanoiData.diskCount))+offset int left=(int)(x-width/2) int height=20 int top=panelHanoi.Height-(hanoiData.diskList[key].Count-j)*height e.Graphics.FillRectangle(new SolidBrush(Color.Blue), new Rectangle(left, top, width, height-2)) e.Graphics.DrawString(hanoiData.diskList[key][j].ToString(), this.Font, new SolidBrush(Color.White), left, top) } }-nt width = (int)((panelHanoi.Width/3- offset)*((float)hanoiData.diskList[key][j]/hanoiData.diskCount))+offset int left=(int)(x-width/2) int height=20 int top=panelHanoi.Height-(hanoiData.diskList[key].Count-j)*height e.Graphics.FillRectangle(new SolidBrush(Color.Blue), new Rectangle(left, top, width, height-2)) e.Graphics.DrawString(hanoiData.diskList[key][j].ToString(), this.Font, new SolidBrush(Color.White), left, top) } }
Platform: | Size: 68608 | Author: zlqiufeng | Hits:

[J2MEAlign-Text-MIDlet-Example

Description: With the help of the canvas class, we can draw as many as graphics we want in our application. Similarly we can also set the different alignment to the text. In this J2ME Midlet we are going to set the text at different locations such as right, left, top right and top left etc.. to set the alignment we have used "g.drawString() " and defined different values in it with the height and width within it.
Platform: | Size: 162816 | Author: Nitin Patel | Hits:

[JSP/JavaCreating-Canvas-Form-Example

Description: This example shows that how to use the Canvas Class in a Form. In this example we take two field in which integer number passed from the form and result will display on a Canvas circle. The Following methods are used in this example: getWidth() getHeight() setColor() fillRect() setGrayScale() drawString()
Platform: | Size: 275456 | Author: Jayesh Parmar | Hits:

[JSP/Javaexperiment1

Description: 个人原创:熟悉JDK的安装和配置,学习如何编写并运行简单的Application程序和Applet程序(能输出一条简单的问候信息): 1.在Editplus(或JCreator ,Textpad)环境下编写一个HelloWorld.java程序, (1)在主方法static public void main(String[ ] args)中调用System.out.println()方法,使程序输出一条问候信息; (2) 编译运行程序,观察运行情况和输出结果。(使用JDK环境,调用javac.exe和java.exe编译和执行程序) 2.在Editplus(或JCreator ,Textpad)环境下编写一个HelloWorldApplet.java程序。 (1)在public void paint(Graphics g)方法中调用g.drawString()方法,使程序输出一条问候信息; (2) 编译运行程序,观察运行情况和输出结果。(使用JDK环境,调用javac.exe编译和浏览器解释执行Applet程序) -Familiar with the installation and configuration of the JDK, learn how to write and run a simple Application procedures and Applet (can output a simple greeting message): A. Editplus (or JCreator, Textpad) Environment write a HelloWorld.java procedures, (1) is called in the main method static public void main (String [] args) System.out.println () method, the program outputs a greeting message (2) compile and run the program, observe the operation and output results. (Using JDK environment, call the javac.exe and java.exe compile and execute the program) Two. Under Editplus (or JCreator, Textpad) Environment write a HelloWorldApplet.java program. G.drawString (1) public void paint (Graphics g) method call () method, the program outputs a greeting message (2) compile and run the program, observe the operation and output results. (Using JDK environment, to call javac.exe compiled and interpreted by the browser to perform Applets)
Platform: | Size: 2048 | Author: 李瑞 | Hits:

[JSP/JavaJavaB-

Description: 《Java语言程序设计》源代码 很好的JAVA入门的好的代码-*/ import java.awt.Graphics public class HelloToJava extends java.applet.Applet { /** Initialization method that will be called after the applet is loaded * into the browser. */ public String sHello public void init() { // TODO start asynchronous download of heavy resources sHello="欢迎来到Java世界!" } public void paint(Graphics g){ g.drawString(sHello, 50, 50) } // TODO overwrite start(), stop() and destroy() methods }
Platform: | Size: 190464 | Author: 万利 | Hits:

[JSP/JavaJava-languageprogram

Description: Java快速入门Java是美国Sun Microsystems公司于1995年5月正式发布的程序设计语言,它是前身是公司为智能消费类家用电器(如:电视机、电话、闹钟、烤面包机)研究而开发的,直到1993年Web开始在Internet上盛行,开发小组试着将这一技术转移到Web网络上,并获得了空前的成功。- java course import java.awt.Graphics import java.applet.Applet public class Hello2 extends Applet{ public String s public void init(){ s=new String("欢迎你学习Java语言!") } public void paint(Graphics g){ g.drawString(s,50,50) } }
Platform: | Size: 117760 | Author: kaifa | Hits:

[OS programimagefont

Description: C#实现在图片上绘制文字,使用DrawString方法绘制的文字。打开任意一幅图片,然后在文本框中输入任意你想要的文字,点击“绘制文字”按钮,你输入的文字会显示在打开图片的左上角位置。-C# draw the text on the picture, use the DrawString method to draw text. Open any picture, any text you want in the text box and then click on the "Draw Text" button, you enter the text displayed in the open position of the upper-left corner of the picture.
Platform: | Size: 10240 | Author: 吴海军 | Hits:

[OS programhuizhi

Description: C#使用自身的DrawString方法绘制文字,源码简单,示例演示了绘制过程,具体实现思路请参阅源码文件,运行示例程序后,点击“绘制文字”按钮,即可看到由DrawString方法生成的一行文字。-C# uses the DrawString method to draw text, source code example demonstrates the rendering process, specific ideas, please refer to the source file, run the sample program, click on the " Draw Text" button, you can see a line of text generated by the DrawString method.
Platform: | Size: 9216 | Author: 汪秋云 | Hits:

[CSharpdraw

Description: C#使用自身的DrawString方法绘制文字,源码简单,示例演示了绘制过程-C# uses its own DrawString method to draw text, source code simple example demonstrates the rendering process
Platform: | Size: 3072 | Author: 小白 | Hits:

[CSharpimagefont

Description:  C#实现在图片上绘制文字,使用DrawString方法绘制的文字。打开任意一幅图片,然后在文本框中输入任意你想要的文字,点击“绘制文字”按钮,你输入的文字会显示在打开图片的左上角位置。   new Font("宋体", 50), 绘制的字体名称和字号   new SolidBrush(Color.Red)字体的颜色,可自己改-C# implementation to draw text on the picture, use the DrawString method to draw text. Open any one picture, and then in the text box, enter any text you want, click on " Draw Text" button, you enter the text displayed in the upper left corner to open the picture. new Font (" Arial" , 50), rendering the font name and size new SolidBrush (Color.Red) color of the font, you can change their own
Platform: | Size: 12288 | Author: tpudn51 | Hits:

[CSharpdrawfont

Description:  C#使用自身的DrawString方法绘制文字,源码简单,示例演示了绘制过程,具体实现思路请参阅源码文件,运行示例程序后,点击“绘制文字”按钮,即可看到由DrawString方法生成的一行文字。-C# uses its own DrawString method to draw text, source code simple example demonstrates the drawing process, the specific realization of ideas, see source code files, run the sample program, click on " Draw Text" button, you can see by the DrawString method to generate a line of text.
Platform: | Size: 12288 | Author: tpudn54 | Hits:

[CSharpShadowFont

Description: C#实现的字体阴影ShadowFont特效,实现了两种阴影字效果。一种是对文本使用去锯齿的边缘处理,在两个不同的位置绘制文本,形成阴影;另一个是以阴影为线条,构造影线画刷,先画背景再画前景,使用graphics.DrawString来绘制文字的阴影-C# implementation ShadowFont font shadow effects, implements two words shadow effect. One is to use the jagged edges of text processing, in two different locations to draw text, shadows another is the shadow of the line, construct shadow brush, painting the background first and then draw prospects to use graphics.DrawString draw text shadows
Platform: | Size: 8192 | Author: gpudn18 | Hits:

[JSP/Javajfontstext

Description: Java平台字体演示示例,演示不同字体在不同样式和不同字体大小情况下的显示效果。所有的字体都是程序运行平台上的字体。具体的绘制过程中用到了Graphics2D 类中的drawString()方法,用于绘制文本。-Java platform font demo, demo different fonts in different styles and different font sizes for the display case. All fonts are fonts program running on the platform. Concrete used in the process of drawing Graphics2D class drawString () method is used to draw the text.
Platform: | Size: 23552 | Author: jpudn70 | Hits:

[OS programPrintExample

Description: 自己学习时写的VB.NET程序,试验了drawstring、drawline方法的各种用法。-this program is writen during my learning of VB.NET,in which some method of using "drawstring""drawline" is presented.
Platform: | Size: 134144 | Author: 智鑫 | Hits:

[androidDrawString

Description: 一个在线交互的安卓画板,安卓端,利用socket和服务器通信-An online interactive sketchpad Andrews, Andrews end, the use of socket communications and server
Platform: | Size: 5447680 | Author: Yu Jingcheng | Hits:
« 12 »

CodeBus www.codebus.net