當前位置: 首頁>>代碼示例>>Java>>正文


Java NativeCursor類代碼示例

本文整理匯總了Java中org.apache.harmony.awt.wtk.NativeCursor的典型用法代碼示例。如果您正苦於以下問題:Java NativeCursor類的具體用法?Java NativeCursor怎麽用?Java NativeCursor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NativeCursor類屬於org.apache.harmony.awt.wtk包,在下文中一共展示了NativeCursor類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNativeCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
NativeCursor getNativeCursor() {
    if (nativeCursor != null) {
        return nativeCursor;
    }
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (type != CUSTOM_CURSOR) {
        nativeCursor = toolkit.createNativeCursor(type);
    } else {
        nativeCursor = toolkit.createCustomNativeCursor(image, hotSpot,
                                                        name);
    }
    return nativeCursor;
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:14,代碼來源:Cursor.java

示例2: createCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
/**
 * @see org.apache.harmony.awt.wtk.CursorFactory#createCursor(int)
 */
public NativeCursor createCursor(int type) {
    if (type >= 0 && type < predefined.length) {
        long cursor = x11.XCreateFontCursor(display, predefined[type]);
        return new LinuxCursor(cursor, display);
    }
    return null;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:11,代碼來源:LinuxCursorFactory.java

示例3: createCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
/**
 * @see org.apache.harmony.awt.wtk.CursorFactory#createCursor(int)
 */
@Override
public NativeCursor createCursor(int type) {
    if (type >= 0 && type < predefined.length) {
        long hCursor = win32.LoadCursorW(0l, predefined[type]);
        return new WinCursor(eventQueue, hCursor);
    }
    return null;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:12,代碼來源:WinCursorFactory.java

示例4: setNativeCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
void setNativeCursor(NativeCursor nativeCursor) {
    this.nativeCursor = nativeCursor;
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:4,代碼來源:Cursor.java

示例5: createCustomCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
/**
 * @see org.apache.harmony.awt.wtk.CursorFactory#createCustomCursor(java.awt.Image, int, int)
 */
public NativeCursor createCustomCursor(Image img, int xHotSpot, int yHotSpot) {

    int width = img.getWidth(null);
    int height = img.getHeight(null);
    BufferedImage bufImg = Utils.getBufferedImage(img);
    if(bufImg == null) throw new NullPointerException(Messages.getString("awt.29C"));

    //must convert image into TYPE_BYTE_BINARY format of depth 1
    BufferedImage bmpSrc = convertTo1Bit(bufImg);
    BufferedImage bmpMask = getMask(bufImg);
    //get pixel data from bufImg & create X11 pixmap
    byte[] bmpSrcData = ((DataBufferByte) bmpSrc.getData().getDataBuffer()).getData();
    byte[] rSrcData = convertToLSBFirst(bmpSrcData);
    byte[] bmpMaskData = ((DataBufferByte) bmpMask.getData().getDataBuffer()).getData();
    byte[] rMaskData = convertToLSBFirst(bmpMaskData);

    ArrayAccessor arrayAccess = AccessorFactory.getArrayAccessor();
    long wnd = factory.getRootWindow();
    LockedArray larr = arrayAccess.lockArrayShort(rSrcData);
    long dataPtr = larr.getAddress();
    long pixmap = x11.XCreateBitmapFromData(display, wnd,
            dataPtr, width, height);
    //System.out.println("source pixmap=" + pixmap);
    larr.release();

    larr = arrayAccess.lockArrayShort(rMaskData);
    dataPtr = larr.getAddress();
    long pixmapMask = x11.XCreateBitmapFromData(display, wnd, dataPtr,
            width, height);
    //System.out.println("mask pixmap=" + pixmap);
    larr.release();
    int fgRGB = bufImg.getRGB(0, 0);
    Color fgColor = new Color(fgRGB);
    Color bkColor = getBkColor(bufImg, fgColor);
    X11.XColor bkColorPtr = getXColor(bkColor);
    X11.XColor fgColorPtr = getXColor(fgColor);
    //then pass this pixmap to x11.XCreatePixmapCursor()
    long cursor = x11.XCreatePixmapCursor(display, pixmap, pixmapMask,
            fgColorPtr, bkColorPtr, xHotSpot, yHotSpot);

    x11.XFreePixmap(display, pixmap);
    x11.XFreePixmap(display, pixmapMask);

    return new LinuxCursor(cursor, display);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:49,代碼來源:LinuxCursorFactory.java

示例6: createCustomCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
/**
 * @see org.apache.harmony.awt.wtk.CursorFactory#createCustomCursor(java.awt.Image, int, int)
 */
@Override
public NativeCursor createCustomCursor(Image img, int xHotSpot, int yHotSpot) {
    long hCursor = WinIcons.createIcon(false, img, xHotSpot, yHotSpot);
    return new WinCursor(eventQueue, hCursor, false);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:9,代碼來源:WinCursorFactory.java

示例7: createCustomCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
/**
 * @see org.apache.harmony.awt.wtk.CursorFactory#createCustomCursor(java.awt.Image, int, int)
 */
public NativeCursor createCustomCursor(Image img, int xHotSpot, int yHotSpot) {

    int width = img.getWidth(null);
    int height = img.getHeight(null);
    BufferedImage bufImg = Utils.getBufferedImage(img);
    //must convert image into TYPE_BYTE_BINARY format of depth 1
    BufferedImage bmpSrc = convertTo1Bit(/*bufImg*/img);
    BufferedImage bmpMask = getMask(bufImg);
    //get pixel data from bufImg & create X11 pixmap
    byte[] bmpSrcData = ((DataBufferByte) bmpSrc.getData().getDataBuffer()).getData();
    byte[] bmpMaskData = ((DataBufferByte) bmpMask.getData().getDataBuffer()).getData();

    ArrayAccessor arrayAccess = AccessorFactory.getArrayAccessor();
    long wnd = factory.getRootWindow();
    LockedArray larr = arrayAccess.lockArrayShort(bmpSrcData);
    long dataPtr = larr.getAddress();
    long pixmap = x11.XCreateBitmapFromData(display, wnd,
            dataPtr, width, height);
    //System.out.println("source pixmap=" + pixmap);
    larr.release();

    larr = arrayAccess.lockArrayShort(bmpMaskData);
    dataPtr = larr.getAddress();
    long pixmapMask = x11.XCreateBitmapFromData(display, wnd, dataPtr,
            width, height);
    //System.out.println("mask pixmap=" + pixmap);
    larr.release();
    int fgRGB = bufImg.getRGB(0, 0);
    Color fgColor = new Color(fgRGB);
    Color bkColor = getBkColor(bufImg, fgColor);
    X11.XColor bkColorPtr = getXColor(bkColor);
    X11.XColor fgColorPtr = getXColor(fgColor);
    //then pass this pixmap to x11.XCreatePixmapCursor()
    long cursor = x11.XCreatePixmapCursor(display, pixmap, pixmapMask,
            fgColorPtr, bkColorPtr, xHotSpot, yHotSpot);

    x11.XFreePixmap(display, pixmap);
    x11.XFreePixmap(display, pixmapMask);

    return new LinuxCursor(cursor, display);
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:45,代碼來源:LinuxCursorFactory.java

示例8: createNativeCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
/**
 * Returns a shared instance of implementation of org.apache.harmony.awt.wtk.NativeCursor
 * for current platform for
 * @param type - Java Cursor type
 * @return new instance of implementation of NativeCursor
 */
NativeCursor createNativeCursor(int type) {
    return wtk.getCursorFactory().getCursor(type);
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:10,代碼來源:Toolkit.java

示例9: createCustomNativeCursor

import org.apache.harmony.awt.wtk.NativeCursor; //導入依賴的package包/類
/**
 * Returns a shared instance of implementation of org.apache.harmony.awt.wtk.NativeCursor
 * for current platform for custom cursor
 * @param type - Java Cursor type
 * @return new instance of implementation of NativeCursor
 */
NativeCursor createCustomNativeCursor(Image img, Point hotSpot, String name) {
    return wtk.getCursorFactory().createCustomCursor(img, hotSpot.x, hotSpot.y);
}
 
開發者ID:mike10004,項目名稱:appengine-imaging,代碼行數:10,代碼來源:Toolkit.java


注:本文中的org.apache.harmony.awt.wtk.NativeCursor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。