Esempio n. 1
0
 protected static double getOffset(Note note, Clef clef) {
   double positionOffset = 0;
   // TODO if (clef.isPerc())
   byte noteHeight = note.getStrictHeight();
   // position for G clef, line 2
   switch (noteHeight) {
     case Note.C:
       positionOffset = -1.5;
       break;
     case Note.D:
       positionOffset = -1;
       break;
     case Note.E:
       positionOffset = -0.5;
       break;
     case Note.F:
       positionOffset = 0;
       break;
     case Note.G:
       positionOffset = 0.5;
       break;
     case Note.A:
       positionOffset = 1;
       break;
     case Note.B:
       positionOffset = 1.5;
       break;
   }
   if (clef.isG()) {
     positionOffset += clef.getLineNumber() - 2;
   } else if (clef.isC()) { // C clef, line 3
     positionOffset += 3;
     positionOffset += clef.getLineNumber() - 3;
   } else { // F clef, line 4
     positionOffset += 2.5 + 3.5;
     positionOffset += clef.getLineNumber() - 4;
   }
   // clef octave +8 | -8
   positionOffset -=
       (clef.getOctaveTransposition() + (clef.getInvisibleOctaveTransposition())) * 3.5;
   // note octave
   positionOffset += note.getOctaveTransposition() * 3.5;
   return positionOffset;
 }
Esempio n. 2
0
 public double render(Graphics2D context) {
   super.render(context);
   /*char[] chars2 = {ScoreMetrics.STAFF_SIX_LINES};
   context.drawChars(chars2, 0, chars2.length,
   		(int)m_base.getX(), (int)(m_base.getY()));*/
   if (!m_clef.isNone()) {
     Color previousColor = context.getColor();
     setColor(context, ScoreElements.CLEF);
     char[] chars = {getMusicalFont().getClef(m_clef)};
     context.drawChars(
         chars,
         0,
         chars.length,
         (int) (getBase().getX() + getMetrics().getNoteWidth() / 4),
         (int) (getBase().getY() - getMetrics().getNoteHeight() * (m_clef.getLineNumber() - 1)));
     context.setColor(previousColor);
   }
   return getWidth();
 }