use of javafx.scene.SnapshotParameters in project cryptomator by cryptomator.
the class DraggableListCell method onDragDetected.
private void onDragDetected(MouseEvent event) {
if (getItem() == null) {
return;
}
final ClipboardContent content = new ClipboardContent();
content.putString(Integer.toString(getIndex()));
final Image snapshot = this.snapshot(new SnapshotParameters(), null);
final Dragboard dragboard = startDragAndDrop(TransferMode.MOVE);
dragboard.setDragView(snapshot);
dragboard.setContent(content);
event.consume();
}
use of javafx.scene.SnapshotParameters in project JFoenix by jfoenixadmin.
the class JFXDatePickerContent method forward.
protected void forward(int offset, ChronoUnit unit, boolean focusDayCell, boolean withAnimation) {
if (withAnimation) {
if (tempImageTransition == null || tempImageTransition.getStatus().equals(Status.STOPPED)) {
Pane monthContent = (Pane) calendarPlaceHolder.getChildren().get(0);
this.getParent().setManaged(false);
SnapshotParameters snapShotparams = new SnapshotParameters();
snapShotparams.setFill(Color.TRANSPARENT);
WritableImage temp = monthContent.snapshot(snapShotparams, new WritableImage((int) monthContent.getWidth(), (int) monthContent.getHeight()));
ImageView tempImage = new ImageView(temp);
calendarPlaceHolder.getChildren().add(calendarPlaceHolder.getChildren().size() - 2, tempImage);
TranslateTransition imageTransition = new TranslateTransition(Duration.millis(160), tempImage);
imageTransition.setToX(-offset * calendarPlaceHolder.getWidth());
imageTransition.setOnFinished((finish) -> calendarPlaceHolder.getChildren().remove(tempImage));
monthContent.setTranslateX(offset * calendarPlaceHolder.getWidth());
TranslateTransition contentTransition = new TranslateTransition(Duration.millis(160), monthContent);
contentTransition.setToX(0);
tempImageTransition = new ParallelTransition(imageTransition, contentTransition);
tempImageTransition.setOnFinished((finish) -> {
calendarPlaceHolder.getChildren().remove(tempImage);
this.getParent().setManaged(true);
});
tempImageTransition.play();
}
}
YearMonth yearMonth = selectedYearMonth.get();
DateCell dateCell = currentFocusedDayCell;
if (dateCell == null || !dayCellDate(dateCell).getMonth().equals(yearMonth.getMonth()))
dateCell = findDayCellOfDate(yearMonth.atDay(1));
goToDayCell(dateCell, offset, unit, focusDayCell);
}
use of javafx.scene.SnapshotParameters in project processing by processing.
the class PGraphicsFX2D method loadPixels.
// //////////////////////////////////////////////////////////////
//
// // COLOR MODE
//
// // All colorMode() variations are inherited from PGraphics.
//
//
//
// //////////////////////////////////////////////////////////////
//
// // COLOR CALC
//
// // colorCalc() and colorCalcARGB() inherited from PGraphics.
//
//
//
// //////////////////////////////////////////////////////////////
//
// // COLOR DATATYPE STUFFING
//
// // final color() variations inherited.
//
//
//
// //////////////////////////////////////////////////////////////
//
// // COLOR DATATYPE EXTRACTION
//
// // final methods alpha, red, green, blue,
// // hue, saturation, and brightness all inherited.
//
//
//
// //////////////////////////////////////////////////////////////
//
// // COLOR DATATYPE INTERPOLATION
//
// // both lerpColor variants inherited.
//
//
//
// //////////////////////////////////////////////////////////////
//
// // BEGIN/END RAW
//
//
// @Override
// public void beginRaw(PGraphics recorderRaw) {
// showMethodWarning("beginRaw");
// }
//
//
// @Override
// public void endRaw() {
// showMethodWarning("endRaw");
// }
//
//
//
// //////////////////////////////////////////////////////////////
//
// // WARNINGS and EXCEPTIONS
//
// // showWarning and showException inherited.
//
//
//
// //////////////////////////////////////////////////////////////
//
// // RENDERER SUPPORT QUERIES
//
//
// //public boolean displayable() // true
//
//
// //public boolean is2D() // true
//
//
// //public boolean is3D() // false
//////////////////////////////////////////////////////////////
// PIMAGE METHODS
@Override
public void loadPixels() {
if ((pixels == null) || (pixels.length != pixelWidth * pixelHeight)) {
pixels = new int[pixelWidth * pixelHeight];
loaded = false;
}
if (!loaded) {
if (snapshotImage == null || snapshotImage.getWidth() != pixelWidth || snapshotImage.getHeight() != pixelHeight) {
snapshotImage = new WritableImage(pixelWidth, pixelHeight);
}
SnapshotParameters sp = new SnapshotParameters();
if (pixelDensity != 1) {
sp.setTransform(Transform.scale(pixelDensity, pixelDensity));
}
snapshotImage = ((PSurfaceFX) surface).canvas.snapshot(sp, snapshotImage);
PixelReader pr = snapshotImage.getPixelReader();
pr.getPixels(0, 0, pixelWidth, pixelHeight, argbFormat, pixels, 0, pixelWidth);
loaded = true;
modified = false;
}
}
use of javafx.scene.SnapshotParameters in project FXyzLib by Birdasaur.
the class Patterns method createPattern.
public Image createPattern(CarbonPatterns cp, boolean save) {
ImagePattern pattern;
switch(cp) {
case DARK_CARBON:
pattern = createCarbonPattern();
break;
case LIGHT_CARBON:
pattern = createLightCarbonPattern();
break;
case CARBON_KEVLAR:
pattern = createCarbonKevlarPattern();
break;
default:
pattern = createCarbonPattern();
break;
}
Rectangle rectangle = new Rectangle(width, height);
if (pattern != null) {
rectangle.setFill(pattern);
}
rectangle.setStrokeWidth(0);
imgPattern = rectangle.snapshot(new SnapshotParameters(), null);
if (save) {
saveImage();
}
return imgPattern;
}
use of javafx.scene.SnapshotParameters in project FXyzLib by Birdasaur.
the class Patterns method createLightCarbonPattern.
public static final ImagePattern createLightCarbonPattern() {
final double WIDTH = 12;
final double HEIGHT = 12;
final Canvas CANVAS = new Canvas(WIDTH, HEIGHT);
final GraphicsContext CTX = CANVAS.getGraphicsContext2D();
double offsetY = 0;
CTX.beginPath();
CTX.rect(0, 0, WIDTH * 0.5, HEIGHT * 0.5);
CTX.closePath();
CTX.setFill(new LinearGradient(0, offsetY * HEIGHT, 0, 0.5 * HEIGHT + offsetY * HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(108, 108, 108)), new Stop(1, Color.rgb(100, 100, 100))));
CTX.fill();
CTX.beginPath();
CTX.rect(WIDTH * 0.083333, 0, WIDTH * 0.333333, HEIGHT * 0.416666);
CTX.closePath();
offsetY = 0;
CTX.setFill(new LinearGradient(0, offsetY * HEIGHT, 0, 0.416666 * HEIGHT + offsetY * HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(142, 142, 142)), new Stop(1, Color.rgb(130, 130, 130))));
CTX.fill();
CTX.beginPath();
CTX.rect(WIDTH * 0.5, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
CTX.closePath();
offsetY = 0.5;
CTX.setFill(new LinearGradient(0, offsetY * HEIGHT, 0, 0.5 * HEIGHT + offsetY * HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(108, 108, 108)), new Stop(1, Color.rgb(100, 100, 100))));
CTX.fill();
CTX.beginPath();
CTX.rect(WIDTH * 0.583333, HEIGHT * 0.5, WIDTH * 0.333333, HEIGHT * 0.416666);
CTX.closePath();
offsetY = 0.5;
CTX.setFill(new LinearGradient(0, offsetY * HEIGHT, 0, 0.416666 * HEIGHT + offsetY * HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(142, 142, 142)), new Stop(1, Color.rgb(130, 130, 130))));
CTX.fill();
CTX.beginPath();
CTX.rect(WIDTH * 0.5, 0, WIDTH * 0.5, HEIGHT * 0.5);
CTX.closePath();
offsetY = 0;
CTX.setFill(new LinearGradient(0, offsetY * HEIGHT, 0, 0.5 * HEIGHT + offsetY * HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(152, 152, 152)), new Stop(1, Color.rgb(146, 146, 146))));
CTX.fill();
CTX.beginPath();
CTX.rect(WIDTH * 0.583333, HEIGHT * 0.083333, WIDTH * 0.333333, HEIGHT * 0.416666);
CTX.closePath();
offsetY = 0.083333;
CTX.setFill(new LinearGradient(0, offsetY * HEIGHT, 0, 0.416666 * HEIGHT + offsetY * HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(160, 160, 160)), new Stop(1, Color.rgb(152, 152, 152))));
CTX.fill();
CTX.beginPath();
CTX.rect(0, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
CTX.closePath();
offsetY = 0.5;
CTX.setFill(new LinearGradient(0, offsetY * HEIGHT, 0, 0.5 * HEIGHT + offsetY * HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(152, 152, 152)), new Stop(1, Color.rgb(146, 146, 146))));
CTX.fill();
CTX.beginPath();
CTX.rect(WIDTH * 0.083333, HEIGHT * 0.583333, WIDTH * 0.333333, HEIGHT * 0.416666);
CTX.closePath();
offsetY = 0.583333;
CTX.setFill(new LinearGradient(0, offsetY * HEIGHT, 0, 0.416666 * HEIGHT + offsetY * HEIGHT, false, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(160, 160, 160)), new Stop(1, Color.rgb(152, 152, 152))));
CTX.fill();
final Image PATTERN_IMAGE = CANVAS.snapshot(new SnapshotParameters(), null);
final ImagePattern PATTERN = new ImagePattern(PATTERN_IMAGE, 0, 0, WIDTH, HEIGHT, false);
return PATTERN;
}
Aggregations