Search in sources :

Example 1 with SnapshotParameters

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();
}
Also used : SnapshotParameters(javafx.scene.SnapshotParameters) ClipboardContent(javafx.scene.input.ClipboardContent) BorderImage(javafx.scene.layout.BorderImage) Image(javafx.scene.image.Image) Dragboard(javafx.scene.input.Dragboard)

Example 2 with SnapshotParameters

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);
}
Also used : WritableImage(javafx.scene.image.WritableImage) SnapshotParameters(javafx.scene.SnapshotParameters) YearMonth(java.time.YearMonth) ImageView(javafx.scene.image.ImageView)

Example 3 with SnapshotParameters

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;
    }
}
Also used : WritableImage(javafx.scene.image.WritableImage) SnapshotParameters(javafx.scene.SnapshotParameters) PixelReader(javafx.scene.image.PixelReader)

Example 4 with SnapshotParameters

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;
}
Also used : SnapshotParameters(javafx.scene.SnapshotParameters) ImagePattern(javafx.scene.paint.ImagePattern) Rectangle(javafx.scene.shape.Rectangle)

Example 5 with SnapshotParameters

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;
}
Also used : LinearGradient(javafx.scene.paint.LinearGradient) SnapshotParameters(javafx.scene.SnapshotParameters) GraphicsContext(javafx.scene.canvas.GraphicsContext) Stop(javafx.scene.paint.Stop) Canvas(javafx.scene.canvas.Canvas) ImagePattern(javafx.scene.paint.ImagePattern) Image(javafx.scene.image.Image)

Aggregations

SnapshotParameters (javafx.scene.SnapshotParameters)11 WritableImage (javafx.scene.image.WritableImage)6 Image (javafx.scene.image.Image)5 ImagePattern (javafx.scene.paint.ImagePattern)4 IOException (java.io.IOException)3 Canvas (javafx.scene.canvas.Canvas)3 GraphicsContext (javafx.scene.canvas.GraphicsContext)3 LinearGradient (javafx.scene.paint.LinearGradient)3 Stop (javafx.scene.paint.Stop)3 ImageView (javafx.scene.image.ImageView)2 ClipboardContent (javafx.scene.input.ClipboardContent)2 File (java.io.File)1 YearMonth (java.time.YearMonth)1 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 Map (java.util.Map)1 SwingFXUtils (javafx.embed.swing.SwingFXUtils)1 Chart (javafx.scene.chart.Chart)1 PixelReader (javafx.scene.image.PixelReader)1 Clipboard (javafx.scene.input.Clipboard)1