本文整理汇总了Java中org.eclipse.swt.dnd.ImageTransfer类的典型用法代码示例。如果您正苦于以下问题:Java ImageTransfer类的具体用法?Java ImageTransfer怎么用?Java ImageTransfer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageTransfer类属于org.eclipse.swt.dnd包,在下文中一共展示了ImageTransfer类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTransferType
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
Transfer getTransferType(String mime) {
if (mime.equals("text/plain")) {
return TextTransfer.getInstance();
}
if (mime.equals("text/rtf")) {
return RTFTransfer.getInstance();
}
if (mime.equals("text/html")) {
return HTMLTransfer.getInstance();
}
if (mime.equals("text/uri-list")) {
return URLTransfer.getInstance();
}
if (mime.equals("application/x-java-rawimage")) {
return ImageTransfer.getInstance();
}
if (mime.equals("application/x-java-file-list") || mime.equals("java.file-list")) {
return FileTransfer.getInstance();
}
return getCustomTransfer(mime);
}
示例2: getMime
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
String getMime(Transfer transfer) {
if (transfer.equals(TextTransfer.getInstance())) {
return "text/plain";
}
if (transfer.equals(RTFTransfer.getInstance())) {
return "text/rtf";
} ;
if (transfer.equals( HTMLTransfer.getInstance())) {
return "text/html";
}
if (transfer.equals(URLTransfer.getInstance())) {
return "text/uri-list";
}
if (transfer.equals( ImageTransfer.getInstance())) {
return "application/x-java-rawimage";
}
if (transfer.equals(FileTransfer.getInstance())) {
return "application/x-java-file-list";
}
if (transfer instanceof CustomTransfer) {
return ((CustomTransfer)transfer).getMime();
}
return null;
}
示例3: setContents
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
/**
* Sets the contents of the clipboard. This will erase the previous contents of this as well as the system clipboard. The provided contents will not be
* garbage-collected until some other contents are set using this method.
*
* @param contents
* the new contents
*/
public void setContents(Object contents, ImageData image) {
org.eclipse.swt.dnd.Clipboard cb = new org.eclipse.swt.dnd.Clipboard(null);
String contentString = null;
// TODO: Improve it so that it supports a better textual representation, if we feel that is important.
if (contents != null && contents instanceof Object[]) {
Object[] arr = (Object[]) contents;
if (arr.length == 4 && arr[2] != null) {
contentString = arr[2].toString();
} else
contentString = contents.toString();
}
// if have text in here, it has higher priority than image in ms word.
// disabled image transfer until CruiseControl runs on 3.4+
if (image != null)
cb.setContents(new Object[] { contents, image }, new Transfer[] { TRANSFER, ImageTransfer.getInstance() });
else
cb.setContents(new Object[] { contents, contentString }, new Transfer[] { TRANSFER, TextTransfer.getInstance() });
cb.dispose();
}
示例4: saveToImageFile
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
void saveToImageFile() {
Dimension size = rootFig.getPreferredSize();
Image image = new Image(Display.getDefault(), size.width, size.height);
GC gc = new GC(image);
SWTGraphics graphics = new SWTGraphics(gc);
rootFig.paint(graphics);
Clipboard clipboard = new Clipboard(Display.getDefault());
clipboard.setContents(new Object[]{image.getImageData()}, new Transfer[]{ ImageTransfer.getInstance()});
image.dispose();
gc.dispose();
}
示例5: copy
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
/**
* Copies the content of {@link #mImageLabel} to the clipboard.
*/
private void copy() {
mClipboard.setContents(
new Object[] {
mImageLabel.getImage().getImageData()
}, new Transfer[] {
ImageTransfer.getInstance()
});
}
示例6: run
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
public void run(IAction action) {
Image image = view.getViewer().getImage();
ImageData imageData = image.getImageData();
ImageTransfer imageTransfer = ImageTransfer.getInstance();
Clipboard clipboard = new Clipboard(Display.getCurrent());
clipboard.setContents(new Object[] { imageData }, new Transfer[] { imageTransfer });
}
示例7: getTransferType
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
Transfer getTransferType(String mime) {
if (mime.equals("text/plain")) return TextTransfer.getInstance();
if (mime.equals("text/rtf")) return RTFTransfer.getInstance();
if (mime.equals("text/html")) return HTMLTransfer.getInstance();
if (mime.equals("text/uri-list")) return URLTransfer.getInstance();
if (mime.equals("application/x-java-rawimage")) return ImageTransfer.getInstance();
if (mime.equals("application/x-java-file-list") || mime.equals("java.file-list")) {
return FileTransfer.getInstance();
}
return getCustomTransfer(mime);
}
示例8: getMime
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
String getMime(Transfer transfer) {
if (transfer.equals(TextTransfer.getInstance())) return "text/plain";
if (transfer.equals(RTFTransfer.getInstance())) return "text/rtf"; ;
if (transfer.equals( HTMLTransfer.getInstance())) return "text/html";
if (transfer.equals(URLTransfer.getInstance())) return "text/uri-list";
if (transfer.equals( ImageTransfer.getInstance())) return "application/x-java-rawimage";
if (transfer.equals(FileTransfer.getInstance())) return "application/x-java-file-list";
if (transfer instanceof CustomTransfer) return ((CustomTransfer)transfer).getMime();
return null;
}
示例9: addDropSupport
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
/** This method adds drop (drag & drop) support to a given SWT widget
* @param widget an SWT widget such as a label or a composite */
private void addDropSupport(final Widget widget) {
int ops = DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
final FileTransfer fTransfer = FileTransfer.getInstance();
final ImageTransfer iTransfer = ImageTransfer.getInstance();
Transfer[] transfers = new Transfer[] { fTransfer, iTransfer };
DropTarget target = new DropTarget((Control) widget, ops);
target.setTransfer(transfers);
target.addDropListener(this);
}
示例10: copyTransformationImage
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
public void copyTransformationImage( TransMeta transMeta ) {
TransGraph transGraph = delegates.trans.findTransGraphOfTransformation( transMeta );
if ( transGraph == null ) {
return;
}
Clipboard clipboard = GUIResource.getInstance().getNewClipboard();
Point area = transMeta.getMaximum();
Image image = transGraph.getTransformationImage( Display.getCurrent(), area.x, area.y, 1.0f );
clipboard.setContents(
new Object[] { image.getImageData() }, new Transfer[] { ImageTransfer.getInstance() } );
}
示例11: copyToClipBoard
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
void copyToClipBoard() {
Dimension size = rootFig.getPreferredSize();
Image image = new Image(Display.getDefault(), size.width, size.height);
GC gc = new GC(image);
SWTGraphics graphics = new SWTGraphics(gc);
rootFig.paint(graphics);
Clipboard clipboard = new Clipboard(Display.getDefault());
clipboard.setContents(new Object[]{image.getImageData()}, new Transfer[]{ ImageTransfer.getInstance()});
image.dispose();
gc.dispose();
}
示例12: copyToClipBoard
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
void copyToClipBoard() {
Composite item = viewer;
Point p = viewer.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Rectangle size = item.getClientArea();
System.out.println(p + " " + size);
// compositeViewer.setBackground(Constants.HIGHLIGHT_COLOR);
GC gc = new GC(item);
// Rectangle clipping2 = gc.getClipping();
// Image img = new Image(Display.getDefault(), size.width, size.height);
// gc.copyArea(img, 0, 0);
// ImageData imageData = img.getImageData();
RGB[] rgb = new RGB[256];
// build grey scale palette: 256 different grey values are generated.
for (int i = 0; i < 256; i++) {
rgb[i] = new RGB(i, i, i);
}
// Construct a new indexed palette given an array of RGB values.
PaletteData palette = new PaletteData(rgb);
Image img2 = new Image(Display.getDefault(), new ImageData(size.width, size.height, 8, palette));
// gc.setClipping(0, 0, p.x, p.y);
gc.copyArea(img2, 0, 0);
Shell popup = new Shell(Display.getDefault());
popup.setText("Image");
popup.setBounds(50, 50, 200, 200);
Canvas canvas = new Canvas(popup, SWT.NONE);
canvas.setBounds(img2.getBounds());
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.drawImage(img2, 0, 0);
}
});
popup.open();
Clipboard clipboard = new Clipboard(Display.getDefault());
clipboard.setContents(new Object[]{img2.getImageData()}, new Transfer[]{ ImageTransfer.getInstance()});
img2.dispose();
gc.dispose();
}
示例13: copy
import org.eclipse.swt.dnd.ImageTransfer; //导入依赖的package包/类
/**
* Copies the content of {@link #mImageLabel} to the clipboard.
*/
private void copy() {
mClipboard.setContents(new Object[] { mImageLabel.getImage().getImageData() },
new Transfer[] { ImageTransfer.getInstance() });
}