コード例 #1
0
ファイル: RobbyPathPrediction.java プロジェクト: Brae/Robby
 // This is where the shit really goes down
 public static void moveThroughMaze(Room room, Robot robby, Picture pic) {
   while (!(robby.get_xpos() == destX) || !(robby.get_ypos() == destY)) {
     if (destX > robby.get_xpos()) {
       robby.face_right();
       if (robby.ahead_is_colour(room, Room.WHITE)) {
         robby.move();
         pic.draw(room, robby);
       } else {
         if (destY > robby.get_ypos()) {
           robby.face_up();
           if (!robby.ahead_is_colour(room, Room.WHITE)) {
             robby.face_left();
             if (!robby.ahead_is_colour(room, Room.WHITE)) {
               robby.face_down();
               robby.move();
               pic.draw(room, robby);
             } else {
               robby.move();
               pic.draw(room, robby);
             }
           } else {
             robby.move();
             pic.draw(room, robby);
           }
         }
       }
     } else {
       if (destY > robby.get_ypos()) {
         robby.face_up();
       }
     }
   }
   System.out.println("Success!");
 }
コード例 #2
0
ファイル: Event.java プロジェクト: babybook/Babybook
  @Override
  public String toXML() {
    StringBuffer buffer = new StringBuffer();

    buffer.append("<event>");
    buffer.append(super.toXML());
    buffer.append("<name>" + name + "</name>");
    buffer.append("<location>" + location + "</location>");
    buffer.append("<type>" + type + "</type>");
    buffer.append("<other>" + other + "</other>");
    buffer.append("<description>" + description + "</description>");
    buffer.append("<dateTime>" + Utilities.getISODate(this.dateTime) + "</dateTime>");
    buffer.append("<pictures>");
    for (Picture picture : pictures) {
      buffer.append(picture.toXML());
    }
    buffer.append("</pictures>");
    buffer.append("<children>");
    for (Person child : children) {
      buffer.append(child.toXML("child"));
    }
    buffer.append("</children>");
    buffer.append("</event>");

    return buffer.toString();
  }
コード例 #3
0
 /** Test Main. It will explore Splatoon! */
 public static void main(String args[]) {
   // Picture pix = new Picture("snowman.jpg");
   Picture pix = new Picture("splatoon.jpg");
   Picture smallPic = pix.scale(.5, .48);
   smallPic.explore();
   smallPic.write("smallSplatoon.jpg");
 }
コード例 #4
0
ファイル: WholeUnitTest.java プロジェクト: chaikens/gradingCS
 public static void main(String[] a) {
   Picture p = new Picture("/home/seth/black.jpg");
   p.vignette();
   p.show();
   Scanner sc = new Scanner(System.in);
   String n = sc.next();
   System.exit(0);
 }
コード例 #5
0
ファイル: Contact.java プロジェクト: blackat/design-patterns
 @Override
 public String toString() {
   if (picture.getName() == null) {
     return "picture is going to be retrieved...";
   } else {
     return picture.getFormat() + " " + picture.getName() + " " + new String(picture.getImage());
   }
 }
コード例 #6
0
ファイル: MemoryCard.java プロジェクト: susieagerholm/java
 /** Return all the pictures with a given resolution on width. @ param List<Picture> */
 public List<Picture> getAll(int wResolution) {
   List result = new ArrayList();
   for (Picture p : pictures) {
     if (p.getWResolution() == wResolution) {
       result.add(p);
     }
   }
   return result;
 }
コード例 #7
0
 /** Method to test the collage method */
 public static void testCollage() {
   Picture canvas = new Picture(850, 1300);
   // Picture beach = new Picture("beach.jpg");
   // beach.sepia();
   // beach.explore();
   canvas.createCollage();
   canvas.explore();
   canvas.write("rarePepes.jpg");
 }
コード例 #8
0
ファイル: Lab5A.java プロジェクト: gsyncer1/Classwork
  public static void main(String[] args) {
    FileChooser.setMediaPath("/home/linux/ieng6/cs8w/cs8wfs/Desktop/mediasources/");

    Picture input1 = new Picture("bird1.jpg");
    input1.explore();

    Picture redBird = input1.greenToRed();
    redBird.show();
  }
コード例 #9
0
 public static void main(String[] args) {
   Picture p = new Picture(FileChooser.getMediaPath("horse.jpg"));
   Graphics g = p.getGraphics();
   Point ul = new Point(68, 24);
   Point te = new Point(182, 123);
   String message = "This is a test." + "  Of a message with more than one line in it.";
   SpeechBalloon balloon = new SpeechBalloon(ul, 200, te, message);
   balloon.draw(g);
   p.show();
 }
コード例 #10
0
 public SeamCarver(Picture picture) {
   this.picture = new Picture(picture);
   energy = new double[picture.width()][picture.height()];
   parent = new int[picture.width()][picture.height()];
   for (int y = 0; y < height(); y++) {
     for (int x = 0; x < width(); x++) {
       energy[x][y] = energy(x, y);
     }
   }
 }
コード例 #11
0
  public Picture getPicture(Picture picture) {

    for (Picture p : this.pictures) {
      if (p.equals(picture)) {
        return p;
      }
    }

    return null;
  }
コード例 #12
0
  public Picture getMainPic() {

    for (Picture p : this.pictures) {
      if (p.getMain()) {
        return p;
      }
    }

    return null;
  }
コード例 #13
0
  public static void showGallery(Long id, String name) {
    notFoundIfNull(id);
    Gallery gallery = Gallery.findById(id);
    notFoundIfNull(gallery);

    List<Picture> pictures = gallery.getPictures();
    List<ImageView> images = new ArrayList<ImageView>();
    for (Picture picture : pictures) images.add(picture.toImageView());

    render("Application/gallery.html", images, gallery);
  }
コード例 #14
0
    public SampleView(Context context) {
      super(context);
      setFocusable(true);
      setFocusableInTouchMode(true);

      mPicture = new Picture();
      drawSomething(mPicture.beginRecording(200, 100));
      mPicture.endRecording();

      mDrawable = new PictureDrawable(mPicture);
    }
コード例 #15
0
 /**
  * The energy of pixel (x, y) is Δx^2(x, y) + Δy^2(x, y)
  *
  * @param x The pixel at column x
  * @param y The pixel at column y
  * @return The energy of pixel at column x and row y in current picture
  */
 public double energy(int x, int y) {
   if (x < 0 || x > width() - 1 || y < 0 || y > height() - 1) {
     throw new IndexOutOfBoundsException();
   }
   if (x == 0 || x == width() - 1 || y == 0 || y == height() - 1) {
     return MAX_ENERGY;
   }
   double xDiff = gradient(picture.get(x - 1, y), picture.get(x + 1, y));
   double yDiff = gradient(picture.get(x, y - 1), picture.get(x, y + 1));
   return xDiff + yDiff;
 }
コード例 #16
0
ファイル: Test3.java プロジェクト: alekseym/maimage
  public static void main(String[] args) {

    System.out.println("Test3: ");

    Picture pic = new Picture();
    pic.loadFromFile("in.txt");

    pic.setValue(0, 0, 123);
    if (pic.getValue(0, 0) == 123) System.out.println("OK");
    else System.out.println("Fail");
  }
コード例 #17
0
  public static void main(String[] args) {
    Picture inputImg = new Picture(args[0]);
    System.out.printf("image is %d columns by %d rows\n", inputImg.width(), inputImg.height());
    inputImg.show();
    SeamCarver sc = new SeamCarver(inputImg);

    System.out.printf("Displaying horizontal seam calculated.\n");
    showHorizontalSeam(sc);

    System.out.printf("Displaying vertical seam calculated.\n");
    showVerticalSeam(sc);
  }
コード例 #18
0
  public SeamCarver(Picture picture) {
    // create a seam carver object based on the given picture
    int picWidth = picture.width();
    int picHeight = picture.height();
    currentPicture = picture;
    pixelColor = new Color[picWidth][picHeight];

    for (int i = 0; i < picHeight; i++) {
      for (int j = 0; j < picWidth; j++) {
        pixelColor[j][i] = picture.get(j, i);
      }
    }
  }
コード例 #19
0
ファイル: RobbyPathPrediction.java プロジェクト: Brae/Robby
  public static void main(String[] args) {
    Room room = new Room(8);
    Robot robby = new Robot();
    Picture pic = new Picture(room, robby);
    pic.draw(room, robby);
    printCoords(robby);

    // Set end point
    setDestination(room);

    // Start solving
    // moveThroughMaze(room,robby,pic);
    aStar(room, robby, pic);
  }
コード例 #20
0
ファイル: Picture.java プロジェクト: penny2luan/test
  /* Main method for testing - each class in Java can have a main
   * method
   */
  public static void main(String[] args) {
    Picture desert = new Picture("Desert.jpg");
    Picture koala = new Picture("Koala.jpg");
    //    beach.explore();
    //    beach.zeroBlue();
    //    desert.chromakey(koala);
    //    desert.sepia(25, 3);
    koala.sepia();
    //    desert.encode("ABCDEFGHIJKLMNOPasdfgwe6");
    //    System.out.println(desert.decode());

    //    desert.explore();
    koala.explore();
  }
コード例 #21
0
ファイル: Picture.java プロジェクト: phroa/computerscience
 /** Method to create a collage of several pictures */
 public void createCollage() {
   Picture flower1 = new Picture("flower1.jpg");
   Picture flower2 = new Picture("flower2.jpg");
   this.copy(flower1, 0, 0);
   this.copy(flower2, 100, 0);
   this.copy(flower1, 200, 0);
   Picture flowerNoBlue = new Picture(flower2);
   flowerNoBlue.zeroBlue();
   this.copy(flowerNoBlue, 300, 0);
   this.copy(flower1, 400, 0);
   this.copy(flower2, 500, 0);
   this.mirrorVertical();
   this.write("collage.jpg");
 }
コード例 #22
0
ファイル: GraphicExporter.java プロジェクト: and146/SPLAT
 public void exportGraphic(Picture picture, OutputStream out) throws IOException {
   int width = picture.getPictureWidth();
   int height = picture.getPictureHeight();
   Document doc = new Document(new com.lowagie.text.Rectangle(width, height));
   try {
     PdfWriter pWriter = PdfWriter.getInstance(doc, out);
     doc.open();
     Graphics2D g = pWriter.getDirectContent().createGraphics(width, height);
     picture.paintPicture(g);
     g.dispose();
     doc.close();
   } catch (DocumentException e) {
     throw (IOException) new IOException(e.getMessage()).initCause(e);
   }
 }
コード例 #23
0
ファイル: ImageData.java プロジェクト: jschear/AnimotoCrop
  /* Create a Picture object from image data
   * in a 2D array of ints.  This is primarily
   * a helper method for show() and save(),
   * but is declared public because it is
   * useful in its own right.
   */
  public static Picture getPicture(int[][] img) {
    if (img == null) return null;
    if (img.length == 0) return null;
    if (img[0].length == 0) return null;

    Picture p = new Picture(img[0].length, img.length);

    for (int row = 0; row < img.length; row++) {
      for (int col = 0; col < img[0].length; col++) {
        p.set(col, row, new java.awt.Color(img[row][col]));
      }
    }

    return p;
  }
コード例 #24
0
 public void cropAndCopy(
     Picture sourcePicture,
     int startSourceRow,
     int endSourceRow,
     int startSourceCol,
     int endSourceCol,
     int startDestRow,
     int startDestCol) {
   Pixel leftPixel = null;
   Pixel rightPixel = null;
   Pixel[][] pixels = this.getPixels2D();
   Color rightColor = null;
   Pixel[][] fromPixels = sourcePicture.getPixels2D();
   Pixel[][] toPixels = this.getPixels2D();
   Pixel fromPixel = null;
   Pixel toPixel = null;
   for (int fromRow = startSourceRow, toRow = endSourceRow;
       fromRow < fromPixels.length && toRow < toPixels.length;
       fromRow++, toRow++) {
     for (int fromCol = startSourceCol, toCol = endSourceCol;
         fromCol < fromPixels[0].length && toCol < toPixels[0].length;
         fromCol++, toCol++) {
       fromPixel = fromPixels[fromRow][fromCol];
       toPixel = toPixels[toRow][toCol];
       toPixel.setColor(fromPixel.getColor());
     }
   }
 }
コード例 #25
0
ファイル: Picture.java プロジェクト: penny2luan/test
 /**
  * Method to replace blue pixels with pixels from the second picture.
  *
  * @param second picture to replace blue pixels with
  */
 public void chromakey(Picture second) {
   Pixel[][] pixels = this.getPixels2D();
   Pixel[][] pixels2 = second.getPixels2D();
   for (int row = 0; row < pixels.length; row++)
     for (int col = 0; col < pixels[0].length; col++)
       if (pixels[row][col].getColor().getBlue() >= 200)
         pixels[row][col].setColor(pixels2[row][col].getColor());
 }
コード例 #26
0
  /**
   * Method to create a new picture by scaling the current picture by the given x and y factors
   *
   * @param xFactor the amount to scale in x
   * @param yFactor the amount to scale in y
   * @return the resulting picture
   */
  public Picture scale(double xFactor, double yFactor) {
    // set up the scale transform
    AffineTransform scaleTransform = new AffineTransform();
    scaleTransform.scale(xFactor, yFactor);

    // create a new picture object that is the right size
    Picture result = new Picture((int) (getWidth() * xFactor), (int) (getHeight() * yFactor));

    // get the graphics 2d object to draw on the result
    Graphics graphics = result.getGraphics();
    Graphics2D g2 = (Graphics2D) graphics;

    // draw the current image onto the result image scaled
    g2.drawImage(this.getImage(), scaleTransform, null);

    return result;
  }
コード例 #27
0
    @Override
    protected void onDraw(Canvas canvas) {
      canvas.drawColor(Color.WHITE);

      canvas.drawPicture(mPicture);

      canvas.drawPicture(mPicture, new RectF(0, 100, getWidth(), 200));

      mDrawable.setBounds(0, 200, getWidth(), 300);
      mDrawable.draw(canvas);

      ByteArrayOutputStream os = new ByteArrayOutputStream();
      mPicture.writeToStream(os);
      InputStream is = new ByteArrayInputStream(os.toByteArray());
      canvas.translate(0, 300);
      canvas.drawPicture(Picture.createFromStream(is));
    }
コード例 #28
0
ファイル: ImageLabFrame.java プロジェクト: per-ola/db2004
  private Picture initialImage() {
    pic2 = new Picture(500, 600);
    pic1 = new Picture(500, 600);

    for (int x = 0; x < pic2.width(); x++)
      for (int y = 0; y < pic2.height(); y++) {
        double dist = 1.0 - Math.sqrt((x - 300) * (x - 300) + (y - 200) * (y - 200)) / 500;
        int red =
            (int)
                (dist < 0.5
                    ? 0
                    : Math.min(Math.pow(dist, 0.4) + Math.pow(dist - 0.5, 0.1), 1.0) * 255);
        int green = (int) (dist * 255);
        int blue = 0;
        pic2.set(x, y, new Color(red, green, blue));
      }
    return pic2;
  }
コード例 #29
0
ファイル: Main.java プロジェクト: damacode/MyTumblr
 private static void handlePost(Post post) {
   Main.post_post_hash.put(post, post);
   for (Picture picture : post.pictures) {
     Helper.downloadFileFromURLToFileInTemp(picture.thumb_url, picture.thumb_name);
     picture.md5_id = Helper.createMD5FromFileInTemp(picture.thumb_name);
     Helper.moveTempImageToStore(picture.thumb_name, new File(Main.blogdir, picture.md5_id));
     if (!Main.pic_pic_hash.containsKey(picture)) {
       Main.pic_pic_hash.put(picture, picture);
       Main.pic_post_hash.put(picture, post);
       Helper.downloadFileFromURLToFileInTemp(picture.media_url, picture.media_name);
       Helper.moveTempImageToStore(picture.media_name, new File(Main.blogdir, picture.md5_id));
     } else {
       if (!post.equals(Main.pic_post_hash.get(picture))) {
         dup_post_list.put(post, Main.pic_post_hash.get(picture));
       }
     }
   }
 }
コード例 #30
0
ファイル: Admin.java プロジェクト: ankur-sharda/repinzle-demo
 public void putNewTagsInTagList() {
   List<String> tags = Picture.listtags();
   Iterator<String> itr = tags.iterator();
   while (itr.hasNext()) {
     String value = itr.next();
     Tag tag = new Tag(value);
     tag.save();
   }
 }