package bluej.utility.javafx;
import javafx.beans.property.DoubleProperty;
import javafx.geometry.Orientation;
import javafx.scene.shape.Polygon;
import javafx.scene.transform.Scale;
| A triangle arrow shape, used for foldout panes.
|
public class TriangleArrow
extends Polygon{
public static final double TRIANGLE_BASE = 14;
public static final double TRIANGLE_DEPTH = 10;
private final Scale scale;
private final Orientation orientation;
| Makes a triangle arrow, used in foldout containers.
|
| @param orientation The orientation. VERTICAL makes a triangle arrow pointed upwards, HORIZONTAL makes one pointed leftwards.
|
public TriangleArrow(Orientation orientation)
{
JavaFXUtil.addStyleClass(this, "triangle-arrow");
scale = new Scale(1.0, 1.0);
this.orientation = orientation;
switch (orientation)
{
case HORIZONTAL:
getPoints().setAll(
TRIANGLE_DEPTH - 1, 1.0,
1.0, TRIANGLE_BASE * 0.5,
TRIANGLE_DEPTH - 1, TRIANGLE_BASE - 1);
scale.setPivotX(TRIANGLE_DEPTH * 0.5);
scale.setPivotY(TRIANGLE_BASE * 0.5);
break;
case VERTICAL:
getPoints().setAll(
1.0, TRIANGLE_DEPTH - 1,
TRIANGLE_BASE * 0.5, 1.0,
TRIANGLE_BASE - 1, TRIANGLE_DEPTH - 1);
scale.setPivotX(TRIANGLE_BASE * 0.5);
scale.setPivotY(TRIANGLE_DEPTH * 0.5);
break;
}
getTransforms().add(scale);
setPickOnBounds(true);
}
| The scale property. Setting this to 1.0 leaves the arrow normal,
| i.e. facing up/left, while setting it to -1.0 reverses it,
| making it face down/right. You can either set it instantly, or animate
| the transition.
|
public DoubleProperty scaleProperty()
{
if (orientation == Orientation.HORIZONTAL)
return scale.xProperty();
else{ return scale.yProperty();
}
}
}
top,
use,
map,
class TriangleArrow
. TriangleArrow
. scaleProperty
76 neLoCode
+ 7 LoComm