Examples of NoteElement


Examples of com.music.xmlmodel.NoteElement

            Iterator<Note> noteIterator = partNotes.iterator();
            int measureNumber = 1;
            Measure currentMeasure = createMeasure(score, measureNumber++);
            while (noteIterator.hasNext()) {
                Note note = noteIterator.next();
                NoteElement xmlNote = new NoteElement();
                int length = (int) (getClosestLength(note.getRhythmValue()) * 10000);
                switch(length) {
                case (int) (THIRTYSECOND_NOTE * 10000): xmlNote.setType("32nd"); break;
                case (int) (SIXTEENTH_NOTE * 10000): xmlNote.setType("16th"); break;
                case (int) (EIGHTH_NOTE * 10000): xmlNote.setType("eighth"); break;
                case (int) (QUARTER_NOTE * 10000): xmlNote.setType("quarter"); break;
                case (int) (DOTTED_QUARTER_NOTE * 10000): xmlNote.setType("quarter"); xmlNote.setDot(""); break;
                case (int) (HALF_NOTE * 10000): xmlNote.setType("half"); break;
                case (int) (WHOLE_NOTE * 10000): xmlNote.setType("whole"); break;
                default: xmlNote.setType("/" + (length / 10000d));
                }
                xmlNote.setDuration((int) (note.getRhythmValue() * 2));
                xmlNote.setVoice(idx);
                if (!note.isRest()) {
                    xmlNote.setPitch(new Pitch());
                    int pitch = note.getPitch() % 12;
                    String sPitch = NOTES[pitch];
                    int octave = note.getPitch() / 12 - 1;
                    xmlNote.getPitch().setOctave(octave);
                    if (sPitch.length() > 1) {
                        xmlNote.getPitch().setAlter((byte) (sPitch.contains("#") ? 1 : -1));
                        sPitch = sPitch.substring(0, 1);
                    }
                    xmlNote.getPitch().setStep(sPitch);
                } else {
                    xmlNote.setRest(new RestElement());
                }

                currentMeasure.getNotes().add(xmlNote);
                currentMeasureSize += note.getRhythmValue();
                if (currentMeasureSize >= normalizedMeasureSize) {
View Full Code Here

Examples of org.tinyuml.draw.NoteElement

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

Examples of org.tinyuml.draw.NoteElement

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

Examples of org.tinyuml.draw.NoteElement

   */
  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);
    assertNull(conn.getModelElement());
    assertEquals(clss, conn.getNode0());
    assertEquals(note, conn.getNode1());
View Full Code Here

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

Examples of org.tinyuml.umldraw.shared.NoteElement

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

Examples of org.tinyuml.umldraw.shared.NoteElement

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

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

Examples of org.tinyuml.umldraw.shared.NoteElement

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

Examples of org.tinyuml.umldraw.shared.NoteElement

  /**
   * {@inheritDoc}
   */
  public NoteElement createNote() {
    NoteElement noteElem = new NoteElement();
    noteElem.addNodeChangeListener(diagram);
    return noteElem;
  }
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.