本文整理汇总了Java中com.musala.atmosphere.commons.geometry.Point.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Point.getX方法的具体用法?Java Point.getX怎么用?Java Point.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.musala.atmosphere.commons.geometry.Point
的用法示例。
在下文中一共展示了Point.getX方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStartCommand
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Point touchLocation = (Point) intent.getSerializableExtra(LocationPointerConstants.CENTER_POINT_INTENT_NAME.getValue());
WindowManager.LayoutParams params = new WindowManager.LayoutParams(densityIndependentPixelToPixel(LOCATION_POINTER_DIAMETER),
densityIndependentPixelToPixel(LOCATION_POINTER_DIAMETER),
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP | Gravity.LEFT;
params.x = touchLocation.getX() - densityIndependentPixelToPixel(LOCATION_POINTER_RADIUS);
params.y = (touchLocation.getY() - densityIndependentPixelToPixel(LOCATION_POINTER_RADIUS))
- getStatusBarHeight();
ShowPointerTask locationPointerTask;
locationPointerTask = new ShowPointerTask(params);
locationPointerTask.execute(params);
return START_NOT_STICKY;
}
示例2: testFailedLongPress
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testFailedLongPress() throws Exception {
UiElement longPressTextField = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());
// make sure to click outside the element
final Bounds elementBounds = longPressTextField.getProperties().getBounds();
Point lowerRightCorner = elementBounds.getLowerRightCorner();
final int x = lowerRightCorner.getX();
final int y = lowerRightCorner.getY();
final int offset = 1;
Point outerPoint = new Point(x + offset, y + offset);
// long press
boolean longPressResult = longPressTextField.longPress(outerPoint, LONG_PRESS_TIMEOUT);
assertFalse("Text box for gesture verification was long pressed.", longPressResult);
}
示例3: tapScreenLocation
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
/**
* Executes a simple tap on the screen of this device at a specified location point.
*
* @param tapPoint
* - {@link Point Point} on the screen to tap on
*
* @return <code>true</code> if tapping screen is successful, <code>false</code> if it fails
*/
public boolean tapScreenLocation(Point tapPoint) {
boolean isTapSuccessful = true;
int tapPointX = tapPoint.getX();
int tapPointY = tapPoint.getY();
String query = "input tap " + tapPointX + " " + tapPointY;
showTapLocation(tapPoint);
try {
shellCommandExecutor.execute(query);
} catch (CommandFailedException e) {
isTapSuccessful = false;
}
return isTapSuccessful;
}
示例4: validatePointOnScreen
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
/**
* Checks whether the given point is inside the bounds of the screen, and throws an {@link IllegalArgumentException}
* otherwise.
*
* @param point
* - the point to be checked
*/
private void validatePointOnScreen(Point point) {
Pair<Integer, Integer> resolution = deviceInformation.getResolution();
boolean hasPositiveCoordinates = point.getX() >= 0 && point.getY() >= 0;
boolean isOnScreen = point.getX() <= resolution.getKey() && point.getY() <= resolution.getValue();
if (!hasPositiveCoordinates || !isOnScreen) {
String exeptionMessageFormat = "The passed point with coordinates (%d, %d) is outside the bounds of the screen. Screen dimentions (%d, %d)";
String message = String.format(exeptionMessageFormat,
point.getX(),
point.getY(),
resolution.getKey(),
resolution.getValue());
LOGGER.error(message);
throw new IllegalArgumentException(message);
}
}
示例5: createPinchIn
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
/**
* Creates a pinch in {@link Gesture}.
*
* @param firstFingerInitial
* - the initial position of the first finger performing the gesture
* @param secondFingerInitial
* - the initial position of the second finger performing the gesture
* @return a {@link Gesture} that represents pinch in on a device.
*/
public static Gesture createPinchIn(Point firstFingerInitial, Point secondFingerInitial) {
// calculating the point where the two fingers will meet
int toX = (firstFingerInitial.getX() + secondFingerInitial.getX()) / 2;
int toY = (firstFingerInitial.getY() + secondFingerInitial.getY()) / 2;
Point to = new Point(toX, toY);
Timeline firstFingerMovement = createScrollMovement(firstFingerInitial, to, PINCH_DURATION);
Timeline secondFingerMovement = createScrollMovement(secondFingerInitial, to, PINCH_DURATION);
Gesture pinchIn = new Gesture();
pinchIn.add(firstFingerMovement);
pinchIn.add(secondFingerMovement);
return pinchIn;
}
示例6: createPinchOut
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
/**
* Creates a pinch out {@link Gesture}.
*
* @param firstFingerEnd
* - the point where the first finger will be at the end of the pinch
* @param secondFingerEnd
* - the point where the second finger will be at the end of the pinch
* @return a {@link Gesture} that represents pinch out on a device.
*/
public static Gesture createPinchOut(Point firstFingerEnd, Point secondFingerEnd) {
// calculating the start point of the gesture
int fromX = (firstFingerEnd.getX() + secondFingerEnd.getX()) / 2;
int fromY = (firstFingerEnd.getY() + secondFingerEnd.getY()) / 2;
Point from = new Point(fromX, fromY);
Timeline firstFingerMovement = createScrollMovement(from, firstFingerEnd, PINCH_DURATION);
Timeline secondFingerMovement = createScrollMovement(from, secondFingerEnd, PINCH_DURATION);
Gesture pinchOut = new Gesture();
pinchOut.add(firstFingerMovement);
pinchOut.add(secondFingerMovement);
return pinchOut;
}
示例7: pinchIn
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
/**
* Simulates a pinch in on the element. NOTE emulator devices may not detect pinch gestures on UI elements with size
* smaller than 100x100dp.
*
* @return <code>true</code> if the pinch in is successful, <code>false</code> if it fails
* @throws StaleElementReferenceException
* if the element has become stale before executing this method
*/
public boolean pinchIn() {
revalidateThrowing();
Bounds elementBounds = propertiesContainer.getBounds();
final int BOUNDS_OFFSET_DENOMINATOR = 10;
final int WIDTH_OFFSET = elementBounds.getWidth() / BOUNDS_OFFSET_DENOMINATOR;
final int HEIGHT_OFFSET = elementBounds.getHeight() / BOUNDS_OFFSET_DENOMINATOR;
// starting the pinch at a distance from the exact bounds of the element so that it will not affect other UI
// elements
Point lowerRight = elementBounds.getLowerRightCorner();
int firstFingerInitialX = lowerRight.getX() - WIDTH_OFFSET;
int firstFingerInitialY = lowerRight.getY() - HEIGHT_OFFSET;
Point firstFingerInitial = new Point(firstFingerInitialX, firstFingerInitialY);
Point upperLeft = elementBounds.getUpperLeftCorner();
int secondFingerInitialX = upperLeft.getX() + WIDTH_OFFSET;
int secondFingerInitialY = upperLeft.getY() + HEIGHT_OFFSET;
Point secondFingerInitial = new Point(secondFingerInitialX, secondFingerInitialY);
boolean result = (boolean) communicator.sendAction(RoutingAction.GESTURE_PINCH_IN, firstFingerInitial, secondFingerInitial);
return result;
}
示例8: createCircle
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
/**
* Constructs a {@link Timeline} that, when drawn, results in a circular trajectory.
*
* @param center
* - the coordinates of the circle origin (as a {@link Point})
* @param radius
* - radius of the circle
* @param startTime
* - the moment in time at which the first {@link Anchor} should be reached
* @param totalDuration
* - the total duration of the resulting generated gesture (in milliseconds)
* @param inSteps
* - amount of {@link Anchor} instances that the generated {@link Timeline} should contain
* @return the resulting populated {@link Timeline} instance
*/
public static Timeline createCircle(Point center, float radius, int startTime, int totalDuration, int inSteps) {
final float FULL_RADIANS = (float) (Math.PI * 2.0f);
Timeline result = new Timeline();
final float STEP_ANGLE_RAD = FULL_RADIANS / inSteps;
final float INSURANCE_ANGLE = 0.2f;
for (float rotRad = 0; rotRad < INSURANCE_ANGLE + FULL_RADIANS; rotRad += STEP_ANGLE_RAD) {
int x = (int) (center.getX() + Math.cos(rotRad) * radius);
int y = (int) (center.getY() + Math.sin(rotRad) * radius);
int timeProgress = (int) (totalDuration * (rotRad / FULL_RADIANS));
Anchor point = new Anchor(x, y, startTime + timeProgress);
result.add(point);
}
return result;
}
示例9: createSwipe
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
/**
* Creates a swipe gesture {@link Gesture} from passed point in passed direction.
*
* @param startPoint
* - the start point of the swipe
* @param swipeDirection
* - the direction of the swipe
* @param resolution
* - this is a pair which present the resolution of the screen
* @return a {@link Gesture} that represents swipe on a device.
*/
public static Gesture createSwipe(Point startPoint, SwipeDirection swipeDirection, Pair<Integer, Integer> resolution) {
int endX = startPoint.getX();
int endY = startPoint.getY();
switch (swipeDirection) {
case UP:
endY = Math.max(endY - SWIPE_DISTANCE, 0);
break;
case DOWN:
endY = Math.min(endY + SWIPE_DISTANCE, resolution.getValue());
break;
case LEFT:
endX = Math.max(endX - SWIPE_DISTANCE, 0);
break;
case RIGHT:
endX = Math.min(endX + SWIPE_DISTANCE, resolution.getKey());
break;
}
Point endPoint = new Point(endX, endY);
Timeline swipeTimeline = createScrollMovement(startPoint, endPoint, SWIPE_INTERVAL);
Gesture swipe = new Gesture();
swipe.add(swipeTimeline);
return swipe;
}
示例10: match
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
@Override
public boolean match(UiElementPropertiesContainer propertiesContainer, AccessibilityNodeInfo nodeInformation) {
// TODO Improve the logic for matching components
Rect accessibilityNodeBounds = new Rect();
nodeInformation.getBoundsInScreen(accessibilityNodeBounds);
Bounds propertiesContainerBounds = propertiesContainer.getBounds();
if (propertiesContainer.getBounds() != null) {
Point selectorBoundsUpperCorner = propertiesContainerBounds.getUpperLeftCorner();
if ((accessibilityNodeBounds.height() != propertiesContainerBounds.getHeight())
|| (accessibilityNodeBounds.width() != propertiesContainerBounds.getWidth())
|| (selectorBoundsUpperCorner.getX() != accessibilityNodeBounds.left)
|| (selectorBoundsUpperCorner.getY() != accessibilityNodeBounds.top)) {
return false;
}
}
if (propertiesContainer.getClassName() != null && nodeInformation.getClassName() != null
&& !propertiesContainer.getClassName().equals(nodeInformation.getClassName().toString())) {
return false;
}
if (propertiesContainer.getPackageName() != null && nodeInformation.getPackageName() != null
&& !propertiesContainer.getPackageName().equals(nodeInformation.getPackageName().toString())) {
return false;
}
String nodeContentDescription = nodeInformation.getContentDescription() != null
? nodeInformation.getContentDescription().toString() : null;
if (propertiesContainer.getContentDescriptor() != null
&& !propertiesContainer.getContentDescriptor().equals(nodeContentDescription)) {
return false;
}
String nodeText = nodeInformation.getText() != null ? nodeInformation.getText().toString() : null;
if (propertiesContainer.getText() != null && !propertiesContainer.getText().equals(nodeText)) {
return false;
}
return propertiesContainer.isCheckable() == nodeInformation.isCheckable()
&& propertiesContainer.isChecked() == nodeInformation.isChecked()
&& propertiesContainer.isClickable() == nodeInformation.isClickable()
&& propertiesContainer.isEnabled() == nodeInformation.isEnabled()
&& propertiesContainer.isFocusable() == nodeInformation.isFocusable()
&& propertiesContainer.isFocused() == nodeInformation.isFocused()
&& propertiesContainer.isLongClickable() == nodeInformation.isLongClickable()
&& propertiesContainer.isPassword() == nodeInformation.isPassword()
&& propertiesContainer.isScrollable() == nodeInformation.isScrollable()
&& propertiesContainer.isSelected() == nodeInformation.isSelected();
}
开发者ID:MusalaSoft,项目名称:atmosphere-commons,代码行数:52,代码来源:UiElementPropertiesContainerMatcherCompat.java
示例11: createScrollMovement
import com.musala.atmosphere.commons.geometry.Point; //导入方法依赖的package包/类
/**
* Defines a {@link Timeline} for a scroll between two points with a given duration.
*
* @param from
* - the initial point of the motion
* @param to
* - the end point of the motion
* @param duration
* - the duration of the scroll motion in milliseconds
* @return a {@link Timeline} representing a scroll motion on a device.
*/
private static Timeline createScrollMovement(Point from, Point to, int duration) {
Timeline scroll = new Timeline();
Anchor startPoint = new Anchor(from.getX(), from.getY(), 0);
scroll.add(startPoint);
Anchor endPoint = new Anchor(to.getX(), to.getY(), duration);
scroll.add(endPoint);
return scroll;
}