本文整理匯總了Java中javafx.scene.control.Slider.getOrientation方法的典型用法代碼示例。如果您正苦於以下問題:Java Slider.getOrientation方法的具體用法?Java Slider.getOrientation怎麽用?Java Slider.getOrientation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Slider
的用法示例。
在下文中一共展示了Slider.getOrientation方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: positionThumb
import javafx.scene.control.Slider; //導入方法依賴的package包/類
/**
* Called when ever either min, max or value changes, so thumb's layoutX, Y is recomputed.
*/
void positionThumb(final boolean animate) {
Slider s = getSkinnable();
if (s.getValue() > s.getMax()) return;// this can happen if we are bound to something
boolean horizontal = s.getOrientation() == Orientation.HORIZONTAL;
final double endX = (horizontal) ? trackStart + (((trackLength * ((s.getValue() - s.getMin()) /
(s.getMax() - s.getMin()))) - thumbWidth / 2)) : thumbLeft;
final double endY = (horizontal) ? thumbTop :
snappedTopInset() + trackLength - (trackLength * ((s.getValue() - s.getMin()) /
(s.getMax() - s.getMin()))); // - thumbHeight/2
if (animate) {
// lets animate the thumb transition
final double startX = thumb.getLayoutX();
final double startY = thumb.getLayoutY();
Transition transition = new Transition() {
{
setCycleDuration(Duration.millis(200));
}
@Override
protected void interpolate(double frac) {
if (!Double.isNaN(startX)) {
thumb.setLayoutX(startX + frac * (endX - startX));
}
if (!Double.isNaN(startY)) {
thumb.setLayoutY(startY + frac * (endY - startY));
}
}
};
transition.play();
} else {
thumb.setLayoutX(endX);
thumb.setLayoutY(endY);
}
}
示例2: computeMinWidth
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
final Slider s = getSkinnable();
if (s.getOrientation() == Orientation.HORIZONTAL) {
return (leftInset + minTrackLength() + thumb.minWidth(-1) + rightInset);
} else {
return (leftInset + thumb.prefWidth(-1) + rightInset);
}
}
示例3: computeMinHeight
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
final Slider s = getSkinnable();
if (s.getOrientation() == Orientation.HORIZONTAL) {
return (topInset + thumb.prefHeight(-1) + bottomInset);
} else {
return (topInset + minTrackLength() + thumb.prefHeight(-1) + bottomInset);
}
}
示例4: computePrefWidth
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
final Slider s = getSkinnable();
if (s.getOrientation() == Orientation.HORIZONTAL) {
if (showTickMarks) {
return Math.max(140, tickLine.prefWidth(-1));
} else {
return 140;
}
} else {
return leftInset + Math.max(thumb.prefWidth(-1), track.prefWidth(-1)) +
((showTickMarks) ? (trackToTickGap + tickLine.prefWidth(-1)) : 0) + rightInset;
}
}
示例5: computePrefHeight
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
final Slider s = getSkinnable();
if (s.getOrientation() == Orientation.HORIZONTAL) {
return topInset + Math.max(thumb.prefHeight(-1), track.prefHeight(-1)) +
((showTickMarks) ? (trackToTickGap + tickLine.prefHeight(-1)) : 0) + bottomInset;
} else {
if (showTickMarks) {
return Math.max(140, tickLine.prefHeight(-1));
} else {
return 140;
}
}
}
示例6: positionThumb
import javafx.scene.control.Slider; //導入方法依賴的package包/類
/**
* Called when ever either min, max or value changes, so thumb's layoutX, Y is recomputed.
*/
void positionThumb(final boolean animate) {
Slider s = getSkinnable();
if (s.getValue() > s.getMax()) return;// this can happen if we are bound to something
boolean horizontal = s.getOrientation() == Orientation.HORIZONTAL;
final double endX = (horizontal) ? trackStart + (((trackLength * ((s.getValue() - s.getMin()) /
(s.getMax() - s.getMin()))) - thumbWidth/2)) : thumbLeft;
final double endY = (horizontal) ? thumbTop :
snappedTopInset() + trackLength - (trackLength * ((s.getValue() - s.getMin()) /
(s.getMax() - s.getMin()))); // - thumbHeight/2
if (animate) {
// lets animate the thumb transition
final double startX = thumb.getLayoutX();
final double startY = thumb.getLayoutY();
Transition transition = new Transition() {
{
setCycleDuration(Duration.millis(200));
}
@Override protected void interpolate(double frac) {
if (!Double.isNaN(startX)) {
thumb.setLayoutX(startX + frac * (endX - startX));
}
if (!Double.isNaN(startY)) {
thumb.setLayoutY(startY + frac * (endY - startY));
}
}
};
transition.play();
} else {
thumb.setLayoutX(endX);
thumb.setLayoutY(endY);
}
}
示例7: computeMinWidth
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
final Slider s = getSkinnable();
if (s.getOrientation() == Orientation.HORIZONTAL) {
return (leftInset + minTrackLength() + thumb.minWidth(-1) + rightInset);
} else {
return(leftInset + thumb.prefWidth(-1) + rightInset);
}
}
示例8: computeMinHeight
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
final Slider s = getSkinnable();
if (s.getOrientation() == Orientation.HORIZONTAL) {
return(topInset + thumb.prefHeight(-1) + bottomInset);
} else {
return(topInset + minTrackLength() + thumb.prefHeight(-1) + bottomInset);
}
}
示例9: computePrefWidth
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
final Slider s = getSkinnable();
if (s.getOrientation() == Orientation.HORIZONTAL) {
if(showTickMarks) {
return Math.max(140, tickLine.prefWidth(-1));
} else {
return 140;
}
} else {
return leftInset + Math.max(thumb.prefWidth(-1), track.prefWidth(-1)) +
((showTickMarks) ? (trackToTickGap+tickLine.prefWidth(-1)) : 0) + rightInset;
}
}
示例10: computePrefHeight
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
final Slider s = getSkinnable();
if (s.getOrientation() == Orientation.HORIZONTAL) {
return topInset + Math.max(thumb.prefHeight(-1), track.prefHeight(-1)) +
((showTickMarks) ? (trackToTickGap+tickLine.prefHeight(-1)) : 0) + bottomInset;
} else {
if(showTickMarks) {
return Math.max(140, tickLine.prefHeight(-1));
} else {
return 140;
}
}
}
示例11: checkDefaults
import javafx.scene.control.Slider; //導入方法依賴的package包/類
protected void checkDefaults(Slider slider, double min, double max, double value) {
if (Double.compare(slider.getValue(), value) != 0) {
reportGetterFailure("Slider.getValue()");
}
if (Double.compare(slider.getMin(), min) != 0) {
reportGetterFailure("Slider.getMin()");
}
if (Double.compare(slider.getMax(), max) != 0) {
reportGetterFailure("Slider.getMax()");
}
if (Double.compare(slider.getBlockIncrement(), 10) != 0) {
reportGetterFailure("Slider.getBlockIncrement()");
}
if (Double.compare(slider.getMajorTickUnit(), 25) != 0) {
reportGetterFailure("Slider.getMajorTickUnit()");
}
if (Double.compare(slider.getMinorTickCount(), 3) != 0) {
reportGetterFailure("Slider.getMinorTickCount()");
}
if (slider.isShowTickLabels() != false) {
reportGetterFailure("Slider.isShowTickLabels()");
}
if (slider.isShowTickMarks() != false) {
reportGetterFailure("Slider.isShowTickMarks()");
}
if (slider.isSnapToTicks() != false) {
reportGetterFailure("Slider.isSnapToTicks()");
}
if (slider.getOrientation() != Orientation.HORIZONTAL) {
reportGetterFailure("Slider.getOrientation()");
}
}
示例12: start
import javafx.scene.control.Slider; //導入方法依賴的package包/類
@Override
public void start(final Stage stage)
{
final Slider slider = new Slider();
slider.setOrientation(Orientation.HORIZONTAL);
slider.setShowTickLabels(true);
slider.setShowTickMarks(true);
slider.setMajorTickUnit(20.0);
slider.setMin(-100.0);
slider.setMax(100.0);
slider.setValue(10.0);
slider.valueProperty().addListener((observable, old, value)->
{
System.out.println("Value: " + value);
});
final SliderMarkers markers = new SliderMarkers(slider);
markers.setAlarmMarkers(-100, -10, 70, 90);
final String font = "-fx-font-size: 30px";
slider.setStyle(font);
markers.setStyle(font);
final GridPane layout = new GridPane();
layout.add(markers, 0, 0);
layout.getChildren().add(slider);
if (slider.getOrientation() == Orientation.VERTICAL)
{
GridPane.setConstraints(slider, 1, 0);
GridPane.setVgrow(slider, Priority.ALWAYS);
}
else
{
GridPane.setConstraints(slider, 0, 1);
GridPane.setHgrow(slider, Priority.ALWAYS);
}
final Scene scene = new Scene(layout, 800, 700);
stage.setScene(scene);
stage.setTitle("Slider Demo");
stage.show();
markers.update();
}