A Collection of graded Java Graphics Programs using the JavaFX graphics library.
From the Book: Java Graphics for Games 1: JavaFX Line, Shape and Color.
A collection of working Java programs to create two-dimensional images and vector drawings on our computer screen. It is a cookbook of recipes of Java programs that enable the reader to do all kinds of interesting things with drawings and images. JavaFX is the best Java graphics library for this purpose. However JavaFX is poorly documented on the internet particularly with regard to simple, self-contained examples.
This is a cookbook of recipes of Java programs intended to enable the reader to do all kinds of interesting things with drawings and images . We assume the readers are not experienced programmers All the Java programs are designed to be self contained. Simply copy-pasting them into an editor and then executing them should result in immediate execution.
The plan of this collection is:
chapter 1. Getting Started with Java Java with JavaFX source code program is cleaner and more logical than Java programs that used the outdated AWT and Swing graphics libraries.
chapter 2. JavaFX Graphics Primitives Primitives are the fundamental drawn shapes like lines, curves, circles. ellipses, rectangles, polygons. A reference example of each primitive is given as back-to-basics reference set.
chapter 3. Lines and Polylines Lines can be styled by width, dash patterns, end cap styles, color. Shapes enclosed by straight line segments can also be filled with various colors, a chosen degree of transparency, fill patterns and shading variations. These same attributes apply to all the other graphic primitives.
Chapter 4 Rectangles Examples of the outline and fill style possibilities are given, including gradient fill patterns. The different ways of packaging different Java classes together to make an a single applications are given.
Chapter 5 Color The complexities of color description and specification are dealt withl. The simplest and most consistent way of specifying color are shown. Ways of mixing colors and transforming one color into another are shown.
Chapter 6 Circles, Ellipses Using Java arrays to construct families of similar shapes are demonstrated.
Chapter 7 Polygons Polygons composed of many straight line segments are the most obvious way of drawing complex shapes. The methods of deriving sub-shapes by getting the intersection, the subtraction or the union of two shapes is demonstrated.
Chapter 8 Arcs The basic principles of arc drawing are demonstrated.
Chapter 9 Quadratic Curves The construction and behavior of quadratic bezier curves is demonstrated. Quadratic curves may be thought of as the younger brother of Cubic Bezier curves, the subject of the next chapter.
Chapter 10 Cubic Curves Cubic Bezier curves are the most important and useful graphic primitive available. Using only cubic curves absolutely any two dimensional drawn shape can be made. In the next chapter on paths we see how this can be done with relative ease.
Chapter 11 Paths The key to creating absolutely any known shape is the JavaFX path. With a view to being able to capture and reproduce drawings created in a vector drawing editor like Inkscape, the techniques for manipulating Java arrays are explained. The refinement of using multiple randomized copies of a drawing that more closely resembles the results of drawing with pencils on paper are shown.
Chapter 12 SVG Here we deal with how to capture a drawing in a Vector Graphics editor such as Inkscape. The same principles will apply to any other vector graphics editing package. We see how to convert the resulting captured SVG file into Java arrays. SVG or Scaled Vector Graphics, is the XML standard in web design.
Chapter 13 Text Control The control of fonts (typefaces), size, style, alignment color and layout are demonstrated.
Chapter 14 Image The JavaFX Image class deals with raster images – photos, paintings or any image that is not in a vector format. Essentially jpg, png and gif images are used – how to retrieve them and how to display them.
Chapter 15 Layout Layout is concerned with how to present graphical objects on a surface. The choices are many: absolute, flow, tile, stack, grid, anchor, border, horizontal, vertical and dialog. There are short examples of each.
Chapter 16 Visual Effects Visual effects are a range enhancements that can be added to graphics: shadows, glows, blurring, reflections, displacement mapping, tones and filters, blending and color filtering.
Chapter 17 Mouse Control When working with graphics the computer mouse is the main user control device rather than the keyboard. This chapter deals with the detail of mouse event handling.
Chapter 18 User Interface Controls – Part 1
User interface control covers a large library of classes. Each one offers complex usage options. Learning to use them effectively requires us to experiment with them extensively. In this chapter the following are covered: Button, RadioButton, ToggleButton, CheckBox, ChoiceBox, Slider, ProgressBar, Progress Indicator, ScrollBar, ScrollPane , ComboBox, ListView.
Brief examples of each are given to get us started.
Chapter 19 User Interface Controls – Part 2 This chapter is a continuation of the previous one and covers: TextField, PasswordField, Hyperlink, DatePicker, FileChooser, Menu, Tooltip, Separator, HTMLEditor, Pagination, TableView, TreeView, TreeTableView
Chapter 20 Geometry Transforms: Rotation, Scaling, Translation and Shear JavaFX has standard classes for altering the geometry of shapes which are presented here. Methods of achieving identical results using more fundamental Java code are given.