当前位置: 首页>>代码示例>>Java>>正文


Java Point类代码示例

本文整理汇总了Java中com.musala.atmosphere.commons.geometry.Point的典型用法代码示例。如果您正苦于以下问题:Java Point类的具体用法?Java Point怎么用?Java Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Point类属于com.musala.atmosphere.commons.geometry包,在下文中一共展示了Point类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-service,代码行数:25,代码来源:LocationPointerService.java

示例2: parse

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
/**
 * Converts a UI element bounds in the format <b>[startX,startY][endX,endY]</b> (fetched from the UI XML file) to a
 * Pair&lt;Point, Point;&gt; format.
 * 
 * @param bounds
 *        String containing UiElement bounds to be parsed.
 * @return Bounds pair containing the UiElement bounds.
 */
public static Bounds parse(String bounds) {
    final String BOUNDS_STRING_PATTERN = "\\[(-*\\d+),(-*\\d+)\\]\\[(-*\\d+),(-*\\d+)\\]";
    final Pattern BOUNDS_PATTERN = Pattern.compile(BOUNDS_STRING_PATTERN);
    final Matcher BOUNDS_MATCHER = BOUNDS_PATTERN.matcher(bounds);

    if (BOUNDS_MATCHER.find()) {
        int firstPointX = Integer.parseInt(BOUNDS_MATCHER.group(1));
        int firstPointY = Integer.parseInt(BOUNDS_MATCHER.group(2));
        Point first = new Point(firstPointX, firstPointY);

        int secondPointX = Integer.parseInt(BOUNDS_MATCHER.group(3));
        int secondPointY = Integer.parseInt(BOUNDS_MATCHER.group(4));
        Point second = new Point(secondPointX, secondPointY);

        Bounds result = new Bounds(first, second);
        return result;
    } else {
        String message = String.format("' %s ' is not in the required bounds format.", bounds);
        LOGGER.error(message);
        throw new IllegalArgumentException(message);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-commons,代码行数:31,代码来源:UiElementBoundsParser.java

示例3: listOfAccessibilityElementsDeserializerTest

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void listOfAccessibilityElementsDeserializerTest() {
    AccessibilityElement firstElement = new AccessibilityElement();
    AccessibilityElement secondElement = new AccessibilityElement();
    AccessibilityElement thirdElement = new AccessibilityElement();

    firstElement.setPath(TestConst.TEST_PATH);
    secondElement.setEnabled(true);
    thirdElement.setBounds(new Bounds(new Point(0, 0), new Point(4, 4)));

    List<AccessibilityElement> list = Arrays.asList(firstElement, secondElement, thirdElement);

    List<AccessibilityElement> deserializedResponseData = (List<AccessibilityElement>) getExpectedResponseData(RoutingAction.GET_UI_ELEMENTS,
                                                                                                               list);

    AccessibilityElement actualFirstElement = deserializedResponseData.get(0);
    AccessibilityElement actualSecondElement = deserializedResponseData.get(1);
    AccessibilityElement actualThirdElement = deserializedResponseData.get(2);

    Assert.assertEquals(TestConst.TEST_PATH, actualFirstElement.getPath());
    Assert.assertEquals(3, deserializedResponseData.size());
    Assert.assertTrue(actualSecondElement.isEnabled());
    Assert.assertEquals(2, actualThirdElement.getBounds().getCenter().getX());
    Assert.assertEquals(2, actualThirdElement.getBounds().getCenter().getY());
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-commons,代码行数:26,代码来源:CollectionsDeserialziationTest.java

示例4: testDragToPoint

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testDragToPoint() throws Exception {
    Screen deviceScreen = testDevice.getActiveScreen();

    UiElementSelector imageElementSelector = new UiElementSelector();
    imageElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, IMAGE_ELEMENT_ID);
    UiElement imageElement = deviceScreen.getElement(imageElementSelector);

    UiElementSelector textElementSelector = new UiElementSelector();
    textElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, TEXT_ELEMENT_ID);
    UiElement texElement = deviceScreen.getElement(textElementSelector);

    Point destinationPoint = texElement.getProperties().getBounds().getCenter();
    imageElement.drag(destinationPoint);

    deviceScreen.updateScreen();
    imageElement = deviceScreen.getElement(imageElementSelector);
    Point actualPoint = imageElement.getProperties().getBounds().getCenter();
    assertEquals(MESSAGE_TEST_FAIL, destinationPoint, actualPoint);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:21,代码来源:DragTest.java

示例5: testDragToUiElement

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testDragToUiElement() throws Exception {
    Screen deviceScreen = testDevice.getActiveScreen();

    UiElementSelector imageElementSelector = new UiElementSelector();
    imageElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, IMAGE_ELEMENT_ID);
    UiElement imageElement = deviceScreen.getElement(imageElementSelector);

    UiElementSelector textElementSelector = new UiElementSelector();
    textElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, TEXT_ELEMENT_ID);
    UiElement textElement = deviceScreen.getElement(textElementSelector);

    imageElement.drag(textElement);

    deviceScreen.updateScreen();

    imageElement = deviceScreen.getElement(imageElementSelector);
    textElement = deviceScreen.getElement(textElementSelector);

    Point expectedPoint = textElement.getProperties().getBounds().getCenter();
    Point actualPoint = imageElement.getProperties().getBounds().getCenter();

    assertEquals(MESSAGE_TEST_FAIL, expectedPoint, actualPoint);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:25,代码来源:DragTest.java

示例6: testDragToUiElementSelector

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testDragToUiElementSelector() throws Exception {
    Screen deviceScreen = testDevice.getActiveScreen();

    UiElementSelector imageElementSelector = new UiElementSelector();
    imageElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, IMAGE_ELEMENT_ID);
    UiElement imageElement = deviceScreen.getElement(imageElementSelector);

    UiElementSelector textElementSelector = new UiElementSelector();
    textElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, TEXT_ELEMENT_ID);
    UiElement texElement = deviceScreen.getElement(textElementSelector);

    imageElement.drag(textElementSelector);

    imageElement = deviceScreen.getElement(imageElementSelector);
    texElement = deviceScreen.getElement(textElementSelector);

    Point expectedPoint = texElement.getProperties().getBounds().getCenter();
    Point actualPoint = imageElement.getProperties().getBounds().getCenter();

    assertEquals(MESSAGE_TEST_FAIL, expectedPoint, actualPoint);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:23,代码来源:DragTest.java

示例7: testDragToElementToText

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testDragToElementToText() throws Exception {
    Screen deviceScreen = testDevice.getActiveScreen();

    UiElementSelector imageElementSelector = new UiElementSelector();
    imageElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, IMAGE_ELEMENT_ID);
    UiElement imageElement = deviceScreen.getElement(imageElementSelector);

    UiElementSelector textElementSelector = new UiElementSelector();
    textElementSelector.addSelectionAttribute(CssAttribute.RESOURCE_ID, TEXT_ELEMENT_ID);
    UiElement textElement = deviceScreen.getElement(textElementSelector);

    imageElement.drag("Drag Test");

    deviceScreen.updateScreen();
    imageElement = deviceScreen.getElement(imageElementSelector);

    Point expectedPoint = textElement.getProperties().getBounds().getCenter();
    Point actualPoint = imageElement.getProperties().getBounds().getCenter();
    assertEquals(MESSAGE_TEST_FAIL, expectedPoint, actualPoint);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:22,代码来源:DragTest.java

示例8: testDeviceDoubleTap

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testDeviceDoubleTap() throws Exception {
    UiElement doubleTapValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());

    // getting the point at the center of the element
    doubleTapValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());
    UiElementPropertiesContainer doubleTapValidatorProperties = doubleTapValidator.getProperties();
    Bounds elementBounds = doubleTapValidatorProperties.getBounds();
    Point centerPoint = elementBounds.getCenter();

    boolean tapResult = testDevice.doubleTap(centerPoint);

    // assert that the method indicates success
    assertTrue("Double tapping UI element returned false.", tapResult);

    // assert that UI element has received a double tap gesture
    doubleTapValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());
    assertDoubleTapped("The element did not recieve a double tap gesture.");
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:20,代码来源:DoubleTapTest.java

示例9: testRelativeDoubleTap

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testRelativeDoubleTap() throws Exception {
    UiElement doubleTapValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());

    // the tap point is relative to the element's coordinates
    doubleTapValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());
    Point tapPoint = new Point(0, 0);
    boolean tapResult = doubleTapValidator.doubleTap(tapPoint);

    // assert that the method indicated success
    assertTrue("Double tapping UI element returned false.", tapResult);

    // assert that UI element has received a double tap gesture
    doubleTapValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());
    assertDoubleTapped("The element did not recieve a double tap gesture.");
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:17,代码来源:DoubleTapTest.java

示例10: testRelativeTap

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testRelativeTap() throws Exception {
    UiElement imeRelativeLayout = getElementByContentDescriptor(IME_RELATIVE_LAYOUT_CONTENT_DESCRIPTOR);
    UiElementPropertiesContainer imeRelativeLayoutProperties = imeRelativeLayout.getProperties();

    UiElement emptyTextBox = getElementByContentDescriptor(ContentDescriptor.EMPTY_TEXT_BOX.toString());
    UiElementPropertiesContainer emptyTextBoxProperties = emptyTextBox.getProperties();

    Bounds emptyTextBoxBoundsAttributeValue = emptyTextBoxProperties.getBounds();
    Point emptyTextBoxUpperLeftCorner = emptyTextBoxBoundsAttributeValue.getUpperLeftCorner();

    Bounds imeRelativeLayoutBoundsAttributeValue = imeRelativeLayoutProperties.getBounds();
    Point imeRelativeLayoutUpperLeftCorner = imeRelativeLayoutBoundsAttributeValue.getRelativePoint(emptyTextBoxUpperLeftCorner);

    assertTrue(TAPPING_SCREEN_FAILED_MESSAGE, imeRelativeLayout.tap(imeRelativeLayoutUpperLeftCorner));

    Thread.sleep(TIMEOUT);

    assertInputTextBoxIsFocused(FOCUSING_ELEMENT_FAILED_MESSAGE);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:21,代码来源:TapTest.java

示例11: testSetScreenOffTimeoutOnRealDevice

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testSetScreenOffTimeoutOnRealDevice() throws Exception {
    DeviceSelectorBuilder selectorBuilder = new DeviceSelectorBuilder().deviceType(DeviceType.DEVICE_ONLY);
    DeviceSelector testDeviceSelector = selectorBuilder.build();

    try {
        initTestDevice(testDeviceSelector);
    } catch (NoAvailableDeviceFoundException e) {
    }

    assumeNotNull(testDevice);
    setTestDevice(testDevice);
    startMainActivity();

    defaultTimeOut = testDevice.getScreenOffTimeout();

    testDevice.setScreenOffTimeout(SCREEN_OFF_TIMEOUT);
    testDevice.tapScreenLocation(new Point(2, 3));
    assertTrue("Device is not awake.", testDevice.isAwake());

    assertEquals("Expected screen of timeout does not match.", testDevice.getScreenOffTimeout(), SCREEN_OFF_TIMEOUT);

    Thread.sleep(SCREEN_OFF_TIMEOUT + TIME_TO_WAIT);
    assertFalse("Device is awake.", testDevice.isAwake());
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:26,代码来源:ScreenOffTimeoutTest.java

示例12: testDeviceSwipe

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testDeviceSwipe() throws Exception {
    UiElement swipeValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());
    UiElementPropertiesContainer swipeValidatorProperties = swipeValidator.getProperties();
    Bounds elementBounds = swipeValidatorProperties.getBounds();
    Point centerPoint = elementBounds.getCenter();

    SwipeDirection directionDown = SwipeDirection.UP;

    boolean swipeResult = testDevice.swipe(centerPoint, directionDown);

    // assert that the method indicates success
    assertTrue("Swipping returned false.", swipeResult);

    assertSwipedUp("The element did not recieve a swipe gesture.");
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:17,代码来源:SwipeTest.java

示例13: testDevicePinchIn

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testDevicePinchIn() throws Exception {
    UiElement gestureValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());

    // getting the point at the center of the element
    gestureValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());
    UiElementPropertiesContainer gestureValidatorProperties = gestureValidator.getProperties();

    Bounds elementBounds = gestureValidatorProperties.getBounds();
    Point firstFingerInitial = elementBounds.getUpperLeftCorner();
    Point secondFingerInitial = elementBounds.getLowerRightCorner();

    boolean pinchInResult = testDevice.pinchIn(firstFingerInitial, secondFingerInitial);

    // assert that the method indicates success
    assertTrue("Pinching in UiElement returned false.", pinchInResult);

    // assert that UI element has received a pinch in gesture
    assertPinchedIn("The element did not recieve a pinch in gesture.");
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:21,代码来源:PinchTest.java

示例14: testDevicePinchOut

import com.musala.atmosphere.commons.geometry.Point; //导入依赖的package包/类
@Test
public void testDevicePinchOut() throws Exception {
    UiElement gestureValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());

    // getting the point at the center of the element
    gestureValidator = getElementByContentDescriptor(ContentDescriptor.GESTURE_VALIDATOR.toString());
    UiElementPropertiesContainer gestureValidatorProperties = gestureValidator.getProperties();

    Bounds elementBounds = gestureValidatorProperties.getBounds();
    Point firstFingerEnd = elementBounds.getUpperLeftCorner();
    Point secondFingerEnd = elementBounds.getLowerRightCorner();

    boolean pinchOutResult = testDevice.pinchOut(firstFingerEnd, secondFingerEnd);

    // assert that the method indicates success
    assertTrue("Pinching out UiElement returned false.", pinchOutResult);

    // assert that UI element has received a pinch out gesture
    assertPinchedOut("The element did not recieve a pinch out gesture.");
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:21,代码来源:PinchTest.java

示例15: 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);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-integration-tests,代码行数:18,代码来源:LongPressTest.java


注:本文中的com.musala.atmosphere.commons.geometry.Point类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。