private void drag(MouseEvent e) { Node node = get(); if (isEnable() && pressedCorner != null && e.isConsumed() == false && node != null) { double dx = e.getScreenX() - startX; if (pressedCorner.horizontal == HorizontalDirection.RIGHT) { width.set(MathUtil.toRange(startWidth + dx, minWidth.get(), maxWidth.get())); } else if (pressedCorner.horizontal == HorizontalDirection.LEFT) { width.set(MathUtil.toRange(startWidth - dx, minWidth.get(), maxWidth.get())); node.setLayoutX(startWidth + startPosX - width.get()); } double dy = e.getScreenY() - startY; if (pressedCorner.vertical == VerticalDirection.DOWN) { height.set(MathUtil.toRange(startHeight + dy, minHeight.get(), maxHeight.get())); } else if (pressedCorner.vertical == VerticalDirection.UP) { height.set(MathUtil.toRange(startHeight - dy, minHeight.get(), maxHeight.get())); node.setLayoutY(startHeight + startPosY - height.get()); } e.consume(); } }
private void drawMarking(double value, HorizontalDirection side, double markWidth, String... styles) { double y = getValueHeight(value); double x = (side == HorizontalDirection.LEFT) ? (bottomRadius - topRadius - markWidth) : (bottomRadius + topRadius); Line line = new Line(x, y, x + markWidth, y); line.getStyleClass().setAll(Arrays.stream(styles).map(style -> style + "-marking").collect(Collectors.toList())); pane.getChildren().add(line); markings.add(line); Text text = new Text(gauge.getFormattedValue(value)); text.setY(y + 4); text.getStyleClass().setAll(Arrays.stream(styles).map(style -> style + "-text").collect(Collectors.toList())); if(side == HorizontalDirection.LEFT) { text.setTextAlignment(TextAlignment.RIGHT); double wrappingWidth = restrain(2 * bottomRadius, 60, 240); text.setWrappingWidth(wrappingWidth); text.setX(x - wrappingWidth - 4); } else { text.setTextAlignment(TextAlignment.LEFT); text.setX(x + markWidth + 4); } pane.getChildren().add(text); markings.add(text); }
public PlayerControl() { Texture staticTexture = FXGL.getAssetLoader() .loadTexture("dude.png") .subTexture(new Rectangle2D(0, 0, 32, 42)); animatedTexture = FXGL.getAssetLoader() .loadTexture("dude.png") .subTexture(new Rectangle2D(32, 0, 32*3, 42)) .superTexture(staticTexture, HorizontalDirection.RIGHT) .toAnimatedTexture(4, Duration.seconds(0.5)); animWalk = animatedTexture.getAnimationChannel(); animStand = new AnimationChannel(animatedTexture.getImage(), 4, 32, 42, Duration.seconds(1), 1, 1); animJump = new AnimationChannel(animatedTexture.getImage(), 4, 32, 42, Duration.seconds(0.75), 1, 1);; animatedTexture.setAnimationChannel(animStand); animatedTexture.start(FXGL.getApp().getStateMachine().getPlayState()); jumpTimer = FXGL.newLocalTimer(); }
public StyleableObjectProperty<HorizontalDirection> rangePositionProperty() { if (rangePosition == null) { rangePosition = CssHelper.createProperty(StyleableProperties.RANGE_POSITION, this); rangePosition.addListener(obs -> redraw()); } return rangePosition; }
public StyleableObjectProperty<HorizontalDirection> thresholdPositionProperty() { if (thresholdPosition == null) { thresholdPosition = CssHelper.createProperty(StyleableProperties.THRESHOLD_POSITION, this); thresholdPosition.addListener(obs -> redraw()); } return thresholdPosition; }
private Corner(Cursor cursor, HorizontalDirection horizontal, VerticalDirection vertical) { this.cursor = cursor; this.horizontal = horizontal; this.vertical = vertical; }
public HorizontalDirection getRangePosition() { return rangePosition == null ? DEFAULT_RANGE_POSITION : rangePosition.get(); }
public void setRangePosition(HorizontalDirection newPosition) { rangePosition.set(newPosition); }
public HorizontalDirection getThresholdPosition() { return thresholdPosition == null ? DEFAULT_THRESHOLD_POSITION : thresholdPosition.get(); }
public void setThresholdPosition(HorizontalDirection newPosition) { thresholdPosition.set(newPosition); }