SOM moved to OpenProject Git
@@ -0,0 +1,238 @@
|
||||
package GUI;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ProgressIndicator;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.text.Font;
|
||||
import model.SOMConfig;
|
||||
import model.SOMImage;
|
||||
import model.SOMLayout;
|
||||
import workers.FilesWorker;
|
||||
import workers.ScaleWorker;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* Created by Simon on 13.06.2016.
|
||||
*/
|
||||
public class CaptureCtl {
|
||||
|
||||
@FXML
|
||||
public StackPane capturePane;
|
||||
@FXML
|
||||
public Label countdownText;
|
||||
@FXML
|
||||
public ImageView image;
|
||||
@FXML
|
||||
public ProgressIndicator pictureLoadIndicator;
|
||||
|
||||
// series switch
|
||||
public boolean series = false;
|
||||
// Timer for coutdown
|
||||
Timer timer;
|
||||
// series picture counter
|
||||
private int seriesCounter;
|
||||
// countdown counter
|
||||
private int counter = 0;
|
||||
|
||||
// Initialisation
|
||||
public void initialize() {
|
||||
setPane();
|
||||
setImage();
|
||||
setCountdownText();
|
||||
setPictureLoadIndicator();
|
||||
}
|
||||
|
||||
private void setPictureLoadIndicator() {
|
||||
pictureLoadIndicator.setVisible(false);
|
||||
|
||||
pictureLoadIndicator.setPrefHeight(SOMLayout.screenHeight / 4);
|
||||
pictureLoadIndicator.setPrefWidth(SOMLayout.screenHeight / 4);
|
||||
|
||||
pictureLoadIndicator.setMaxSize(SOMLayout.screenHeight / 2, SOMLayout.screenHeight / 2);
|
||||
|
||||
pictureLoadIndicator.setStyle("-fx-progress-color: white;");
|
||||
}
|
||||
|
||||
private void setCountdownText() {
|
||||
|
||||
capturePane.setAlignment(Pos.CENTER);
|
||||
countdownText.setAlignment(Pos.CENTER);
|
||||
|
||||
countdownText.setPrefSize(SOMLayout.screenHeight / 2, SOMLayout.screenHeight / 2);
|
||||
countdownText.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
|
||||
|
||||
countdownText.setText(null);
|
||||
countdownText.setFont(new Font("Century Gothic Bold", SOMLayout.screenHeight / 4));
|
||||
countdownText.setTextFill(SOMLayout.WHITE);
|
||||
}
|
||||
|
||||
public void setPane() {
|
||||
capturePane.setBackground(SOMLayout.BLACK_BG);
|
||||
}
|
||||
|
||||
public void setImage() {
|
||||
// Set the image aspect ratio to be preserved
|
||||
image.setPreserveRatio(true);
|
||||
|
||||
// Set the image to the image View
|
||||
image.setImage(SOMLayout.SPLASH_IMAGE);
|
||||
|
||||
// make it fit the height of the Screen
|
||||
image.setFitHeight(SOMLayout.screenHeight);
|
||||
|
||||
// Calculate the offset to center it horizontally if the image is wider than the screen (or narrower)
|
||||
double aspect = image.getImage().getWidth() / image.getImage().getHeight();
|
||||
double scaledWidth = aspect * SOMLayout.screenHeight;
|
||||
double offset = (scaledWidth - SOMLayout.screenWidth) / 2;
|
||||
|
||||
image.setX(-offset);
|
||||
}
|
||||
|
||||
public void setSeries(Boolean series) {
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
/* LOGIC
|
||||
* -----------------------------------------------------------------
|
||||
* -----------------------------------------------------------------
|
||||
* */
|
||||
protected void shoot(boolean series) {
|
||||
// Check for series mode
|
||||
System.out.println("shoot");
|
||||
|
||||
// Change to the capture screen
|
||||
SOMGUI.changetocapture();
|
||||
|
||||
if (series)
|
||||
// if series mode is on, set the counter to amount of pictures to make
|
||||
seriesCounter = SOMConfig.SERIES_COUNTER;
|
||||
else
|
||||
// else set it to one
|
||||
seriesCounter = 1;
|
||||
|
||||
|
||||
//start the first countdown
|
||||
countdown2();
|
||||
}
|
||||
|
||||
protected void countdown2() {
|
||||
// set the Countdown Value
|
||||
counter = SOMConfig.COUNTDOWN_COUNTER;
|
||||
|
||||
// open a Timer
|
||||
timer = new Timer();
|
||||
// give it a Task
|
||||
TimerTask task = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (seriesCounter == 0)
|
||||
counter = 0;
|
||||
|
||||
System.out.println("countdown " + counter);
|
||||
// It feels better if there is still
|
||||
// a second after the counter is at
|
||||
// 0, so it will count to -1
|
||||
|
||||
// show smile instead of a zero
|
||||
if (counter == 0) {
|
||||
|
||||
Platform.runLater(new Runnable() {
|
||||
public void run() {
|
||||
// Remove Text
|
||||
countdownText.setText(null);
|
||||
// Set Countdown Smile Image
|
||||
countdownText.setGraphic(new ImageView(SOMLayout.SMILE_IMAGE));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
// shoot the camera
|
||||
else if (counter <= -1) {
|
||||
|
||||
// Run on Javafx Thread
|
||||
Platform.runLater(new Runnable() {
|
||||
public void run() {
|
||||
// Remove Graphic
|
||||
countdownText.setGraphic(null);
|
||||
// Remove Text
|
||||
countdownText.setText(null);
|
||||
}
|
||||
});
|
||||
|
||||
// cancel the timer
|
||||
timer.cancel();
|
||||
// show the Load indicator
|
||||
pictureLoadIndicator.setVisible(true);
|
||||
// hide the Countdown Text
|
||||
countdownText.setVisible(false);
|
||||
// actually take the picture
|
||||
takePicture();
|
||||
// Count down one Picture
|
||||
seriesCounter--;
|
||||
|
||||
// check if pictures are left
|
||||
if (seriesCounter > 0) {
|
||||
// restart if pictures left
|
||||
countdown2();
|
||||
|
||||
|
||||
} else {
|
||||
// Change the UI
|
||||
Platform.runLater(new Runnable() {
|
||||
public void run() {
|
||||
// change to Picture scene
|
||||
SOMGUI.changetopicture();
|
||||
// set the Gallery page to the first
|
||||
SOMGUI.galleryCtl.setPage();
|
||||
// update the Gallery
|
||||
SOMGUI.galleryCtl.getGalleryImages();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// Show the Time left
|
||||
else {
|
||||
|
||||
Platform.runLater(new Runnable() {
|
||||
public void run() {
|
||||
// Set Countdown Text
|
||||
countdownText.setText(String.valueOf(counter + 1));
|
||||
// Set the Counter Visible
|
||||
countdownText.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
counter--;
|
||||
}
|
||||
};
|
||||
|
||||
// start the timer
|
||||
timer.schedule(task, 0, 1000);
|
||||
}
|
||||
|
||||
private void takePicture() {
|
||||
// Capture the image
|
||||
SOMImage newImage = FilesWorker.waitForImageAndCapture();
|
||||
|
||||
//Scale the image to preview
|
||||
ScaleWorker.scale(newImage, ScaleWorker.PREVIEW);
|
||||
// set te image to UI
|
||||
image.setImage(new Image(newImage.getPrv().toURI().toString()));
|
||||
SOMGUI.pictureCtl.image.setImage(new Image(newImage.getPrv().toURI().toString()));
|
||||
|
||||
// trigger the thumb calculation
|
||||
ScaleWorker.scale(newImage, ScaleWorker.THUMBNAIL);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
package GUI;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.VPos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import model.SOMConfig;
|
||||
import model.SOMEvent;
|
||||
import model.SOMImage;
|
||||
import model.SOMLayout;
|
||||
import workers.ScaleWorker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Simon on 13.06.2016.
|
||||
*/
|
||||
public class GalleryCtl {
|
||||
@FXML
|
||||
private Pane pane;
|
||||
@FXML
|
||||
private GridPane grid;
|
||||
@FXML
|
||||
private Button forthButton;
|
||||
@FXML
|
||||
private Button backButton;
|
||||
@FXML
|
||||
private Button pictureButton;
|
||||
@FXML
|
||||
private ImageView galleryImageView1;
|
||||
@FXML
|
||||
private ImageView galleryImageView2;
|
||||
@FXML
|
||||
private ImageView galleryImageView3;
|
||||
@FXML
|
||||
private ImageView galleryImageView4;
|
||||
@FXML
|
||||
private ImageView galleryImageView5;
|
||||
@FXML
|
||||
private ImageView galleryImageView6;
|
||||
@FXML
|
||||
private ImageView galleryImageView7;
|
||||
@FXML
|
||||
private ImageView galleryImageView8;
|
||||
@FXML
|
||||
private ImageView galleryImageView9;
|
||||
@FXML
|
||||
private Button galleryButton1;
|
||||
@FXML
|
||||
private Button galleryButton2;
|
||||
@FXML
|
||||
private Button galleryButton3;
|
||||
@FXML
|
||||
private Button galleryButton4;
|
||||
@FXML
|
||||
private Button galleryButton5;
|
||||
@FXML
|
||||
private Button galleryButton6;
|
||||
@FXML
|
||||
private Button galleryButton7;
|
||||
@FXML
|
||||
private Button galleryButton8;
|
||||
@FXML
|
||||
private Button galleryButton9;
|
||||
|
||||
private ImageView[] imageViews;
|
||||
private Button[] imageButtons;
|
||||
private int page = 0;
|
||||
private SOMImage[] somPageImagesArray = new SOMImage[9];
|
||||
|
||||
public void initialize() {
|
||||
setPane();
|
||||
setGrid();
|
||||
setBackButton();
|
||||
setForthButton();
|
||||
setPictureButton();
|
||||
|
||||
imageViews = new ImageView[]{
|
||||
galleryImageView1,
|
||||
galleryImageView2,
|
||||
galleryImageView3,
|
||||
galleryImageView4,
|
||||
galleryImageView5,
|
||||
galleryImageView6,
|
||||
galleryImageView7,
|
||||
galleryImageView8,
|
||||
galleryImageView9
|
||||
};
|
||||
imageButtons = new Button[]{
|
||||
galleryButton1,
|
||||
galleryButton2,
|
||||
galleryButton3,
|
||||
galleryButton4,
|
||||
galleryButton5,
|
||||
galleryButton6,
|
||||
galleryButton7,
|
||||
galleryButton8,
|
||||
galleryButton9
|
||||
};
|
||||
|
||||
setImageViews();
|
||||
getGalleryImages();
|
||||
setImageButtons();
|
||||
}
|
||||
|
||||
private void setImageButtons() {
|
||||
int i = 0;
|
||||
for (Button imageButton : imageButtons) {
|
||||
imageButton.setText(null);
|
||||
imageButton.setBackground(SOMLayout.BLACK_BG);
|
||||
|
||||
final int finalI = i;
|
||||
imageButton.setOnMouseReleased(new EventHandler<MouseEvent>() {
|
||||
|
||||
public void handle(MouseEvent event) {
|
||||
if (!somPageImagesArray[finalI].isPrvthere()) {
|
||||
ScaleWorker.scale(somPageImagesArray[finalI], ScaleWorker.PREVIEW);
|
||||
}
|
||||
SOMGUI.pictureCtl.image.setImage(new Image(somPageImagesArray[finalI].getPrv().toURI().toString()));
|
||||
SOMGUI.captureCtl.image.setImage(new Image(somPageImagesArray[finalI].getPrv().toURI().toString()));
|
||||
SOMGUI.changetopicture();
|
||||
}
|
||||
});
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private void setImageViews() {
|
||||
for (ImageView imageView : imageViews) {
|
||||
// Set the image aspect ratio to be preserved
|
||||
imageView.setPreserveRatio(true);
|
||||
|
||||
// Set the image to the image View
|
||||
imageView.setImage(SOMLayout.SPLASH_IMAGE);
|
||||
|
||||
// make it fit the height of the Screen
|
||||
imageView.setFitHeight(SOMLayout.screenHeight / 3);
|
||||
imageView.setFitWidth(SOMLayout.screenWidth / 4);
|
||||
|
||||
// position the images in Center
|
||||
GridPane.setValignment(imageView, VPos.CENTER);
|
||||
GridPane.setHalignment(imageView, HPos.CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPane() {
|
||||
pane.setPrefSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
pane.setMinSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
pane.setBackground(SOMLayout.BLACK_BG);
|
||||
}
|
||||
|
||||
public void setGrid() {
|
||||
grid.setPrefHeight(SOMLayout.screenHeight);
|
||||
grid.setPrefWidth(SOMLayout.screenWidth);
|
||||
grid.setMinSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setForthButton() {
|
||||
// get the button height & width
|
||||
int height = (SOMLayout.screenHeight / 4);
|
||||
// set alignment
|
||||
GridPane.setHalignment(forthButton, HPos.CENTER);
|
||||
GridPane.setValignment(forthButton, VPos.CENTER);
|
||||
// set the Button height & width
|
||||
forthButton.setPrefSize(height, height);
|
||||
|
||||
// Make it a circle
|
||||
forthButton.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
|
||||
|
||||
//Set Text Color
|
||||
forthButton.setTextFill(SOMLayout.WHITE);
|
||||
forthButton.setText(null);
|
||||
|
||||
// Set Image
|
||||
ImageView imageView = new ImageView(SOMLayout.FORTH_IMAGE);
|
||||
|
||||
forthButton.setGraphic(imageView);
|
||||
|
||||
// Set Mouse Press Action
|
||||
forthButton.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
// Feedback
|
||||
forthButton.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
|
||||
}
|
||||
});
|
||||
|
||||
// Set Mouse Release Action
|
||||
forthButton.setOnMouseReleased(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
|
||||
// Feedback
|
||||
forthButton.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
|
||||
|
||||
// Action
|
||||
action();
|
||||
}
|
||||
|
||||
// Action Performed
|
||||
private void action() {
|
||||
page++;
|
||||
getGalleryImages();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setBackButton() {
|
||||
// get the button height & width
|
||||
int height = (SOMLayout.screenHeight / 4);
|
||||
// set alignment
|
||||
GridPane.setHalignment(backButton, HPos.CENTER);
|
||||
GridPane.setValignment(backButton, VPos.CENTER);
|
||||
// set the Button height & width
|
||||
backButton.setPrefSize(height, height);
|
||||
|
||||
// Make it a circle
|
||||
backButton.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
|
||||
|
||||
//Set Text Color
|
||||
backButton.setTextFill(SOMLayout.WHITE);
|
||||
backButton.setText(null);
|
||||
|
||||
// Set Image
|
||||
ImageView imageView = new ImageView(SOMLayout.BACK_IMAGE);
|
||||
|
||||
backButton.setGraphic(imageView);
|
||||
|
||||
// Set Mouse Press Action
|
||||
backButton.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
// Feedback
|
||||
backButton.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
|
||||
}
|
||||
});
|
||||
|
||||
// Set Mouse Release Action
|
||||
backButton.setOnMouseReleased(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
|
||||
// Feedback
|
||||
backButton.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
|
||||
|
||||
// Action
|
||||
action();
|
||||
}
|
||||
|
||||
// Action Performed
|
||||
private void action() {
|
||||
page--;
|
||||
getGalleryImages();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setPictureButton() {
|
||||
// get the button height & width
|
||||
int height = (SOMLayout.screenHeight / 4);
|
||||
// set alignment
|
||||
GridPane.setHalignment(pictureButton, HPos.CENTER);
|
||||
GridPane.setValignment(pictureButton, VPos.CENTER);
|
||||
// set the Button height & width
|
||||
pictureButton.setPrefSize(height, height);
|
||||
|
||||
// Make it a circle
|
||||
pictureButton.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
|
||||
|
||||
//Set Text Color
|
||||
pictureButton.setTextFill(SOMLayout.WHITE);
|
||||
pictureButton.setText(null);
|
||||
|
||||
// Set Image
|
||||
ImageView imageView = new ImageView(SOMLayout.PICTURE_IMAGE);
|
||||
|
||||
pictureButton.setGraphic(imageView);
|
||||
|
||||
// Set Mouse Press Action
|
||||
pictureButton.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
// Feedback
|
||||
pictureButton.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
|
||||
}
|
||||
});
|
||||
|
||||
// Set Mouse Release Action
|
||||
pictureButton.setOnMouseReleased(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
|
||||
// Feedback
|
||||
pictureButton.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
|
||||
|
||||
// Action
|
||||
action();
|
||||
}
|
||||
|
||||
// Action Performed
|
||||
private void action() {
|
||||
SOMGUI.changetopicture();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setGalleryImageView1(ImageView galleryImageView1) {
|
||||
this.galleryImageView1 = galleryImageView1;
|
||||
}
|
||||
|
||||
/*
|
||||
* LOGIC
|
||||
* -----------------------------------------------------------------------
|
||||
* -----------------------------------------------------------------------
|
||||
* */
|
||||
|
||||
void getGalleryImages() {
|
||||
//Behandelt
|
||||
System.out.println("Galerie baut auf");
|
||||
|
||||
// get the Images as Array
|
||||
List<SOMImage> imagelist = SOMEvent.getInstance().getImages();
|
||||
SOMImage[] imagearray = imagelist.toArray(
|
||||
new SOMImage[imagelist.size()]
|
||||
);
|
||||
// Open new Array for reversing
|
||||
SOMImage[] reverseImageArray = new SOMImage[imagelist.size()];
|
||||
// Reverse the Array
|
||||
for (int h = 0; h < imagearray.length; h++) {
|
||||
reverseImageArray[reverseImageArray.length - h - 1] = imagearray[h];
|
||||
}
|
||||
|
||||
// get the number of images
|
||||
double numberOfPictures = reverseImageArray.length;
|
||||
// calculate the number of pages (round up)
|
||||
int numberOfPages = (int) Math.ceil(numberOfPictures / SOMConfig.IMAGES_PER_PAGE);
|
||||
|
||||
//report to console
|
||||
System.out.println(
|
||||
"WE HAVE "
|
||||
+ numberOfPages
|
||||
+ " PAGES AND "
|
||||
+ reverseImageArray.length
|
||||
+ " IMAGES"
|
||||
);
|
||||
|
||||
// Loop through the Array
|
||||
System.out.println("Start looping through current pages images");
|
||||
|
||||
// Loop through the ImageViews of the current page
|
||||
for (int i = 0; i < SOMConfig.IMAGES_PER_PAGE; i++) {
|
||||
|
||||
// SYSOUT for manual checking
|
||||
System.out.println("Page: " + page);
|
||||
System.out.println("Image of Page: " + (i + 1));
|
||||
System.out.println("Image of whole; " + (i + (page * SOMConfig.IMAGES_PER_PAGE) + 1));
|
||||
|
||||
// If there is an Image to set at the Position
|
||||
// (on the last page it probably stops somewhere in between)
|
||||
if (i + (page * SOMConfig.IMAGES_PER_PAGE) < reverseImageArray.length) {
|
||||
|
||||
// get the current image for the position
|
||||
SOMImage currentSOMImage = reverseImageArray[i + (page * SOMConfig.IMAGES_PER_PAGE)];
|
||||
// Calculate the scaled Image
|
||||
currentSOMImage = ScaleWorker.scale(currentSOMImage, ScaleWorker.THUMBNAIL);
|
||||
|
||||
// REPORT THE Images Path to Console
|
||||
System.out.println(currentSOMImage.getTmb().toURI().toString());
|
||||
// set the image to corresponding ImageView
|
||||
imageViews[i].setImage(new Image(currentSOMImage.getTmb().toURI().toString()));
|
||||
|
||||
// save the SOMImage to an Array in the
|
||||
// same order for Button Actions etc.
|
||||
somPageImagesArray[i] = currentSOMImage;
|
||||
}
|
||||
// if there are no more images to set
|
||||
else {
|
||||
// Set the image to null
|
||||
imageViews[i].setImage(null);
|
||||
|
||||
// save the SOMImage to an Array in the
|
||||
// same order for Button Actions etc.
|
||||
somPageImagesArray[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
// EN/DISABLE BUTTONS AT THE ENDS
|
||||
if (page >= numberOfPages - 1) {
|
||||
|
||||
forthButton.setDisable(true);
|
||||
} else {
|
||||
forthButton.setDisable(false);
|
||||
}
|
||||
|
||||
if (page <= 0) {
|
||||
backButton.setDisable(true);
|
||||
} else {
|
||||
backButton.setDisable(false);
|
||||
}
|
||||
setImageButtons();
|
||||
}
|
||||
|
||||
// Set the Gallery Page Number
|
||||
public void setPage(int pageNumber) {
|
||||
this.page = pageNumber;
|
||||
}
|
||||
|
||||
// Default to 0
|
||||
public void setPage() {
|
||||
setPage(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
package GUI;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.input.TouchEvent;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import model.SOMEvent;
|
||||
import model.SOMImage;
|
||||
import model.SOMLayout;
|
||||
import workers.ScaleWorker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Simon on 13.06.2016.
|
||||
*/
|
||||
public class PictureCtl {
|
||||
@FXML
|
||||
public Pane pane;
|
||||
|
||||
@FXML
|
||||
public GridPane grid;
|
||||
|
||||
@FXML
|
||||
public Button singleBtn;
|
||||
@FXML
|
||||
public Button seriesBtn;
|
||||
@FXML
|
||||
public Button galleryBtn;
|
||||
|
||||
@FXML
|
||||
public ImageView image;
|
||||
|
||||
public void initialize() {
|
||||
|
||||
// Basic Layout setup
|
||||
setPane();
|
||||
setGrid();
|
||||
|
||||
// Buttons setup
|
||||
setGalleryBtn();
|
||||
setSeriesBtn();
|
||||
setSingleBtn();
|
||||
|
||||
// Image Setup
|
||||
setImage();
|
||||
}
|
||||
|
||||
private void setPane() {
|
||||
pane.setPrefSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
pane.setBackground(SOMLayout.WHITE_BG);
|
||||
}
|
||||
|
||||
private void setGrid() {
|
||||
grid.setPrefSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
|
||||
grid.setAlignment(Pos.CENTER);
|
||||
|
||||
GridPane.setHalignment(galleryBtn, HPos.CENTER);
|
||||
GridPane.setHalignment(singleBtn, HPos.CENTER);
|
||||
GridPane.setHalignment(seriesBtn, HPos.CENTER);
|
||||
}
|
||||
|
||||
private void setSingleBtn() {
|
||||
// get the button height & width
|
||||
int height = (SOMLayout.screenHeight / 4);
|
||||
|
||||
// set the Button height & width
|
||||
singleBtn.setPrefSize(height, height);
|
||||
|
||||
// Make it a circle
|
||||
singleBtn.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
|
||||
|
||||
//Set Text Color
|
||||
singleBtn.setTextFill(SOMLayout.WHITE);
|
||||
singleBtn.setText(null);
|
||||
|
||||
// Set Image
|
||||
ImageView imageView = new ImageView(SOMLayout.SINGLE_PHOTO_IMAGE);
|
||||
singleBtn.setGraphic(imageView);
|
||||
|
||||
// INTERACTION
|
||||
// Set the Action to run after Button is Pressed
|
||||
EventHandler singleCapturePressedEventHandler = new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
singleBtn.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
|
||||
}
|
||||
};
|
||||
|
||||
// Set the Action to run after Button is Released
|
||||
EventHandler singleCaptureReleasedEventHandler = new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
|
||||
// Feedback (button gets less transparent)
|
||||
singleBtn.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
|
||||
|
||||
// Action
|
||||
action();
|
||||
}
|
||||
|
||||
// Action Performed
|
||||
private void action() {
|
||||
// Capture one image (false means no series mode)
|
||||
SOMGUI.captureCtl.shoot(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Set Mouse Press Action
|
||||
singleBtn.setOnMousePressed(singleCapturePressedEventHandler);
|
||||
|
||||
// Set Mouse Release Action
|
||||
singleBtn.setOnMouseReleased(singleCaptureReleasedEventHandler);
|
||||
|
||||
// Set Touch Press Action
|
||||
singleBtn.setOnTouchPressed(singleCapturePressedEventHandler);
|
||||
|
||||
// Set Touch Release Action
|
||||
singleBtn.setOnTouchReleased(singleCaptureReleasedEventHandler);
|
||||
}
|
||||
|
||||
private void setSeriesBtn() {
|
||||
// get the button height & width
|
||||
int height = (SOMLayout.screenHeight / 4);
|
||||
|
||||
// set the Button height & width
|
||||
seriesBtn.setPrefSize(height, height);
|
||||
|
||||
// Make it a circle
|
||||
seriesBtn.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
|
||||
|
||||
//Set Text Color
|
||||
seriesBtn.setTextFill(SOMLayout.WHITE);
|
||||
seriesBtn.setText(null);
|
||||
|
||||
// Set Image
|
||||
ImageView imageView = new ImageView(SOMLayout.SERIES_PHOTO_IMAGE);
|
||||
|
||||
seriesBtn.setGraphic(imageView);
|
||||
|
||||
//INTERACTION
|
||||
//Set Action after Series Button is pressed
|
||||
EventHandler<MouseEvent> seriesCapturePressedEventHandler = new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
// Feedback (Button gets lesstransparent)
|
||||
seriesBtn.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
|
||||
}
|
||||
};
|
||||
//Set Action after series Button is released
|
||||
EventHandler<MouseEvent> seriesCaptureReleasedEventHandler = new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
|
||||
// Feedback (Button gets less transparent)
|
||||
seriesBtn.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
|
||||
|
||||
// Shoot series (true means series Mode)
|
||||
SOMGUI.captureCtl.shoot(true);
|
||||
}
|
||||
|
||||
}; //Set Action after Series Button is pressed
|
||||
EventHandler<TouchEvent> seriesCapturePressedTouchEventHandler = new EventHandler<TouchEvent>() {
|
||||
public void handle(TouchEvent event) {
|
||||
// Feedback (Button gets lesstransparent)
|
||||
seriesBtn.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
|
||||
}
|
||||
};
|
||||
//Set Action after series Button is released
|
||||
EventHandler<TouchEvent> seriesCaptureReleasedTouchEventHandler = new EventHandler<TouchEvent>() {
|
||||
public void handle(TouchEvent event) {
|
||||
|
||||
// Feedback (Button gets less transparent)
|
||||
seriesBtn.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
|
||||
|
||||
// Shoot series (true means series Mode)
|
||||
SOMGUI.captureCtl.shoot(true);
|
||||
}
|
||||
|
||||
};
|
||||
// Set Mouse Press Action
|
||||
seriesBtn.setOnMousePressed(seriesCapturePressedEventHandler);
|
||||
|
||||
// Set Mouse Release Action
|
||||
seriesBtn.setOnMouseReleased(seriesCaptureReleasedEventHandler);
|
||||
// Set Mouse Press Action
|
||||
seriesBtn.setOnTouchPressed(seriesCapturePressedTouchEventHandler);
|
||||
|
||||
// Set Mouse Release Action
|
||||
seriesBtn.setOnTouchReleased(seriesCaptureReleasedTouchEventHandler);
|
||||
}
|
||||
|
||||
private void setGalleryBtn() {
|
||||
// get the button height & width
|
||||
int height = (SOMLayout.screenHeight / 4);
|
||||
|
||||
// set the Button height & width
|
||||
galleryBtn.setPrefSize(height, height);
|
||||
|
||||
// Make it a circle
|
||||
galleryBtn.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
|
||||
|
||||
//Set Text Color
|
||||
galleryBtn.setTextFill(SOMLayout.WHITE);
|
||||
galleryBtn.setText(null);
|
||||
|
||||
// Set Image
|
||||
ImageView imageView = new ImageView(SOMLayout.GALLERY_IMAGE);
|
||||
|
||||
galleryBtn.setGraphic(imageView);
|
||||
|
||||
// Set Mouse Press Action
|
||||
galleryBtn.setOnMousePressed(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
// Feedback
|
||||
galleryBtn.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
|
||||
}
|
||||
});
|
||||
|
||||
// Set Mouse Release Action
|
||||
galleryBtn.setOnMouseReleased(new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent event) {
|
||||
|
||||
// Feedback
|
||||
galleryBtn.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
|
||||
|
||||
// Action
|
||||
action();
|
||||
}
|
||||
|
||||
// Action Performed
|
||||
private void action() {
|
||||
SOMGUI.changetogallery();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setImage() {
|
||||
// Set the image aspect ratio to be preserved
|
||||
image.setPreserveRatio(true);
|
||||
|
||||
// Set the image to the image View
|
||||
Image splash = SOMLayout.SPLASH_IMAGE;
|
||||
image.setImage(splash);
|
||||
|
||||
// make it fit the height of the Screen
|
||||
image.setFitHeight(SOMLayout.screenHeight);
|
||||
|
||||
// Get the Event Images
|
||||
List<SOMImage> somImageList = SOMEvent.getInstance().getImages();
|
||||
int numberOfImages = somImageList.size();
|
||||
|
||||
if (numberOfImages != 0) {
|
||||
// Set the last Image of the session
|
||||
SOMImage somImage = somImageList.get(numberOfImages - 1);
|
||||
|
||||
// update the Image State
|
||||
// TODO Probably not necessary
|
||||
somImage.updateImageState();
|
||||
|
||||
// Scale the Image if needed
|
||||
ScaleWorker.scale(somImage, ScaleWorker.PREVIEW);
|
||||
|
||||
// set the Image to UI
|
||||
image.setImage(new Image(somImage.getPrv().toURI().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package GUI;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import model.SOMLayout;
|
||||
import workers.FilesWorker;
|
||||
|
||||
/**
|
||||
* Created by Simon on 13.06.2016.
|
||||
*/
|
||||
public class SOMGUI extends Application {
|
||||
|
||||
|
||||
// picture
|
||||
// gallery
|
||||
// upload
|
||||
// capture
|
||||
// warn
|
||||
|
||||
// CONTROLLER
|
||||
public static PictureCtl pictureCtl;
|
||||
public static GalleryCtl galleryCtl;
|
||||
public static UploadCtl uploadCtl;
|
||||
public static CaptureCtl captureCtl;
|
||||
public static WarnCtl warnCtl;
|
||||
// STAGE
|
||||
private static Stage thestage;
|
||||
// PANES
|
||||
private static Parent picture;
|
||||
private static Parent gallery;
|
||||
private static Parent upload;
|
||||
private static Parent capture;
|
||||
private static Parent warn;
|
||||
//SCENES
|
||||
private static Scene pictureScene;
|
||||
private static Scene galleryScene;
|
||||
private static Scene uploadScene;
|
||||
private static Scene captureScene;
|
||||
private static Scene warnScene;
|
||||
// INSTANCE
|
||||
private static SOMGUI somgui;
|
||||
|
||||
protected SOMGUI() throws Exception {
|
||||
// set up the scenes
|
||||
FXMLLoader pictureLoader = new FXMLLoader(getClass().getResource("/fxml/picture.fxml"));
|
||||
picture = pictureLoader.load();
|
||||
pictureCtl = pictureLoader.getController();
|
||||
|
||||
FXMLLoader galleryLoader = new FXMLLoader(getClass().getResource("/fxml/gallery.fxml"));
|
||||
gallery = galleryLoader.load();
|
||||
galleryCtl = galleryLoader.getController();
|
||||
|
||||
FXMLLoader uploadLoader = new FXMLLoader(getClass().getResource("/fxml/upload.fxml"));
|
||||
upload = uploadLoader.load();
|
||||
uploadCtl = uploadLoader.getController();
|
||||
|
||||
FXMLLoader captureLoader = new FXMLLoader(getClass().getResource("/fxml/capture.fxml"));
|
||||
capture = captureLoader.load();
|
||||
captureCtl = captureLoader.getController();
|
||||
|
||||
FXMLLoader warnLoader = new FXMLLoader(getClass().getResource("/fxml/warn.fxml"));
|
||||
warn = warnLoader.load();
|
||||
warnCtl = warnLoader.getController();
|
||||
|
||||
// Initialize the Scenes
|
||||
pictureScene = new Scene(picture, SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
galleryScene = new Scene(gallery, SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
uploadScene = new Scene(upload, SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
captureScene = new Scene(capture, SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
warnScene = new Scene(warn, SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
}
|
||||
|
||||
public static SOMGUI getInstance() throws Exception {
|
||||
if (somgui == null) {
|
||||
somgui = new SOMGUI();
|
||||
}
|
||||
return somgui;
|
||||
}
|
||||
|
||||
public static void changetopicture() {
|
||||
thestage.setScene(pictureScene);
|
||||
}
|
||||
|
||||
public static void changetogallery() {
|
||||
thestage.setScene(galleryScene);
|
||||
}
|
||||
|
||||
public static void changetoupload() {
|
||||
thestage.setScene(uploadScene);
|
||||
}
|
||||
|
||||
public static void changetocapture() {
|
||||
thestage.setScene(captureScene);
|
||||
}
|
||||
|
||||
public static void changetowarn() {
|
||||
thestage.setScene(warnScene);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
// make the Stage Accessible
|
||||
thestage = primaryStage;
|
||||
|
||||
// remove all borders
|
||||
thestage.initStyle(StageStyle.UNDECORATED);
|
||||
// set stage to fullscreen
|
||||
thestage.setFullScreen(true);
|
||||
// set the upper left X & Y position of the stage
|
||||
thestage.setX(0);
|
||||
thestage.setY(0);
|
||||
|
||||
// set stage visible
|
||||
thestage.show();
|
||||
|
||||
// Set the Upload scene
|
||||
changetoupload();
|
||||
// Start Upload Process
|
||||
FilesWorker.upload();
|
||||
// Set the Picture scene
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package GUI;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import model.SOMLayout;
|
||||
|
||||
/**
|
||||
* Controller for upload.fxml UI
|
||||
* Created by Simon on 10.05.2016.
|
||||
*/
|
||||
public class UploadCtl {
|
||||
|
||||
|
||||
@FXML
|
||||
public ProgressBar folderProgressBar;
|
||||
@FXML
|
||||
public ProgressBar pictureProgressBar;
|
||||
@FXML
|
||||
public ProgressBar cleanProgressBar;
|
||||
@FXML
|
||||
public ImageView folderImageView;
|
||||
@FXML
|
||||
public ImageView pictureImageView;
|
||||
@FXML
|
||||
public ImageView cleanImageView;
|
||||
@FXML
|
||||
public Label headLabel;
|
||||
@FXML
|
||||
public Label folderLabel;
|
||||
@FXML
|
||||
public Label picLabel;
|
||||
@FXML
|
||||
public Label cleanLabel;
|
||||
@FXML
|
||||
private Pane pane;
|
||||
@FXML
|
||||
private GridPane grid;
|
||||
|
||||
public UploadCtl() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Up the UI
|
||||
* each part of the UI is accessed via the Setter
|
||||
*/
|
||||
public void initialize() {
|
||||
// Set up the Upload UI parts
|
||||
|
||||
// basic structure
|
||||
setPane();
|
||||
setGrid();
|
||||
|
||||
// headline
|
||||
setHeadLbl();
|
||||
|
||||
// folder row
|
||||
setFolderIV();
|
||||
setFolderLbl();
|
||||
setFolderProg();
|
||||
|
||||
// picture row
|
||||
setPicIV();
|
||||
setPicLbl();
|
||||
setPicProg();
|
||||
|
||||
// cleanup row
|
||||
setCleanIV();
|
||||
setCleanLbl();
|
||||
setCleanProg();
|
||||
}
|
||||
|
||||
private void setPane() {
|
||||
pane.setPrefSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
pane.setBackground(SOMLayout.BLACK_BG);
|
||||
}
|
||||
|
||||
private void setGrid() {
|
||||
grid.setPrefSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
|
||||
GridPane.setHalignment(folderImageView, HPos.CENTER);
|
||||
GridPane.setHalignment(folderLabel, HPos.CENTER);
|
||||
GridPane.setHalignment(folderProgressBar, HPos.CENTER);
|
||||
|
||||
GridPane.setHalignment(pictureImageView, HPos.CENTER);
|
||||
GridPane.setHalignment(picLabel, HPos.CENTER);
|
||||
GridPane.setHalignment(pictureProgressBar, HPos.CENTER);
|
||||
|
||||
GridPane.setHalignment(cleanImageView, HPos.CENTER);
|
||||
GridPane.setHalignment(cleanLabel, HPos.CENTER);
|
||||
GridPane.setHalignment(cleanProgressBar, HPos.CENTER);
|
||||
|
||||
GridPane.setHalignment(headLabel, HPos.CENTER);
|
||||
}
|
||||
|
||||
private void setFolderProg() {
|
||||
folderProgressBar.setPrefSize(SOMLayout.screenWidth, 3);
|
||||
}
|
||||
|
||||
private void setPicProg() {
|
||||
pictureProgressBar.setPrefSize(SOMLayout.screenWidth, 3);
|
||||
}
|
||||
|
||||
private void setCleanProg() {
|
||||
cleanProgressBar.setPrefSize(SOMLayout.screenWidth, 3);
|
||||
}
|
||||
|
||||
private void setFolderIV() {
|
||||
folderImageView.setImage(SOMLayout.GALLERY_IMAGE);
|
||||
}
|
||||
|
||||
private void setPicIV() {
|
||||
folderImageView.setImage(SOMLayout.GALLERY_IMAGE);
|
||||
}
|
||||
|
||||
private void setCleanIV() {
|
||||
folderImageView.setImage(SOMLayout.GALLERY_IMAGE);
|
||||
}
|
||||
|
||||
private void setHeadLbl() {
|
||||
headLabel.setTextFill(Color.web("#ffffff"));
|
||||
}
|
||||
|
||||
private void setFolderLbl() {
|
||||
folderLabel.setTextFill(Color.web("#ffffff"));
|
||||
}
|
||||
|
||||
private void setPicLbl() {
|
||||
picLabel.setTextFill(Color.web("#ffffff"));
|
||||
}
|
||||
|
||||
private void setCleanLbl() {
|
||||
cleanLabel.setTextFill(Color.web("#ffffff"));
|
||||
}
|
||||
|
||||
// set the progress
|
||||
// public void setFolderProgress(double value) {
|
||||
// folderProgressBar.setProgress(value);
|
||||
// System.out.println("Folder Progress set to: "+ value);
|
||||
// }
|
||||
|
||||
public void setPicProgress(double value) {
|
||||
pictureProgressBar.setProgress(value);
|
||||
}
|
||||
|
||||
public void setCleanProgress(double value) {
|
||||
pictureProgressBar.setProgress(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package GUI;
|
||||
|
||||
/**
|
||||
* Created by Simon on 13.06.2016.
|
||||
*/
|
||||
public class WarnCtl {
|
||||
public void initialize() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: Start
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Created by Simon on 10.05.2016.
|
||||
*/
|
||||
|
||||
import GUI.SOMGUI;
|
||||
import model.SOMConfig;
|
||||
import model.SOMEvent;
|
||||
|
||||
public class Start extends SOMGUI {
|
||||
public Start() throws Exception {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Log the start
|
||||
System.out.println("Gestartet!");
|
||||
|
||||
// Start the UI
|
||||
launch(args);
|
||||
|
||||
// Set up the backend
|
||||
// get configuration
|
||||
SOMConfig config = SOMConfig.getInstance();
|
||||
config.readConfig();
|
||||
|
||||
// get event instance
|
||||
SOMEvent event = SOMEvent.getInstance();
|
||||
event.getEventImages();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package model;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Calendar;
|
||||
|
||||
@XmlRootElement(name = "Config")
|
||||
public class SOMConfig {
|
||||
|
||||
|
||||
// important Paths
|
||||
@XmlElement(name = "PICTURES_PATH")
|
||||
public static final File PICTURES_PATH = new File("images");
|
||||
// The Box's ID
|
||||
// Todo Throw out!! or by MAC Adress
|
||||
@XmlElement(name = "BOX_ID")
|
||||
public static final String BOX_ID = "selfomat-42";
|
||||
// Number of pictures in series mode
|
||||
@XmlElement(name = "SERIES_COUNTER")
|
||||
public static final int SERIES_COUNTER = 4;
|
||||
// Seconds before image is taken
|
||||
@XmlElement(name = "COUNTDOWN_COUNTER")
|
||||
public static final int COUNTDOWN_COUNTER = 3;
|
||||
// Images per Page in the Gallery
|
||||
public static final int IMAGES_PER_PAGE = 9;
|
||||
// Make the Scaling Algorithm switchable
|
||||
public static final int SCALING_GRAPHICS_2D = 0;
|
||||
public static final int SCALING_IMAGE_ICON = 1;
|
||||
public static final int SCALING_JAVAFX = 2;
|
||||
public static final int SCALING_ALGORITHM = SCALING_GRAPHICS_2D;
|
||||
// Path to configfile
|
||||
//TODO Resource??
|
||||
private static final File configfile = new File(SOMLayout.class.getResource("/config/config.xml").getFile());
|
||||
// Instance
|
||||
private static SOMConfig config = null;
|
||||
|
||||
|
||||
// Constructor
|
||||
private SOMConfig() {
|
||||
// TODO fix readConfig
|
||||
// readConfig();
|
||||
|
||||
// get the default Displays' dimensions
|
||||
System.out.println("Screen Dimensions: " + SOMLayout.screenWidth + "x" + SOMLayout.screenHeight);
|
||||
}
|
||||
|
||||
// Instance
|
||||
public static SOMConfig getInstance() {
|
||||
// Singleton Pattern
|
||||
if (config == null) {
|
||||
config = new SOMConfig();
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
// Write Config
|
||||
private void writeConfig() {
|
||||
try {
|
||||
|
||||
// TODO catch possible fail
|
||||
configfile.getParentFile().mkdirs();
|
||||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(SOMConfig.class);
|
||||
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
|
||||
|
||||
// output pretty printed
|
||||
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||
|
||||
jaxbMarshaller.marshal(this, configfile);
|
||||
jaxbMarshaller.marshal(this, System.out);
|
||||
|
||||
} catch (JAXBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Read Config
|
||||
public void readConfig() {
|
||||
try {
|
||||
|
||||
if (Files.exists(configfile.toPath())) {
|
||||
|
||||
JAXBContext jaxbContext = JAXBContext
|
||||
.newInstance(SOMConfig.class);
|
||||
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext
|
||||
.createUnmarshaller();
|
||||
config = (SOMConfig) jaxbUnmarshaller.unmarshal(configfile);
|
||||
|
||||
System.out.println();
|
||||
} else {
|
||||
this.writeConfig();
|
||||
}
|
||||
} catch (JAXBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// return the current Timestamp
|
||||
public long getCurrentTimestamp() {
|
||||
// 1) create a java calendar instance
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
// 2) get a java.util.Date from the calendar instance.
|
||||
// this date will represent the current instant, or "now".
|
||||
java.util.Date now = calendar.getTime();
|
||||
|
||||
// 3) a java current time (now) instance
|
||||
java.sql.Timestamp c = new java.sql.Timestamp(now.getTime());
|
||||
return c.getTime();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package model;
|
||||
|
||||
import workers.FilesWorker;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author simon
|
||||
*/
|
||||
public class SOMEvent {
|
||||
/**
|
||||
* The instance for the Singleton
|
||||
*/
|
||||
private static SOMEvent event = null;
|
||||
/**
|
||||
* The Event Date
|
||||
*/
|
||||
private final Date date = new Date();
|
||||
/**
|
||||
* All images form the Event
|
||||
*/
|
||||
private final List<SOMImage> images = new ArrayList<SOMImage>();
|
||||
/**
|
||||
* The currently selected image
|
||||
*/
|
||||
private SOMImage currentimage;
|
||||
/**
|
||||
* Makes the getEventImages function unusable after first use
|
||||
*/
|
||||
private boolean imagesread = false;
|
||||
|
||||
/**
|
||||
* Event Constructor
|
||||
*/
|
||||
private SOMEvent() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Instance of the Event (Singleton)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static SOMEvent getInstance() {
|
||||
// Singleton to prevent Instantiation
|
||||
if (event == null) {
|
||||
event = new SOMEvent();
|
||||
// event.currentimage = SOMImage.getFallbackImage();
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the List of Images already shot at the event if SOM is turned off
|
||||
* in between. Gets unfunctional after one time use caused by imagesread
|
||||
* boolean.
|
||||
*/
|
||||
public void getEventImages() {
|
||||
// Behandelt
|
||||
if (!imagesread) {
|
||||
|
||||
File[] files = FilesWorker.getSourcePath().listFiles();
|
||||
|
||||
assert files != null;
|
||||
Arrays.sort(files);
|
||||
|
||||
for (File file : files) {
|
||||
SOMImage img = new SOMImage(file.getName());
|
||||
img.updateImageState();
|
||||
this.addImage(img);
|
||||
}
|
||||
|
||||
imagesread = true;
|
||||
}
|
||||
// return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Given Image to the Events' Image List
|
||||
*
|
||||
* @param now
|
||||
* @return
|
||||
*/
|
||||
public void addImage(SOMImage now) {
|
||||
images.add(now);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Events' Date
|
||||
*
|
||||
* @return the date
|
||||
*/
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List of all of the Events' images
|
||||
*
|
||||
* @return the images
|
||||
*/
|
||||
public List<SOMImage> getImages() {
|
||||
// If there are no Event Images Collected
|
||||
if (images.size() == 0)
|
||||
// get all the events' images
|
||||
getEventImages();
|
||||
//...and return them
|
||||
return images;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the last image shot
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SOMImage getLastImage() {
|
||||
SOMImage[] imagesarr = this.images.toArray(new SOMImage[this.images
|
||||
.size()]);
|
||||
|
||||
return imagesarr[imagesarr.length - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Icon of the last shot image and sets the "current image" to
|
||||
* this one
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public void createAndSetLastImage() {
|
||||
this.currentimage = getLastImage();
|
||||
// this.currenticon =
|
||||
// makeIcon(this.currentimage);
|
||||
// return currenticon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given Image as the Current Image, creates a Preview and sets it
|
||||
* to UI
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public void createAndSetImage(SOMImage image) {
|
||||
this.currentimage = image;
|
||||
// this.currenticon =
|
||||
// makeIcon(this.currentimage);
|
||||
// return currenticon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the given ImageIcon as the current Icon
|
||||
* <p>
|
||||
* // * @param ImageIcon
|
||||
* small
|
||||
*/
|
||||
public void setCurrentIcon() {
|
||||
/*
|
||||
The ImageIcon of the currently shown Image
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Current Image for the Print Panel to pass to the System
|
||||
* Printing Queue
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SOMImage getCurrentimage() {
|
||||
return currentimage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package model;
|
||||
|
||||
import workers.FilesWorker;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class SOMImage {
|
||||
|
||||
private static String name; // 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
|
||||
|
||||
SOMImage(String name) {
|
||||
|
||||
File src = new File(FilesWorker.getSourcePath().toString() + "/" + name);
|
||||
|
||||
File prv = new File(FilesWorker.getPreviewPath().toString() + "/"
|
||||
+ name);
|
||||
|
||||
File tmb = new File(FilesWorker.getThumbPath().toString() + "/" + name);
|
||||
|
||||
File fnl = new File(FilesWorker.getFinalPath().toString() + "/" + name);
|
||||
|
||||
File tmp = new File(FilesWorker.getTempPath().toString() + "/" + name);
|
||||
|
||||
this.tmb = tmb;
|
||||
this.prv = prv;
|
||||
this.src = src;
|
||||
this.fnl = fnl;
|
||||
this.tmp = tmp;
|
||||
|
||||
this.updateImageState();
|
||||
}
|
||||
|
||||
public SOMImage() {
|
||||
super();
|
||||
|
||||
int numberOfEventPictures = SOMEvent.getInstance().getImages().size();
|
||||
String fill = "00000";
|
||||
int nmb = (numberOfEventPictures + 1);
|
||||
String number = String.valueOf(nmb);
|
||||
String filledNumber = fill.substring(number.length()) + number;
|
||||
name = filledNumber + ".jpg";
|
||||
|
||||
File src = new File(FilesWorker.getSourcePath().toString() + "/" + name);
|
||||
File prv = new File(FilesWorker.getPreviewPath().toString() + "/" + name);
|
||||
File tmb = new File(FilesWorker.getThumbPath().toString() + "/" + name);
|
||||
File fnl = new File(FilesWorker.getFinalPath().toString() + "/" + name);
|
||||
File tmp = new File(FilesWorker.getTempPath().toString() + "/" + name);
|
||||
|
||||
this.tmb = tmb;
|
||||
this.prv = prv;
|
||||
this.src = src;
|
||||
this.fnl = fnl;
|
||||
this.tmp = tmp;
|
||||
|
||||
this.updateImageState();
|
||||
}
|
||||
|
||||
public void updateImageState() {
|
||||
// tmb
|
||||
tmbthere = Files.exists(tmb.toPath());
|
||||
// prv
|
||||
prvthere = Files.exists(prv.toPath());
|
||||
// src
|
||||
srcthere = Files.exists(src.toPath());
|
||||
// fnl
|
||||
fnlthere = Files.exists(fnl.toPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tmb
|
||||
*/
|
||||
public File getTmb() {
|
||||
return this.tmb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the prv
|
||||
*/
|
||||
public File getPrv() {
|
||||
return prv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the src
|
||||
*/
|
||||
public File getSrc() {
|
||||
return src;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fnl
|
||||
*/
|
||||
public File getFnl() {
|
||||
return fnl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tmp
|
||||
*/
|
||||
public File getTmp() {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tmbthere
|
||||
*/
|
||||
public boolean isTmbthere() {
|
||||
return tmbthere;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the prvthere
|
||||
*/
|
||||
public boolean isPrvthere() {
|
||||
return prvthere;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the srcthere
|
||||
*/
|
||||
public boolean isSrcthere() {
|
||||
return srcthere;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fnlthere
|
||||
*/
|
||||
public boolean isFnlthere() {
|
||||
return fnlthere;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type 0 = thumb, 1 = preview, 2 = full Size
|
||||
* @return
|
||||
*/
|
||||
public ImageIcon toImageIcon(int type) {
|
||||
File imagepath;
|
||||
switch (type) {
|
||||
case 0:
|
||||
imagepath = getTmb();
|
||||
break;
|
||||
case 1:
|
||||
imagepath = getPrv();
|
||||
break;
|
||||
case 2:
|
||||
imagepath = getSrc();
|
||||
break;
|
||||
default:
|
||||
imagepath = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ImageIcon(imagepath.getPath());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package model;
|
||||
|
||||
public class SOMLanguage {
|
||||
// for Testing
|
||||
public static final String pre = "";
|
||||
// for Use
|
||||
// public static String pre = "/resources";
|
||||
/**
|
||||
* Languagestring of the Button that switches back one Panel
|
||||
*/
|
||||
// public static final String UIBtnBack = "Zurück";
|
||||
/**
|
||||
* Tells People to SMILE!
|
||||
*/
|
||||
public static final String UIBtnSmile = "SMILE";
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package model;
|
||||
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.BackgroundFill;
|
||||
import javafx.scene.layout.CornerRadii;
|
||||
import javafx.stage.Screen;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class SOMLayout {
|
||||
// Fonts
|
||||
public static final Font H_0 = new Font(Font.SANS_SERIF, 1, 150);
|
||||
public static final Font H_1 = new Font(Font.SANS_SERIF, 1, 100);
|
||||
public static final Font H_2 = new Font(Font.SANS_SERIF, 1, 75);
|
||||
public static final Font P = new Font(Font.SANS_SERIF, 1, 50);
|
||||
// Icons & Images
|
||||
//UI
|
||||
public static final javafx.scene.image.Image GALLERY_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Gallery.png").toString());
|
||||
public static final javafx.scene.image.Image SINGLE_PHOTO_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_CaptureSingle.png").toString());
|
||||
public static final javafx.scene.image.Image SERIES_PHOTO_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_CaptureSeries.png").toString());
|
||||
public static final javafx.scene.image.Image PRINT_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Print.png").toString());
|
||||
public static final javafx.scene.image.Image PICTURE_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Picture.png").toString());
|
||||
public static final javafx.scene.image.Image SMILE_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Smiley.png").toString()); //TODO LINK right image
|
||||
public static final javafx.scene.image.Image BACK_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Back.png").toString()); //TODO LINK right image
|
||||
public static final javafx.scene.image.Image FORTH_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMIcons_Forth.png").toString()); //TODO LINK right image
|
||||
//CI
|
||||
public static final javafx.scene.image.Image LOGO_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMLogo.png").toString());
|
||||
public static final javafx.scene.image.Image SPLASH_IMAGE = new javafx.scene.image.Image(ClassLoader.class.getResource("/img/SOMSplash.jpg").toString());
|
||||
public static final javafx.scene.paint.Color WHITE = new javafx.scene.paint.Color(1, 1, 1, 1);
|
||||
public static final Background WHITE_BG = new Background(new BackgroundFill(WHITE, null, null));
|
||||
// Screen
|
||||
// private static final GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||
private static final javafx.geometry.Rectangle2D gd = Screen.getPrimary().getBounds();
|
||||
public static final int screenWidth = (int) gd.getWidth();
|
||||
public static final int screenHeight = (int) gd.getHeight();
|
||||
// Layout
|
||||
private static final int row = screenHeight / 3;
|
||||
private static final int column = screenWidth / 4;
|
||||
// Colors
|
||||
private static final javafx.scene.paint.Color BLACK = new javafx.scene.paint.Color(0, 0, 0, 1);
|
||||
//Backgrounds
|
||||
public static final Background BLACK_BG = new Background(new BackgroundFill(BLACK, null, null));
|
||||
private static final javafx.scene.paint.Color TRANSPARENT_10 = new javafx.scene.paint.Color(0.05, 0.05, 0.05, 0.6);
|
||||
public static final Background TRANSPARENT_10_BG = new Background(new BackgroundFill(TRANSPARENT_10, null, null));
|
||||
private static final javafx.scene.paint.Color TRANSPARENT_20 = new javafx.scene.paint.Color(0.05, 0.05, 0.05, 0.8);
|
||||
public static final Background TRANSPARENT_20_BG = new Background(new BackgroundFill(TRANSPARENT_20, null, null));
|
||||
private static final Background TRANSPARENT_10_BG_ROUNDED = new Background(new BackgroundFill(TRANSPARENT_10, new CornerRadii(12), null));
|
||||
private static final Background TRANSPARENT_20_BG_ROUNDED = new Background(new BackgroundFill(TRANSPARENT_20, new CornerRadii(12), null));
|
||||
|
||||
public static int getRow(int span) {
|
||||
return row * span;
|
||||
}
|
||||
|
||||
public static int getColumn(int span) {
|
||||
return column * span;
|
||||
}
|
||||
|
||||
public static Background getTransparentBG10rounded(int radius) {
|
||||
return new Background(
|
||||
new BackgroundFill(
|
||||
TRANSPARENT_10_BG_ROUNDED.getFills().get(0).getFill(),
|
||||
new CornerRadii(radius),
|
||||
TRANSPARENT_10_BG_ROUNDED.getFills().get(0).getInsets()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static Background getTransparentBG20rounded(int radius) {
|
||||
return new Background(
|
||||
new BackgroundFill(
|
||||
TRANSPARENT_20_BG_ROUNDED.getFills().get(0).getFill(),
|
||||
new CornerRadii(radius),
|
||||
TRANSPARENT_20_BG_ROUNDED.getFills().get(0).getInsets()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package workers;
|
||||
|
||||
import model.SOMImage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static java.nio.file.StandardCopyOption.ATOMIC_MOVE;
|
||||
|
||||
/**
|
||||
* @author Simon Gehrig
|
||||
*/
|
||||
class CaptureWorker {
|
||||
|
||||
/**
|
||||
* Captures an image and returns it
|
||||
*
|
||||
* @return the SOMImage captured or null in case of failure
|
||||
*/
|
||||
public static SOMImage now() {
|
||||
SOMImage image = new SOMImage();
|
||||
try {
|
||||
// get a process taking the image
|
||||
ProcessBuilder builder = new ProcessBuilder(
|
||||
"gphoto2",
|
||||
"--capture-image-and-download",
|
||||
"--filename=" + image.getTmp().toString());
|
||||
builder.redirectErrorStream(true);
|
||||
|
||||
// launch capture!
|
||||
Process process = builder.start();
|
||||
|
||||
// wait for the process to end
|
||||
if (process.waitFor() == 0) {
|
||||
|
||||
// MOVE & RENAME THE IMAGE
|
||||
Files.move(image.getTmp().toPath(), image.getSrc().toPath(), ATOMIC_MOVE);
|
||||
} else {
|
||||
System.out.println("Capture Process failed");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return image;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,510 @@
|
||||
package workers;
|
||||
|
||||
import GUI.SOMGUI;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import model.SOMConfig;
|
||||
import model.SOMEvent;
|
||||
import model.SOMImage;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.DirectoryFileFilter;
|
||||
import org.apache.commons.io.filefilter.TrueFileFilter;
|
||||
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.file.*;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static java.nio.file.StandardWatchEventKinds.*;
|
||||
|
||||
public class FilesWorker {
|
||||
|
||||
private static final SOMEvent event = SOMEvent.getInstance();
|
||||
|
||||
public FilesWorker() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a File is an image and returns false if not.
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static boolean isImage(Path path) {
|
||||
File f = path.toFile();
|
||||
String mimeType = new MimetypesFileTypeMap().getContentType(f);
|
||||
String type = mimeType.split("/")[0];
|
||||
return type.equals("image");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Path to the Source (direct from Camera) images directory, or
|
||||
* if a File of one of the other Folders is given the Source File' Path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getSourcePath() {
|
||||
File src = new File(getEventPicDir().toString() + "/src");
|
||||
|
||||
// TODO catch possible fail
|
||||
src.mkdirs();
|
||||
return src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Path to the Preview Images (Full Screen) images directory, or
|
||||
* if a File of one of the other Folders is given the Preview File' Path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getPreviewPath() {
|
||||
File prv = new File(getEventPicDir().toString() + "/prv");
|
||||
|
||||
// TODO catch possible fail
|
||||
prv.mkdirs();
|
||||
return prv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Path to the Thumbnail (Gallery) images directory, or if a
|
||||
* File of one of the other Folders is given the Thumbnail File' Path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getThumbPath() {
|
||||
File tmb = new File(getEventPicDir().toString() + "/tmb");
|
||||
|
||||
// TODO catch possible fail
|
||||
tmb.mkdirs();
|
||||
return tmb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Path to the Final images directory, or if a File of one of
|
||||
* the other Folders is given the Final Files' Path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getFinalPath() {
|
||||
File fnl = new File(getEventPicDir().toString() + "/fnl");
|
||||
|
||||
// TODO catch possible fail
|
||||
fnl.mkdirs();
|
||||
return fnl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Path to the Temporary (pre-source) images directory, or if a
|
||||
* File of one of the other Folders is given the Thumbnail File' Path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static File getTempPath() {
|
||||
File tmp = new File(getEventPicDir().toString() + "/tmp");
|
||||
|
||||
// TODO catch possible fail
|
||||
tmp.mkdirs();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Directory for the Event and Creates the Folders
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static File getEventPicDir() {
|
||||
DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
|
||||
|
||||
String timeString = df.format(event.getDate());
|
||||
|
||||
String boxID = SOMConfig.BOX_ID;
|
||||
|
||||
File picturesPath = SOMConfig.PICTURES_PATH;
|
||||
|
||||
File eventPicDir = new File(picturesPath.toString() + "/" + timeString
|
||||
+ "/" + boxID);
|
||||
|
||||
// TODO catch possible fail
|
||||
eventPicDir.mkdirs();
|
||||
|
||||
return eventPicDir;
|
||||
}
|
||||
|
||||
private static boolean internet() {
|
||||
|
||||
Socket sock = new Socket();
|
||||
InetSocketAddress socketAddress = new InetSocketAddress("google.com", 80);
|
||||
|
||||
try {
|
||||
sock.connect(socketAddress, 3000);
|
||||
System.out.println("Internet available");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
System.out.println("Internet NOT available");
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
sock.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void upload() {
|
||||
try {
|
||||
|
||||
// Get all Files in the image Folder
|
||||
List<File> images = allFilesForUpload();
|
||||
// Lists for either dirs or pictures
|
||||
List<File> dirs = new ArrayList<File>();
|
||||
List<File> pics = new ArrayList<File>();
|
||||
|
||||
//relative ones
|
||||
// int directoriesUploaded = 0;
|
||||
// int picturesUploaded = 0;
|
||||
|
||||
// Check for internet connection
|
||||
if (internet()) {
|
||||
|
||||
// Count Files and Dirs
|
||||
for (int i = 0; i < images.size(); i++) {
|
||||
|
||||
// get the current file
|
||||
File file = images.get(i);
|
||||
|
||||
System.out.println(file);
|
||||
|
||||
// get dirs
|
||||
if (file.isDirectory()
|
||||
&& !file.toString().contains("prv")
|
||||
&& !file.toString().contains("tmb")
|
||||
&& !file.toString().contains("tmp")
|
||||
&& !file.toString().contains("fnl")) {
|
||||
dirs.add(file);
|
||||
|
||||
}
|
||||
// get pics
|
||||
else if (file.isFile()
|
||||
&& file.toPath().toString().contains("src")) {
|
||||
pics.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
// REPORT TO CONSOLE
|
||||
System.out.println(dirs.size() + " Directories");
|
||||
System.out.println(pics.size() + " Pics");
|
||||
// GET THE UI
|
||||
|
||||
|
||||
FXMLLoader fxmlLoader = new FXMLLoader();
|
||||
try {
|
||||
fxmlLoader.setLocation(
|
||||
FilesWorker.class.getClassLoader().getResource("fxml/upload.fxml")
|
||||
);
|
||||
|
||||
fxmlLoader.load();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
List<File> limitdirs = new ArrayList<File>();
|
||||
// TODO Limit Uploads
|
||||
for (File dir : dirs
|
||||
) {
|
||||
|
||||
i++;
|
||||
|
||||
System.out.println("Queueing Dir " + dir.toString());
|
||||
limitdirs.add(dir);
|
||||
if (limitdirs.size() >= 3 || limitdirs.size() == i) {
|
||||
|
||||
System.out.println("Launch Dir upload");
|
||||
uploadDir(limitdirs);
|
||||
|
||||
System.out.println("Clear Queue");
|
||||
limitdirs.clear();
|
||||
}
|
||||
}
|
||||
// uploadDir(dirs);
|
||||
List<File> limitpics = new ArrayList<File>();
|
||||
for (File pic : pics
|
||||
) {
|
||||
i++;
|
||||
System.out.println("Queueing Dir " + pic.toString());
|
||||
limitpics.add(pic);
|
||||
if (limitpics.size() >= 3 || limitdirs.size() == i) {
|
||||
|
||||
System.out.println("Launch Pic upload");
|
||||
uploadFile(limitpics);
|
||||
|
||||
System.out.println("Clear Queue");
|
||||
limitpics.clear();
|
||||
}
|
||||
}
|
||||
// uploadFile(pics);
|
||||
|
||||
SOMGUI.changetopicture();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void uploadFile(final List<File> files) throws Exception {
|
||||
final Thread[] threads = new Thread[files.size()];
|
||||
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
|
||||
System.out.println("launch Upload Process: " + i);
|
||||
|
||||
final File file = files.get(i);
|
||||
|
||||
final int pictureCounter = i + 1;
|
||||
Task<Boolean> task = new Task<Boolean>() {
|
||||
|
||||
@Override
|
||||
protected Boolean call() throws Exception {
|
||||
// build the upload process
|
||||
// TODO remove -k option (this option skips certificate verification)
|
||||
ProcessBuilder builder = new ProcessBuilder(
|
||||
"curl",
|
||||
"-T",
|
||||
file.toString(),
|
||||
"-u",
|
||||
"upload:geheim",
|
||||
"https://cloud.selfom.at/remote.php/webdav/" + file.toString().replace("/src", ""),
|
||||
"-k");
|
||||
|
||||
// make the process traceable
|
||||
builder.redirectErrorStream(true);
|
||||
|
||||
|
||||
Process process = builder.start();
|
||||
// launch upload process
|
||||
|
||||
// wait for the process to end
|
||||
if (process.waitFor() == 0) {
|
||||
// process ended successful
|
||||
System.out.println("file uploaded: " + file);
|
||||
|
||||
// TODO get the length of all threads
|
||||
// TODO bind to UI
|
||||
updateProgress(pictureCounter, threads.length);
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// process ended failing
|
||||
// TODO Catch failed uploads
|
||||
System.out.println("process ended failing " + file);
|
||||
Thread.sleep(1000);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SOMGUI.uploadCtl.pictureProgressBar.progressProperty().bind(task.progressProperty());
|
||||
|
||||
threads[i] = new Thread(task);
|
||||
threads[i].setDaemon(true);
|
||||
threads[i].start();
|
||||
}
|
||||
int i = 0;
|
||||
while (i < threads.length) {
|
||||
threads[i].join();
|
||||
i++;
|
||||
}
|
||||
//TODO Catch fails
|
||||
}
|
||||
|
||||
private static void uploadDir(final List<File> dirs) throws Exception {
|
||||
|
||||
final Thread[] threads = new Thread[dirs.size()];
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
|
||||
System.out.println("launch mkdir Process: " + i);
|
||||
|
||||
final File dir = dirs.get(i);
|
||||
final int directoryCounter = i + 1;
|
||||
Task<Boolean> task = new Task<Boolean>() {
|
||||
|
||||
@Override
|
||||
protected Boolean call() throws Exception {
|
||||
// build the Upload process with curl
|
||||
// TODO remove -k option (this option skips certificate verification)
|
||||
ProcessBuilder builder = new ProcessBuilder("curl",
|
||||
"-u",
|
||||
"upload:geheim",
|
||||
"-X",
|
||||
"MKCOL",
|
||||
"https://cloud.selfom.at/remote.php/webdav/" + dir.toString().replace("/src", ""),
|
||||
"-k");
|
||||
|
||||
// make the process traceable
|
||||
builder.redirectErrorStream(true);
|
||||
|
||||
// launch upload process
|
||||
Process process = builder.start();
|
||||
|
||||
// wait for the process to end
|
||||
if (process.waitFor() == 0) {
|
||||
// Process ended successful
|
||||
System.out.println("directory made: " + dir);
|
||||
|
||||
//Set upload Progress
|
||||
// TODO get the length of all threads
|
||||
// TODO bind to UI
|
||||
updateProgress(directoryCounter, threads.length);
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// Process ended failing
|
||||
System.out.println("process ended failing " + dir);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SOMGUI.uploadCtl.folderProgressBar.progressProperty().bind(task.progressProperty());
|
||||
|
||||
// Start the Task
|
||||
threads[i] = new Thread(task);
|
||||
threads[i].setDaemon(true);
|
||||
threads[i].start();
|
||||
} // End of loop
|
||||
|
||||
// Join the tasks
|
||||
int i = 0;
|
||||
while (i < threads.length) {
|
||||
threads[i].join();
|
||||
i++;
|
||||
}
|
||||
|
||||
//TODO Catch upload fails
|
||||
}
|
||||
|
||||
private static List<File> allFilesForUpload() {
|
||||
|
||||
File dir = SOMConfig.PICTURES_PATH;
|
||||
|
||||
Collection filesAndDirs = FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, DirectoryFileFilter.DIRECTORY);
|
||||
|
||||
return new ArrayList<File>(filesAndDirs);
|
||||
}
|
||||
|
||||
// TODO static??
|
||||
public static SOMImage waitForImageAndCapture() {
|
||||
//Behandelt
|
||||
try {
|
||||
|
||||
// Set the Source Path to be watched
|
||||
Path dir = getSourcePath().toPath();
|
||||
|
||||
// REGISTER WATCH SERVICE
|
||||
WatchService watcher = FileSystems.getDefault().newWatchService();
|
||||
dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
|
||||
|
||||
System.out.println("Watch Service registered for dir: "
|
||||
+ dir.getFileName());
|
||||
|
||||
// TRIGGER THE CAPTURE
|
||||
System.out.println("START CAPTURE THREAD");
|
||||
SOMImage newImage = CaptureWorker.now();
|
||||
|
||||
while (true) {
|
||||
|
||||
WatchKey key;
|
||||
|
||||
try {
|
||||
key = watcher.take();
|
||||
} catch (InterruptedException ex) {
|
||||
return newImage;
|
||||
}
|
||||
|
||||
for (WatchEvent<?> event : key.pollEvents()) {
|
||||
WatchEvent.Kind<?> kind = event.kind();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
WatchEvent<Path> ev = (WatchEvent<Path>) event;
|
||||
Path fileName = ev.context();
|
||||
|
||||
System.out.println(kind.name() + ": " + fileName);
|
||||
// check for a file being created
|
||||
if (
|
||||
// Make sure there is an Image created
|
||||
kind == ENTRY_CREATE
|
||||
// Check that filename is the same as expected image
|
||||
&& fileName.toString().equals(
|
||||
newImage.getSrc().getName())) {
|
||||
|
||||
//Set the Progress Indicator to 0.5
|
||||
SOMGUI.captureCtl.pictureLoadIndicator.setProgress(0.5);
|
||||
|
||||
// START THE "PICTURE HAS ARRIVED" ACTION
|
||||
System.out.println("The image is there!!!");
|
||||
|
||||
// ADD THE IMAGE TO THE EVENT
|
||||
FilesWorker.event.addImage(newImage);
|
||||
|
||||
// Set last Image
|
||||
System.out.println("Set the taken Picture to UI");
|
||||
FilesWorker.event.createAndSetImage(FilesWorker.event.getLastImage());
|
||||
|
||||
// Hide the Progress Indicator
|
||||
SOMGUI.captureCtl.pictureLoadIndicator.setVisible(false);
|
||||
// Set back the Progress Indicator
|
||||
SOMGUI.captureCtl.pictureLoadIndicator.setProgress(-1);
|
||||
|
||||
//Close Watcher
|
||||
watcher.close();
|
||||
} else if (
|
||||
// Make sure there is an Image created
|
||||
kind == ENTRY_CREATE
|
||||
// Check that filename is the same as expected image
|
||||
&& !fileName.toString().equals(
|
||||
newImage.getSrc().getName())) {
|
||||
// TODO Catch wrong pictures, only for testing
|
||||
// Hide the Progress Indicator
|
||||
SOMGUI.captureCtl.pictureLoadIndicator.setVisible(false);
|
||||
// Set back the Progress Indicator
|
||||
SOMGUI.captureCtl.pictureLoadIndicator.setProgress(-1);
|
||||
|
||||
//Close Watcher
|
||||
watcher.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
boolean valid = key.reset();
|
||||
if (!valid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// return the new image
|
||||
newImage.updateImageState();
|
||||
return newImage;
|
||||
|
||||
} catch (IOException ex) {
|
||||
System.err.println(ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package workers;
|
||||
|
||||
//import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// import org.cups4j.PrintJob;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class PrintWorker implements Runnable {
|
||||
private static Thread queueWorker = null;
|
||||
private static PrintWorker instance;
|
||||
// TODO Add Printer Model Code
|
||||
private final List<File> waitQueue = new ArrayList<File>();
|
||||
private final List<File> workQueue = new ArrayList<File>();
|
||||
private final File printcountfile = new File("src/main/resources/config/printcount");
|
||||
private File imagetransfer = null;
|
||||
private int copiestransfer = 0;
|
||||
private int printcount = getPrintcount();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private PrintWorker(int copies, File image) {
|
||||
|
||||
this.imagetransfer = image;
|
||||
this.copiestransfer = copies;
|
||||
|
||||
if (queueWorker == null) {
|
||||
queueWorker = new Thread(this);
|
||||
queueWorker.setName("SOMPrintQueue");
|
||||
queueWorker.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param copies
|
||||
* @param image
|
||||
*/
|
||||
public static void print(int copies, File image) {
|
||||
|
||||
if (instance == null) {
|
||||
instance = new PrintWorker(copies, image);
|
||||
} else {
|
||||
instance.addPrint(copies, image);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void resumePrint() {
|
||||
synchronized (queueWorker) {
|
||||
System.out.println("resume print thread");
|
||||
queueWorker.notify();
|
||||
}
|
||||
}
|
||||
|
||||
public Thread getQueueWorker() {
|
||||
return queueWorker;
|
||||
}
|
||||
|
||||
private void addPrint(int copies, File image) {
|
||||
|
||||
// add to Print Queue
|
||||
for (int i = 0; i < copies; i++) {
|
||||
waitQueue.add(image);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void workQueue() {
|
||||
if (printcountfile.exists()) {
|
||||
printcount = getPrintcount();
|
||||
}
|
||||
// Refresh working queue (if there is anything to refresh)
|
||||
if (waitQueue.size() != 0) {
|
||||
for (File image :
|
||||
waitQueue) {
|
||||
// switch files over from wait to work
|
||||
workQueue.add(image);
|
||||
// waitQueue.remove(image);
|
||||
}
|
||||
// TODO Recursion may do this
|
||||
waitQueue.removeAll(waitQueue);
|
||||
}
|
||||
|
||||
// work all the workQueue Files
|
||||
if (workQueue.size() != 0) {
|
||||
for (File image :
|
||||
workQueue) {
|
||||
|
||||
// Halt the Process if anything is empty
|
||||
if (printcount % 36 == 0) {
|
||||
// Check Paper (18 per Package)
|
||||
// MainFrame mf = MainFrame.getInstance();
|
||||
// JPanel cp = (JPanel) mf.getContentPane();
|
||||
// CardLayout cl = (CardLayout) cp.getLayout();
|
||||
//
|
||||
// WarnPanel.getInstance().setTextText("Bitte Papier und Farbe wechseln");
|
||||
|
||||
// cl.show(cp, "warn");
|
||||
|
||||
try {
|
||||
synchronized (queueWorker) {
|
||||
System.out.println("pause print thread");
|
||||
queueWorker.wait();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Todo set printcount to 0
|
||||
|
||||
} else if (printcount % 18 == 0) {
|
||||
// // Check Ink (36 per Package)
|
||||
// MainFrame mf = MainFrame.getInstance();
|
||||
// JPanel cp = (JPanel) mf.getContentPane();
|
||||
// CardLayout cl = (CardLayout) cp.getLayout();
|
||||
//
|
||||
// WarnPanel.getInstance().setTextText("Bitte Papier wechseln");
|
||||
// cl.show(cp, "warn");
|
||||
|
||||
try {
|
||||
synchronized (queueWorker) {
|
||||
System.out.println("pause print thread");
|
||||
queueWorker.wait();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
sendToPrinter(image);
|
||||
System.out.println("Drucke " + printcount);
|
||||
|
||||
// Timeout in Milliseconds
|
||||
try {
|
||||
System.out.println("Going to Sleep");
|
||||
Thread.sleep(65000);
|
||||
System.out.println("Waking Up");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//remove the just printed File from Queue
|
||||
// workQueue.remove(image);
|
||||
addPrintcount();
|
||||
}
|
||||
|
||||
workQueue.removeAll(workQueue);
|
||||
|
||||
workQueue();
|
||||
|
||||
}
|
||||
|
||||
// Recurse
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
workQueue();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param image
|
||||
*/
|
||||
private void sendToPrinter(File image) {
|
||||
// Bild in Druckwarteschlange einfügen
|
||||
String command = "lp " + image.toString();
|
||||
System.out.println(command);
|
||||
|
||||
try {
|
||||
Process child = Runtime.getRuntime().exec(command);
|
||||
System.out.println(child.getErrorStream().toString());
|
||||
addPrintcount();
|
||||
} catch (IOException e) {
|
||||
System.out.println("Print Failed");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void addPrintcount() {
|
||||
// Count up the prints
|
||||
printcount++;
|
||||
// Write printcount to File (for recovery)
|
||||
// try {
|
||||
// FileUtils.writeStringToFile(printcountfile, Integer.toString(printcount));
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private int getPrintcount() {
|
||||
if (printcount == 0) {
|
||||
if (printcountfile.exists()) {
|
||||
System.out.println("printcount is 0, Prontcountfile exists");
|
||||
// try {
|
||||
// // read printcount File
|
||||
// printcount = Integer.parseInt(FileUtils.readFileToString(printcountfile));
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
} else {
|
||||
printcount = 0;
|
||||
}
|
||||
}
|
||||
return printcount;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void run() {
|
||||
// TODO run implementation
|
||||
|
||||
addPrint(copiestransfer, imagetransfer);
|
||||
|
||||
// work down print Queue
|
||||
workQueue();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,514 @@
|
||||
package workers;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.embed.swing.SwingFXUtils;
|
||||
import model.SOMConfig;
|
||||
import model.SOMImage;
|
||||
import model.SOMLayout;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.CropImageFilter;
|
||||
import java.awt.image.FilteredImageSource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ScaleWorker extends Thread {
|
||||
|
||||
public static final int SOURCE = 0;
|
||||
public static final int PREVIEW = 1;
|
||||
public static final int THUMBNAIL = 2;
|
||||
|
||||
SOMConfig config = SOMConfig.getInstance();
|
||||
|
||||
public static SOMImage scale(SOMImage somImage1, final int type) {
|
||||
|
||||
final SOMImage somImage = somImage1;
|
||||
Task task = new Task() {
|
||||
@Override
|
||||
protected SOMImage call() throws Exception {
|
||||
// Do the scale work
|
||||
return prepareandStart(somImage, type);
|
||||
}
|
||||
};
|
||||
|
||||
// open Thread
|
||||
Thread thread = new Thread(task);
|
||||
// start Thread
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//return the somImage1
|
||||
return somImage1;
|
||||
}
|
||||
|
||||
// Overload of scale() that lets you enter Arrays of Pictures
|
||||
public static SOMImage[] scale(SOMImage[] somImages, int type) {
|
||||
// loop through Array of SOMImages
|
||||
for (SOMImage image : somImages) {
|
||||
//update the image
|
||||
image = scale(image, type);
|
||||
}
|
||||
// return the imagearray
|
||||
return somImages;
|
||||
}
|
||||
|
||||
private static SOMImage prepareandStart(SOMImage somImage, int type) {
|
||||
|
||||
|
||||
// the image before scaling
|
||||
// Image sourceImage;
|
||||
// the image after scaling
|
||||
// Image resultImage;
|
||||
|
||||
// type of image to be used to scale down
|
||||
int source = SOURCE;
|
||||
|
||||
// check for scaled versions of the image
|
||||
somImage.updateImageState();
|
||||
|
||||
// preview
|
||||
if (type == PREVIEW) {
|
||||
// check if the requested image already exists
|
||||
if (somImage.isPrvthere())
|
||||
// exit the scaler
|
||||
return somImage;
|
||||
|
||||
// The requested image does not exist,
|
||||
}
|
||||
|
||||
// thumbnail
|
||||
if (type == THUMBNAIL) {
|
||||
// check if the requested image already exists
|
||||
if (somImage.isTmbthere()) {
|
||||
return somImage;
|
||||
}
|
||||
// The requested image does not exist,
|
||||
// check for Preview to scale faster
|
||||
if (somImage.isPrvthere()) {
|
||||
source = PREVIEW;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// In any other case we need to scale the
|
||||
// full sized image, which is default
|
||||
|
||||
somImage = generateScaledImage(somImage, type, source);
|
||||
|
||||
return somImage;
|
||||
}
|
||||
|
||||
private static SOMImage generateScaledImage(SOMImage somImage, int target, int source) {
|
||||
// the source image size
|
||||
double sourceWidth = 0;
|
||||
double sourceHeight = 0;
|
||||
|
||||
// the scaled sources width and height
|
||||
// before cropping
|
||||
int scaledSourceHeight;
|
||||
int scaledSourceWidth;
|
||||
|
||||
// the later image size
|
||||
int targetWidth = 0;
|
||||
int targetHeight = 0;
|
||||
|
||||
// Aspect ratio before cropping
|
||||
double sourceAspect;
|
||||
// The ImageViews' cropped aspect ratio
|
||||
double targetAspect;
|
||||
|
||||
// Source File
|
||||
File sourceFile = somImage.getSrc();
|
||||
// Target File
|
||||
File targetFile = null;
|
||||
|
||||
// ImageIcons
|
||||
ImageIcon sourceImageIcon;
|
||||
ImageIcon targetImageIcon;
|
||||
|
||||
// JAVAFX Images
|
||||
javafx.scene.image.Image targetImage;
|
||||
|
||||
// Buffered Images
|
||||
BufferedImage scaledSourceBufferedImage;
|
||||
BufferedImage croppedBufferedImage;
|
||||
|
||||
// Graphics for Buffered Images
|
||||
Graphics2D scaledSourceGraphics;
|
||||
Graphics croppedGraphics;
|
||||
|
||||
// get the target IMAGE SIZES
|
||||
// and the target FILE
|
||||
switch (target) {
|
||||
|
||||
// for the preview
|
||||
case PREVIEW:
|
||||
targetWidth = SOMLayout.screenWidth;
|
||||
targetHeight = SOMLayout.screenHeight;
|
||||
|
||||
targetFile = somImage.getPrv();
|
||||
|
||||
// for the Thumbnail
|
||||
break;
|
||||
case THUMBNAIL:
|
||||
targetWidth = SOMLayout.getColumn(1);
|
||||
targetHeight = SOMLayout.getRow(1);
|
||||
|
||||
targetFile = somImage.getTmb();
|
||||
break;
|
||||
}
|
||||
|
||||
// get the SOURCE FILE
|
||||
switch (source) {
|
||||
case SOURCE:
|
||||
sourceFile = somImage.getSrc();
|
||||
break;
|
||||
case PREVIEW:
|
||||
sourceFile = somImage.getPrv();
|
||||
break;
|
||||
}
|
||||
|
||||
switch (SOMConfig.SCALING_ALGORITHM) {
|
||||
|
||||
// GRAPHICS 2D ----------------------------------------------------------
|
||||
case SOMConfig.SCALING_GRAPHICS_2D: {
|
||||
// Generate an ImageIcon from the Source File
|
||||
sourceImageIcon = new ImageIcon(sourceFile.getPath());
|
||||
|
||||
// the sources original width and height
|
||||
sourceWidth = sourceImageIcon.getIconWidth();
|
||||
sourceHeight = sourceImageIcon.getIconHeight();
|
||||
|
||||
// Calculate the aspect ratio before cropping
|
||||
sourceAspect = (sourceWidth) / (sourceHeight);
|
||||
|
||||
// Calculate the ImageViews' cropped aspect ratio
|
||||
targetAspect = ((double) targetWidth) / ((double) targetHeight);
|
||||
|
||||
// if picture is higher than frame
|
||||
if (sourceAspect < targetAspect) {
|
||||
scaledSourceHeight = (int) Math.ceil(targetWidth / sourceAspect);
|
||||
scaledSourceWidth = targetWidth;
|
||||
}
|
||||
|
||||
// if Picture is narrower (or equal)
|
||||
else {
|
||||
scaledSourceWidth = (int) Math.ceil(targetHeight * sourceAspect);
|
||||
scaledSourceHeight = targetHeight;
|
||||
}
|
||||
|
||||
// Probably way faster than ImageIcon
|
||||
System.out.println("Scale with Graphics2D:");
|
||||
|
||||
// Print the File Path
|
||||
System.out.println(sourceFile.toString());
|
||||
|
||||
// Print the Sizes
|
||||
System.out.println("Size now: " + sourceWidth + "px X " + sourceHeight + "px");
|
||||
System.out.println("Size between: " + scaledSourceWidth + "px X " + scaledSourceHeight + "px");
|
||||
System.out.println("Size after: " + targetWidth + "px X " + targetHeight + "px");
|
||||
|
||||
// SCALE -----------------------------------------------------------
|
||||
// THE -------------------------------------------------------------
|
||||
// SOURCE ----------------------------------------------------------
|
||||
|
||||
// Get the ImageIcon
|
||||
Image sourceImageIconImage = sourceImageIcon.getImage();
|
||||
System.out.println("Got the ImageIcon");
|
||||
|
||||
// Open a buffered Image in the specified size
|
||||
// (with no data at this point --> black image)
|
||||
scaledSourceBufferedImage = new BufferedImage(
|
||||
scaledSourceWidth,
|
||||
scaledSourceHeight,
|
||||
BufferedImage.TYPE_INT_RGB
|
||||
);
|
||||
System.out.println("Got the BufferedImage");
|
||||
|
||||
// Get the Graphics2D
|
||||
scaledSourceGraphics = scaledSourceBufferedImage.createGraphics();
|
||||
System.out.println("Got the Graphics2D");
|
||||
|
||||
// Set the Rendering hints
|
||||
scaledSourceGraphics.setRenderingHint(
|
||||
RenderingHints.KEY_INTERPOLATION,
|
||||
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
|
||||
);
|
||||
System.out.println("Rendering Hints Set");
|
||||
|
||||
// Actually Scale the Image
|
||||
scaledSourceGraphics.drawImage(sourceImageIconImage, 0, 0, scaledSourceWidth, scaledSourceHeight, null);
|
||||
System.out.println("IMAGE SCALED");
|
||||
|
||||
scaledSourceGraphics.dispose();
|
||||
// System Resources Released
|
||||
// TODO Can we use this for perormance??
|
||||
|
||||
System.out.println("Got the target Image Icon");
|
||||
|
||||
|
||||
// Calculate the Offsets
|
||||
int wOffset;
|
||||
int hOffset;
|
||||
|
||||
// CROP ------------------------------------------------------------
|
||||
// THE -------------------------------------------------------------
|
||||
// IMAGE -----------------------------------------------------------
|
||||
|
||||
if (sourceAspect > targetAspect) {
|
||||
hOffset = 0;
|
||||
wOffset = (scaledSourceWidth - targetWidth) / 2;
|
||||
} else {
|
||||
hOffset = (scaledSourceHeight - targetHeight) / 2;
|
||||
wOffset = 0;
|
||||
}
|
||||
|
||||
System.out.println("Got the Offset for cropping");
|
||||
|
||||
System.out.println("Get the Crop Image Filter");
|
||||
|
||||
CropImageFilter cropimgf = new CropImageFilter(
|
||||
// Crop by moving the image half the way
|
||||
// it is wider to the left
|
||||
wOffset,
|
||||
// Crop by moving the image half the way
|
||||
// it is higher to the top
|
||||
hOffset,
|
||||
|
||||
targetWidth,
|
||||
targetHeight
|
||||
);
|
||||
|
||||
System.out.println("Ready");
|
||||
|
||||
System.out.println("Get the Filtered image Source");
|
||||
|
||||
FilteredImageSource producer = new FilteredImageSource(
|
||||
scaledSourceBufferedImage.getSource(),
|
||||
cropimgf
|
||||
);
|
||||
|
||||
System.out.println("Ready");
|
||||
|
||||
System.out.println("Get the target Image");
|
||||
Image image = Toolkit.getDefaultToolkit().createImage(
|
||||
producer
|
||||
);
|
||||
System.out.println("Ready");
|
||||
|
||||
System.out.println("Get the target image Icon");
|
||||
targetImageIcon = new ImageIcon( // TODO Veeeery slow on raspberry
|
||||
image
|
||||
);
|
||||
System.out.println("Ready");
|
||||
// TODO Check if there is something in the Image Icon on RPi
|
||||
System.out.println("IMAGE CROPPED");
|
||||
|
||||
// save the smaller image
|
||||
croppedBufferedImage = new BufferedImage(
|
||||
targetWidth,
|
||||
targetHeight,
|
||||
BufferedImage.TYPE_INT_RGB
|
||||
);
|
||||
|
||||
System.out.println("Got the BufferedImage after CROPPING");
|
||||
croppedGraphics = croppedBufferedImage.getGraphics();
|
||||
System.out.println("Got the Graphics");
|
||||
|
||||
croppedGraphics.drawImage(targetImageIcon.getImage(), 0, 0, null);
|
||||
|
||||
System.out.println("Graphics drawn");
|
||||
|
||||
// WRITE ---------------------------------------------------------------
|
||||
// THE -----------------------------------------------------------------
|
||||
// IMAGE ---------------------------------------------------------------
|
||||
|
||||
System.out.println("Writing Thumb");
|
||||
|
||||
System.out.println("Trying to write image to " + targetFile.toString());
|
||||
System.out.println(croppedBufferedImage.toString());
|
||||
// TODO Breaking up at this point on the RPi --> Look at older ScaleWorker
|
||||
|
||||
writeJPEG(targetFile, croppedBufferedImage);
|
||||
|
||||
System.out.println("Image Writer returned: "
|
||||
// + iw
|
||||
);
|
||||
|
||||
|
||||
// UPDATE ---------------------------------------------------------------
|
||||
// IMAGE ----------------------------------------------------------------
|
||||
// STATE ----------------------------------------------------------------
|
||||
|
||||
somImage.updateImageState();
|
||||
|
||||
System.out.println("Image State Updated");
|
||||
|
||||
// Clean up
|
||||
croppedGraphics.dispose();
|
||||
scaledSourceGraphics.dispose();
|
||||
|
||||
image.flush();
|
||||
sourceImageIconImage.flush();
|
||||
|
||||
System.gc();
|
||||
|
||||
break;
|
||||
}
|
||||
case SOMConfig.SCALING_IMAGE_ICON: {
|
||||
// // IMAGE ICON ----------------------------------------------------------
|
||||
// // Generate an ImageIcon from the Source File
|
||||
// sourceImage = new javafx.scene.image.Image(sourceFile.toString());
|
||||
// // the sources original width and height
|
||||
// sourceWidth = sourceImage.getWidth();
|
||||
// sourceHeight = sourceImage.getHeight();
|
||||
//
|
||||
// // Calculate the aspect ratio before cropping
|
||||
// sourceAspect = (sourceWidth) / (sourceHeight);
|
||||
// // Calculate the ImageViews' cropped aspect ratio
|
||||
// targetAspect = ((double) targetWidth) / ((double) targetHeight);
|
||||
//
|
||||
// // if picture is higher than frame
|
||||
// if (sourceAspect < targetAspect) {
|
||||
// scaledSourceHeight = (int) Math.ceil(targetWidth / sourceAspect);
|
||||
// scaledSourceWidth = targetWidth;
|
||||
// }
|
||||
//
|
||||
// // if Picture is narrower (or equal)
|
||||
// else {
|
||||
// scaledSourceWidth = (int) Math.ceil(targetHeight * sourceAspect);
|
||||
// scaledSourceHeight = targetHeight;
|
||||
// }
|
||||
//
|
||||
// //Way too slow for the RPi
|
||||
// System.out.println("Scale with ImageIcon");
|
||||
//
|
||||
// // Scale to right size,
|
||||
// // no cropping
|
||||
// targetImageIcon = new ImageIcon(
|
||||
// sourceImageIcon.getImage().getScaledInstance(
|
||||
// scaledSourceWidth, scaledSourceHeight,
|
||||
// Image.SCALE_FAST
|
||||
// ));
|
||||
//
|
||||
//
|
||||
// // Calculate the Offsets
|
||||
// int wOffset;
|
||||
// int hOffset;
|
||||
//
|
||||
// // ----------
|
||||
// // Crop Image
|
||||
// if (sourceAspect > targetAspect) {
|
||||
// hOffset = 0;
|
||||
// wOffset = (scaledSourceWidth - targetWidth) / 2;
|
||||
// } else {
|
||||
// hOffset = (scaledSourceHeight - targetHeight) / 2;
|
||||
// wOffset = 0;
|
||||
// }
|
||||
//
|
||||
// System.out.println("Got the Offset for cropping");
|
||||
//
|
||||
// System.out.println("Get the Crop Image Filter");
|
||||
// CropImageFilter cropimgf = new CropImageFilter(
|
||||
// // Crop by moving the image half the way
|
||||
// // it is wider to the left
|
||||
// wOffset,
|
||||
// // Crop by moving the image half the way
|
||||
// // it is higher to the top
|
||||
// hOffset,
|
||||
//
|
||||
// targetWidth,
|
||||
// targetHeight
|
||||
// );
|
||||
// System.out.println("Ready");
|
||||
//
|
||||
// System.out.println("Get the Filtered image Source");
|
||||
// FilteredImageSource producer = new FilteredImageSource(
|
||||
// sourceImageIcon.getImage().getSource(),
|
||||
// cropimgf
|
||||
// );
|
||||
// System.out.println("Ready");
|
||||
//
|
||||
// System.out.println("Get the target Image");
|
||||
// Image image = Toolkit.getDefaultToolkit().createImage(
|
||||
// producer
|
||||
// );
|
||||
// System.out.println("Ready");
|
||||
//
|
||||
// System.out.println("Get the target image Icon");
|
||||
// targetImageIcon = new ImageIcon( // TODO Veeeery slow on raspberry
|
||||
// image
|
||||
// );
|
||||
// System.out.println("Ready");
|
||||
// // TODO Check if there is something in the Image Icon on RPi
|
||||
// System.out.println("IMAGE CROPPED");
|
||||
//
|
||||
// // save the smaller image
|
||||
// BufferedImage bufferedImage = new BufferedImage(
|
||||
// targetWidth,
|
||||
// targetHeight,
|
||||
// BufferedImage.TYPE_INT_RGB
|
||||
// );
|
||||
//
|
||||
// System.out.println("Got the BufferedImage after CROPPING");
|
||||
// croppedGraphics = bufferedImage.getGraphics();
|
||||
// System.out.println("Got the Graphics");
|
||||
//
|
||||
// croppedGraphics.drawImage(targetImageIcon.getImage(), 0, 0, null);
|
||||
//
|
||||
// System.out.println("Graphics drawn");
|
||||
//
|
||||
// System.out.println("Writing Thumb");
|
||||
//
|
||||
// System.out.println("Trying to write image to " + targetFile.toString());
|
||||
// System.out.println(bufferedImage.toString());
|
||||
// // TODO Breaking up at this point on the RPi --> Look at older ScaleWorker
|
||||
//
|
||||
// writeJPEG(targetFile, bufferedImage);
|
||||
//
|
||||
// System.out.println("Image Writer returned: "
|
||||
//// + iw
|
||||
// );
|
||||
// somImage.updateImageState();
|
||||
//
|
||||
// System.out.println("Image State Updated");
|
||||
//
|
||||
// somImage.updateImageState();
|
||||
break;
|
||||
}
|
||||
// JAVAFX ----------------------------------------------------------
|
||||
case SOMConfig.SCALING_JAVAFX: {
|
||||
// Scale with javafx
|
||||
// FIXME breaks up
|
||||
targetImage = new javafx.scene.image.Image(sourceFile.toString(), targetWidth, targetHeight, true, false, true);
|
||||
|
||||
BufferedImage bi = SwingFXUtils.fromFXImage(targetImage, null);
|
||||
writeJPEG(targetFile, bi);
|
||||
|
||||
somImage.updateImageState();
|
||||
|
||||
System.out.println("Image State Updated");
|
||||
|
||||
somImage.updateImageState();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return somImage;
|
||||
}
|
||||
|
||||
private static void writeJPEG(File targetFile, BufferedImage bi) {
|
||||
try {
|
||||
boolean iw = ImageIO.write(bi, "JPEG", targetFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: Start
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<Config>
|
||||
<boxID>selfomat-42</boxID>
|
||||
<installationPath>\usr\bin\selfomat</installationPath>
|
||||
<picturesPath>images</picturesPath>
|
||||
</Config>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ProgressIndicator?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<StackPane xmlns:fx="http://javafx.com/fxml/1" fx:id="capturePane" maxHeight="-Infinity" maxWidth="-Infinity"
|
||||
minHeight="-Infinity"
|
||||
minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8"
|
||||
fx:controller="GUI.CaptureCtl">
|
||||
<children>
|
||||
<ImageView fx:id="image" pickOnBounds="true" preserveRatio="true"/>
|
||||
<Label fx:id="countdownText"/>
|
||||
<ProgressIndicator fx:id="pictureLoadIndicator" progress="-1.0"/>
|
||||
</children>
|
||||
</StackPane>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<Pane xmlns:fx="http://javafx.com/fxml/1" fx:id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
|
||||
minWidth="-Infinity" prefHeight="69.0" prefWidth="64.0" xmlns="http://javafx.com/javafx/8"
|
||||
fx:controller="GUI.GalleryCtl">
|
||||
<children>
|
||||
<GridPane fx:id="grid">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints percentWidth="25"/>
|
||||
<ColumnConstraints percentWidth="25"/>
|
||||
<ColumnConstraints percentWidth="25"/>
|
||||
<ColumnConstraints percentWidth="25"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints percentHeight="33.3"/>
|
||||
<RowConstraints percentHeight="33.3"/>
|
||||
<RowConstraints percentHeight="33.3"/>
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Button fx:id="forthButton" mnemonicParsing="false" GridPane.columnIndex="3"/>
|
||||
<Button fx:id="pictureButton" mnemonicParsing="false" GridPane.columnIndex="3" GridPane.rowIndex="1"/>
|
||||
<Button fx:id="backButton" mnemonicParsing="false" GridPane.columnIndex="3" GridPane.rowIndex="2"/>
|
||||
<Button fx:id="galleryButton1" mnemonicParsing="false" text="1">
|
||||
<graphic>
|
||||
<!--ROW 1-->
|
||||
<ImageView fx:id="galleryImageView1" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="galleryButton2" mnemonicParsing="false" text="2" GridPane.columnIndex="1">
|
||||
<graphic>
|
||||
<ImageView fx:id="galleryImageView2" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="galleryButton3" mnemonicParsing="false" text="3" GridPane.columnIndex="2">
|
||||
<graphic>
|
||||
<ImageView fx:id="galleryImageView3" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="galleryButton6" mnemonicParsing="false" text="6" GridPane.columnIndex="2"
|
||||
GridPane.rowIndex="1">
|
||||
<graphic>
|
||||
<ImageView fx:id="galleryImageView6" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="galleryButton4" mnemonicParsing="false" text="4" GridPane.rowIndex="1">
|
||||
<graphic>
|
||||
<!--ROW 2-->
|
||||
|
||||
<ImageView fx:id="galleryImageView4" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="galleryButton5" mnemonicParsing="false" text="5" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="1">
|
||||
<graphic>
|
||||
<ImageView fx:id="galleryImageView5" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="galleryButton9" mnemonicParsing="false" text="9" GridPane.columnIndex="2"
|
||||
GridPane.rowIndex="2">
|
||||
<graphic>
|
||||
<ImageView fx:id="galleryImageView9" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="galleryButton7" mnemonicParsing="false" text="7" GridPane.rowIndex="2">
|
||||
<graphic>
|
||||
<!--ROW 3-->
|
||||
|
||||
<ImageView fx:id="galleryImageView7" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="galleryButton8" mnemonicParsing="false" text="8" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="2">
|
||||
<graphic>
|
||||
<ImageView fx:id="galleryImageView8" preserveRatio="true"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
</Pane>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<Pane xmlns:fx="http://javafx.com/fxml/1" fx:id="pane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
|
||||
minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8"
|
||||
fx:controller="GUI.PictureCtl">
|
||||
<ImageView fx:id="image" pickOnBounds="true" preserveRatio="true">
|
||||
|
||||
</ImageView>
|
||||
<GridPane fx:id="grid">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
<Button fx:id="singleBtn" mnemonicParsing="false" prefHeight="146.0" prefWidth="215.0" text="Button"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
<Button fx:id="galleryBtn" mnemonicParsing="false" prefHeight="146.0" prefWidth="218.0" text="Button"
|
||||
GridPane.rowIndex="2"/>
|
||||
<Button fx:id="seriesBtn" mnemonicParsing="false" prefHeight="183.0" prefWidth="221.0" text="Button"
|
||||
GridPane.columnIndex="2" GridPane.rowIndex="2"/>
|
||||
</GridPane>
|
||||
</Pane>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<Pane xmlns:fx="http://javafx.com/fxml/1" fx:id="pane" xmlns="http://javafx.com/javafx/8" fx:controller="GUI.UploadCtl">
|
||||
<GridPane fx:id="grid" alignment="CENTER" prefHeight="400.0" prefWidth="600.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
<ProgressBar fx:id="folderProgressBar" prefWidth="200.0" progress="0.0" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="2"/>
|
||||
<ProgressBar fx:id="pictureProgressBar" prefWidth="200.0" progress="0.0" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="1"/>
|
||||
<ProgressBar fx:id="cleanProgressBar" prefWidth="200.0" progress="0.0" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="3"/>
|
||||
<ImageView fx:id="folderImageView" fitHeight="100" fitWidth="100.0" pickOnBounds="true" preserveRatio="true"
|
||||
GridPane.rowIndex="1">
|
||||
</ImageView>
|
||||
<ImageView fx:id="pictureImageView" fitHeight="100.0" fitWidth="100.0" pickOnBounds="true"
|
||||
preserveRatio="true"
|
||||
GridPane.rowIndex="2">
|
||||
</ImageView>
|
||||
<ImageView fx:id="cleanImageView" fitHeight="100.0" fitWidth="100" pickOnBounds="true" preserveRatio="true"
|
||||
GridPane.rowIndex="3">
|
||||
</ImageView>
|
||||
<Label fx:id="headLabel" text="Uploading..." GridPane.columnIndex="1"/>
|
||||
<Label fx:id="folderLabel" text="Folders" GridPane.columnIndex="2" GridPane.rowIndex="1"/>
|
||||
<Label fx:id="picLabel" text="Pictures" GridPane.columnIndex="2" GridPane.rowIndex="2"/>
|
||||
<Label fx:id="cleanLabel" text="Clean up" GridPane.columnIndex="2" GridPane.rowIndex="3"/>
|
||||
</GridPane>
|
||||
</Pane>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.TextFlow?>
|
||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
|
||||
prefWidth="600.0" xmlns="http://javafx.com/javafx/8">
|
||||
<ImageView fitHeight="400.0" fitWidth="600.0" pickOnBounds="true" preserveRatio="true"/>
|
||||
<GridPane prefHeight="400.0" prefWidth="600.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="520.0" minWidth="10.0" prefWidth="450.0"/>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="295.0" minWidth="10.0" prefWidth="150.0"/>
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||
</rowConstraints>
|
||||
<Button mnemonicParsing="false" prefHeight="480.0" prefWidth="150.0" text="Button"
|
||||
GridPane.columnIndex="1"/>
|
||||
<TextFlow prefHeight="200.0" prefWidth="200.0"/>
|
||||
</GridPane>
|
||||
</Pane>
|
||||
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 8.0 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 8.2 KiB |
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,5 @@
|
||||
cd images
|
||||
gphoto2 --capture-image
|
||||
gphoto2 --get-all-images
|
||||
gphoto2 --delete-all-images
|
||||
cd
|
||||