jgkamat/ViPaint — pull request #1 by strburst (2014-12-18 20:52:58+00:00)
Title: Refactored stuff in ViPaint

I refactored all the files in the folder ViPaint. I made a bunch of whitespace changes and added/modified a lot of comments. I also renamed ```helpOn``` to ```setHelpOn```.

Also, I recommend that you ```git tag``` the current state of the project (before merging this) as ```v0.0.1``` or ```v0.1``` or whatever, as a reference point.

I'm thinking about adding a mark feature (to jump to different places in the image), a clipboard to copy/paste the image, a save button (it's actually only ~10 lines of code) and maybe some way to change the color from the VimBar, but I'll need to get familiar with the project first, and not run out of free time.

Really quickly, this is all the code you need to save an image ([```Node.snapshot```](https://docs.oracle.com/javase/8/javafx/api/javafx/scene/Node.html#snapshot-javafx.scene.SnapshotParameters-javafx.scene.image.WritableImage-) takes care of the hard work), though without any fancy file-extension autodetect capabilities (it only saves PNGs):
```java
Button saveBtn = new Button("Save PNG");
saveBtn.setOnAction(e -> {
// Save the canvas by snapshotting it into a WritableImage
WritableImage canvasSnap = canvas.snapshot(null, null);

FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save Canvas");
File file = fileChooser.showSaveDialog(stage);

try {
ImageIO.write(SwingFXUtils.fromFXImage(canvasSnap, null),
"png", file);
} catch (IOException err) {
System.out.println("Error writing image.");
err.printStackTrace();
} catch (IllegalArgumentException err) {
System.out.println("No file chosen. Saving skipped.");
}
});
saveBtn.setMaxWidth(Double.MAX_VALUE);
```