Homework 2

Posted by Java Course Staff on October 8, 2016

homework_2

<font size=24>Due: (GMT+8) 2016-10-30 09:00</font>

Part 1: Image Processing

You are encouraged to manipulate images via Java Image IO at the pixel level. An RGB image is composed of a matrix of pixels. Each pixel can be regarded as a three-dimension vector (r, g, b). For some images with transparent pixels (e.g. some PNG images), the vector will be in four-dimension, (r, g, b, a), where a represents alpha.

Prerequisities

Before engaging with those objectives above, you should Baidu or Google the usage of Java ImageIO. You can also read the API document to get an idea of how to manipulate pixels.

Objectives

You are expected to complete all the following three objectives.

  • A: Cut an image.
  • B: zoom out (shrink) an image.
  • C: zoom in (enlarge) an image.

Submission

  • All input and output image files.
  • The entire source code.

Attention

  1. Encapsulated resize methods are not allowed.
  2. When you are enlarging an image, you are required to apply an interpolation(插值) algorithm, such as Bilinear Interpolation(双线性插值), to serve for anti-aliasing(抗锯齿).
  3. You will get bonus points if you apply a more advanced interpolation algorithm.
  4. Encapsulate codes for cutting, shrinking and enlarging into individual methods or classes.
  5. Only BMP, JPG(JPEG) and PNG images are allowed.
  6. The git remote repository should be named as homework_2.

Hint

PART 2 Microsoft Office Document Processing via Apache POI

poi poi poi ~

Part 2 encourages you to manipulate a Microsoft Office document (either Microsoft Word or Microsoft Excel, you are free to choose one of them) via Apache POI.

Apache POI is an open-source project which is a collection of Java libraries designated to Office Processing. Click here for the project homepage.

A video will be posted to tell you how to add the POI libraries to your project dependency.

Requirements for Word processing

If you choose to process a Word document, you are expected to achieve the following 4 goals. You may need a tutorial. Click here.

  • Compute the total number of characters;
  • Compute the total number of paragraphs;
  • Gather the hierarchy of titles & subtitles;
  • Replace a string pattern everywhere it appears in the document;

Requirements for Excel processing

Apache POI is extremely powerful in manipulating Excel documents.

If you choose to process an Excel document, you are expected to achieve the following 5 goals. You may need a tutorial here. Click here.

  • Read cells;
  • Set the format of a cell;
  • Merge cells (合并单元格);
  • Change alignment;
  • Set a formula for a cell.

Submission

For either alternative, you should submit the source code, the input word/excel document, and the output word/excel document.