Files
Application/src/main/java/model/SOMImage.java
T

146 lines
3.1 KiB
Java

package model;
import workers.FilesWorker;
import java.io.File;
import java.util.List;
public class SOMImage {
private final String imageName; // the filename
private final SOMConfig config = SOMConfig.getInstance();
private final File tmb; // thumbnail
private final File prv; // preview
private final File src; // source
private final File fnl; // final
private final File tmp; // temp
private boolean tmbthere; // thumbnail status
private boolean prvthere; // preview status
private boolean srcthere; // source status
private boolean fnlthere; // final status
/**
* Automatically generates an SOMImage Object
* with an incremented Number and all th Paths
*/
public SOMImage() {
// super();
SOMEvent somEvent = SOMEvent.getInstance();
int nrOfEventPics;
List<SOMImage> somEventImages = somEvent.getImages();
nrOfEventPics = somEventImages.size();
String fill = "00000";
int nmb = (nrOfEventPics + 1);
String number = String.valueOf(nmb);
int numberLength = number.length();
String filledNumber = fill.substring(numberLength) + number;
this.imageName = filledNumber + ".jpg";
File sourcePath = FilesWorker.getSourcePath();
this.src = new File(sourcePath + "/" + this.imageName);
File previewPath = FilesWorker.getPreviewPath();
this.prv = new File(previewPath + "/" + this.imageName);
File thumbPath = FilesWorker.getThumbPath();
this.tmb = new File(thumbPath + "/" + this.imageName);
File finalPath = FilesWorker.getFinalPath();
this.fnl = new File(finalPath + "/" + this.imageName);
File tempPath = FilesWorker.getTempPath();
this.tmp = new File(tempPath + "/" + this.imageName);
this.updateImageState();
}
public final void updateImageState() {
// tmb
this.tmbthere = this.tmb.isFile();
// prv
this.prvthere = this.prv.isFile();
// src
this.srcthere = this.src.isFile();
// fnl
this.fnlthere = this.fnl.isFile();
}
/**
* @return the imageName
*/
public String getName() {
return this.imageName;
}
/**
* @return the tmb
*/
public File getTmb() {
return this.tmb;
}
/**
* @return the prv
*/
public File getPrv() {
return this.prv;
}
/**
* @return the src
*/
public File getSrc() {
return this.src;
}
/**
* @return the fnl
*/
public File getFnl() {
return this.fnl;
}
/**
* @return the tmp
*/
public File getTmp() {
return this.tmp;
}
/**
* @return the tmbthere
*/
public boolean isTmbthere() {
return this.tmbthere;
}
/**
* @return the prvthere
*/
public boolean isPrvthere() {
return this.prvthere;
}
/**
* @return the srcthere
*/
public boolean isSrcthere() {
return this.srcthere;
}
/**
* @return the fnlthere
*/
public boolean isFnlthere() {
return this.fnlthere;
}
}