Location:
Search - drawline java
Search list
Description: java写的围棋游戏小程序
开发思路
调用applet类作为父类。在init事件中调用Qipan类,作出panel,上加控制用控件。在paint事件里调用drawline函数画棋盘,注册鼠标动作。鼠标单击位置上用drawoval画出棋子,
事件处理过程
A。重新开始
B。选择尺寸
C。悔棋事件
D。前进事件
有三个文件Weiqi.java,Qizi.java,Qipan.java
Platform: |
Size: 4556 |
Author: 常玉香 |
Hits:
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:
Description: 用bresenham,dda,midpoint三种算法实现画直线,鼠标可在屏幕上取点画直线-With bresenham, dda, midpoint algorithm painting of three straight, the mouse can check on the screen straight stipple
Platform: |
Size: 18432 |
Author: 刘提 |
Hits:
Description: java写的围棋游戏小程序
开发思路
调用applet类作为父类。在init事件中调用Qipan类,作出panel,上加控制用控件。在paint事件里调用drawline函数画棋盘,注册鼠标动作。鼠标单击位置上用drawoval画出棋子,
事件处理过程
A。重新开始
B。选择尺寸
C。悔棋事件
D。前进事件
有三个文件Weiqi.java,Qizi.java,Qipan.java
-Go write java applet game called applet type of development as a parent. Onload event in the init category Qipan make panel, adding controlling controls. Call in the paint incident drawLine function painting board, registered mouse movements. Mouse click position drawoval draw with a pawn, event processing A. A fresh start B. Select Size C.悔棋incident D. There are three documents forward events Weiqi.java, Qizi.java, Qipan.java
Platform: |
Size: 4096 |
Author: 常玉香 |
Hits:
Description: (计算机图形学)分别用Bresenham, DDA及中点法实现画线段的基本方法-(Computer graphics), respectively Bresenham, DDA and the mid-point method to achieve the basic method of drawing line segments
Platform: |
Size: 13312 |
Author: Zhong |
Hits:
Description: java中大部分对图形、文本、图像的操作方法都定义在Graphics类中,所以此次实验使用的方法如Color(int r, int g,int b), setColor(Color c),drawline(int x1,int y1,int x2,int y2)等都来自Graphics类中,此外对文本和字体的处理还用到了Font类中的 new Font(“字体名”,字体风格,字体大小),setFont(Font f)等方法;-Most of java on the graphics, text, images, methods of operation defined in the Graphics class, so the experimental methods such as the use of Color (int r, int g, int b), setColor (Color c), drawline (int x1 , int y1, int x2, int y2) are from the Graphics class, in addition to text and font handling is also used in the Font class of new Font ( Font name , font style, font size), setFont (Font f) and other methods
Platform: |
Size: 31744 |
Author: 若儿 |
Hits:
Description: 基于nasa的worldwind的3D导航界面的设定画线程序,利用鼠标点击,显示规划的路线-Nasa' s worldwind-based 3D navigation interface of the set procedures for drawing a line using the mouse click, indicating the route planning
Platform: |
Size: 1024 |
Author: xulei |
Hits:
Description: 一个Java Applet程序,该程序使用drawLine方法绘制一个5x9的网格
-A Java Applet program that use drawLine method to draw a 5x9 grid
Platform: |
Size: 1024 |
Author: chenmin |
Hits:
Description: JAVA绘制线条示例程序,绘制动态线条-java draw line
Platform: |
Size: 10240 |
Author: 刘 |
Hits: