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 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()); }
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; }
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"); }
EdsError err = EdsError.EDS_ERR_OK; NativeLongByReference number = new NativeLongByReference( new NativeLong( EdsEvfOutputDevice.kEdsEvfOutputDevice_TFT.value() ) ); Pointer data = number.getPointer(); err = CanonUtils.setPropertyData( camera, EdsPropertyID.kEdsPropID_Evf_OutputDevice, 0, NativeLong.SIZE, data ); number = new NativeLongByReference( new NativeLong( 0 ) ); data = number.getPointer(); err = CanonUtils.setPropertyData( camera, EdsPropertyID.kEdsPropID_Evf_Mode, 0, NativeLong.SIZE, data );
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)); }
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); } } }
EdsError err = EdsError.EDS_ERR_OK; NativeLongByReference number = new NativeLongByReference( new NativeLong( 1 ) ); Pointer data = number.getPointer(); err = CanonUtils.setPropertyData( camera, EdsPropertyID.kEdsPropID_Evf_Mode, 0, NativeLong.SIZE, data ); number = new NativeLongByReference( new NativeLong( EdsEvfOutputDevice.kEdsEvfOutputDevice_PC.value() ) ); data = number.getPointer(); err = CanonUtils.setPropertyData( camera, EdsPropertyID.kEdsPropID_Evf_OutputDevice, 0, NativeLong.SIZE, data );
/** * Returns the data type of a specified property * * @param ref Reference to the camera * @param property Property id * @param param Name of the parameter * @return The data type, or null if the parameter isn't supported, or unknown if something else goes wrong. */ public static EdsDataType getPropertyType( 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 ) { final EdsDataType edsDataType = EdsDataType.enumOfValue( type.get( 0 ) ); if ( edsDataType != null ) { //System.out.println( " > property type = " + edsDataType.value() + " : " + edsDataType.name() + " : " + edsDataType.description() ); return edsDataType; } } else if( err == EdsError.EDS_ERR_NOT_SUPPORTED ){ return null; } return EdsDataType.kEdsDataType_Unknown; }
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]); } }
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, unlimdimids[i], name, lenp); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret));
NativeLongByReference sizep = new NativeLongByReference(); IntByReference baseType = new IntByReference(); NativeLongByReference nfieldsp = new NativeLongByReference(); IntByReference classp = new IntByReference(); NativeLongByReference sizep2 = new NativeLongByReference(); ret = nc4.nc_inq_opaque(grpid, typeid, nameo, sizep2); if (ret != 0) throw new IOException(ret + ": " + nc4.nc_strerror(ret));
@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); } }
final NativeLongByReference outRef = new NativeLongByReference(); err = CanonUtils.toEdsError( CanonCamera.EDSDK.EdsGetChildCount( listRef.getValue(), outRef ) );
/** * 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; }
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); }
final NativeLongByReference length = new NativeLongByReference(); err = CanonUtils.toEdsError( CanonCamera.EDSDK.EdsGetLength( streamRef.getValue(), length ) ); if ( err != EdsError.EDS_ERR_OK ) {
E01_Simple.check( result ); final NativeLongByReference outRef = new NativeLongByReference(); result = CanonCamera.EDSDK.EdsGetChildCount( list.getValue(), outRef ).intValue(); E01_Simple.check( result );
NativeLongByReference value = new NativeLongByReference(); result = lib.wdGetNumberScriptResult(scriptResult, value); errors.verifyErrorCode(result, "Cannot extract number result");