1   package fi.jyu.mit.graphics;
2   
3   /**
4    * Luokka jonka avulla voi helposti piirtää kuvioita ruudulle.
5    * Ikkunaan voi lisätä kuvioita, esimerkiksi
6    * <pre>
7    *      window.addLine(0,0,100,100).setColor(Color.RED);
8    *      window.addCircle(0, 0, 1).setColor(Color.RED);
9    *      window.addShape(new Line(0, 0, 10, 10)).setColor(Color.RED);
10   * </pre>
11   * @author Markus Kivioja
12   */
13  public class EasyWindow extends Window implements Easy {
14      
15      private static final long serialVersionUID = 1;
16      
17      /**
18       * Luo uuden ikkunan
19       */
20      public EasyWindow() {
21          super();
22      }
23      
24      /**
25       * Luo uuden ikkunan
26       * @param width ikkunan leveys
27       * @param height ikkunan korkeus
28       */
29      public EasyWindow(int width, int height) {
30          super(width, height);
31      }
32      
33      public Drawable addShape(Drawable shape) {
34          return add(shape);
35      }
36  
37      public Line addLine(double x1, double y1, double x2, double y2) {
38          return (Line)add(new Line(x1, y1, x2, y2));
39      }
40      
41      
42      public Line addLine(double x1, double y1, double z1, double x2, double y2, double z2) {
43          return (Line)add(new Line(x1, y1, z1, x2, y2, z2));
44      }
45      
46  
47      public Circle addCircle(double x, double y, double r) {
48          return (Circle)add(new Circle(x, y, r));
49      }
50      
51      public Circle addCircle(double x, double y, double z, double r) {
52          return (Circle)add(new Circle(x, y, z, r));
53      }
54      
55  
56      public Polygon addPolygon(double[] xpoints, double[] ypoints) {
57          return (Polygon)add(new Polygon(xpoints, ypoints));
58      }
59  
60      public Polygon addPolygon(double[][] points) {
61          return (Polygon)add(new Polygon(points));
62      }
63      
64      public FillPolygon addFillPolygon(double[] xpoints, double[] ypoints) {
65          return (FillPolygon)add(new FillPolygon(xpoints, ypoints));
66      }
67  
68      public FillPolygon addFillPolygon(double[][] points) {
69          return (FillPolygon)add(new FillPolygon(points));
70      }
71  
72      public Axis addAxis(double xLength, double yLength, double zLength) {
73          return (Axis)add(new Axis(xLength, yLength, zLength));
74      }
75  
76      public Axis addAxis(double xLength, double yLength, double zLength, double x, double y, double z) {
77          return (Axis)add(new Axis(xLength, yLength, zLength, x, y, z));
78      }
79  }
80