Java 类org.eclipse.swt.dnd.ImageTransfer 实例源码

项目:JavaFX-FrameRateMeter    文件:OldFXCanvas.java   
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);
}
项目:JavaFX-FrameRateMeter    文件:OldFXCanvas.java   
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;
}
项目:seg.jUCMNav    文件:Clipboard.java   
/**
 * 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();
}
项目:pandionj    文件:RuntimeViewer.java   
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();
}
项目:SMVHunter    文件:ScreenShotDialog.java   
/**
 * Copies the content of {@link #mImageLabel} to the clipboard.
 */
private void copy() {
    mClipboard.setContents(
            new Object[] {
                    mImageLabel.getImage().getImageData()
            }, new Transfer[] {
                    ImageTransfer.getInstance()
            });
}
项目:screenshot    文件:ScreenShotDialog.java   
/**
 * Copies the content of {@link #mImageLabel} to the clipboard.
 */
private void copy() {
    mClipboard.setContents(
            new Object[] {
                    mImageLabel.getImage().getImageData()
            }, new Transfer[] {
                    ImageTransfer.getInstance()
            });
}
项目:eclipsegraphviz    文件:CopyToClipboardAction.java   
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 });
}
项目:JXTN    文件:FXCanvas.java   
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);
}
项目:JXTN    文件:FXCanvas.java   
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;
}
项目:Sammelbox    文件:ImageDropAndManagementComposite.java   
/** 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);
}
项目:pentaho-kettle    文件:Spoon.java   
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() } );
}
项目:pandionj    文件:RuntimeViewer.java   
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();
}
项目:pandionj    文件:FrameView.java   
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();
}
项目:ControlAndroidDeviceFromPC    文件:ScreenShotDialog.java   
/**
 * Copies the content of {@link #mImageLabel} to the clipboard.
 */
private void copy() {
    mClipboard.setContents(new Object[] { mImageLabel.getImage().getImageData() },
            new Transfer[] { ImageTransfer.getInstance() });
}