Giter Site home page Giter Site logo

hollyjm81 / customizable-kids-book Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grimshaw-a/customizable-kids-book

0.0 0.0 0.0 467 KB

This program customizes the layout of a children's book. It features a GUI for selecting customization preferences. It then applies those preferences to master files using Photoshop by means of javascript.

Java 100.00%

customizable-kids-book's Introduction

Custom Children's Book

Synopsis

This program customizes the layout of a children's book. It features a GUI where the user select customizations such as shirt color, favorite zoo animal, child's name, etc. Then those preferences are applied to master files and exported as printable files. The images below are examples of the exported files.

sample image of book sample image of book

Motivation

My friend was creating custom books and compositing them all manually. I created this for him so that the process would be automated and he could save time.

How to Run

This program works in two parts. The first part gathers customization information from the user. This is done through a GUI created using JavaFX. Two java files are necessary to make the GUI run: ZooBook.java and InputScreenInterface.java. ZooBook.java defines a class that stores all the customizable properties for the book. InputScreenInterface.java creates an instance of the ZooBook class and then generates a GUI that prompts the user to enter their customization preferences. These preferences are recorded in an instance of ZooBook and then exported to a .txt file. Before using, the code MUST be updated with a valid path for where the .txt file will be stored. The second part of the process is to apply the customization preferences to the text and graphics of the book. Each spread of the book is stored as a .tif file. A javascript file is provided that will manipulate the .tif files in Adobe Photoshop CC to reflect the customization preferences. The file is named ApplyCustomizations.jsx. This script should be compatible with most versions of Photoshop CC. Again, the code in this script MUST be updated with a valid path for both location of the .tif files and a location to export .jpg files.

Code Example

After making selections and entering custom information, the user comes to the final input screen of the GUI. This screen prompts the user to enter a child's name in a text field. Upon completion, the user clicks the "Finish" button, initiating the following lines of code. The program first looks to see if the entered String is under twelve characters. If not, it halts the process and prints a warning. Otherwise, the String is read from the text field and stored in the ZooBook object. A new .txt file is created and named using the current date and the child's name. The customization information is retrieved from the ZooBook object and written to the .txt file where it can later be used to customize the book's layout files. Finally, it calls a method to load a screen confirming that all information has been recorded succesfully.

finish.setOnAction(e -> {
			if(inputText.getText().length() > 12) {
				warningLabel.setText("*Please limit name to 12 characters.");
				warningLabel.setTextFill(Color.RED);
			} else {
				customBook.setFriendName(inputText.getText());
				java.time.LocalDate todayDate = LocalDate.now();
				String filename = "/Users/..FilePath.../" + todayDate + "-" + customBook.getChildName() + ".txt";
				try {
					BufferedWriter output = new BufferedWriter(new FileWriter(filename));
					output.write(customBook.getChildName() + "#" + customBook.getGender() + "#" + customBook.getHairColor() + "#" + customBook.getSkinTone() + "#" + customBook.hasGlasses() + "#" + customBook.getShirtColor() + "#" + customBook.getAnimal() + "#" + customBook.getFriendName());
					output.close();
				} catch(IOException ex) {
					System.out.println("I/O exception thrown.");
				}
				loadFrame10();
			}
		});

Tests

The GUI prompts the user to enter a child's name in a text field. When the user clicks "Next", the setFriendName method is called. It reads the text in the text field and stores it as a String. The getFriendName method is used later to retrieve this String and write it to an output file along with the other custom information.

@Test
public void testGetFriendName() {
  ZooBook customBook = new ZooBook();
	String friend = "Jackie";
	customBook.setFriendName(friend);
	String returnName = customBook.getFriendName();
	assertEquals(friend, returnName);
}

customizable-kids-book's People

Contributors

grimshaw-a avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.