Java Reference
In-Depth Information
(40, 20)
(40, 20)
(70, 40)
(70, 40)
(45, 45)
(45, 45)
(20, 60)
(20, 60)
(60, 80)
(60, 80)
(a) Polygon
(b) Polyline
F
IGURE
14.38
Polygon
is closed and
Polyline
is not closed.
The UML diagram for the
Polygon
class is shown in FigureĀ 14.39. Listing 14.19 gives an
example that creates a hexagon, as shown in FigureĀ 14.40.
The getter and setter methods for property values
and a getter for property itself are provided in the class,
but omitted in the UML diagram for brevity.
javafx.scene.shape.Arc
+Polygon()
+Polygon(double... points)
+getPoints():
ObservableList<Double>
Creates an empty
Polygon
.
Creates a
Polygon
with the given points.
Returns a list of double values as x-and y-coordinates of the points.
F
IGURE
14.39
Polygon
defines a polygon.
(x, y)
x is
centerX
radius
cos(2
/6)
y is
centerY
radius
sin(2
/6)
6
2
radius
(centerX, centerY)
(a)
(b)
F
IGURE
14.40
(a) A
Polygon
is displayed. (b) A
Polyline
is displayed.
L
ISTING
14.19
ShowPolygon.java
1
import
javafx.application.Application;
2
import
javafx.collections.ObservableList;
3
import
javafx.scene.Scene;
4
import
javafx.scene.layout.Pane;
5
import
javafx.scene.paint.Color;
6
import
javafx.stage.Stage;
7
import
javafx.scene.shape.Polygon;
Search WWH ::
Custom Search