Wednesday, January 7, 2015

Easy Maps Apps in Java and Python

Integrating Google Maps API services into applications provides a great set of location based services for powerful functionality. If you write server side applications in Java or Python, accessing these APIs requires some way to talk to the Google Maps server REST APIs that provide the interfaces.

Google have built an open-source set of client libraries that take care of all the nitty-gritty detail of connecting, and managing Maps API services for both Java and Python.

Alex Danilo introduces these libraries, and what they do - allowing Java and Python server side application developers to save time integrating Maps API services into their applications.

These libraries streamline and simplify the work required to get an application up and running by taking care of things like retry for dropped connections, rate limiting to make sure applications manage their quota, and more.

Documentation for the client libraries is on the Google Developers Site here, and the open source project code is on github here.

If you develop in Java or Python, you should definitely take a look.

Easy Maps Apps in Java and Python

Monday, January 5, 2015

Take snapshot of your JavaFX application

Scene.snapshot() takes a snapshot of scene and returns the rendered image when it is ready.

Example:
package javafxsnapshot;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javax.imageio.ImageIO;

/**
 *
 * @web http://java-buddy.blogspot.com
 */
public class JavaFXSnapshot extends Application {
    
    @Override
    public void start(Stage primaryStage) {
        
        StackPane root = new StackPane();
        Scene scene = new Scene(root, 300, 250);
        
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
                takeSnapShot(scene);
                
            }
        });

        root.getChildren().add(btn);

        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
    
    private void takeSnapShot(Scene scene){
        WritableImage writableImage = 
            new WritableImage((int)scene.getWidth(), (int)scene.getHeight());
        scene.snapshot(writableImage);
        
        File file = new File("snapshot.png");
        try {
            ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png", file);
            System.out.println("snapshot saved: " + file.getAbsolutePath());
        } catch (IOException ex) {
            Logger.getLogger(JavaFXSnapshot.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}

Thursday, January 1, 2015

Beginning Java 8 Games Development

Beginning Java 8 Games Development , written by Java expert and author Wallace Jackson, teaches you the fundamentals of building a highly illustrative game using the Java 8 programming language. In this book, you'll employ open source software as tools to help you quickly and efficiently build your Java game applications. You'll learn how to utilize vector and bit-wise graphics; create sprites and sprite animations; handle events; process inputs; create and insert multimedia and audio files; and more.

Furthermore, you'll learn about JavaFX 8, now integrated into Java 8 and which gives you additional APIs that will make your game application more fun and dynamic as well as give it a smaller foot-print; so, your game application can run on your PC, mobile and embedded devices.

After reading and using this tutorial, you'll come away with a cool Java-based 2D game application template that you can re-use and apply to your own game making ambitions or for fun.

What you’ll learn
  • How to develop games using Java 8
  • How to employ vector-based graphics or bitmap graphics
  • How to create your 2D game sprites
  • How to animate those game sprites
  • How to handle events to process player input
  • How to optimize and implement digital audio assets

Who this book is for
This book is for game developers with little experience using Java, little experience in developing games, or both.

Table of Contents
1. Setting Up a Java 8 Game Development Environment
2. Setting Up Your Java 8 IDE
3. A Java 8 Primer
4. An Introduction to JavaFX 8
5. An Introduction to Game Design
6. The Foundation of Game Design
7. The Foundation of Game Play Loop
8. Creating Your Actor Engine
9. Controlling Your Action Figure
10. Directing the Cast of Actors
11. Moving Your Action Figure in 2D
12. Setting Boundaries for Your Action Figure in 2D
13. Animating Your Action Figure States
14. Setting Up the Game Environment
15. Implementing Game Audio Assets
16. Collision Detection
17. Enhancing Game Play