官术网_书友最值得收藏!

Lines

Line is as simple as it sounds. You write start and end coordinates, and they get connected:

Line line = new Line(10, 10, 100, 50);

Polyline is a set of consecutive lines. You need to provide several pairs of coordinates where the end of each line is the start of the next one. Make sure you are providing an even number of parameters:

// chapter2/shapes/Polylines.java
Polyline polyline = new Polyline();
polyline.getPoints().addAll(
0.0, 0.0,
50.0, 30.0,
10.0, 60.0);

Note that despite not always having a full border, line-type shapes can have a background. If you assign it using the setFill() method, these shapes will use invisible edge, connecting the first and last points of the line. Here is an example of the same polylines with and without a background:

The third shape is a Polygon with the same points set. The only difference between Polygon and Polyline is that the former automatically adds a line between the first and the last points to create a closed figure.

主站蜘蛛池模板: 灌阳县| 六枝特区| 定远县| 兴义市| 偏关县| 固镇县| 东乡县| 什邡市| 丰宁| 万州区| 会泽县| 息烽县| 龙州县| 乐清市| 昌黎县| 开平市| 咸阳市| 新乡县| 抚远县| 个旧市| 宜昌市| 类乌齐县| 固始县| 鲁甸县| 瑞昌市| 鲜城| 浮山县| 丰原市| 冕宁县| 嘉鱼县| 柳江县| 涟源市| 宜丰县| 阳新县| 霍山县| 文安县| 鹤庆县| 中方县| 即墨市| 扶余县| 崇义县|