1 /**
2 * JDateButton: JavaFX Date Button
3 * Copyright 2012,2014 Tony Washer
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ------------------------------------------------------------
17 * SubVersion Revision Information:
18 * $URL: https://svn.code.sf.net/p/jdatebutton/code/tags/v2.1.0-b3/jdatebutton-javafx/src/main/java/net/sourceforge/jdatebutton/javafx/ArrowIcon.java $
19 * $Revision: 34 $
20 * $Author: tonywasher $
21 * $Date: 2015-12-01 16:21:13 +0000 (Tue, 01 Dec 2015) $
22 ******************************************************************************/
23 package net.sourceforge.jdatebutton.javafx;
24
25 import java.awt.Point;
26
27 import javafx.scene.paint.Color;
28 import javafx.scene.shape.Polygon;
29
30 /**
31 * Arrow Icons.
32 */
33 public enum ArrowIcon {
34 /**
35 * Up Arrow.
36 */
37 UP(new Point(1, 9), new Point(5, 1), new Point(9, 9)),
38
39 /**
40 * Down Arrow.
41 */
42 DOWN(new Point(1, 1), new Point(5, 9), new Point(9, 1)),
43
44 /**
45 * Left Arrow.
46 */
47 LEFT(new Point(1, 5), new Point(9, 1), new Point(9, 9)),
48
49 /**
50 * Right Arrow.
51 */
52 RIGHT(new Point(1, 1), new Point(1, 9), new Point(9, 5)),
53
54 /**
55 * DoubleUp Arrow.
56 */
57 DOUBLEUP(new Point(1, 5), new Point(5, 1), new Point(9, 5), new Point(5, 5), new Point(9, 9), new Point(1, 9), new Point(5, 5)),
58
59 /**
60 * DoubleDown Arrow.
61 */
62 DOUBLEDOWN(new Point(1, 1), new Point(1, 9), new Point(5, 5), new Point(9, 5), new Point(5, 9), new Point(1, 5), new Point(5, 5)),
63
64 /**
65 * DoubleLeft Arrow.
66 */
67 DOUBLELEFT(new Point(1, 5), new Point(5, 1), new Point(5, 5), new Point(9, 1), new Point(9, 9), new Point(5, 5), new Point(5, 9)),
68
69 /**
70 * DoubleRight Arrow.
71 */
72 DOUBLERIGHT(new Point(1, 1), new Point(1, 9), new Point(5, 5), new Point(5, 9), new Point(9, 5), new Point(5, 1), new Point(5, 5));
73
74 /**
75 * locations of points.
76 */
77 private final Double[] thePoints;
78
79 /**
80 * Constructor.
81 * @param pPoints the icon points
82 */
83 ArrowIcon(final Point... pPoints) {
84 /* Allocate arrays */
85 int myNumPoints = pPoints.length;
86 thePoints = new Double[myNumPoints << 1];
87
88 /* Loop through the points */
89 for (int i = 0, j = 0; i < myNumPoints; i++, j += 2) {
90 /* Store locations */
91 thePoints[j] = Double.valueOf(pPoints[i].x);
92 thePoints[j + 1] = Double.valueOf(pPoints[i].y);
93 }
94 }
95
96 /**
97 * Obtain a polygon for the arrow.
98 * @return a new polygon
99 */
100 public Polygon getArrow() {
101 /* Allocate new polygon */
102 Polygon myArrow = new Polygon();
103
104 /* Initialise graphics */
105 myArrow.setStroke(Color.GRAY);
106 myArrow.setFill(Color.BLACK);
107
108 /* Add the points */
109 myArrow.getPoints().addAll(thePoints);
110
111 /* Return the arrow */
112 return myArrow;
113 }
114 }