本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: setNativeCursor
import org.apache.harmony.awt.wtk.NativeCursor; //导入依赖的package包/类
void setNativeCursor(NativeCursor nativeCursor) {
this.nativeCursor = nativeCursor;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}