Examples of DoubleDimension


Examples of org.tinyuml.draw.DoubleDimension

  /**
   * Tests the methods.
   */
  public void testMethods() {
    DoubleDimension dim = new DoubleDimension();
    assertEquals(0.0, dim.getWidth());
    assertEquals(0.0, dim.getHeight());
   
    dim.setSize(1.0, 2.3);
    assertEquals(1.0, dim.getWidth());
    assertEquals(2.3, dim.getHeight());
   
    DoubleDimension dim2 = new DoubleDimension(3.1, 5.2);
    assertEquals(3.1, dim2.getWidth());
    assertEquals(5.2, dim2.getHeight());
    assertEquals("DoubleDimension[3.1, 5.2]", dim2.toString());
  }
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

 
  /**
   * Tests the equals and hashCode methods.
   */
  public void testEquals() {
    DoubleDimension dim1 = new DoubleDimension(3.2, 5.3);
    DoubleDimension dim2 = new DoubleDimension(3.2, 5.3);
    DoubleDimension dim3 = new DoubleDimension(51.2, 15.3);
    assertFalse(dim1.equals(null));
    assertTrue(dim1.equals(dim1));
    assertTrue(dim1.equals(dim2));
    assertTrue(dim2.equals(dim1));
    assertFalse(dim1.equals(dim3));
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

 
  /**
   * Tests the centerHorizontally() method.
   */
  public void testCenterHorizontally() {
    Dimension2D size = new DoubleDimension(100, 30);
    label.setSize(40, 10);
    label.setOrigin(0, 12);
    mockParent.expects(once()).method("getSize").will(returnValue(size));
    label.centerHorizontally();
    assertEquals(12.0, label.getOrigin().getY());
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

   */
  public void testCreateRect2d() {

    // Create Rectangle 1
    Point2D p0 = new Point2D.Double(1.0, 3.0);
    Dimension2D size = new DoubleDimension(4, 5);

    Rectangle2D rect = factory.createRect2d(p0, size);
    assertEquals(1.0, rect.getX());
    assertEquals(3.0, rect.getY());
    assertEquals(4.0, rect.getWidth());
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

   */
  protected void setUp() {
    mockNode.expects(atLeastOnce()).method("getAbsoluteX").will(returnValue(x));
    mockNode.expects(atLeastOnce()).method("getAbsoluteY").will(returnValue(y));
    mockNode.expects(atLeastOnce()).method("getSize").
      will(returnValue(new DoubleDimension(width, height)));
    selection.setElement(node);   
  }
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

   */
  public void testCreateRect2d() {

    // Create Rectangle 1
    Point2D p0 = new Point2D.Double(1.0, 3.0);
    Dimension2D size = new DoubleDimension(4, 5);

    Rectangle2D rect = factory.createRect2d(p0, size);
    assertEquals(1.0, rect.getX());
    assertEquals(3.0, rect.getY());
    assertEquals(4.0, rect.getWidth());
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

    mockNode.expects(atLeastOnce()).method("getAbsoluteX1")
      .will(returnValue(x));
    mockNode.expects(atLeastOnce()).method("getAbsoluteY1")
      .will(returnValue(y));
    mockNode.expects(atLeastOnce()).method("getSize")
      .will(returnValue(new DoubleDimension(width, height)));
    selection.setElement(node);   
  }
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

  // *****************************************
  /**
   * Simulates a dragging operation for resizing.
   */
  public void testDragResizeSe() {
    Dimension2D minimumSize = new DoubleDimension(10, 10);
    // start dragging somewhere in the SE handle (322+, 425+)
    selection.startDragging(324.0, 427.0);
    assertTrue(selection.isDragging());
    // make it a little bigger
    mockNode.expects(atLeastOnce()).method("getMinimumSize").
      will(returnValue(minimumSize));
    selection.updatePosition(330.0, 450.0);
    // and draw it
    Mock mockDrawingContext = mock(DrawingContext.class);
    // don't forget that sizes are truncated to the local system'
    Constraint[] params = {eq(2.0), eq(5.0), eq(326.0), eq(443.0), NULL};
    mockDrawingContext.expects(once()).method("drawRectangle").
      with(params);
    selection.draw((DrawingContext) mockDrawingContext.proxy());
    // stop dragging
    mockOperations.expects(once()).method("resizeElement").
      with(eq(selection.getElement()), eq(new Point2D.Double(2.0, 5.0)),
           eq(new DoubleDimension(326.0, 443.0)));
    selection.stopDragging(330.0, 450.0);
    assertFalse(selection.isDragging());
  }
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

  /**
   * Simulates a dragging operation for resizing with truncation.
   */
  public void testDragResizeSeWithTruncation() {
    // At SE resize, the position is < 22 and 25
    Dimension2D minimumSize = new DoubleDimension(20, 20);
    // start dragging somewhere in the SE handle (322+, 425+)
    selection.startDragging(324.0, 427.0);
    assertTrue(selection.isDragging());
    // make it a little smaller
    mockNode.expects(atLeastOnce()).method("getMinimumSize").
View Full Code Here

Examples of org.tinyuml.draw.DoubleDimension

  /**
   * Simulates a dragging operation for resizing on the NW corner.
   */
  public void testDragResizeNw() {
    Point2D origin = new Point2D.Double(0, 0);
    Dimension2D minimumSize = new DoubleDimension(20, 20);
    // start dragging somewhere in the NW handle (2-, 5-)
    selection.startDragging(1, 3);
    assertTrue(selection.isDragging());
    // make it a little bigger
    mockNode.expects(atLeastOnce()).method("getMinimumSize").
      will(returnValue(minimumSize));
    selection.updatePosition(-10.0, -10.0);
    // and draw it
    Mock mockDrawingContext = mock(DrawingContext.class);
    // don't forget that sizes are truncated to the local system'
    Constraint[] params = {eq(-9.0), eq(-8.0), eq(331.0), eq(433.0), NULL};
    mockDrawingContext.expects(once()).method("drawRectangle").
      with(params);
    selection.draw((DrawingContext) mockDrawingContext.proxy());
    // stop dragging
    mockOperations.expects(once()).method("resizeElement").
      with(eq(selection.getElement()), eq(new Point2D.Double(-9.0, -8.0)),
           eq(new DoubleDimension(331.0, 433.0)));
    selection.stopDragging(-10.0, -10.0);
    assertFalse(selection.isDragging());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.