本文整理汇总了Java中javafx.scene.paint.Stop.getOffset方法的典型用法代码示例。如果您正苦于以下问题:Java Stop.getOffset方法的具体用法?Java Stop.getOffset怎么用?Java Stop.getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.paint.Stop
的用法示例。
在下文中一共展示了Stop.getOffset方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ladder
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
/**
* Get the color at the give {@code position} in the ladder of color stops
*/
private static Color ladder(final double position, final Stop[] stops) {
Stop prevStop = null;
for (int i=0; i<stops.length; i++) {
Stop stop = stops[i];
if(position <= stop.getOffset()){
if (prevStop == null) {
return stop.getColor();
} else {
return interpolateLinear((position-prevStop.getOffset())/(stop.getOffset()-prevStop.getOffset()), prevStop.getColor(), stop.getColor());
}
}
prevStop = stop;
}
// position is greater than biggest stop, so will we biggest stop's color
return prevStop.getColor();
}
示例2: getColor
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
private Color getColor(double t) {
if (t < 0 || t > 1) {
throw new IllegalArgumentException("t = " + t);
}
for (int i = 1; i < colorStops.size(); i++) {
Stop s = colorStops.get(i);
Stop p = colorStops.get(i-1);
if (t <= s.getOffset()) {
double start = p.getOffset();
double end = s.getOffset();
return p.getColor().interpolate(s.getColor(), (t-start) / (end-start));
}
}
throw new IllegalArgumentException("t > last stop's offset: t="+t+", offset="+colorStops.get(colorStops.size()-1));
}
示例3: interpolateColor
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());
final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;
double red = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
double green = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
double blue = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
double opacity = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));
return Color.color(red, green, blue, opacity);
}
示例4: interpolateColor
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());
final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;
double red = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
double green = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
double blue = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
double opacity = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));
return Color.color(red, green, blue, opacity);
}
示例5: interpolateColor
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
public static final Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());
final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;
double red = clamp(0, 1, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
double green = clamp(0, 1, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
double blue = clamp(0, 1, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
double opacity = clamp(0, 1, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));
return Color.color(red, green, blue, opacity);
}
示例6: interpolateColor
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());
final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;
double red = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
double green = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
double blue = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
double opacity = Helper.clamp(0.0, 1.0, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));
return Color.color(red, green, blue, opacity);
}
示例7: interpolateColor
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());
final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;
double red = clamp(0d, 1d, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
double green = clamp(0d, 1d, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
double blue = clamp(0d, 1d, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
double opacity = clamp(0d, 1d, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));
return Color.color(red, green, blue, opacity);
}
示例8: interpolateColor
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());
final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;
double red = clamp(0.0, 1.0, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
double green = clamp(0.0, 1.0, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
double blue = clamp(0.0, 1.0, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
double opacity = clamp(0.0, 1.0, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));
return Color.color(red, green, blue, opacity);
}
示例9: interpolateColor
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
private Color interpolateColor(final Stop LOWER_BOUND, final Stop UPPER_BOUND, final double POSITION) {
final double POS = (POSITION - LOWER_BOUND.getOffset()) / (UPPER_BOUND.getOffset() - LOWER_BOUND.getOffset());
final double DELTA_RED = (UPPER_BOUND.getColor().getRed() - LOWER_BOUND.getColor().getRed()) * POS;
final double DELTA_GREEN = (UPPER_BOUND.getColor().getGreen() - LOWER_BOUND.getColor().getGreen()) * POS;
final double DELTA_BLUE = (UPPER_BOUND.getColor().getBlue() - LOWER_BOUND.getColor().getBlue()) * POS;
final double DELTA_OPACITY = (UPPER_BOUND.getColor().getOpacity() - LOWER_BOUND.getColor().getOpacity()) * POS;
double red = clamp(0d, 1d, (LOWER_BOUND.getColor().getRed() + DELTA_RED));
double green = clamp(0d, 1d, (LOWER_BOUND.getColor().getGreen() + DELTA_GREEN));
double blue = clamp(0d, 1d, (LOWER_BOUND.getColor().getBlue() + DELTA_BLUE));
double opacity = clamp(0d, 1d, (LOWER_BOUND.getColor().getOpacity() + DELTA_OPACITY));
return Color.color(red, green, blue, opacity);
}
示例10: getNewStop
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
private Stop getNewStop ( Stop previous ) {
Dialog<Stop> dialog = new Dialog<>();
dialog.setTitle("Stop Editor");
dialog.setHeaderText(previous == null ? "Define a new Stop" : "Edit the selected Stop");
dialog.getDialogPane().getButtonTypes().addAll(OK, CANCEL);
Spinner<Double> offsetSpinner = new Spinner<>(0.0, 1.0, previous == null ? 0.0 : previous.getOffset(), 0.01);
ColorPicker colorPicker = new ColorPicker(previous == null ? Color.GOLDENROD : previous.getColor());
GridPane grid = new GridPane();
offsetSpinner.setEditable(true);
offsetSpinner.setPrefWidth(USE_COMPUTED_SIZE);
colorPicker.setPrefWidth(USE_COMPUTED_SIZE);
grid.setHgap(6);
grid.setVgap(12);
grid.setPadding(new Insets(12, 12, 12, 12));
grid.getColumnConstraints().add(0, new ColumnConstraints(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, Priority.ALWAYS, HPos.RIGHT, true));
grid.getColumnConstraints().add(1, new ColumnConstraints(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, Priority.ALWAYS, HPos.LEFT, true));
grid.add(new Label("Offset:"), 0, 0);
grid.add(offsetSpinner, 1, 0);
grid.add(new Label("Color:"), 0, 1);
grid.add(colorPicker, 1, 1);
dialog.initOwner(stopsTable.getScene().getWindow());
dialog.getDialogPane().getScene().getStylesheets().add("/styles/dark-style.css");
dialog.getDialogPane().setContent(grid);
dialog.setResultConverter(b -> {
if ( b == OK ) {
return new Stop(offsetSpinner.getValue(), colorPicker.getValue());
} else {
return null;
}
});
Platform.runLater(() -> offsetSpinner.requestFocus());
return dialog.showAndWait().orElse(null);
}
示例11: addPressed
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
@FXML
void addPressed( ActionEvent event ) {
Stop stop = getNewStop(null);
if ( stop != null ) {
boolean done = false;
for ( int i = 0; i < stopsTable.getItems().size(); i++ ) {
if ( stopsTable.getItems().get(i).getOffset() > stop.getOffset() ) {
done = true;
stopsTable.getItems().add(i, stop);
break;
}
}
if ( !done ) {
stopsTable.getItems().add(stop);
}
}
}
示例12: editPressed
import javafx.scene.paint.Stop; //导入方法依赖的package包/类
@FXML
void editPressed( ActionEvent event ) {
int index = stopsTable.getSelectionModel().getSelectedIndex();
Stop stop = getNewStop(stopsTable.getItems().get(index));
if ( stop != null ) {
stopsTable.getItems().remove(index);
boolean done = false;
for ( int i = 0; i < stopsTable.getItems().size(); i++ ) {
if ( stopsTable.getItems().get(i).getOffset() > stop.getOffset() ) {
done = true;
stopsTable.getItems().add(i, stop);
break;
}
}
if ( !done ) {
stopsTable.getItems().add(stop);
}
}
}