Supertuba12 / storage-estimator

Image storage estimator written in Java.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Image Storage Estimator

Description

A command line interface program which can estimate the storage size needed for a set of images. The program currently supports the following types of image formats:

  • Baseline JPEG
  • JPEG 2000
  • Uncompressed bitmap images (BMP)

From the CLI, the user can estimate the storage size for and image using a command on the form

J/JPG/JP2/JPEG2000/BMP width height

J/JPG corresponds to baseline JPEG images, JP2/JPEG2000 to JPEG 2000, and BMP to uncompressed bitmaps.

Furthermore, images can be grouped/stacked through the command

G i, i, ...

The program will continue to read commands until the user issues a command Q/q. This will trigger the program to do a final estimation of the total storage size needed for all given images/groups.

Design

For the assignment at hand the strategy pattern seemed as an appropriate choice, since the task involved executing a specific algorithm, depending on which type of image was given by the user.

UML class diagram of the Image Estimator program.

The class Client contains the main method from which the CLI is initiated. It will read from the standard input, and use the first argument to try to instantiate the correct Image enumeration type. Arguments following the first are considered to be either dimension values width and height for the image, or index values for the grouping of images.

With the help of the enum type the client can use a controller class ImageContext to execute the proper estimation strategy for the image/group. All estimations are stored in a collection created by the client.

Once the user enters a quit command, the client will use an internal method calculateTotalStorage to calculate the total storage needed.

Image

Each Image enum has a private field ImageStrategy strategy which can be reached through the class' public method getStrategy(). The field value is specified during the construction of the enum and made final.

ImageContext

ImageContext is the controller used to execute the desired strategy. The class has a method setStrategy() for setting the desired strategy, and a method execute() for executing it. ImageContext is used by the client during runtime.

ImageStrategy

The abstract class ImageStrategy defines the required methods for the concrete strategy classes. As of now, it only requires the concrete classes to implement the method estimateStorage().

Assumptions

The assignment description mentions that by grouping images in a stack the images can be compressed further. Thus, it was assumed that the individual estimations for the images in question could be replaced with the stack size estimation. It was also assumed that the index value for images not grouped remains the same after removal of the grouped images. The group's index value was assigned in the same order as any other image.

About

Image storage estimator written in Java.


Languages

Language:Java 100.0%