Package org.tinyuml.draw

Examples of org.tinyuml.draw.DoubleDimension


   * Tests the draw() method.
   */
  public void testDraw() {
    setAddLabelExpectations();
    compartment.addLabel((Label) mockLabel.proxy());
    Dimension2D parentSize = new DoubleDimension(10, 4);
    setRecalculateSizeWithOneLabelExpectations(parentSize);
    Constraint[] rectParams = { eq(0.0), eq(0.0), eq(90.0), eq(22.0),
      eq(Color.WHITE) };
    mockParent.expects(once()).method("getAbsoluteX1").will(returnValue(0.0));
    mockParent.expects(once()).method("getAbsoluteY1").will(returnValue(0.0));
View Full Code Here


   */
  public void testDrawLeftAligned() {
    setAddLabelExpectations();
    compartment.setAlignment(Alignment.LEFT);
    compartment.addLabel((Label) mockLabel.proxy());
    Dimension2D parentSize = new DoubleDimension(10, 4);
    setRecalculateSizeWithOneLabelExpectations(parentSize);
    Constraint[] rectParams = { eq(0.0), eq(0.0), eq(90.0), eq(22.0),
      eq(Color.WHITE) };
    mockParent.expects(once()).method("getAbsoluteX1").will(returnValue(0.0));
    mockParent.expects(once()).method("getAbsoluteY1").will(returnValue(0.0));
View Full Code Here

  /**
   * 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

 
  /**
   * 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

    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)));
    mockNode.expects(once()).method("addNodeChangeListener");
    selection = new NodeSelection((DiagramOperations) mockOperations.proxy(),
      (Node) mockNode.proxy());
  }
View Full Code Here

  // *****************************************
  /**
   * 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

  /**
   * 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

  /**
   * 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

  /**
   * Simulates a dragging operation for resizing with truncation, NW corner.
   */
  public void testDragResizeNwWithTruncation() {
    // At NW resize, the position is > (322 - 20) and (425 - 20)
    Dimension2D minimumSize = new DoubleDimension(20, 20);
    // start dragging somewhere in the NW handle (2-, 5-)
    selection.startDragging(1.0, 3.0);
    assertTrue(selection.isDragging());
    // make it a little smaller, dragging it to the lower right
    mockNode.expects(atLeastOnce()).method("getMinimumSize").
View Full Code Here

  /**
   * Simulates a dragging operation for resizing on the NE corner.
   */
  public void testDragResizeNe() {
    Point2D origin = new Point2D.Double(0, 0);
    Dimension2D minimumSize = new DoubleDimension(20, 20);
    // start dragging somewhere in the NW handle (322+, 5-)
    selection.startDragging(324, 3);
    assertTrue(selection.isDragging());
    // make it a little bigger
    mockNode.expects(atLeastOnce()).method("getMinimumSize").
      will(returnValue(minimumSize));
    selection.updatePosition(340.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(2.0), eq(-8.0), eq(336.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(2.0, -8.0)),
           eq(new DoubleDimension(336.0, 433.0)));
    selection.stopDragging(340.0, -10.0);
    assertFalse(selection.isDragging());
  }
View Full Code Here

TOP

Related Classes of org.tinyuml.draw.DoubleDimension

Copyright © 2018 www.massapicom. 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.