1 package sample;
2
3 import java.awt.Color;
4 import fi.jyu.mit.graphics.*;
5
6
10 public class UkkoSample {
11
12
16 public static class Ukko extends DrawableCollection {
17 private final Drawable kasi;
18 private final Drawable jalka;
19
20
25 public Ukko(double dx,double dy) {
26 super();
27 move(dx,dy,0.0);
28 add(new Circle(0,0,20));
29 add(new Line(0,0,0,100)).move(0,20,0);
30 kasi = add(new Line(0,0,0,90)).move(0,30,0).rotate(Axis.Z,30);
31 add(new Line(0,0,0, 90)).move(0, 30,0).rotate(Axis.Z,-130);
32 add(new Line(0,0,0,100)).move(0,120,0).rotate(Axis.Z, 25);
33 jalka = add(new Line(0,0,0,100)).move(0,120,0).rotate(Axis.Z, -25);
34 }
35
36
44 public Ukko(double dx,double dy, double s, double deg, Color color) {
45 this(dx,dy);
46 if ( s != 1 ) scale(s,s,s);
47 if ( deg != 0 ) rotate(Axis.Z,deg);
48 if ( color != null ) setColor(color);
49 }
50
51
52
55 public Drawable getKasi() { return kasi; }
56
57
60 public Drawable getJalka() { return jalka; }
61
62 }
63
64
67 @SuppressWarnings("unused")
68 public static void main(String[] args) {
69 Window window = new Window();
70 window.add(new Ukko(60,60));
71 Ukko pukko = new Ukko(160,60,0.5,0,Color.RED); window.add(pukko);
72 Drawable oukko = window.add(new Ukko(260,60,0.3,0,Color.ORANGE));
73 window.showWindow();
74 Ukko ukko = new Ukko(260,180,0.3,0,null); window.add(ukko);
75
76 new Rotator(ukko,Axis.Z,3,200);
77 new Rotator(ukko.getKasi(),Axis.Z,5,230);
78 new Mover(oukko,2,3,0,300);
79 new Rotator(oukko,Axis.Y,10,230);
80
81
83 new MouseFollower(window.getPanel(),pukko,0,0,0,true);
85
86 window.setTitle("Ukot heiluu");
88
89 }
90
91 }
92