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

Search list

[GUI DevelopFontMetrics

Description: 本案例采用Java Applet 实现文字颜色的不停改变,并产生波浪效果-this case using Java Applet text color has been changed, and generate waves results
Platform: | Size: 3600 | Author: 王伟 | Hits:

[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:

[GUI DevelopFontMetrics

Description: 本案例采用Java Applet 实现文字颜色的不停改变,并产生波浪效果-this case using Java Applet text color has been changed, and generate waves results
Platform: | Size: 3072 | Author: 王伟 | Hits:

[JSP/JavaJavaShadow

Description: Java阴影文字,源代码注释:实现文字运动的线程、文字颜色、背景颜色与阴影颜色、字体高度,运动速度和基线、实现跳动的Image对象、显示字体的FontMetrics对象、/根据Applet尺寸设置文字高度、根据文字宽度调整其高度、设置默认阴影颜色、实例化运动文字线程、线程休眠,即跳动间隔时间-Java shadow text, source code comments: the thread of text movement, text color, background color, and shadow color, font, height, movement speed and baseline, beating Image object display font FontMetrics object/the Applet size set text height , adjust its height according to text width, set the default shadow color, the instantiated movement text thread, thread to sleep, that beating the interval
Platform: | Size: 9216 | Author: pudn1377 | Hits:

[JSP/JavaJavaWaveText

Description: Java波浪文字,一个利用Java处理字符的实例,可以设置运动方向参数,显示文本的字符数组,高速文本颜色,显示字体的 FontMetrics对象,得到Graphics实例,得到Image实例,填充颜色数组数据,初始化颜色数组。-Java wavy text, an instance of the use of Java processing characters, you can set the direction of motion parameters, and displays the text character array, high-speed text color, font FontMetrics object Graphics instance Image instance, fill color array data, initialization an array of colors.
Platform: | Size: 16384 | Author: pudn1385 | Hits:

[Software Engineeringjava-basis

Description: Eclipse下运行java Swarm以及jheatbugs例子的图文攻略 看了很多网上的说明,好像运行都有点问题,自己摸索了下,参照Swarm网站的How to Set Up Java Swarm in Eclipse ------------------- CLSFractal: Thread mouseClicked BlankArea:mouseEventDemo mousePressed Myblack: Graphics Color MouseEventDemo:MouseListener barCha:FontMetrics solid Color-Eclipse run java Swarm and jheatbugs read a lot of examples of graphic Raiders online description, it seems to run a little problem, their own way, the reference to the Swarm website How to Set Up Java Swarm in Eclipse------------------- CLSFractal: Thread mouseClicked BlankArea: mouseEventDemo mousePressed Myblack: Graphics Color MouseEventDemo: MouseListener barCha: FontMetrics solid Color
Platform: | Size: 195584 | Author: xx | Hits:

CodeBus www.codebus.net