下面列出了怎么用javafx.scene.CacheHint的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Constructor.
*
* @param text the label to use for the text. Styles will be copied from
* this label.
* @param wrapText specifies whether text wrapping is allowed in this label.
* @param style the CSS style of the label. This can be null.
* @param tipsPane the tooltip for the label. This can be null.
* @param contextMenuItems a list of menu items to add to the context menu
* of the label. This can be null.
*/
public SelectableLabel(final String text, boolean wrapText, String style, final TooltipPane tipsPane, final List<MenuItem> contextMenuItems) {
getStyleClass().add("selectable-label");
setText(text == null ? "" : text);
setWrapText(wrapText);
setEditable(false);
setPadding(Insets.EMPTY);
setCache(true);
setCacheHint(CacheHint.SPEED);
setMinHeight(USE_PREF_SIZE);
if (style != null) {
setStyle(style);
}
if (tipsPane != null) {
TooltipUtilities.activateTextInputControl(this, tipsPane);
}
this.contextMenuItems = contextMenuItems;
}
private VBox getLoadingPane()
{
//This returns the loading screen
//Base pane
VBox loadingPane = new VBox();
loadingPane.setSpacing(5);
loadingPane.setAlignment(Pos.CENTER);
//Loading Indicator (will be customised to match with the design language later)
loadingIndicator = new ProgressIndicator(0);
//enable caching to improve performance
loadingIndicator.setCache(true);
loadingIndicator.setCacheHint(CacheHint.SPEED);
//Loading info Label
loadingInfoLabel = new Label();
//Add them and return the node
loadingPane.getChildren().addAll(loadingIndicator, loadingInfoLabel);
return loadingPane;
}
public HealingNumber(String text, GameToken parent) {
this.parent = parent;
setText(text);
setFill(Color.GREEN);
setStyle("-fx-font-size: 28pt; -fx-font-family: \"System\";-fx-font-weight: bolder;-fx-stroke: black;-fx-stroke-width: 2;");
setCache(true);
setCacheHint(CacheHint.SPEED);
parent.getAnchor().getChildren().add(this);
NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
TranslateTransition animation = new TranslateTransition(Duration.seconds(0.5), this);
animation.setToY(-30);
animation.setOnFinished(this::onComplete);
animation.play();
}
private void flipForward() {
timeline.stop();
flap.setCache(true);
flap.setCacheHint(CacheHint.ROTATE);
//flap.setCacheHint(CacheHint.SPEED);
currentSelectionIndex++;
if (currentSelectionIndex >= characters.size()) {
currentSelectionIndex = 0;
}
nextSelectionIndex = currentSelectionIndex + 1;
if (nextSelectionIndex >= characters.size()) {
nextSelectionIndex = 0;
}
KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
//KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN);
KeyFrame keyFrame = new KeyFrame(Duration.millis(tile.getFlipTimeInMS()), keyValueFlap);
timeline.getKeyFrames().setAll(keyFrame);
timeline.play();
}
public UnitedStatesMapPane() {
getStyleClass().add("map-pane");
setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
setPrefHeight(450);
setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
liveMap.setId("liveMap");
liveMap.setManaged(false);
liveMap.setCache(true);
liveMap.setCacheHint(CacheHint.SCALE);
getChildren().add(liveMap);
overlayGroup.setId("overlay");
// setip map transforms
liveMap.getTransforms().setAll(mapPreTranslate, mapScale, mapPostTranslate);
// load map fxml
try {
statesGroup = FXMLLoader.load(UnitedStatesMapPane.class.getResource("us-states-map.fxml"));
} catch (IOException e) {
e.printStackTrace();
}
// set live map children
liveMap.getChildren().addAll(statesGroup, overlayGroup);
}
public UnitedStatesMapPane() {
getStyleClass().add("map-pane");
setMinSize(USE_PREF_SIZE, USE_PREF_SIZE);
setPrefHeight(450);
setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
liveMap.setId("liveMap");
liveMap.setManaged(false);
liveMap.setCache(true);
liveMap.setCacheHint(CacheHint.SCALE);
getChildren().add(liveMap);
overlayGroup.setId("overlay");
// setip map transforms
liveMap.getTransforms().setAll(mapPreTranslate, mapScale, mapPostTranslate);
// load map fxml
try {
statesGroup = FXMLLoader.load(UnitedStatesMapPane.class.getResource("us-states-map.fxml"));
} catch (IOException e) {
e.printStackTrace();
}
// set live map children
liveMap.getChildren().addAll(statesGroup, overlayGroup);
}
/**
* Constructor.
* @param box a ChartIndicatorBox
*/
public TaChart(IndicatorBox box){
mapTradingRecordMarker = new HashMap<>();
this.chartIndicatorBox = box;
this.chartIndicatorBox.getIndicartors().addListener(this);
XYDataset candlesBarData = createOHLCDataset(chartIndicatorBox.getBarSeries());
this.mainPlot = createMainPlot(candlesBarData);
this.combinedXYPlot = createCombinedDomainXYPlot(mainPlot);
this.setCache(true);
this.setCacheHint(CacheHint.SPEED);
final JFreeChart chart = new JFreeChart(combinedXYPlot);
TaChartViewer viewer = new TaChartViewer(chart);
Color chartBackground = Color.WHITE;
chart.setBackgroundPaint(chartBackground);
getChildren().add(viewer);
LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.TOP);
legend.setItemFont(new Font("Arial", Font.BOLD, 12));
Color legendBackground = new Color(0, 0, 0, 0);
legend.setBackgroundPaint(legendBackground);
chartIndicatorBox.getObservableBarSeries().addListener((ob, o, n) -> reloadBarSeries(n));
}
private void drawNeedle() {
double needleWidth = size * 0.04536638;
double needleHeight = size * 0.23706897;
needle.setCache(false);
needle.getElements().clear();
needle.getElements().add(new MoveTo(needleWidth * 0.813182897862233, needleHeight *0.227272727272727));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.754441805225653, needleHeight *0.0743545454545455, needleWidth *0.788052256532067, needleHeight * 0, needleWidth * 0.499643705463183, needleHeight * 0));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.211235154394299, needleHeight *0, needleWidth *0.248907363420428, needleHeight * 0.0741090909090909, needleWidth * 0.186104513064133, needleHeight * 0.227272727272727));
needle.getElements().add(new LineTo(needleWidth * 0.000831353919239905, needleHeight * 0.886363636363636));
needle.getElements().add(new CubicCurveTo(needleWidth * -0.0155581947743468, needleHeight *0.978604545454545, needleWidth *0.211235154394299, needleHeight * 1, needleWidth * 0.499643705463183, needleHeight * 1));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.788052256532067, needleHeight *1, needleWidth *1.0253919239905, needleHeight * 0.976459090909091, needleWidth * 0.998456057007126, needleHeight * 0.886363636363636));
needle.getElements().add(new LineTo(needleWidth * 0.813182897862233, needleHeight *0.227272727272727));
needle.getElements().add(new ClosePath());
needle.getElements().add(new MoveTo(needleWidth * 0.552826603325416, needleHeight *0.854286363636364));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.536223277909739, needleHeight *0.852981818181818, needleWidth *0.518313539192399, needleHeight * 0.852272727272727, needleWidth * 0.499643705463183, needleHeight * 0.852272727272727));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.480237529691211, needleHeight *0.852272727272727, needleWidth *0.46166270783848, needleHeight * 0.853040909090909, needleWidth * 0.444513064133017, needleHeight * 0.854445454545455));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.37313539192399, needleHeight *0.858890909090909, needleWidth *0.321496437054632, needleHeight * 0.871736363636364, needleWidth * 0.321496437054632, needleHeight * 0.886868181818182));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.321496437054632, needleHeight *0.905681818181818, needleWidth *0.401330166270784, needleHeight * 0.920959090909091, needleWidth * 0.499643705463183, needleHeight * 0.920959090909091));
needle.getElements().add(new LineTo(needleWidth * 0.500285035629454, needleHeight *0.920959090909091));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.598598574821853, needleHeight *0.920959090909091, needleWidth *0.678432304038005, needleHeight * 0.905681818181818, needleWidth * 0.678432304038005, needleHeight * 0.886868181818182));
needle.getElements().add(new CubicCurveTo(needleWidth * 0.678432304038005, needleHeight *0.871554545454545, needleWidth *0.625534441805226, needleHeight * 0.858581818181818, needleWidth * 0.552826603325416, needleHeight * 0.854286363636364));
needle.getElements().add(new ClosePath());
needle.setCache(true);
needle.setCacheHint(CacheHint.ROTATE);
}
private void flipForward() {
timeline.stop();
flap.setCache(true);
flap.setCacheHint(CacheHint.ROTATE);
//flap.setCacheHint(CacheHint.SPEED);
currentSelectionIndex++;
if (currentSelectionIndex >= characters.size()) {
currentSelectionIndex = 0;
}
nextSelectionIndex = currentSelectionIndex + 1;
if (nextSelectionIndex >= characters.size()) {
nextSelectionIndex = 0;
}
KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
//KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN);
KeyFrame keyFrame = new KeyFrame(Duration.millis(tile.getFlipTimeInMS()), keyValueFlap);
timeline.getKeyFrames().setAll(keyFrame);
timeline.play();
}
private void resize() {
width = getWidth() - getInsets().getLeft() - getInsets().getRight();
height = getHeight() - getInsets().getTop() - getInsets().getBottom();
if (ASPECT_RATIO * width > height) {
width = 1 / (ASPECT_RATIO / height);
} else if (1 / (ASPECT_RATIO / height) > width) {
height = ASPECT_RATIO * width;
}
if (width > 0 && height > 0) {
if (isZoomEnabled()) resetZoom();
pane.setCache(true);
pane.setCacheHint(CacheHint.SCALE);
pane.setScaleX(width / PREFERRED_WIDTH);
pane.setScaleY(height / PREFERRED_HEIGHT);
group.resize(width, height);
group.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);
pane.setCache(false);
}
}
@Override protected void redraw() {
locale = gauge.getLocale();
formatString = new StringBuilder("%.").append(Integer.toString(gauge.getDecimals())).append("f").toString();
ticksAndSectionsCanvas.setCache(false);
ticksAndSections.clearRect(0, 0, width, height);
if (gauge.getSectionsVisible()) drawSections(ticksAndSections);
drawTickMarks(ticksAndSections);
ticksAndSectionsCanvas.setCache(true);
ticksAndSectionsCanvas.setCacheHint(CacheHint.QUALITY);
//unitText.setFill(gauge.getUnitColor());
unitText.setText(gauge.getUnit());
if (gauge.isLedVisible()) drawLed(led);
shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null);
// Markers
drawMarkers();
thresholdTooltip.setText("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")");
}
@Override protected void redraw() {
sectionsVisible = gauge.getSectionsVisible();
locale = gauge.getLocale();
barColor = gauge.getBarColor();
thresholdColor = gauge.getThresholdColor();
needle.setFill(gauge.getNeedleColor());
titleText.setFill(gauge.getTitleColor());
subTitleText.setFill(gauge.getSubTitleColor());
unitText.setFill(gauge.getUnitColor());
valueText.setFill(gauge.getValueColor());
buttonTooltip.setText(gauge.getButtonTooltipText());
mainCanvas.setCache(false);
mainCanvas.setWidth(size);
mainCanvas.setHeight(size);
drawMainCanvas();
mainCanvas.setCache(true);
mainCanvas.setCacheHint(CacheHint.QUALITY);
resizeText();
}
OverLayRipple() {
super();
setOverLayBounds(this);
this.getStyleClass().add("jfx-rippler-overlay");
// update initial position
if (JFXRippler.this.getChildrenUnmodifiable().contains(control)) {
double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX());
double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY());
Bounds bounds = control.getBoundsInParent();
this.setX(bounds.getMinX() + diffMinX - snappedLeftInset());
this.setY(bounds.getMinY() + diffMinY - snappedTopInset());
}
// set initial attributes
setOpacity(0);
setCache(true);
setCacheHint(CacheHint.SPEED);
setCacheShape(true);
setManaged(false);
}
@Override protected void redraw() {
pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(gauge.getBorderWidth() / PREFERRED_WIDTH * size))));
pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));
locale = gauge.getLocale();
formatString = new StringBuilder("%.").append(Integer.toString(gauge.getDecimals())).append("f").toString();
colorGradientEnabled = gauge.isGradientBarEnabled();
noOfGradientStops = gauge.getGradientBarStops().size();
barBackground.setStroke(gauge.getBarBackgroundColor());
// Areas, Sections and Tick Marks
sectionCanvas.setCache(false);
sectionCtx.clearRect(0, 0, size, size);
if (gauge.isGradientBarEnabled() && gauge.getGradientLookup() != null) {
drawGradientBar();
if (gauge.getMajorTickMarksVisible()) drawTickMarks();
} else if (gauge.getSectionsVisible()) {
drawSections();
if (gauge.getMajorTickMarksVisible()) drawTickMarks();
}
sectionCanvas.setCache(true);
sectionCanvas.setCacheHint(CacheHint.QUALITY);
needle.setFill(gauge.getNeedleColor());
}
protected void starting() {
// init animation values
if (start == null) {
oldCache = region.get().isCache();
oldCacheHint = region.get().getCacheHint();
radii = region.get().getBackground() == null ? null : region.get()
.getBackground()
.getFills()
.get(0)
.getRadii();
insets = region.get().getBackground() == null ? null : region.get()
.getBackground()
.getFills()
.get(0)
.getInsets();
start = fromValue.get();
end = toValue.get();
region.get().setCache(true);
region.get().setCacheHint(CacheHint.SPEED);
}
}
/**
* Creates the new ticker billboard
*/
public void createBillboard() {
matrix = DotMatrixBuilder.create().prefSize(925, 54).colsAndRows(196, 11).dotOnColor(Color.rgb(255, 55, 0))
.dotOffColor(Color.rgb(64, 64, 64)).dotShape(DotShape.ROUND).matrixFont(MatrixFont8x8.INSTANCE).build();
billboard = new StackPane(matrix);
// billboard.setPadding(new Insets(1));
billboard.setBackground(
new Background(new BackgroundFill(Color.rgb(20, 20, 20), CornerRadii.EMPTY, Insets.EMPTY)));
// billboard.setBorder(new Border(new BorderStroke(Color.DARKCYAN,
// BorderStrokeStyle.DOTTED, CornerRadii.EMPTY, BorderWidths.FULL)));
dragNode = new DraggableNode(billboard, stage, 925, 54);
dragNode.setCache(true);
dragNode.setCacheShape(true);
dragNode.setCacheHint(CacheHint.SPEED);
}
/**
* Called when the animation is starting
*/
protected void starting() {
if (useCache) {
oldCache = node.isCache();
oldCacheHint = node.getCacheHint();
node.setCache(true);
node.setCacheHint(CacheHint.SPEED);
}
}
/**
* {@inheritDoc}
*/
@Override
public void initialise() {
final ScrollPane scrollPane = new ScrollPane();
scrollPane.getStyleClass().add("iconListWidget");
scrollPane.setCache(true);
scrollPane.setCacheHint(CacheHint.QUALITY);
scrollPane.setContent(createContent(scrollPane));
getChildren().addAll(scrollPane);
}
public void redraw() {
chartCanvas.setCache(false);
drawChart();
chartCanvas.setCache(true);
chartCanvas.setCacheHint(CacheHint.QUALITY);
overlayCanvas.setCache(false);
drawOverlay();
overlayCanvas.setCache(true);
overlayCanvas.setCacheHint(CacheHint.QUALITY);
redrawText();
}
@Override
public void cache(Pane node) {
if (!cache.containsKey(node)) {
SnapshotParameters snapShotparams = new SnapshotParameters();
snapShotparams.setFill(Color.TRANSPARENT);
WritableImage temp = node.snapshot(snapShotparams,
new WritableImage((int) node.getLayoutBounds().getWidth(),
(int) node.getLayoutBounds().getHeight()));
ImageView tempImage = new ImageView(temp);
tempImage.setCache(true);
tempImage.setCacheHint(CacheHint.SPEED);
cache.put(node, new ArrayList<>(node.getChildren()));
node.getChildren().setAll(tempImage);
}
}
private void resize() {
width = getWidth() - getInsets().getLeft() - getInsets().getRight();
height = getHeight() - getInsets().getTop() - getInsets().getBottom();
size = width < height ? width : height;
if (ASPECT_RATIO * width > height) {
width = 1 / (ASPECT_RATIO / height);
} else if (1 / (ASPECT_RATIO / height) > width) {
height = ASPECT_RATIO * width;
}
if (width > 0 && height > 0) {
if (isZoomEnabled()) resetZoom();
pane.setCache(true);
pane.setCacheHint(CacheHint.SCALE);
pane.setScaleX(width / PREFERRED_WIDTH);
pane.setScaleY(height / PREFERRED_HEIGHT);
group.resize(width, height);
group.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);
//heatMap.setSize(width, height);
//heatMap.relocate(((getWidth() - getInsets().getLeft() - getInsets().getRight()) - width) * 0.5, ((getHeight() - getInsets().getTop() - getInsets().getBottom()) - height) * 0.5);
heatMap.setScaleX(pane.getScaleX());
heatMap.setScaleY(pane.getScaleY());
heatMap.setTranslateX(group.getBoundsInParent().getMinX() - group.getLayoutBounds().getMinX());
heatMap.setTranslateY(group.getBoundsInParent().getMinY() - group.getLayoutBounds().getMinY());
pane.setCache(false);
}
}
private void drawFlaps() {
double cornerRadius = tile.getRoundedCorners() ? size * 0.025 : 0;
// Upper Background
upperBackground.setCache(false);
upperBackgroundCtx.clearRect(0, 0, width, flapHeight);
Helper.drawRoundedRect(upperBackgroundCtx, new CtxBounds(0, 0, width, flapHeight), new CtxCornerRadii(cornerRadius, cornerRadius, 0, 0));
upperBackgroundCtx.setFill(tile.getBackgroundColor());
upperBackgroundCtx.fill();
upperBackground.setCache(true);
upperBackground.setCacheHint(CacheHint.SPEED);
// Lower Background
lowerBackground.setCache(false);
lowerBackgroundCtx.clearRect(0, 0, width, flapHeight);
Helper.drawRoundedRect(lowerBackgroundCtx, new CtxBounds(0, 0, width, flapHeight), new CtxCornerRadii(0, 0, cornerRadius, cornerRadius));
lowerBackgroundCtx.setFill(tile.getBackgroundColor());
lowerBackgroundCtx.fill();
lowerBackground.setCache(true);
lowerBackground.setCacheHint(CacheHint.SPEED);
// Flap
flap.setCache(false);
flapCtx.clearRect(0, 0, width, flapHeight);
Helper.drawRoundedRect(flapCtx, new CtxBounds(0, 0, width, flapHeight), new CtxCornerRadii(cornerRadius, cornerRadius, 0, 0));
flapCtx.setFill(tile.getBackgroundColor());
flapCtx.fill();
flap.setCache(true);
flap.setCacheHint(CacheHint.SPEED);
}
public void redraw() {
chartCanvas.setCache(false);
drawChart();
chartCanvas.setCache(true);
chartCanvas.setCacheHint(CacheHint.QUALITY);
overlayCanvas.setCache(false);
drawOverlay();
overlayCanvas.setCache(true);
overlayCanvas.setCacheHint(CacheHint.QUALITY);
drawText();
}
private void drawSections(final GraphicsContext CTX) {
sectionsCanvas.setCache(false);
CTX.clearRect(0, 0, sectionsCanvas.getWidth(), sectionsCanvas.getHeight());
CTX.setFill(gauge.getBackgroundPaint());
if (Orientation.VERTICAL == orientation) {
CTX.fillRect(0, 0, 0.5 * width, 0.9 * height);
} else {
CTX.fillRect(0, 0, 0.79699248 * width, 0.5 * height);
}
double tmpStepSize = stepSize * 1.11111111;
double minValue = gauge.getMinValue();
double maxValue = gauge.getMaxValue();
int listSize = gauge.getSections().size();
for (int i = 0 ; i < listSize ; i++) {
final Section SECTION = gauge.getSections().get(i);
final double SECTION_START;
final double SECTION_SIZE = SECTION.getRange() * tmpStepSize;
if (Double.compare(SECTION.getStart(), maxValue) <= 0 && Double.compare(SECTION.getStop(), minValue) >= 0) {
if (Double.compare(SECTION.getStart(), minValue) < 0 && Double.compare(SECTION.getStop(), maxValue) < 0) {
SECTION_START = minValue * tmpStepSize;
} else {
SECTION_START = height - (SECTION.getStart() * tmpStepSize) - SECTION_SIZE;
}
CTX.save();
CTX.setFill(SECTION.getColor());
if (Orientation.VERTICAL == orientation) {
CTX.fillRect(0.0, SECTION_START, 0.5 * width, SECTION_SIZE);
} else {
CTX.fillRect(SECTION_START, 0.0, SECTION_SIZE, 0.5 * height);
}
CTX.restore();
}
}
sectionsCanvas.setCache(true);
sectionsCanvas.setCacheHint(CacheHint.QUALITY);
}
/**
* this method will cache the node only if it wasn't cached before
*/
public void cache() {
if (!isCached.getAndSet(true)) {
this.cache = node.isCache();
this.cacheHint = node.getCacheHint();
node.setCache(true);
node.setCacheHint(CacheHint.SPEED);
if (node instanceof Region) {
this.cacheShape = ((Region) node).isCacheShape();
this.snapToPixel = ((Region) node).isSnapToPixel();
((Region) node).setCacheShape(true);
((Region) node).setSnapToPixel(true);
}
}
}
private void createHourPointer() {
double width = size * 0.09733333;
double height = size * 0.42066667;
hour.setCache(false);
hour.getElements().clear();
hour.getElements().add(new MoveTo(0.0, 0.0));
hour.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.884310618066561 * height, 0.0, 0.884310618066561 * height));
hour.getElements().add(new CubicCurveTo(0.0, 0.9477020602218701 * height, 0.22602739726027396 * width, height, 0.5 * width, height));
hour.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9477020602218701 * height, width, 0.884310618066561 * height));
hour.getElements().add(new CubicCurveTo(width, 0.884310618066561 * height, width, 0.0, width, 0.0));
hour.getElements().add(new LineTo(0.0, 0.0));
hour.getElements().add(new ClosePath());
hour.setCache(true);
hour.setCacheHint(CacheHint.ROTATE);
}
private void createMinutePointer() {
double width = size * 0.09733333;
double height = size * 0.548;
minute.setCache(false);
minute.getElements().clear();
minute.getElements().add(new MoveTo(0.0, 0.0));
minute.getElements().add(new CubicCurveTo(0.0, 0.0, 0.0, 0.9111922141119222 * height, 0.0, 0.9111922141119222 * height));
minute.getElements().add(new CubicCurveTo(0.0, 0.9598540145985401 * height, 0.22602739726027396 * width, height, 0.5 * width, height));
minute.getElements().add(new CubicCurveTo(0.773972602739726 * width, height, width, 0.9598540145985401 * height, width, 0.9111922141119222 * height));
minute.getElements().add(new CubicCurveTo(width, 0.9111922141119222 * height, width, 0.0, width, 0.0));
minute.getElements().add(new LineTo(0.0, 0.0));
minute.getElements().add(new ClosePath());
minute.setCache(true);
minute.setCacheHint(CacheHint.ROTATE);
}
private void drawNeedle() {
double needleWidth = size * 0.064;
double needleHeight = size * 0.44;
needle.setCache(false);
needle.getElements().clear();
needle.getElements().add(new MoveTo(0.1875 * needleWidth, 0.0));
needle.getElements().add(new CubicCurveTo(0.1875 * needleWidth, 0.0,
0.1875 * needleWidth, 0.8727272727272727 * needleHeight,
0.1875 * needleWidth, 0.8727272727272727 * needleHeight));
needle.getElements().add(new CubicCurveTo(0.0625 * needleWidth, 0.8818181818181818 * needleHeight,
0.0, 0.9 * needleHeight,
0.0, 0.9272727272727272 * needleHeight));
needle.getElements().add(new CubicCurveTo(0.0, 0.9636363636363636 * needleHeight,
0.25 * needleWidth, needleHeight,
0.5 * needleWidth, needleHeight));
needle.getElements().add(new CubicCurveTo(0.75 * needleWidth, needleHeight,
needleWidth, 0.9636363636363636 * needleHeight,
needleWidth, 0.9272727272727272 * needleHeight));
needle.getElements().add(new CubicCurveTo(needleWidth, 0.9 * needleHeight,
0.9375 * needleWidth, 0.8818181818181818 * needleHeight,
0.8125 * needleWidth, 0.8727272727272727 * needleHeight));
needle.getElements().add(new CubicCurveTo(0.8125 * needleWidth, 0.8727272727272727 * needleHeight,
0.8125 * needleWidth, 0.0,
0.8125 * needleWidth, 0.0));
needle.getElements().add(new LineTo(0.1875 * needleWidth, 0.0));
needle.getElements().add(new ClosePath());
needle.setCache(true);
needle.setCacheHint(CacheHint.ROTATE);
}
public static Node createLoadingNode () {
Circle c0 = new Circle(65);
c0.setFill(Color.TRANSPARENT);
c0.setStrokeWidth(0.0);
Circle c1 = new Circle(50);
c1.setFill(Color.TRANSPARENT);
c1.setStrokeType(StrokeType.INSIDE);
c1.setStrokeLineCap(StrokeLineCap.BUTT);
c1.getStrokeDashArray().addAll(78.54); // 50 * 2 * 3.1416 / 4
c1.setCache(true);
c1.setCacheHint(CacheHint.ROTATE);
c1.getStyleClass().add("loading-circle");
setRotate(c1, true, 440.0, 10);
Circle c2 = new Circle(40);
c2.setFill(Color.TRANSPARENT);
c2.setStrokeType(StrokeType.INSIDE);
c2.setStrokeLineCap(StrokeLineCap.BUTT);
c2.getStrokeDashArray().addAll(41.89); // 40 * 2 * 3.1416 / 6
c2.setCache(true);
c2.setCacheHint(CacheHint.ROTATE);
c2.getStyleClass().add("loading-circle");
setRotate(c2, true, 360.0, 14);
Circle c3 = new Circle(30);
c3.setFill(Color.TRANSPARENT);
c3.setStrokeType(StrokeType.INSIDE);
c3.setStrokeLineCap(StrokeLineCap.BUTT);
c3.getStyleClass().add("loading-circle");
Group g = new Group(c0, c1, c2, c3);
g.getStylesheets().add(Dialogs.class.getResource("/com/adr/helloiot/styles/loading.css").toExternalForm());
return g;
}
public static Node createSmallLoadingNode () {
Circle c0 = new Circle(45);
c0.setFill(Color.TRANSPARENT);
c0.setStrokeWidth(0.0);
Circle c2 = new Circle(40);
c2.setFill(Color.TRANSPARENT);
c2.setStrokeType(StrokeType.INSIDE);
c2.setStrokeLineCap(StrokeLineCap.BUTT);
c2.getStrokeDashArray().addAll(41.89); // 40 * 2 * 3.1416 / 6
c2.setCache(true);
c2.setCacheHint(CacheHint.ROTATE);
c2.getStyleClass().add("loading-circle");
setRotate(c2, true, 360.0, 14);
Circle c3 = new Circle(30);
c3.setFill(Color.TRANSPARENT);
c3.setStrokeType(StrokeType.INSIDE);
c3.setStrokeLineCap(StrokeLineCap.BUTT);
c3.getStyleClass().add("loading-circle");
Group g = new Group(c0, c2, c3);
g.getStylesheets().add(Dialogs.class.getResource("/com/adr/helloiot/styles/loading.css").toExternalForm());
return g;
}