Initial commit...
This commit is contained in:
107
Java Peojects/FXImager/src/v0.0.1/Controller.java
Normal file
107
Java Peojects/FXImager/src/v0.0.1/Controller.java
Normal file
@@ -0,0 +1,107 @@
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.TilePane;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class Controller {
|
||||
private DirectoryChooser folderChooser = new DirectoryChooser();
|
||||
private Image pth = new Image(".");
|
||||
private Image previewPth = new Image(".");
|
||||
private ImageView imgView = new ImageView(pth);
|
||||
private String textAreaPth = "";
|
||||
private File directory;
|
||||
@FXML // fx:id="dir"
|
||||
private Label dir; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="txtDirPath"
|
||||
private TextField txtDirPath; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="clear"
|
||||
private Button clear; // Value injected by FXMLLoader
|
||||
@FXML // fx:id="tilePane"
|
||||
private TilePane tilePane; // Value injected by FXMLLoader
|
||||
|
||||
// Handler for TextArea[fx:id="txtDirPath"] onKeyReleased
|
||||
@FXML
|
||||
void onEnter(KeyEvent event) {
|
||||
if (event.getCode().equals(KeyCode.ENTER)) {
|
||||
textAreaPth = txtDirPath.getText();
|
||||
System.out.println(textAreaPth);
|
||||
newDir();
|
||||
}
|
||||
else
|
||||
System.out.println("Not calling newDir...");
|
||||
}
|
||||
// Handler for Button[fx:id="dir"] onAction
|
||||
@FXML
|
||||
void setNewDir(MouseEvent event) {
|
||||
newDir();
|
||||
}
|
||||
@FXML
|
||||
void clearBttnClick(ActionEvent event) {
|
||||
tilePane.getChildren().clear();
|
||||
tilePane.getChildren().addAll(dir);
|
||||
}
|
||||
public void newDir() {
|
||||
Stage stage = new Stage();
|
||||
if (textAreaPth != "")
|
||||
directory = new File(textAreaPth);
|
||||
else
|
||||
directory = folderChooser.showDialog(stage);
|
||||
|
||||
File[] fileList = directory.listFiles();
|
||||
int size = fileList.length;
|
||||
tilePane.getChildren().clear();
|
||||
txtDirPath.setText("" + directory);
|
||||
for (int i=0; i<size; i++) {
|
||||
imgView = new ImageView("file://" + fileList[i]);
|
||||
String title = "" + fileList[i];
|
||||
imgView.setFitWidth(300);
|
||||
imgView.setFitHeight(200);
|
||||
tilePane.getChildren().add(imgView);
|
||||
final ImageView imgViewPoped = new ImageView("file://" + fileList[i]);
|
||||
// image click actions
|
||||
imgView.setOnMouseClicked(e -> {
|
||||
displayImg(imgViewPoped, title);
|
||||
});
|
||||
}
|
||||
}
|
||||
public void displayImg(ImageView imgViewPoped, String title) {
|
||||
imgViewPoped.setLayoutX(0);
|
||||
imgViewPoped.setLayoutY(0);
|
||||
Stage popOut = new Stage();
|
||||
Pane pane = new Pane();
|
||||
imgViewPoped.fitWidthProperty().bind(pane.widthProperty());
|
||||
imgViewPoped.fitHeightProperty().bind(pane.heightProperty());
|
||||
pane.getChildren().addAll(imgViewPoped);
|
||||
Scene scene = new Scene(pane, 1280, 900);
|
||||
popOut.setTitle(title);
|
||||
popOut.initStyle(StageStyle.UNDECORATED);
|
||||
popOut.setScene(scene);
|
||||
popOut.show();
|
||||
|
||||
imgViewPoped.setOnMouseClicked(e -> {
|
||||
popOut.close();
|
||||
});
|
||||
}
|
||||
@FXML // This method is called by the FXMLLoader when initialization is complete
|
||||
void initialize() {
|
||||
assert clear != null : "fx:id=\"clear\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert dir != null : "fx:id=\"dir\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tilePane != null : "fx:id=\"tilePane\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert txtDirPath != null : "fx:id=\"txtDirPath\" was not injected: check your FXML file 'window.fxml'.";
|
||||
// Initialize your logic here: all @FXML variables will have been injected
|
||||
}
|
||||
}
|
23
Java Peojects/FXImager/src/v0.0.1/Main.java
Normal file
23
Java Peojects/FXImager/src/v0.0.1/Main.java
Normal file
@@ -0,0 +1,23 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
|
||||
|
||||
public class Main extends Application {
|
||||
@Override
|
||||
public void start(final Stage stage) throws Exception {
|
||||
Scene scene = new Scene(FXMLLoader.load(Main.class.getResource("window.fxml")));
|
||||
scene.getStylesheets().add("stylesheet.css");
|
||||
stage.setScene(scene);
|
||||
//stage.setResizable(false); // keeps window from resizing
|
||||
stage.setTitle("Image Viewer");
|
||||
stage.setMinWidth(300);
|
||||
stage.setMinHeight(300);
|
||||
stage.show();
|
||||
}
|
||||
// needed because you know... it's java.
|
||||
public static void main(String[] args) { launch(args); }
|
||||
}
|
5
Java Peojects/FXImager/src/v0.0.1/stylesheet.css
Normal file
5
Java Peojects/FXImager/src/v0.0.1/stylesheet.css
Normal file
@@ -0,0 +1,5 @@
|
||||
.root {
|
||||
-fx-background: rgba(68, 68, 68, 0.8); // == #444444;
|
||||
}
|
||||
.button {
|
||||
}
|
37
Java Peojects/FXImager/src/v0.0.1/window.fxml
Normal file
37
Java Peojects/FXImager/src/v0.0.1/window.fxml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?scenebuilder-background-color 0x444444ff?>
|
||||
|
||||
<AnchorPane minHeight="300.0" minWidth="300.0" prefHeight="600.0" prefWidth="950.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="Controller">
|
||||
<children>
|
||||
<HBox alignment="TOP_RIGHT" layoutY="0.0" prefHeight="21.0" prefWidth="948.0" AnchorPane.leftAnchor="1.0" AnchorPane.rightAnchor="1.0">
|
||||
<children>
|
||||
<TextField fx:id="txtDirPath" blendMode="DIFFERENCE" onKeyReleased="#onEnter" prefWidth="200.0" promptText="Dir Path" HBox.hgrow="ALWAYS" />
|
||||
<Button fx:id="clear" mnemonicParsing="false" onAction="#clearBttnClick" text="Clear" />
|
||||
</children>
|
||||
</HBox>
|
||||
<ScrollPane id="ScrollPane" minHeight="300.0" minWidth="300.0" prefHeight="547.0" prefViewportHeight="534.0" prefViewportWidth="742.0" prefWidth="770.0" style=" -fx-fit-to-height: true; -fx-fit-to-width: true;" AnchorPane.bottomAnchor="-2.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="25.0">
|
||||
<content>
|
||||
<TilePane fx:id="tilePane" hgap="15.0" prefHeight="532.0" prefWidth="755.0" vgap="15.0">
|
||||
<children>
|
||||
<Label fx:id="dir" contentDisplay="CENTER" labelFor="$clear" onMouseClicked="#setNewDir" prefHeight="575.0" prefWidth="948.0" text="Choose Dir" textAlignment="LEFT" textFill="#dfdfdf" textOverrun="CLIP" underline="false" wrapText="false" TilePane.alignment="CENTER_LEFT">
|
||||
<font>
|
||||
<Font name="System Bold" size="32.0" />
|
||||
</font>
|
||||
<TilePane.margin>
|
||||
<Insets />
|
||||
</TilePane.margin>
|
||||
</Label>
|
||||
</children>
|
||||
</TilePane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
</AnchorPane>
|
107
Java Peojects/FXImager/src/v0.0.2/Controller.java
Normal file
107
Java Peojects/FXImager/src/v0.0.2/Controller.java
Normal file
@@ -0,0 +1,107 @@
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.TilePane;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class Controller {
|
||||
private DirectoryChooser folderChooser = new DirectoryChooser();
|
||||
private Image pth = new Image(".");
|
||||
private Image previewPth = new Image(".");
|
||||
private ImageView imgView = new ImageView(pth);
|
||||
private String textAreaPth = "";
|
||||
private File directory;
|
||||
@FXML private Label dir; // Value injected by FXMLLoader
|
||||
@FXML private TextField txtDirPath; // Value injected by FXMLLoader
|
||||
@FXML private Button clear; // Value injected by FXMLLoader
|
||||
@FXML private TilePane tilePane; // Value injected by FXMLLoader
|
||||
|
||||
// This method is called by the FXMLLoader when initialization is complete
|
||||
@FXML void initialize() {
|
||||
assert clear != null : "fx:id=\"clear\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert dir != null : "fx:id=\"dir\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert tilePane != null : "fx:id=\"tilePane\" was not injected: check your FXML file 'window.fxml'.";
|
||||
assert txtDirPath != null : "fx:id=\"txtDirPath\" was not injected: check your FXML file 'window.fxml'.";
|
||||
// Initialize your logic here: all @FXML variables will have been injected
|
||||
}
|
||||
|
||||
// Handler for TextArea[fx:id="txtDirPath"] onKeyReleased
|
||||
@FXML void onEnter(KeyEvent event) {
|
||||
if (event.getCode().equals(KeyCode.ENTER)) {
|
||||
textAreaPth = txtDirPath.getText();
|
||||
System.out.println(textAreaPth);
|
||||
newDir();
|
||||
}
|
||||
else
|
||||
System.out.println("Not calling newDir...");
|
||||
}
|
||||
// Handler for Button[fx:id="dir"] onAction
|
||||
@FXML void setNewDir(MouseEvent event) {
|
||||
newDir();
|
||||
}
|
||||
public void newDir() {
|
||||
Stage stage = new Stage();
|
||||
if (textAreaPth != "")
|
||||
directory = new File(textAreaPth);
|
||||
else
|
||||
directory = folderChooser.showDialog(stage);
|
||||
|
||||
File[] fileList = directory.listFiles();
|
||||
int size = fileList.length;
|
||||
tilePane.getChildren().clear();
|
||||
txtDirPath.setText("" + directory);
|
||||
for (int i=0; i<size; i++) {
|
||||
if(fileList[i].getName().toLowerCase().contains(".png") ||
|
||||
fileList[i].getName().toLowerCase().contains(".jpg")||
|
||||
fileList[i].getName().toLowerCase().contains(".gif") ||
|
||||
fileList[i].getName().toLowerCase().contains(".jpeg")) {
|
||||
imgView = new ImageView("file://" + fileList[i]);
|
||||
String title = "" + fileList[i];
|
||||
imgView.setFitWidth(300);
|
||||
imgView.setFitHeight(200);
|
||||
tilePane.getChildren().add(imgView);
|
||||
final ImageView imgViewPoped = new ImageView("file://" + fileList[i]);
|
||||
// image click actions
|
||||
imgView.setOnMouseClicked(mouse -> {
|
||||
if (mouse.getClickCount() == 2 && !mouse.isConsumed()) {
|
||||
mouse.consume();
|
||||
displayImg(imgViewPoped, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void displayImg(ImageView imgViewPoped, String title) {
|
||||
Stage popOut = new Stage();
|
||||
Pane pane = new Pane();
|
||||
imgViewPoped.setLayoutX(0);
|
||||
imgViewPoped.setLayoutY(0);
|
||||
imgViewPoped.fitWidthProperty().bind(pane.widthProperty());
|
||||
imgViewPoped.fitHeightProperty().bind(pane.heightProperty());
|
||||
pane.getChildren().add(imgViewPoped);
|
||||
Scene scene = new Scene(pane, 1280, 900);
|
||||
popOut.setTitle(title);
|
||||
popOut.setScene(scene);
|
||||
popOut.show();
|
||||
}
|
||||
@FXML void clearBttnClick(ActionEvent event) {
|
||||
tilePane.getChildren().clear();
|
||||
tilePane.getChildren().addAll(dir);
|
||||
txtDirPath.setText("");
|
||||
}
|
||||
}
|
23
Java Peojects/FXImager/src/v0.0.2/Main.java
Normal file
23
Java Peojects/FXImager/src/v0.0.2/Main.java
Normal file
@@ -0,0 +1,23 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
|
||||
|
||||
public class Main extends Application {
|
||||
@Override
|
||||
public void start(final Stage stage) throws Exception {
|
||||
Scene scene = new Scene(FXMLLoader.load(Main.class.getResource("window.fxml")));
|
||||
scene.getStylesheets().add("stylesheet.css");
|
||||
stage.setScene(scene);
|
||||
//stage.setResizable(false); // keeps window from resizing
|
||||
stage.setTitle("Image Viewer");
|
||||
stage.setMinWidth(300);
|
||||
stage.setMinHeight(300);
|
||||
stage.show();
|
||||
}
|
||||
// needed because you know... it's java.
|
||||
public static void main(String[] args) { launch(args); }
|
||||
}
|
5
Java Peojects/FXImager/src/v0.0.2/stylesheet.css
Normal file
5
Java Peojects/FXImager/src/v0.0.2/stylesheet.css
Normal file
@@ -0,0 +1,5 @@
|
||||
.root {
|
||||
-fx-background: rgba(68, 68, 68, 0.8); // == #444444;
|
||||
}
|
||||
.button {
|
||||
}
|
37
Java Peojects/FXImager/src/v0.0.2/window.fxml
Normal file
37
Java Peojects/FXImager/src/v0.0.2/window.fxml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?scenebuilder-background-color 0x444444ff?>
|
||||
|
||||
<AnchorPane minHeight="300.0" minWidth="300.0" prefHeight="600.0" prefWidth="950.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="Controller">
|
||||
<children>
|
||||
<HBox alignment="TOP_RIGHT" layoutY="0.0" prefHeight="21.0" prefWidth="948.0" AnchorPane.leftAnchor="1.0" AnchorPane.rightAnchor="1.0">
|
||||
<children>
|
||||
<TextField fx:id="txtDirPath" blendMode="DIFFERENCE" onKeyReleased="#onEnter" prefWidth="200.0" promptText="Dir Path" HBox.hgrow="ALWAYS" />
|
||||
<Button fx:id="clear" mnemonicParsing="false" onAction="#clearBttnClick" text="Clear" />
|
||||
</children>
|
||||
</HBox>
|
||||
<ScrollPane id="ScrollPane" minHeight="300.0" minWidth="300.0" prefHeight="547.0" prefViewportHeight="534.0" prefViewportWidth="742.0" prefWidth="770.0" style=" -fx-fit-to-height: true; -fx-fit-to-width: true;" AnchorPane.bottomAnchor="-2.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="25.0">
|
||||
<content>
|
||||
<TilePane fx:id="tilePane" hgap="15.0" prefHeight="532.0" prefWidth="755.0" vgap="15.0">
|
||||
<children>
|
||||
<Label fx:id="dir" contentDisplay="CENTER" labelFor="$clear" onMouseClicked="#setNewDir" prefHeight="575.0" prefWidth="948.0" text="Choose Dir" textAlignment="LEFT" textFill="#dfdfdf" textOverrun="CLIP" underline="false" wrapText="false" TilePane.alignment="CENTER_LEFT">
|
||||
<font>
|
||||
<Font name="System Bold" size="32.0" />
|
||||
</font>
|
||||
<TilePane.margin>
|
||||
<Insets />
|
||||
</TilePane.margin>
|
||||
</Label>
|
||||
</children>
|
||||
</TilePane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</children>
|
||||
</AnchorPane>
|
Reference in New Issue
Block a user