filecontroller
Class ReadPGMImageFile

java.lang.Object
  extended by filecontroller.ReadPGMImageFile

public class ReadPGMImageFile
extends java.lang.Object

The ReadPGMImageFile -class reads Portable GreyMap (PGM) images made by user, and converts them to form this program uses. PGM files contains also a header part in the beginning of file, which is read and pulled apart before the actual data.

Version:
1
Author:
Potkuri -group

Field Summary
private  java.awt.Color colorOfCornerArea
          Background color of corner area in weather -image.
private  java.awt.Color colorOfRadarArea
          Background color of radar area in weather -image.
private  int[] colorPalette
          colorPalette array of colors in integer RGB.
private  java.lang.String dataDir
          dataDir is directory for PGM-images.
private  java.lang.String errorMessage
          errorMessage if errors.
private  java.awt.image.BufferedImage mapImage
          mapImage weather image.
private  int[][] mapMatrix
          mapMatrix weather image in numeric-mode.
private  java.awt.image.BufferedImage offScreenImage
          offScreenImage is working area for Java 2D.
private  Parameters parameters
          parameters Current instance of Parameter class.
private  int pictureHeight
          pictureWidth map height.
private  int pictureWidth
          pictureWidth map width.
private  int[] radarImageSize
          radarImageSize size of PGM-image.
private  int radarPics
          currentRadarPic latest composed image.
private  int renderMapHeight
          render height.
private  int renderMapWidth
          render width.
private  java.lang.Boolean status
          status is false if construct fails.
private  java.util.ArrayList<java.lang.String> weatherFiles
          weatherFiles is list of images.
private  int weatherFilesPointer
          currentWeatherFile Pointer to current row.
 
Constructor Summary
ReadPGMImageFile(Parameters parameters)
          Constructor of this class.
 
Method Summary
 java.lang.String getErrorMessage()
          Returns latest error message.
 java.awt.image.BufferedImage getMap()
          Returns rendered weather data in bufferedImage -format.
 int[][] getMapMatrix()
          Returns rendered weather data in integer matrix.
private  java.lang.String getPictureName()
          This method returns path and name of the next PGM-image in order.
private  int[] getPrintColorPalette()
          This method initialize a color palette, which is used when rendering storms from weather data into BufferedImage-object.
 boolean getStatus()
          Returns a current status of this instance.
private  boolean loadList(java.lang.String filename)
          Load user's weather data-list from file.
private  boolean loadPicture()
          Method renders a PGM-image.
private  boolean recognizeHeaderLine(java.lang.String headerLine, int headerNumber)
          Method tries to recognize PGM picture's current header line, and set the value of the header into program's data structure.
private  boolean renderWeathermapToBufferedImage()
          This method converts the weather data from integer matrix into bufferedImage.
 boolean update()
          Method renders next PGM -images from user's list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colorOfCornerArea

private java.awt.Color colorOfCornerArea
Background color of corner area in weather -image.


colorOfRadarArea

private java.awt.Color colorOfRadarArea
Background color of radar area in weather -image.


colorPalette

private int[] colorPalette
colorPalette array of colors in integer RGB.


dataDir

private java.lang.String dataDir
dataDir is directory for PGM-images.


errorMessage

private java.lang.String errorMessage
errorMessage if errors.


mapImage

private java.awt.image.BufferedImage mapImage
mapImage weather image.


mapMatrix

private int[][] mapMatrix
mapMatrix weather image in numeric-mode.


offScreenImage

private java.awt.image.BufferedImage offScreenImage
offScreenImage is working area for Java 2D.


parameters

private Parameters parameters
parameters Current instance of Parameter class.


pictureHeight

private int pictureHeight
pictureWidth map height.


pictureWidth

private int pictureWidth
pictureWidth map width.


radarImageSize

private int[] radarImageSize
radarImageSize size of PGM-image.


radarPics

private int radarPics
currentRadarPic latest composed image.


renderMapHeight

private int renderMapHeight
render height.


renderMapWidth

private int renderMapWidth
render width.


status

private java.lang.Boolean status
status is false if construct fails.


weatherFiles

private java.util.ArrayList<java.lang.String> weatherFiles
weatherFiles is list of images.


weatherFilesPointer

private int weatherFilesPointer
currentWeatherFile Pointer to current row.

Constructor Detail

ReadPGMImageFile

public ReadPGMImageFile(Parameters parameters)
Constructor of this class. If constructor fails, the status of this instance is set as false.

Parameters:
parameters - Current parameter -class.
Method Detail

getErrorMessage

public java.lang.String getErrorMessage()
Returns latest error message.

Returns:
message

getMap

public java.awt.image.BufferedImage getMap()
Returns rendered weather data in bufferedImage -format.

Returns:
BufferedImage map

getMapMatrix

public int[][] getMapMatrix()
Returns rendered weather data in integer matrix. Values are represented on dBZ -scale.

Returns:
matrix

getPictureName

private java.lang.String getPictureName()
This method returns path and name of the next PGM-image in order. When there is no more files in this set, method returns the first image.

Returns:
String Path of next PGM-image.

getPrintColorPalette

private int[] getPrintColorPalette()
This method initialize a color palette, which is used when rendering storms from weather data into BufferedImage-object. In practice, color values are stored into a integer matrix with 250 cells. The colors are represented in Java's RGM-mode.

Returns:
colors

getStatus

public boolean getStatus()
Returns a current status of this instance. If status is false, there probably is a new error message available.

Returns:
status

loadList

private boolean loadList(java.lang.String filename)
Load user's weather data-list from file. The list defines the PGM-images we use when rendering weather data.

Parameters:
filename - Name of user list, this comes from Parameter -class.
Returns:
load succeed

loadPicture

private boolean loadPicture()
Method renders a PGM-image. Weather information is represented in numeric array, where values reflect weather fierceness on dBZ scale.

Returns:
render succeed

recognizeHeaderLine

private boolean recognizeHeaderLine(java.lang.String headerLine,
                                    int headerNumber)
Method tries to recognize PGM picture's current header line, and set the value of the header into program's data structure. Rather the headers are identified by it's header number, this is possible because the headers are always on same format.

Parameters:
headerLine - Current line.
headerNumber - Number of line.
Returns:
boolean

renderWeathermapToBufferedImage

private boolean renderWeathermapToBufferedImage()
This method converts the weather data from integer matrix into bufferedImage. BufferedImage is used later by Graphics- class.

Returns:
rendering succeed

update

public boolean update()
Method renders next PGM -images from user's list. Returns false if there is no more weather data, or if file not found.

Returns:
update succeed