Java program that creates a photo album application. Which will load a collection of images and displays them in a album layout. The program will allow the user to tag images with metadata:
•Title for the photo
. Limited to 100 characters.
•Description for the photo
. Limited to 300 characters.
•Date taken
•Place taken
Functional Specs
1.Your album should be able to display the pictures sorted by Title, Date, and Place.
2.When the user clicks on a photo, data should be displayed.
3.The user should be able to add or remove pics.
*Please note the swing library cannot be used only scene (vBox,hBox, etc...)
*This is what I have so far - I can display and select images but Im not sure how to apply the buttons to remove, add, and add data (title, date, place) Please help, thank you.
public class PhotoAlbum extends Application {
Stage stage;
@Override
public void start(Stage primaryStage) throws
Exception {
stage =
primaryStage;
ScrollPane root = new
ScrollPane();
TilePane tile = new
TilePane();
root.setStyle("-fx-background-color: DAE6F3;");
tile.setPadding(new
Insets(15, 15, 15, 15));
tile.setHgap(15);
String path = "src/image/";
File folder = new
File(path);
File[] listOfFiles =
folder.listFiles();
for (final File file
: listOfFiles) {
ImageView imageView;
imageView = createImageView(file);
tile.getChildren().addAll(imageView);
}
root.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); //
Horizontal
root.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); //
Vertical scroll bar
root.setFitToWidth(true);
root.setContent(tile);
primaryStage.setWidth(Screen.getPrimary().getVisualBounds().getWidth());
primaryStage.setHeight(Screen.getPrimary().getVisualBounds()
.getHeight());
Scene scene = new
Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
private ImageView createImageView(final File
imageFile) {
//
DEFAULT_THUMBNAIL_WIDTH is a constant you need to define
// The last two
arguments are: preserveRatio, and use smooth (slower)
// resizing
ImageView imageView =
null;
try {
final Image image = new Image(new FileInputStream(imageFile), 150,
0, true,
true);
imageView = new ImageView(image);
imageView.setFitWidth(150);
imageView.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent mouseEvent) {
if(mouseEvent.getButton().equals(MouseButton.PRIMARY)){
if(mouseEvent.getClickCount() == 2){
try {
BorderPane borderPane = new BorderPane();
ImageView imageView = new ImageView();
Image image = new Image(new FileInputStream(imageFile));
imageView.setImage(image);
imageView.setStyle("-fx-background-color: BLACK");
imageView.setFitHeight(stage.getHeight() - 10);
imageView.setPreserveRatio(true);
imageView.setSmooth(true);
imageView.setCache(true);
borderPane.setCenter(imageView);
borderPane.setStyle("-fx-background-color: BLACK");
Stage newStage = new Stage();
newStage.setWidth(stage.getWidth());
newStage.setHeight(stage.getHeight());
newStage.setTitle(imageFile.getName());
Scene scene = new Scene(borderPane,Color.BLACK);
newStage.setScene(scene);
newStage.show();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
}
});
} catch
(FileNotFoundException ex) {
ex.printStackTrace();
}
return imageView;
}
public static void main(String[] args)
{
launch(args);
}
}
CODE :
@Override
public void onClick(View arg0) {
switch (arg0.getId()){
break;
case R.id.capture_dp:
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, setImageUri());
startActivityForResult(intent, TAKE_PHOTO_CODE);
break;
case R.id.add_galery_dp:
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
i.putExtra(MediaStore.EXTRA_OUTPUT, setImageUri());
startActivityForResult(i, PICK_FROM_GALLERY);
break;
case R.id.delete_image_dp:
break;
}
public Uri setImageUri() {
File file = new File(Environment.getExternalStorageDirectory()
+"/android/data/spaj_foto/spaj_foto("+counter+").png");
Uri imgUri = Uri.fromFile(file);
this.imgPath = file.getAbsolutePath();
return imgUri;
}
public String getImagePath() {
return imgPath;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_CANCELED) {
if (requestCode == TAKE_PHOTO_CODE) {
selectedImagePath = getImagePath();
foto_dp.setImageBitmap(decodeFile(selectedImagePath));
if (requestCode == PICK_FROM_GALLERY) {
selectedImagePath = getImagePath();
foto_dp.setImageBitmap(decodeFile(selectedImagePath));
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
}
public Bitmap decodeFile(String path) {
try {
// Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, o);
// The new size we want to scale to
final int REQUIRED_SIZE = 70;
// Find the correct scale value. It should be the power of 2.
int scale = 1;
while (o.outWidth / scale / 2 >= REQUIRED_SIZE && o.outHeight / scale / 2 >=
REQUIRED_SIZE)
scale *= 2;
// Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
return BitmapFactory.decodeFile(path, o2);
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
If we want to ADD the album directly, we can also use this method :
AlbumEntry myAlbum = new AlbumEntry();
myAlbum.setTitle(new PlainTextConstruct("Trip to France"));
myAlbum.setDescription(new PlainTextConstruct("My recent trip to France was delightful!"));
AlbumEntry insertedEntry = myService.insert(postUrl, myAlbum);
If we want to remove the album data, we can use the method :
myAlbum.delete();
Java program that creates a photo album application. Which will load a collection of images...
//No JPanel please: Write a javafx application that displays an image and //plays a sound effect with each mouse click. Rotate through four images and //five sound effects, so the image/sound effect pairing is different each time. //What my problem is on is actually getting the pictures to switch. The x variable //works perfect for the sound change but I am unsure what to do with y for the //image change. Also I dont know if I should put this...
Java FX Application
Purpose
The purpose of this assignment is to get you familiar with the
basics of the JavaFX GUI interface components. This assignment will
cover Labels, Fonts, Basic Images, and Layouts. You will use a
StackPane and a BorderPane to construct the layout to the right. In
addition you will use the Random class to randomly load an image
when the application loads
Introduction
The application sets the root layout to a BorderPane. The
BorderPane can be divided...
Using JAVA FX how would I combine the two programs below
into one interface that allows the user to pick which specific
program they would like to play. They should be able to choose
which one they want to play and then switch between them if
necesary. All of this must be done in JAVA FX code
Black jack javafx - first game program
package application;
import java.util.Arrays;
import java.util.ArrayList;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.geometry.Insets;...
Java: In this assignment, you will create an accumulator accumulator-calculator that displays a sad face “ :-( “ whenever the number displayed by the calculator is negative and a happy face “ :-) ” whenever the number displayed is positive. The calculator responds to the following commands: num + , num - , num * , num / and C ( Clear ). After initial run, if the user clicks 8 and then presses the “+” button for example, the...
JavaFX! Just need to fill several lanes of code please!!!
CSE205 OOP and Data Structure Quiz #15 Last Name (print) First Name (print) Write a JavaFX GUI application program that simulates a timer. The timer should show "count: the beginning and increase the number by 1 in every one second, and so on. o" at .3 A Timer - × A Timer Count: 0 Count: 1 (B) After 1 second, the GUI Window (A) Initial GUI Window According to the...
/ Finish the code to make it work import static javafx.application.Application.launch; import java.io.File; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ChoiceBox; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.media.AudioClip; import javafx.stage.Stage; public class JukeBox extends Application { private ChoiceBox<String> choice; private AudioClip[] tunes; private AudioClip current; private Button playButton, stopButton; //----------------------- // presents an interface that allows the user to select and play // a tune from a drop down box //----------------------- ...
This task involves constructing a Java program that supports interaction via a graphical user interface.The object is to implement a Scrabble graphical game. The basis for the game is quite simple. Presented with a 6x6 grid of Scrabble tiles, the challenge is for the player(s) to form as many high scoring words as possible. Words may only be formed from sequences of adjacent tiles. Two tiles are adjacent if their edges or corners meet. A tile may...
JAVAFX ONLY PROGRAM!!!!!
SORTING WITH NESTED CLASSES AND LAMBDA
EXPRESSIONS.
DIRECTIONS ARE BELOW:
DIRECTIONS:
The main point of the exercise is to demonstrate your
ability to use various types of nested classes. Of course, sorting
is important as well, but you don’t really need to do much more
than create the class that does the comparison. In general, I like
giving you some latitude in how you design and implement your
projects. However, for this assignment, each piece is very...
JavaFX program - Add a second level to the game. //Main game object/class package main; import java.util.ArrayList; import javafx.animation.AnimationTimer; import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.Label; import javafx.scene.image.ImageView; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class Game extends Pane implements Runnable { // instance variables private ArrayList<MOB> mobs; private ArrayList<Rectangle> hitBoxes; private ArrayList<Treasure> treasure; private Player player; private final ImageView background = new ImageView(); private Level level; private SimpleIntegerProperty score; private...
Modify the JavaFX TipCalculator application program to allow the user to enter the number of persons in the party through a text field. Calculate and display the amount owed by each person in the party if the bill is to be split evenly among the party members. /////////// TipCalculatorController.java: import java.math.BigDecimal; import java.math.RoundingMode; import java.text.NumberFormat; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.scene.control.TextField; public class TipCalculatorController { // formatters for currency and percentages private...