Package org.tinyuml.umldraw.shared

Examples of org.tinyuml.umldraw.shared.NoteElement


  /**
   * Tests the clone() method.
   */
  public void testClone() {
    Mock mockParent1 = mock(CompositeNode.class);
    NoteElement note = NoteElement.getPrototype();
    assertNull(note.getParent());
    assertNull(note.getModelElement());
    note.setOrigin(0, 0);
    note.setSize(100, 80);
    note.setLabelText("oldlabel");
    note.setParent((CompositeNode) mockParent1.proxy());
   
    NoteElement cloned = (NoteElement) note.clone();
    assertTrue(note != cloned);
    assertEquals(note.getParent(), cloned.getParent());
    assertEquals("oldlabel", cloned.getLabelText());
    note.setLabelText("mylabel");
    assertFalse(cloned.getLabelText() == note.getLabelText());
   
    // now test the label
    mockParent1.expects(atLeastOnce()).method("getAbsoluteX1")
      .will(returnValue(0.0));
    mockParent1.expects(atLeastOnce()).method("getAbsoluteY1")
      .will(returnValue(0.0));
    assertNotNull(cloned.getLabelAt(20, 20));
    assertNull(cloned.getLabelAt(-1.0, -2.0));
    assertTrue(cloned.getLabelAt(20.0, 20.0) != note.getLabelAt(20.0, 20.0));
    assertTrue(cloned.getLabelAt(20.0, 20.0).getSource() == cloned);
    assertTrue(cloned.getLabelAt(20.0, 20.0).getParent() == cloned);
  }
View Full Code Here


 
  /**
   * Tests the acceptsConnection() method.
   */
  public void testAcceptsConnection() {
    NoteElement note = NoteElement.getPrototype();
    ClassElement anyumlnode = ClassElement.getPrototype();
    assertTrue(note.acceptsConnection(RelationType.NOTE_CONNECTOR,
      RelationEndType.UNSPECIFIED, anyumlnode));
    assertTrue(note.acceptsConnection(RelationType.NOTE_CONNECTOR,
      RelationEndType.SOURCE, anyumlnode));
    assertTrue(note.acceptsConnection(RelationType.NOTE_CONNECTOR,
      RelationEndType.TARGET, anyumlnode));
    assertFalse(note.acceptsConnection(RelationType.DEPENDENCY,
      RelationEndType.UNSPECIFIED, anyumlnode));
  }
View Full Code Here

  /**
   * Tests the creation of a note connection.
   */
  public void testCreateNoteConnection() {
    ClassElement clss = (ClassElement) factory.createNode(ElementType.CLASS);
    NoteElement note = (NoteElement) factory.createNode(ElementType.NOTE);
    NoteConnection conn = (NoteConnection)
      factory.createConnection(RelationType.NOTE_CONNECTOR, clss, note);
    assertStdConnectionConditions(conn, clss, note);
    assertNull(conn.getModelElement());
  }
View Full Code Here

  /**
   * Tests the clone() method.
   */
  public void testClone() {
    Mock mockParent1 = mock(CompositeNode.class);
    NoteElement note = NoteElement.getPrototype();
    assertNull(note.getParent());
    assertNull(note.getModelElement());
    note.setOrigin(0, 0);
    note.setSize(100, 80);
    note.setLabelText("oldlabel");
    note.setParent((CompositeNode) mockParent1.proxy());
   
    NoteElement cloned = (NoteElement) note.clone();
    assertTrue(note != cloned);
    assertEquals(note.getParent(), cloned.getParent());
    assertEquals("oldlabel", cloned.getLabelText());
    note.setLabelText("mylabel");
    assertFalse(cloned.getLabelText() == note.getLabelText());
   
    // now test the label
    mockParent1.expects(atLeastOnce()).method("getAbsoluteX1")
      .will(returnValue(0.0));
    mockParent1.expects(atLeastOnce()).method("getAbsoluteY1")
      .will(returnValue(0.0));
    assertNotNull(cloned.getLabelAt(20, 20));
    assertNull(cloned.getLabelAt(-1.0, -2.0));
    assertTrue(cloned.getLabelAt(20.0, 20.0) != note.getLabelAt(20.0, 20.0));
    assertTrue(cloned.getLabelAt(20.0, 20.0).getSource() == cloned);
    assertTrue(cloned.getLabelAt(20.0, 20.0).getParent() == cloned);
  }
View Full Code Here

 
  /**
   * Tests the acceptsConnection() method.
   */
  public void testAcceptsConnection() {
    NoteElement note = NoteElement.getPrototype();
    ClassElement anyumlnode = ClassElement.getPrototype();
    assertTrue(note.acceptsConnection(RelationType.NOTE_CONNECTOR,
      RelationEndType.UNSPECIFIED, anyumlnode));
    assertTrue(note.acceptsConnection(RelationType.NOTE_CONNECTOR,
      RelationEndType.SOURCE, anyumlnode));
    assertTrue(note.acceptsConnection(RelationType.NOTE_CONNECTOR,
      RelationEndType.TARGET, anyumlnode));
    assertFalse(note.acceptsConnection(RelationType.DEPENDENCY,
      RelationEndType.UNSPECIFIED, anyumlnode));
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public NoteElement createNote() {
    NoteElement noteElem = new NoteElement();
    noteElem.addNodeChangeListener(diagram);
    return noteElem;
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public NoteElement createNote() {
    NoteElement noteElem = (NoteElement) NoteElement.getPrototype().clone();
    noteElem.addNodeChangeListener(diagram);
    return noteElem;
  }
View Full Code Here

  /**
   * Test creating a NoteElement.
   */
  public void testCreateNote() {
    NoteElement node = factory.createNote();
    assertNull(node.getParent());
    assertTrue(node.getNodeChangeListeners().contains(diagram));   
  }
View Full Code Here

   */
  public void testCreateNoteConnection() {
    mockElementFactory.expects(atLeastOnce()).method("create").
      with(eq(ElementType.CLASS)).will(returnValue(clss));
    ClassElement clss = factory.createClass();
    NoteElement note = factory.createNote();
    NoteConnection conn = (NoteConnection)
      factory.createNoteConnection(clss, note);
    assertEquals(clss, conn.getNode1());
    assertEquals(note, conn.getNode2());
    assertEquals(1, clss.getConnections().size());
    assertEquals(1, note.getConnections().size());
    assertNull(conn.getParent());
  }
View Full Code Here

  /**
   * Tests the creation of a note connection.
   */
  public void testCreateNoteConnection() {
    ClassElement clss = (ClassElement) factory.createNode(ElementType.CLASS);
    NoteElement note = (NoteElement) factory.createNode(ElementType.NOTE);
    NoteConnection conn = (NoteConnection)
      factory.createConnection(RelationType.NOTE_CONNECTOR, clss, note);
    assertStdConnectionConditions(conn, clss, note);
    assertNull(conn.getModelElement());
  }
View Full Code Here

TOP

Related Classes of org.tinyuml.umldraw.shared.NoteElement

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.