r6.dvi

Similar documents
r3.dvi

r8.dvi

AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import import java.awt.* ; // AWT Graphics import java.awt.graphics; // AWT Gra

AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import import java.awt.* ; // AWT Graphics import java.awt.graphics; // AWT Gra

Java演習(4) -- 変数と型 --

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

Java演習(6) -- 条件分岐 --

r4.dvi

r3.dvi

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

Java 2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q 2.

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

アプレットの作成

r2.dvi

( ) p.1 x y y = ( x ) 1 γ γ = filtergamma.java import java.applet.*; public class filtergamma extends Applet{ Image img; Image new_img; publi

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

2 p.2 2 Java > javac Hello0.java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.j

Java演習(2) -- 簡単なプログラム --

Applet java.lang.object java.awt.component java.awt.container java.awt.panel java.applet.applet

untitled

任意の加算プログラム

r2.dvi

< F2D89BA8EE882C E6A7464>

< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

< F2D A839382CC906A2E6A7464>

text_13.dvi

入門Java解答.doc

< F2D E E6A7464>

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C

K227 Java 2

新・明解Java入門

Microsoft PowerPoint prog1_doc2x.pptx

Java学習教材


Local variable x y i paint public class Sample extends Applet { public void paint( Graphics gc ) { int x, y;... int i=10 ; while ( i < 100 ) {... i +=

Microsoft PowerPoint prog1_doc2.pptx

10K pdf

< F2D82518CC282CC D2E6A7464>

r4.dvi

表示の更新もそういた作業のひとつに当たる スレッドの使用アニメーション アニメーションやシミュレーションなどは画面の更新が一定のタイミングで行われていく この連続した画面の更新をスレッドを利用して行う しかし paint() メソッドを直接呼び出して表示を更新することはできない その理由


< F2D834F838C A815B A CC>

< F2D B838A835882CC8CF68EAE2E6A7464>

< F2D F B834E2E6A7464>

tn_soturon_sjis.dvi

r14.dvi

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else , 2 { } boolean true false 2 boolean Gr

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

< F2D B825082CC96E291E82E6A7464>

Java updated

< F2D A838B838D96402E6A7464>

解きながら学ぶJava入門編

piyo0702a.rtfd

< F2D82B682E182F182AF82F12E6A7464>

I. (i) Java? (A). 2Apples (B). Vitamin-C (C). Peach21 (D). Pine_Apple (ii) Java? (A). Java (B). Java (C). Java (D). JavaScript Java JavaScript Java (i

KeyListener init addkeylistener addactionlistener addkeylistener addkeylistener( this ); this.addkeylistener( this ); KeyListener public void keytyped

I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A

Java講座

< F2D92DE82E8914B82CC977088D32E6A7464>

r14.dvi

< F2D825282CC947B909482CC A815B83682E6A>

Java講座



Chapter JDK KeyListener keypressed(keyevent e ) keyreleased(keyevent e ) keytyped(keyevent e ) MouseListener mouseclicked(mouseeven

Java演習(9) -- クラスとメソッド --

課題

教材ドットコムオリジナル教材 0から始めるiアフ リ リファレンス i アプリ簡易リファレンス ver i アプリ Java 独自のメソッド (1)iアプリの命令を使えるようにする import com.nttdocomo.ui.*; (2) 乱数を使う import java.u

< F2D8EA CE909482CC92EA82852E6A7464>

Safari AppletViewer Web HTML Netscape Web Web 15-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web up

課題

上達Java解答.doc

II Java :30 12:00 I. I IV II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

Microsoft PowerPoint ppt

I. (i) Foo public (A). javac Foo.java java Foo.class (C). javac Foo java Foo (ii)? (B). javac Foo.java java Foo (D). javac Foo java Foo.class (A). Jav

JAVA入門

untitled

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java

2

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mousec

Java講座

I java A

Java言語 第1回

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

アプレットⅠ

r1.dvi

< F2D BCA82CC978E89BA82CC8EC08CB12E6A7464>

Microsoft PowerPoint - prog10.ppt

JavaプログラミングⅠ

2.2 Java C main Java main 2 C 6 C Java 3 C Java ( ) G101Hello.java G101Hello main G101Hello.java /* G101Hello */ class G101Hello { /* main */ public s

Microsoft PowerPoint - prog10.ppt

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

Transcription:

I 2005 6 2005.11.18 1 1.1 2 Hello, World public class r5ex2 extends JApplet { Font fn = new Font("Helvetica", Font.BOLD, 24); g2.setfont(fn); for(int i = 0; i < 10; ++i) { g2.setpaint(new Color(100+i*5, 0, 255-i*20)); g2.drawstring("hello, World", 30+3*i, 30+7*i); g2.setpaint(new Color(255, 0, 0)); g2.fillrect(100, 100, 50, 50); g2.setpaint(new Color(0, 255, 0)); g2.filloval(150, 150, 100, 50); Color.red Color.green Color ( ) (Color ) API 1.2 : Graphics ( ) 1

(0, 0) X Y imac 1000 800 HTML ( 300 200 ) (x,y) (x,y) fillrect() filloval() 1: fillrect filloval 1.3 : Graphics (= ) drawrect() fillrect() API g.fillrect(x, y,, ); (x, y) ( 1 ) drawoval() filloval() g.filloval(x, y,, ); ( 1 ) fillpolygon() 2 g.fillpolygon(a, b, n); n 2 n i (a[i], b[i]) API 1.4 3 sin 2 GeneralPath translate() scale() import java.awt.geom.*; public class r5ex3 extends JApplet { GeneralPath p1 = new GeneralPath(); 2

for(int i = -15; i <= 15; ++i) { float x = i * 0.1f; float y = (float)math.sin(3*x); if(i == -15) p1.moveto(x, y); else p1.lineto(x, y); GeneralPath p2 = new GeneralPath(); p2.moveto(0f, 0f); for(int i = 0; i < 100; ++i) { float r = 0.01f * i, theta = 0.2f * i; p2.lineto(r*(float)math.cos(theta), r*(float)math.sin(theta)); g2.setstroke(new BasicStroke(0.03f)); g2.translate(150f, 100f); g2.scale(100f, -100f); g2.setpaint(new Color(100, 0, 255)); g2.draw(p1); g2.setpaint(new Color(250, 100, 0)); g2.draw(p2); 1.5 4 20 X/Y public class r5ex4 extends JApplet { int[] xpts = new int[20]; int[] ypts = new int[20]; int[] width = new int[20]; int[] height = new int[20]; Color[] cols = new Color[20]; public void init() { for(int i = 0; i < 20; ++i) { xpts[i] = (int)(math.random()*150); ypts[i] = (int)(math.random()*250); width[i] = (int)(math.random()*100+10); height[i] = (int)(math.random()*100+10); cols[i] = new Color((int)(255*Math.random()), (int)(255*math.random()), (int)(255*math.random())); for(int i = 0; i < 20; ++i) { g2.setpaint(cols[i]); g2.fillrect(xpts[i], ypts[i], width[i], height[i]); 3

paint() 2 (API ) ( ) ( ) ( Rect Rect r1 = new Rect(, X, Y,, ); //... r1.draw(graphics2d ); // ( ) ( ) new XXX(...) ( ) 1 draw() ( ) ( ) draw() Graphics2D paint() Rect public public class R6Sample1 extends JApplet { Rect r1 = new Rect(Color.red, 100, 100, 80, 60); Rect r2 = new Rect(new Color(0.5f, 1f, 0f, 0.7f), 150, 120, 60, 90); r1.draw(g2); r2.draw(g2); class Rect { Paint pat; int xpos, ypos, width, height; public Rect(Paint p, int x, int y, int w, int h) { pat = p; xpos = x; ypos = y; width = w; height = h; public void draw(graphics2d g) { g.setpaint(pat); g.fillrect(xpos-width/2, ypos-height/2, width, height); 2 (Rect ) paint() 4

RGB API Rect Rect ( ) X/Y ( ) ( ) public Rect(...)... new Rect(...) draw() Graphics g setcolor() fillrect() ( Graphics ) Rect Rect HTML 1 <html> <head><title>sample</title></head> <body> <h1>sample</h1> <applet code="r6sample1.class" width=300 height=200></applet> </body> </html> 1 1 3 2 1 a. Circle 2 public Circle(Paint p, int x, int y, int r) --- public void draw(graphics2d g) --- X/Y b. Triangle 2 public Triangle(Paint p, int x0, int y0, int x1, int y1, int x2, int y2) --- public void draw(graphics2d g) --- 3 c. 1 Flag 2 public Flag(Paint p1, Paint p2, int x, int y, int r) --- public void draw(graphics2d g) --- ( ) X/Y ( ) 3 Java [...], 1 5

(x,y) c1 c2 3*r r 4*r 2: ::= ::= [public] class [extends ] { ( [= ]; ) ::= (, ) [throws ] { ::= public static final ::= [] void ::= boolean byte char int long float double ::= ::= [= ]; ; if( ) [else ] while( ) for([ =] ; ; ) { break; continue; ::= [ ] new (, ) new [ ]. (, ). (, ).. ( ) ::= [l] [f] "..."... true false null ; 1 ( a = b; = ( ) ( new new new ( ) (true false) null l long int f float double 4 g.fillrect(...) g.filloval(...) 1 ( Jack-o-lantern ) import java.applet.applet; 6

public class R6Sample2 extends Applet { Jack j1 = new Jack(new Color(80, 120, 200), new Color(40, 80, 0, 200), 100, 100, 60); Jack j2 = new Jack(new Color(200,180,50,200),new Color(240, 200, 90), 180, 120, 50); j1.draw(g2); j2.draw(g2); class Jack { Circle cir; Triangle eyel, eyer, mouth; public Jack(Paint p1, Paint p2, int x, int y, int r) { int u = r / 4; cir = new Circle(p1, x, y, r); eyel = new Triangle(p2, x-3*u, y-u, x-u, y-u, x-2*u, y-2*u); eyer = new Triangle(p2, x+3*u, y-u, x+u, y-u, x+2*u, y-2*u); mouth = new Triangle(p2, x-u, y+2*u, x+u, y+2*u, x, y+3*u); public void draw(graphics2d g) { cir.draw(g); eyel.draw(g); eyer.draw(g); mouth.draw(g); class Circle { Paint pat; int xpos, ypos, rad; public Circle(Paint p, int x, int y, int r) { pat = p; xpos = x; ypos = y; rad = r; public void draw(graphics2d g) { g.setpaint(pat); g.filloval(xpos-rad, ypos-rad, 2*rad, 2*rad); class Triangle { Paint pat; int[] xpts, ypts; public Triangle(Paint p, int x0, int y0, int x1, int y1, int x2, int y2) { pat = p; xpts = new int[]{x0,x1,x2; ypts = new int[]{y0,y1,y2; public void draw(graphics2d g) { g.setpaint(pat); g.fillpolygon(xpts, ypts, 3); Jack 1 3 7

new int[]{,,... 3!: 5 (Image) Java Java 2 BufferedImage java.awt.image import BufferedImage 3 new BufferedImage(,, ) TYPE INT ARGB ( BufferedImage ) API 2 getgraphics() setrgb(x, y, p) (x, y) p TYPE INT ARGB p 32 8 ( 0 255 ) Color getrgb() Graphics drawimage() g.drawimage(img, x, y, null) (x, y) g.drawimage(img, x, y, w, h, null) (x, y) w h 2 BufferedImage null import java.awt.image.*; public class R6Sample3 extends JApplet { BufferedImage im = new BufferedImage(40, 40, BufferedImage.TYPE_INT_ARGB); public void init() { for(int x = 0; x < 40; ++x) { for(int y = 0; y < 40; ++y) { int r = (int)(256*math.random()); 8

int g = (int)(256*math.random()); int b = (int)(256*math.random()); im.setrgb(x, y, new Color(r, g, b, 150).getRGB()); Graphics2D g2 = (Graphics2D)im.getGraphics(); g2.drawline(0, 40, 40, 0); g2.drawimage(im, 10, 10, null); g2.drawimage(im, 30, 30, 200, 200, null); 40x40 init() 1 paint() 5 4 6 Paint Color API Paint Paint (API implements ) 1 Color 1 Paint 2 GradientPaint ( ) TexturePaint 2 ( float ) new GradientPaint(x 1, y 1, c 1, x 2, y 2, c 2 ) true new GradientPaint(x 1, y 1, c 1, x 2, y 2, c 2, true) ( 3) (x, y), w, h Rectangle2D.Float API new TexturePaint(img, new Rectangle2D.Float(x,y,w,h)) 9

(x,y) w h 3: TexturePaint import java.awt.geom.*; import java.awt.image.*; public class R6Sample3 extends JApplet { Rect r0, r1, r2; public void init() { r0 = new Rect(Color.green, 80, 80, 100, 40); BufferedImage im = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D)im.getGraphics(); g2.setpaint(new Color(1f, 0f, 0f, 0.7f)); g2.filloval(0, 0, 20, 20); for(int x = 0; x < 20; ++x) for(int y = 0; y < x; ++y) im.setrgb(x, y, 0x00FFFFFF); TexturePaint tp = new TexturePaint(im, new Rectangle2D.Float(0, 0, 10, 20)); r1 = new Rect(tp, 100, 100, 80, 160); GradientPaint gp = new GradientPaint(90f, 90f, new Color(1f,1f,1f,0.1f), 180f, 180f, Color.blue); r2 = new Rect(gp, 150, 120, 100, 90); r0.draw(g2); r1.draw(g2); r2.draw(g2); class Rect { Paint pat; int xpos, ypos, width, height; public Rect(Paint p, int x, int y, int w, int h) { pat = p; xpos = x; ypos = y; width = w; height = h; public void draw(graphics2d g) { g.setpaint(pat); g.fillrect(xpos-width/2, ypos-height/2, width, height); 10

r0 r1 r2 5 6 ( ) A 6A 2 3 WWW HTML cp1 report6a.html 1. Subject: Report 6A 2. 3. 1 4. 5. Q1. Q2. Q3. B 6B 6 HTML cp1 report6b.html 10 (10:30 ) 1. Subject: Report 6B 2. 3. 4. 5. Q1. / Q2. Q3. 11