예제 #1
0
  public static void main(String[] args) {

    DrawingTablet dt = new DrawingTablet(100, 100);

    DrawableCircle dc = new DrawableCircle(50, 50, 30);
    dc.setColor(Color.yellow);
    dt.drawShape(dc);

    DrawablePoint dp = new DrawablePoint(40, 50);
    dp.setColor(Color.red);
    dt.drawShape(dp);
    for (int i = 1; i <= 5; i++) {
      dp.translate(5, 0);
      dt.drawShape(dp);
    }

    DrawableString ds = new DrawableString(30, 45, "Testing.");
    dt.drawShape(ds);

    DrawableLine newLine = new DrawableLine(15, 16, 55, 60);
    newLine.setColor(Color.blue);
    dt.drawShape(newLine);

    DrawableRectangle newRect = new DrawableRectangle(30, 35, 25, 30);
    newRect.setColor(Color.green);
    dt.drawShape(newRect);

    DrawableRectangle newSqr = new DrawableRectangle(65, 70, 55, 55);
    newSqr.setColor(Color.pink);
    dt.drawShape(newSqr);

    dt.show();
  }
예제 #2
0
  /**
   * a main method to draw my picture
   *
   * @param args
   */
  public static void main(String[] args) {

    DrawingTablet drawTablet = new DrawingTablet(100, 100);

    DrawableCircle drawCircle = new DrawableCircle(20, 20, 20);
    drawCircle.setColor(Color.yellow);
    drawTablet.drawShape(drawCircle);

    /*DrawablePoint dp = new DrawablePoint(40,50);
    dp.setColor(Color.red);
    dt.drawShape(dp);
    for (int i=1; i <=5; i++) {
        dp.translate(5,0);
        dt.drawShape(dp);
    }*/

    DrawableString drawString = new DrawableString(30, 90, "My picture");
    drawTablet.drawShape(drawString);

    /*DrawableLine newLine = new DrawableLine(15, 16, 55,60);
    newLine.setColor(Color.blue);
    dt.drawShape(newLine);*/

    DrawableRectangle newRect = new DrawableRectangle(41, 50, 50, 25);
    newRect.setColor(Color.green);
    drawTablet.drawShape(newRect);

    DrawableRectangle newRectg = new DrawableRectangle(45, 55, 15, 20);
    newRectg.setColor(Color.pink);
    drawTablet.drawShape(newRectg);

    DrawableRectangle newSqr = new DrawableRectangle(65, 55, 15, 15);
    newSqr.setColor(Color.pink);
    drawTablet.drawShape(newSqr);

    DrawableLine newLine = new DrawableLine(85, 50, 95, 50);
    newLine.setColor(Color.blue);
    drawTablet.drawShape(newLine);
    for (int i = 1; i <= 25; i++) {
      newLine.translate(-1, -1);
      drawTablet.drawShape(newLine);
    }

    DrawableLine newLine1 = new DrawableLine(35, 50, 45, 50);
    newLine1.setColor(Color.blue);
    drawTablet.drawShape(newLine1);
    for (int i = 1; i <= 25; i++) {
      newLine1.translate(+1, -1);
      drawTablet.drawShape(newLine1);
    }
    drawTablet.show();

    drawTablet.write("keyframe2.dat");
  }
예제 #3
0
 /**
  * test the main method for lab part 2
  *
  * @param args
  * @throws IOException
  */
 public static void main(String[] args) throws IOException {
   FileOutputStream output = new FileOutputStream("aCircle.txt");
   DataOutputStream dos = new DataOutputStream(output);
   DrawableCircle thisCircle = new DrawableCircle(15, 20, 25);
   thisCircle.write(dos);
   FileInputStream input = new FileInputStream("aCircle.txt");
   DataInputStream dis = new DataInputStream(input);
   dis.readLine();
   DrawableCircle copy = new DrawableCircle(dis);
   System.out.println(copy.toString());
   System.out.println(thisCircle.toString());
   dos.close();
 }
예제 #4
0
 public DrawableCircle(DrawableCircle obj0, DrawableCircle obj1, double interp) {
   super(obj0, obj1, interp);
   double theRadius = (1.0 - interp) * obj0.getRadius() + (interp) * obj1.getRadius();
   radius = (int) theRadius;
 }