public NativeLong get() { return getValue().getValue(); } public void set(int v) {
public NativeLong get() { return getValue().getValue(); } public void set(int v) {
public Point getLocation() { NativeLongByReference x = new NativeLongByReference(); NativeLongByReference y = new NativeLongByReference(); int result = lib.wdeGetLocation(element, x, y); errors.verifyErrorCode(result, "Unable to get location of element"); return new Point(x.getValue().intValue(), y.getValue().intValue()); }
public Dimension getSize() { NativeLongByReference width = new NativeLongByReference(); NativeLongByReference height = new NativeLongByReference(); int result = lib.wdeGetSize(element, width, height); errors.verifyErrorCode(result, "Unable to get element size"); return new Dimension(width.getValue().intValue(), height.getValue().intValue()); }
public Point getLocationOnScreenOnceScrolledIntoView() { HWNDByReference hwnd = new HWNDByReference(); NativeLongByReference x = new NativeLongByReference(); NativeLongByReference y = new NativeLongByReference(); NativeLongByReference width = new NativeLongByReference(); NativeLongByReference height = new NativeLongByReference(); if (lib.wdeGetDetailsOnceScrolledOnToScreen(element, hwnd, x, y, width, height) != 0) { return null; } return new Point(x.getValue().intValue(), y.getValue().intValue()); }
public void dragAndDropBy(int moveRightBy, int moveDownBy) { HWNDByReference hwnd = new HWNDByReference(); NativeLongByReference x = new NativeLongByReference(); NativeLongByReference y = new NativeLongByReference(); NativeLongByReference width = new NativeLongByReference(); NativeLongByReference height = new NativeLongByReference(); int result = lib.wdeGetDetailsOnceScrolledOnToScreen(element, hwnd, x, y, width, height); errors.verifyErrorCode(result, "Unable to determine location once scrolled on to screen"); lib.wdeMouseDownAt(hwnd.getValue(), x.getValue(), y.getValue()); long endX = x.getValue().longValue() + moveRightBy; long endY = y.getValue().longValue() + moveDownBy; int duration = parent.manage().getSpeed().getTimeOut(); lib.wdeMouseMoveTo(hwnd.getValue(), new NativeLong(duration), x.getValue(), y.getValue(), new NativeLong(endX), new NativeLong(endY)); lib.wdeMouseUpAt(hwnd.getValue(), new NativeLong(endX), new NativeLong(endY)); }
public void hover() { HWNDByReference hwnd = new HWNDByReference(); NativeLongByReference x = new NativeLongByReference(); NativeLongByReference y = new NativeLongByReference(); NativeLongByReference width = new NativeLongByReference(); NativeLongByReference height = new NativeLongByReference(); int result = lib.wdeGetDetailsOnceScrolledOnToScreen(element, hwnd, x, y, width, height); errors.verifyErrorCode(result, "hover"); long midX = x.getValue().longValue() + (width.getValue().longValue() / 2); long midY = y.getValue().longValue() + (height.getValue().longValue() / 2); result = lib.wdeMouseMoveTo(hwnd.getValue(), new NativeLong(100), new NativeLong(0), new NativeLong(0), new NativeLong(midX), new NativeLong(midY)); errors.verifyErrorCode(result, "hover mouse move"); }
public void dragAndDropOn(RenderedWebElement toElement) { HWNDByReference hwnd = new HWNDByReference(); NativeLongByReference x = new NativeLongByReference(); NativeLongByReference y = new NativeLongByReference(); NativeLongByReference width = new NativeLongByReference(); NativeLongByReference height = new NativeLongByReference(); int result = lib.wdeGetDetailsOnceScrolledOnToScreen(element, hwnd, x, y, width, height); errors.verifyErrorCode(result, "Unable to determine location once scrolled on to screen"); NativeLong startX = new NativeLong(x.getValue().longValue() + (width.getValue().longValue() / 2)); NativeLong startY = new NativeLong(y.getValue().longValue() + (height.getValue().longValue() / 2)); lib.wdeMouseDownAt(hwnd.getValue(), startX, startY); Pointer other = ((InternetExplorerElement) toElement).element; result = lib.wdeGetDetailsOnceScrolledOnToScreen(other, hwnd, x, y, width, height); errors.verifyErrorCode(result, "Unable to determine location of target once scrolled on to screen"); NativeLong endX = new NativeLong(x.getValue().longValue() + (width.getValue().longValue() / 2)); NativeLong endY = new NativeLong(y.getValue().longValue() + (height.getValue().longValue() / 2)); int duration = parent.manage().getSpeed().getTimeOut(); lib.wdeMouseMoveTo(hwnd.getValue(), new NativeLong(duration), startX, startY, endX, endY); lib.wdeMouseUpAt(hwnd.getValue(), endX, endY); }
private Map<Integer, String> makeEnum(int grpid, int xtype) throws IOException { byte[] nameb = new byte[Nc4prototypes.NC_MAX_NAME + 1]; IntByReference baseType = new IntByReference(); NativeLongByReference baseSize = new NativeLongByReference(); NativeLongByReference numMembers = new NativeLongByReference(); int ret = nc4.nc_inq_enum(grpid, xtype, nameb, baseType, baseSize, numMembers); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret)); int nmembers = numMembers.getValue().intValue(); String name = makeString(nameb); //System.out.printf(" type=%d name=%s baseType=%d baseType=%d numMembers=%d %n ", // xtype, name, baseType.getValue(), baseSize.getValue().longValue(), nmembers); Map<Integer, String> map = new HashMap<Integer, String>(2 * nmembers); for (int i = 0; i < nmembers; i++) { byte[] mnameb = new byte[Nc4prototypes.NC_MAX_NAME + 1]; IntByReference value = new IntByReference(); ret = nc4.nc_inq_enum_member(grpid, xtype, i, mnameb, value); // void * if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret)); String mname = makeString(mnameb); //System.out.printf(" member name=%s value=%d %n ", mname, value.getValue()); map.put(value.getValue(), mname); } return map; }
int utype = classp.getValue(); if (debug) System.out.printf(" user type id=%d name=%s size=%d baseType=%d nfields=%d class=%d%n", typeid, name, sizep.getValue().longValue(), baseType.getValue(), nfieldsp.getValue().longValue(), utype); UserType ut = new UserType(grpid, typeid, name, sizep.getValue().longValue(), baseType.getValue(), nfieldsp.getValue().longValue(), utype); userTypes.put(typeid, ut);
@Test public void testDifftime() throws Exception { // Pointer to hold the times NativeLongByReference ref = new NativeLongByReference(); // time() returns -1 on error. NativeLong err = new NativeLong(-1L); LibC.time(ref); NativeLong time0 = ref.getValue(); Assert.assertNotSame(time0, err, "Time 0 returned an error (-1)."); Thread.sleep(5000L); LibC.time(ref); NativeLong time1 = ref.getValue(); Assert.assertNotSame(time1, err, "Time 1 returned an error (-1)."); Assert.assertNotSame(time1, time0, "Time 1 returned same time as Time 0."); double diff = LibC.difftime(time1, time0); Assert.assertTrue(diff >= 5, "Time difference was not greater than 5 seconds: " + diff); } }
void readFields() throws IOException { for (int fldidx = 0; fldidx < nfields; fldidx++) { byte[] fldname = new byte[Nc4prototypes.NC_MAX_NAME + 1]; IntByReference field_typeidp = new IntByReference(); IntByReference ndimsp = new IntByReference(); NativeLongByReference offsetp = new NativeLongByReference(); int[] dims = new int[Nc4prototypes.NC_MAX_DIMS]; int ret = nc4.nc_inq_compound_field(grpid, typeid, fldidx, fldname, offsetp, field_typeidp, ndimsp, dims); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret)); Field fld = new Field(grpid, typeid, fldidx, makeString(fldname), offsetp.getValue().intValue(), field_typeidp.getValue(), ndimsp.getValue(), dims); addField(fld); if (debugUserTypes) System.out.printf(" %s add field= %s%n", name, fld); } } }
throw new IllegalStateException("dimension " + dname + " should be unlimited"); int len = lenp.getValue().intValue(); if (len != d.getLength()) { d.setLength(len);
private void makeDimensions(int grpid, Group4 g4) throws IOException { IntByReference ndimsp = new IntByReference(); int ret = nc4.nc_inq_ndims(grpid, ndimsp); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret)); int[] dimids = new int[ndimsp.getValue()]; ret = nc4.nc_inq_dimids(grpid, ndimsp, dimids, 0); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret)); IntByReference nunlimdimsp = new IntByReference(); int[] unlimdimids = new int[Nc4prototypes.NC_MAX_DIMS]; ret = nc4.nc_inq_unlimdims(grpid, nunlimdimsp, unlimdimids); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret)); int ndims = ndimsp.getValue(); for (int i = 0; i < ndims; i++) { byte[] name = new byte[Nc4prototypes.NC_MAX_NAME + 1]; NativeLongByReference lenp = new NativeLongByReference(); ret = nc4.nc_inq_dim(grpid, dimids[i], name, lenp); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret)); String dname = makeString(name); boolean isUnlimited = containsInt(nunlimdimsp.getValue(), unlimdimids, i); Dimension dim = new Dimension(dname, lenp.getValue().intValue(), true, isUnlimited, false); ncfile.addDimension(g4.g, dim); if (debug) System.out.printf(" add Dimension %s (%d) %n", dim, dimids[i]); } }
/** * Get the size of a property * @param ref Reference to the camera/image/liveview object * @param property the property id * @param param * @return Size in bytes */ public static long getPropertySize( final EdsBaseRef ref, final EdsPropertyID property, final long param ) { final int bufferSize = 1; final IntBuffer type = IntBuffer.allocate( bufferSize ); final NativeLongByReference number = new NativeLongByReference( new NativeLong( bufferSize ) ); final EdsError err = CanonUtils.toEdsError( CanonCamera.EDSDK.EdsGetPropertySize( ref, new NativeLong( property.value() ), new NativeLong( param ), type, number ) ); if ( err == EdsError.EDS_ERR_OK ) { //System.out.println( "> property size = " + number.getValue().longValue() ); return number.getValue().longValue(); } return -1; }
final long numCams = outRef.getValue().longValue(); if ( numCams <= 0 ) { err = EdsError.EDS_ERR_DEVICE_NOT_FOUND;
ret = nc4.nc_inq_attlen(grpid, varid, attname, lenp); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret)); int len = lenp.getValue().intValue();
final byte[] data = ref.getValue().getByteArray( 0, length.getValue().intValue() ); CanonUtils.release( imageRef, streamRef ); return data;
result = lib.wdGetNumberScriptResult(scriptResult, value); errors.verifyErrorCode(result, "Cannot extract number result"); toReturn = value.getValue().longValue(); break;