org.jhotdraw8.draw.input.MultiClipboardOutputFormat Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.jhotdraw8.draw Show documentation
Show all versions of org.jhotdraw8.draw Show documentation
JHotDraw8 Drawing Framework
The newest version!
/*
* @(#)MultiClipboardOutputFormat.java
* Copyright © 2023 The authors and contributors of JHotDraw. MIT License.
*/
package org.jhotdraw8.draw.input;
import javafx.scene.input.DataFormat;
import org.jhotdraw8.draw.figure.Drawing;
import org.jhotdraw8.draw.figure.Figure;
import org.jspecify.annotations.Nullable;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.function.Supplier;
/**
* MultiClipboardOutputFormat.
*
* @author Werner Randelshofer
*/
public class MultiClipboardOutputFormat implements ClipboardOutputFormat {
private @Nullable Supplier[] formatSuppliers;
private ClipboardOutputFormat[] formats;
@SafeVarargs
@SuppressWarnings("varargs")
public MultiClipboardOutputFormat(Supplier... formatSuppliers) {
this.formatSuppliers = formatSuppliers;
}
public MultiClipboardOutputFormat(ClipboardOutputFormat... formats) {
this.formats = formats;
}
private void createFormats() {
if (formatSuppliers != null) {
int n = formatSuppliers.length;
formats = new ClipboardOutputFormat[n];
for (int i = 0; i < n; i++) {
formats[i] = formatSuppliers[i].get();
}
formatSuppliers = null;
}
}
@Override
public void write(Map out, Drawing drawing, Collection