go to previous page   go to home page   go to next page highlighting

Answer:

What is the root node of the scene graph in this program?

StackPane pane

What is the child of the root node?

Group emoji

What are the children of that child?

( face, mouth, eyes )

Scene Graph

Scene Graph with StackPane at the Top

The picture shows the scene graph that the program builds. Scene graphs can get quite elaborate and it is useful to arrange objects into a tree-like structure. The scene graph contains all the information the system uses when it draws the window on the screen.

Class Group is a child of class Parent. (Review the Parent inheritance diagram, above.)

The other child of Parent is Region. In terms of a scene graph, Parent nodes have children beneath them. Note that here the word "children" refers to the structure of the scene graph, not to the inheritance hierarchy of Java. The emoji Group has the scene graph children face, mouth, and eyes.

The leaf nodes in the scene graph are those that have no children. These are the Shape nodes.


QUESTION 17:

(Thought Question: ) A Group holds a group of shapes that can be drawn on the screen (such as the emoji in the previous program.)

Do you think you can extend class Group to make your own class that draws something of your own design? For example, would the following work?

public class myShape() extends Group
{
  public myShape( parameters )
  {
    super();  // call the Group constructor
    
    create various shapes
    
    add shapes to the group
  }
}

go to previous page   go to home page   go to next page