<commit_before># Checkpoint Answers Chapter 14 #
## 14.1 ##
The initial version of the GUI library was known as the Abstract Windows Toolkit (AWT). Maps Java code to each operating system's real GUI system. Limited to lowest common denominator among the supported system's.  

After AWT came another version called Swing. Paints all GUI components by itself instead of relying on the underlying operating system. 

Swing is now being replaced by a third version called JavaFX. JavaFX aims to be better suited for today's systems with for example multi-touch support.  

## 14.2 ##
Some reasons for that this book does not teach AWT or Swing:  
1. JavaFX is considered to be the easiest to learn for beginners.  
2. JavaFX is well designed, based around solid object oriented thinking.  
3. JavaFX is the GUI library is the one that is being actively developed by Oracle. Swing will not get any further updates.  

## 14.3 ##
A JavaFX main class is defined by extending the Application class.  
```Java  
public class MyJavaFX extends Application  
```  
The signature of the start method in the application class is:  
```Java  
public void start(Stage primaryStage)
```  
A Stage is a construct that functions as a base window for JavaFX content. An application can have multiple Stages.

A Stage object called primary stage is automatically created by the JVM when the application is launched.

A Stage object is displayed by invoking the show method.    
```Java  
Stage stage = new Stage();  
  
// ...  
// setup of the stage here  
// ...  

stage.show();  
```  
It is possible to prevent the user from resizing a stage.
```Java  
stage.setResizable(false);  
```  

The instruction `Application.launch(args)` is needed in development environments with limited support for JavaFX. This can be replaced by `launch(args)`, because the JavaFX main class is a subtype of Application.  

## 14.4 ##
The output of the program in this exercise is:  
```  
launch application  
Test constructor is invoked  
start method is invoked  
```  

## 14.5 ##
There are some different constructors that can be used to create a Scene.  

Creation of a Scene for a specific root Node.  
```Java  
Scene(Parent root)
```

Creation of a Scene for a specific root Node with a specific size.  
```Java  
Scene(Parent root, double width, double height)  
```  

See the documentation for more examples of constructors for creation of Scene instanses.  

A Scene is set on a Stage by invoking a member method called:  
```  
setScene(Scene value)  
```  

A circle is placed in a Scene by first placing the circle in a pane. This pane can then be placed in the Scene.  

## 14.6 ##
A pane is a form of container for content called nodes.  

A node is a component that have a visual representation and can hence be displayed in a GUI.  

A node can be placed into a pane:
```Java  
pane.getChildren().add(node)  
```  

It is not possible to place a Shape or ImageView into a Scene. These must be placed on for example a pane and this pane can then be placed in the Scene.  

A control or a pane can be place into a scene when constructing a Scene using `new Scene(Parent, width, height)` or `new Scene(Parent)`. Parent is the superclass for Control and Pane.  

## 14.7 ##
There are several constructor variants that can be used to create a Circle.
```Java  
Circle()	// creates an empty instance
Circle(double radius)	// specified radius   
Circle(double centerX, double centerY, double radius)	// specified position and radius  
Circle(double x, double y, double r, Paint fill)	// specified position, radius and fill
Circle(double radius, Paint fill)	// specified radius and fill  
```  
The methods for setting the center of a Circle instance is:    
```Java  
void setCenterY(double value)
```  
The method for setting the radius of a Circle instance is:
```Java  
void setRadius(double value)    
```  
The method for setting the stroke color of a Circle instance is:
```Java  
public final void setStroke(Paint value)      
```  
The method for setting the fill color of a Circle instance is:  
```Java  
public final void setFill(Paint value)      
```  
## 14.8 ##
A binding property is used to bind with a source object. Any changes to the source will be reflected in the bound target.  

A binding property is an instance of of the interface Property.  

A source object is an instance of the inteface  ObservableValue.  

The binding object types for int, long, float, double, and boolean are IntegerProperty, LongProperty, DoubleProperty, and BooleanProperty.  

The classes Integer and Double are not subtypes of ObservableValue. Hence, they cannot be used as a source object in a binding.  

## 14.9 ##
The naming convention that shall be used is as follows.  

The getter method is:  
```Java  
public int getAge()
```  
            
The setter method is:  
```Java  
public void setAge(int age)
```  
            
The property getter is
```Java  
public IntegerProperty ageProperty()
```  

## 14.12 ##
The border color of a node can be set by the use of a style. Here is an example of how to set the border color to red.  
```Java  
node.setStyle("-fx-border: red");  
```  
In i similar way so can the text color of some element be set to a color of choice.  
```Java  
text.setStyle("-fx-fill: red");
```  

## 14.13 ##
Elements such as pane, text, or button can be rotated.  

Rotation of a button 15 degrees counterclockwise is done in the following way.  
```Java  
button.setRotate(-15);  
```  <commit_msg>Added solution to checkpoint 14.14.<commit_after># Checkpoint Answers Chapter 14 #
## 14.1 ##
The initial version of the GUI library was known as the Abstract Windows Toolkit (AWT). Maps Java code to each operating system's real GUI system. Limited to lowest common denominator among the supported system's.  

After AWT came another version called Swing. Paints all GUI components by itself instead of relying on the underlying operating system. 

Swing is now being replaced by a third version called JavaFX. JavaFX aims to be better suited for today's systems with for example multi-touch support.  

## 14.2 ##
Some reasons for that this book does not teach AWT or Swing:  
1. JavaFX is considered to be the easiest to learn for beginners.  
2. JavaFX is well designed, based around solid object oriented thinking.  
3. JavaFX is the GUI library is the one that is being actively developed by Oracle. Swing will not get any further updates.  

## 14.3 ##
A JavaFX main class is defined by extending the Application class.  
```Java  
public class MyJavaFX extends Application  
```  
The signature of the start method in the application class is:  
```Java  
public void start(Stage primaryStage)
```  
A Stage is a construct that functions as a base window for JavaFX content. An application can have multiple Stages.

A Stage object called primary stage is automatically created by the JVM when the application is launched.

A Stage object is displayed by invoking the show method.    
```Java  
Stage stage = new Stage();  
  
// ...  
// setup of the stage here  
// ...  

stage.show();  
```  
It is possible to prevent the user from resizing a stage.
```Java  
stage.setResizable(false);  
```  

The instruction `Application.launch(args)` is needed in development environments with limited support for JavaFX. This can be replaced by `launch(args)`, because the JavaFX main class is a subtype of Application.  

## 14.4 ##
The output of the program in this exercise is:  
```  
launch application  
Test constructor is invoked  
start method is invoked  
```  

## 14.5 ##
There are some different constructors that can be used to create a Scene.  

Creation of a Scene for a specific root Node.  
```Java  
Scene(Parent root)
```

Creation of a Scene for a specific root Node with a specific size.  
```Java  
Scene(Parent root, double width, double height)  
```  

See the documentation for more examples of constructors for creation of Scene instanses.  

A Scene is set on a Stage by invoking a member method called:  
```  
setScene(Scene value)  
```  

A circle is placed in a Scene by first placing the circle in a pane. This pane can then be placed in the Scene.  

## 14.6 ##
A pane is a form of container for content called nodes.  

A node is a component that have a visual representation and can hence be displayed in a GUI.  

A node can be placed into a pane:
```Java  
pane.getChildren().add(node)  
```  

It is not possible to place a Shape or ImageView into a Scene. These must be placed on for example a pane and this pane can then be placed in the Scene.  

A control or a pane can be place into a scene when constructing a Scene using `new Scene(Parent, width, height)` or `new Scene(Parent)`. Parent is the superclass for Control and Pane.  

## 14.7 ##
There are several constructor variants that can be used to create a Circle.
```Java  
Circle()	// creates an empty instance
Circle(double radius)	// specified radius   
Circle(double centerX, double centerY, double radius)	// specified position and radius  
Circle(double x, double y, double r, Paint fill)	// specified position, radius and fill
Circle(double radius, Paint fill)	// specified radius and fill  
```  
The methods for setting the center of a Circle instance is:    
```Java  
void setCenterY(double value)
```  
The method for setting the radius of a Circle instance is:
```Java  
void setRadius(double value)    
```  
The method for setting the stroke color of a Circle instance is:
```Java  
public final void setStroke(Paint value)      
```  
The method for setting the fill color of a Circle instance is:  
```Java  
public final void setFill(Paint value)      
```  
## 14.8 ##
A binding property is used to bind with a source object. Any changes to the source will be reflected in the bound target.  

A binding property is an instance of of the interface Property.  

A source object is an instance of the inteface  ObservableValue.  

The binding object types for int, long, float, double, and boolean are IntegerProperty, LongProperty, DoubleProperty, and BooleanProperty.  

The classes Integer and Double are not subtypes of ObservableValue. Hence, they cannot be used as a source object in a binding.  

## 14.9 ##
The naming convention that shall be used is as follows.  

The getter method is:  
```Java  
public int getAge()
```  
            
The setter method is:  
```Java  
public void setAge(int age)
```  
            
The property getter is
```Java  
public IntegerProperty ageProperty()
```  

## 14.12 ##
The border color of a node can be set by the use of a style. Here is an example of how to set the border color to red.  
```Java  
node.setStyle("-fx-border: red");  
```  
In i similar way so can the text color of some element be set to a color of choice.  
```Java  
text.setStyle("-fx-fill: red");
```  

## 14.13 ##
Elements such as pane, text, or button can be rotated.  

Rotation of a button 15 degrees counterclockwise is done in the following way.  
```Java  
button.setRotate(-15);  
```  

## 14.14 ##
There are various constructors or static methods that can be used to create a Color. The following constructor creates a Color with the specified red, green, blue, and opacity values.  
```Java  
Color(double red, double green, double blue, double opacity)  
```  
The following attempt to create a Color is incorrect because all parameters shall be in the range from 0.0 to 1.0.  
```Java  
new Color(1.2, 2.3, 3.5, 4)		// error
```  
Higher values supplied to the above constructor means lighter colors so when creating two colors, `c1 = new Color(0, 0, 0, 1)` and `c2 = new Color(1, 1, 1, 1)` so will c2 be lihter than c1.  

Invoking `c.darker()` will not change the color value in c, instead so will a new darker color object, based on c, be returned.  
{'fraction_non_alphanumeric': 0.07013536379018613, 'fraction_numerical': 0.010067681895093062, 'mean_word_length': 3.4624386560966403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '338903', 'n_tokens_mistral': 3387, 'n_tokens_neox': 3129, 'n_words': 1774}