Package info.textgrid.lab.noteeditor.mei2013

Examples of info.textgrid.lab.noteeditor.mei2013.Score


        staffDefForm.getId(),
        new Point(this.figurePassingObject.getRootXAxisProgress(),
            GraphicalConstants.DEFAULT_STARTPOINT.y
                + GraphicalConstants.SHAPE_SINGLESYSTEM_HEIGHT
                * indexOfStaffDef));
    StaffDef staffDef = (StaffDef) staffDefForm.getMeiNode();
    ScoreDef scoreDef = (ScoreDef) scoreDefForm.getMeiNode();
    int extentForLabel = 0; // extent for label if present
    if (staffDef.isSetLabel()) {
      extentForLabel = staffDef.getLabel().length()
          * this.figurePassingObject.getLabelSylExtentBase();
    }
    int extentForBrackets = 0;
    BasicElement parent = staffDefForm.getParent();
    while (parent.getFormType() == BasicElement.FormType.StaffGroup) {
      parent = parent.getParent();
      extentForBrackets += GraphicalConstants.SHAPE_STAFFDEF_BRACKET_OFFSET;
    }
    int extentForClefs = 0; // extent for clef keys if present
    if (staffDef.isSetClefShape()) {
      extentForClefs = GraphicalConstants.SHAPE_STAFFDEF_CLEF_OFFSET;
      if (staffDef.getClefShape() == DataCLEFSHAPE.GG) {
        extentForClefs = GraphicalConstants.SHAPE_STAFFDEF_CLEF_OFFSET * 2;
      }
    } else {
      if (scoreDef.isSetClefShape()) {
        extentForClefs = GraphicalConstants.SHAPE_STAFFDEF_CLEF_OFFSET;
        if (scoreDef.getClefShape() == DataCLEFSHAPE.GG) {
          extentForClefs = GraphicalConstants.SHAPE_STAFFDEF_CLEF_OFFSET * 2;
        }
      }
    }
    int extentForKeySig = 0; // extent for key signatures if present
    String keySignatureMEIString;
    if (staffDef.isSetKeySigValue()) {
      keySignatureMEIString = staffDef.getKeySigValue();
    } else {
      if (scoreDef.isSetKeySigValue()) {
        keySignatureMEIString = scoreDef.getKeySigValue();
      } else { // default: empty
        keySignatureMEIString = GraphicalConstants.PROPCOMBO_STRING_ARRAY_KEYSIGVALUES[0];
      }
    }
    if (keySignatureMEIString.length() == 2) {
      // one of the numbered sharps or flats, not '0'
      int countKeysigs = Integer.parseInt(keySignatureMEIString
          .substring(0, 1));
      extentForKeySig = countKeysigs * 5;
    }
    int extentForMeterSign = 0; // extent for meter sign if present
    if (staffDef.isSetMeterSym() || staffDef.isSetMeterCount()
        || staffDef.isSetMeterUnit() || scoreDef.isSetMeterSym()
        || scoreDef.isSetMeterCount() || scoreDef.isSetMeterUnit()) {
      extentForMeterSign = GraphicalConstants.SHAPE_STAFFDEF_METER_OFFSET;
    }
    FigureStaffDefPassingObject figureStaffDefPassingObject = new FigureStaffDefPassingObject(
        extentForLabel, extentForBrackets, extentForClefs,
View Full Code Here


    StaffDefForm staffDefForm = new StaffDefForm();
    if (activeStaffDefList.size() > graphicalSystemNumber) {
      staffDefForm = (StaffDefForm) activeStaffDefList
          .get(graphicalSystemNumber);
    }
    StaffDef staffDef = ((StaffDef) staffDefForm.getMeiNode());
//    ScoreDef scoredef = (ScoreDef) ((ScoreDefForm) MeiNodeNavigator
//        .findAncestorForm(ScoreDefForm.class, staffDefForm))
//        .getMeiNode();
    ScoreDef scoredef = (ScoreDef) MusicPlugin.getDefault().getActiveDiagram().getScoreDefForm().getMeiNode();
    String meterCount = StringConstants.STRING_EMPTY;
    if (staffDef.isSetMeterSym()) {
      if (staffDef.getMeterSym() == DataMETERSIGN.CUT) { // 2/2
        meterCount = "2";
      } else { // common = 4/4
        meterCount = "4";
      }
    } else { // directly placed
      if (staffDef.isSetMeterCount()) {
        meterCount = staffDef.getMeterCount();
      } else {
        if (scoredef.isSetMeterSym()) {
          if (scoredef.getMeterSym() == DataMETERSIGN.CUT) { // 2/2
            meterCount = "2";
          } else { // common = 4/4
            meterCount = "4";
          }
        } else { // directly placed
          if (scoredef.isSetMeterCount()) {
            meterCount = scoredef.getMeterCount();
          } else {
            meterCount = StringConstants.STRING_EMPTY + GraphicalConstants.DEFAULT_METER_COUNT;
          }
        }
      }
    }
    int meterUnit = -1;
    if (staffDef.isSetMeterSym()) {
      if (staffDef.getMeterSym() == DataMETERSIGN.CUT) { // 2/2
        meterUnit = 2;
      } else { // common = 4/4
        meterUnit = 4;
      }
    } else { // directly placed
      if (staffDef.isSetMeterUnit()) {
        meterUnit = staffDef.getMeterUnit().intValue();
      } else {
        if (scoredef.isSetMeterSym()) {
          if (scoredef.getMeterSym() == DataMETERSIGN.CUT) { // 2/2
            meterUnit = 2;
          } else { // common = 4/4
View Full Code Here

    cpd.setDescription(MusicMessages.MEI_documentation_StaffDef_clefdisplace);
    descriptors.add(cpd);
  }

  private void createDefaultStaffDef() {
    StaffDef staffDef = new StaffDef();
    staffDef.setClefShape(GraphicalConstants.DEFAULT_SYSTEM_CLEF);
    staffDef.setMeterCount(StringConstants.STRING_EMPTY + GraphicalConstants.DEFAULT_METER_COUNT);
    staffDef.setMeterUnit(new BigDecimal(
        GraphicalConstants.DEFAULT_METER_UNIT));
    staffDef.setKeySigValue("0"); //$NON-NLS-1$
    setMeiNode(staffDef);
  }
View Full Code Here

            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof StaffDefForm) {
      StaffDefForm contentForm = (StaffDefForm) childForm;
      StaffDef contentNode = (StaffDef) contentForm.getMeiNode();
      contentNode.getMensursAndProportsAndClefGrps().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getMensursAndProportsAndClefGrps().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof MeasureForm) {
      MeasureForm measureForm = (MeasureForm) childForm;
      Measure measureNode = (Measure) measureForm.getMeiNode();
      measureNode.getAnnotsAndSlursAndTupletSpen().clear();
      for (BasicElement measureChildForm : measureForm.getChildren()) {
        measureNode.getAnnotsAndSlursAndTupletSpen().add(
            handleScoreChild(measureChildForm, saveAllVariants));
      }
      return measureNode;
    } else if (childForm instanceof StaffForm) {
      StaffForm contentForm = (StaffForm) childForm;
      Staff contentNode = (Staff) contentForm.getMeiNode();
      contentNode.getSbsAndSymbolsAndOrigs().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getSbsAndSymbolsAndOrigs().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof AppForm) {
      AppForm contentForm = (AppForm) childForm;
      App contentNode = (App) contentForm.getMeiNode();
      contentNode.getRdgs().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getRdgs().add(
            (Rdg) handleScoreChild(contentChildForm,
                saveAllVariants));
      }
      if (contentNode.isSetRdgs() && contentNode.getRdgs().isEmpty())
        contentNode.unsetRdgs();
      if (contentNode.isSetN() && contentNode.getN().isEmpty())
        contentNode.setN(null);
      if (!saveAllVariants) {
        for (BasicElement contentChildForm : contentForm.getChildren()) {
          if(contentChildForm instanceof ReadingForm && ((ReadingForm)contentChildForm).isActive() ) {
            MeiNode parentMeiNode = contentForm.getParent().getMeiNode();
            for(BasicElement grandChild : ((ReadingForm)contentChildForm).getChildren()){
              MeiNodeNavigator.addMeiNodeAsChild(parentMeiNode, grandChild.getMeiNode());
            }           
          }
        }
        return null;

      }
      return contentNode;
    } else if (childForm instanceof ReadingForm) {
      Rdg contentNode;
      ReadingForm contentForm = (ReadingForm) childForm;
      if (!saveAllVariants && !contentForm.isActive()) {
        // ignore this very reading
        return null;
      }
      contentNode = (Rdg) contentForm.getMeiNode();
      contentNode.getSources().clear();
      for (SourceBindingWrapper sbw : contentForm
          .getSourceBindingWrappers()) { // insert the wrapped sources
        contentNode.getSources().add(sbw.getSource().getId());
      }
      if (contentNode.getSources().isEmpty())
        contentNode.unsetSources();
      contentNode.getMRestsAndKeySigsAndProports().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getMRestsAndKeySigsAndProports().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof LayerForm) {
      LayerForm contentForm = (LayerForm) childForm;
      Layer contentNode = (Layer) contentForm.getMeiNode();
      contentNode.getBarLinesAndSyllablesAndGaps().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getBarLinesAndSyllablesAndGaps().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof ChordGroupForm) {
      ChordGroupForm contentForm = (ChordGroupForm) childForm;
      Chord contentNode = (Chord) contentForm.getMeiNode();
      contentNode.getRestoresAndArticsAndUnclears().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getRestoresAndArticsAndUnclears().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      if(contentNode.getArtics().isEmpty()) {
        contentNode.unsetArtics();
      }
      return contentNode;
    } else if (childForm instanceof BeamGroupForm) {
      BeamGroupForm contentForm = (BeamGroupForm) childForm;
      Beam contentNode = (Beam) contentForm.getMeiNode();
      contentNode.getFTremsAndChordsAndDamages().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getFTremsAndChordsAndDamages().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof NoteForm) {
      NoteForm contentForm = (NoteForm) childForm;
      Note contentNode = (Note) contentForm.getMeiNode();
      if (contentNode.getArtics().isEmpty())
        contentNode.unsetArtics();
      return contentNode;
    } else if (childForm instanceof RestForm) {
      RestForm contentForm = (RestForm) childForm;
      Rest contentNode = (Rest) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof MRestForm) {
      MRestForm contentForm = (MRestForm) childForm;
      MRest contentNode = (MRest) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof SpaceForm) {
      SpaceForm contentForm = (SpaceForm) childForm;
      Space contentNode = (Space) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof DynamForm) {
      DynamForm contentForm = (DynamForm) childForm;
      Dynam contentNode = (Dynam) contentForm.getMeiNode();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getContent().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof TieForm) {
      TieForm contentForm = (TieForm) childForm;
View Full Code Here

    StaffGroupForm staffGroupForm = new StaffGroupForm();
    staffGroupForm.setParent(parentForm);
    staffGroupForm.setMeiNode(staffGrp);
    for (MeiNode child : staffGrp.getInstrDevesAndGrpSymsAndStaffDeves()) {
      if (child instanceof StaffDef) {
        StaffDef staffDef = (StaffDef) child;
        if (null == staffDef.getMeterCount()) {
          if (null != scoreDef.getMeterCount()) {
            staffDef.setMeterCount(scoreDef.getMeterCount());
          } else {
            staffDef.setMeterCount(
                StringConstants.STRING_EMPTY
                    + GraphicalConstants.DEFAULT_METER_COUNT);
          }
        }
        if (null == staffDef.getMeterUnit()) {
          if (null != scoreDef.getMeterUnit()) {
            staffDef.setMeterUnit(scoreDef.getMeterUnit());
          } else {
            staffDef.setMeterUnit(new BigDecimal(
                StringConstants.STRING_EMPTY
                    + GraphicalConstants.DEFAULT_METER_UNIT));
          }
        }
        if (null == scoreDef.getMeterSym()) {
          if (null != staffDef.getMeterSym()) {
            staffDef.setMeterSym(scoreDef.getMeterSym());
          } else {
            staffDef.setMeterSym(HelperMethods
                .convertStringToSign(GraphicalConstants.DEFAULT_METER_SYM));
          }
        }
        scoreDefForm.getStaffDefN().put(
            (staffDef.getN() != null) ? staffDef.getN()
                : staffDef.getId(),
            scoreDefForm.getSystemsCount());
        scoreDefForm.addStaffDef(staffDef, staffGrp);
      } else if (child instanceof StaffGrp) {
        // recursive call
        scoreDefForm.addStaffgroup(staffGrp, (StaffGrp) child);
View Full Code Here

   */
  private void massInsertStaffdefs() {
    MusicContainerForm rootForm;
    MusicContainerForm staffDefForm;
    StaffForm staffForm;
    StaffDef staffDefMeiNode;
    if (contentWrapper.isStaffDefsCreateNewStaffGroup()) {
      // create new section and set it as new parent
      rootForm = (MusicContainerForm) MusicPlugin.getDefault().getActiveDiagram()
          .getScoreDefForm().getChildren().get(0);
      MusicContainerForm groupForm = new StaffGroupForm();
      insertCompoundCommand(rootForm, groupForm);
      rootForm = groupForm;
    } else {
      rootForm = (MusicContainerForm) MusicPlugin.getDefault()
          .getActiveDiagram().getScoreDefForm().getChildren().get(0);
    }
    for (InsertStaffDefsDialogEntryWrapper newEntry : entryList) {
      staffDefForm = new StaffDefForm();
      staffDefMeiNode = (StaffDef) staffDefForm.getMeiNode();
      staffDefMeiNode.setClefShape(newEntry.getClefShape());
      staffDefMeiNode.setKeySigValue(newEntry.getKeySigValue());
      staffDefMeiNode.setMeterCount(newEntry
          .getMeterCount());
      staffDefMeiNode
          .setMeterUnit(new BigDecimal(newEntry.getMeterUnit()));
      insertCompoundCommand(rootForm, staffDefForm);
    }
    if (contentWrapper.isStaffDefsFillMeasuresWithStaffs()) {
      for(BasicElement child : MeiNodeNavigator
View Full Code Here

   *
   * @param index
   */
  public void removeStaffDef(StaffDef staffDef) {
    int index = getStaffDefs().indexOf(staffDef);
    StaffGrp staffGrp = this.staffgroups.get(index);
    this.rootStaffTree.removeStaffDef(staffGrp, staffDef);
    // index-based lists
    getStaffDefs().remove(index);
    getStaffgroups().remove(index);
    for (IPropertyDescriptor ipd : descriptors) {
View Full Code Here

    return musicDiagram;
  }

  public static ScoreDef createScoreDef(int stavesCount) {
    ScoreDef scoreDef = new ScoreDef();
    StaffGrp staffGrp = new StaffGrp();
    for (int i = 0; i < stavesCount; i++) {
      StaffDef staffDef = new StaffDef();
      staffDef.setN(String.valueOf(i));
      if (i % 2 == 0)
        staffDef.setClefShape(GraphicalConstants.DEFAULT_SYSTEM_CLEF);
      else
        staffDef.setClefShape(GraphicalConstants.ALTERNATE_SYSTEM_CLEF);
      staffDef.setMeterCount(StringConstants.STRING_EMPTY + GraphicalConstants.DEFAULT_METER_COUNT);
      staffDef.setMeterUnit(new BigDecimal(
          GraphicalConstants.DEFAULT_METER_UNIT));
      staffDef.setKeySigValue("0");
      staffGrp.getInstrDevesAndGrpSymsAndStaffDeves().add(staffDef);
    }
    scoreDef.setStaffGrp(staffGrp);
    return scoreDef;
  }
View Full Code Here

    tpd.setDescription("Symbol");
    descriptors.add(cpd);
  }

  private void createDefaultStaffGrp() {
    setMeiNode(new StaffGrp());
  }
View Full Code Here

            contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof StaffGroupForm) {
      StaffGroupForm contentForm = (StaffGroupForm) childForm;
      StaffGrp contentNode = (StaffGrp) contentForm.getMeiNode();
      contentNode.getInstrDevesAndGrpSymsAndStaffDeves().clear();
      if(contentForm.getChildren().size() == 0) {
        //an empty staffGrp is not allowed and is being cut
        return null;
      }
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getInstrDevesAndGrpSymsAndStaffDeves().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof StaffDefForm) {
      StaffDefForm contentForm = (StaffDefForm) childForm;
      StaffDef contentNode = (StaffDef) contentForm.getMeiNode();
      contentNode.getMensursAndProportsAndClefGrps().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getMensursAndProportsAndClefGrps().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof MeasureForm) {
      MeasureForm measureForm = (MeasureForm) childForm;
      Measure measureNode = (Measure) measureForm.getMeiNode();
      measureNode.getAnnotsAndSlursAndTupletSpen().clear();
      for (BasicElement measureChildForm : measureForm.getChildren()) {
        measureNode.getAnnotsAndSlursAndTupletSpen().add(
            handleScoreChild(measureChildForm, saveAllVariants));
      }
      return measureNode;
    } else if (childForm instanceof StaffForm) {
      StaffForm contentForm = (StaffForm) childForm;
      Staff contentNode = (Staff) contentForm.getMeiNode();
      contentNode.getSbsAndSymbolsAndOrigs().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getSbsAndSymbolsAndOrigs().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof AppForm) {
      AppForm contentForm = (AppForm) childForm;
      App contentNode = (App) contentForm.getMeiNode();
      contentNode.getRdgs().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getRdgs().add(
            (Rdg) handleScoreChild(contentChildForm,
                saveAllVariants));
      }
      if (contentNode.isSetRdgs() && contentNode.getRdgs().isEmpty())
        contentNode.unsetRdgs();
      if (contentNode.isSetN() && contentNode.getN().isEmpty())
        contentNode.setN(null);
      if (!saveAllVariants) {
        for (BasicElement contentChildForm : contentForm.getChildren()) {
          if(contentChildForm instanceof ReadingForm && ((ReadingForm)contentChildForm).isActive() ) {
            MeiNode parentMeiNode = contentForm.getParent().getMeiNode();
            for(BasicElement grandChild : ((ReadingForm)contentChildForm).getChildren()){
              MeiNodeNavigator.addMeiNodeAsChild(parentMeiNode, grandChild.getMeiNode());
            }           
          }
        }
        return null;

      }
      return contentNode;
    } else if (childForm instanceof ReadingForm) {
      Rdg contentNode;
      ReadingForm contentForm = (ReadingForm) childForm;
      if (!saveAllVariants && !contentForm.isActive()) {
        // ignore this very reading
        return null;
      }
      contentNode = (Rdg) contentForm.getMeiNode();
      contentNode.getSources().clear();
      for (SourceBindingWrapper sbw : contentForm
          .getSourceBindingWrappers()) { // insert the wrapped sources
        contentNode.getSources().add(sbw.getSource().getId());
      }
      if (contentNode.getSources().isEmpty())
        contentNode.unsetSources();
      contentNode.getMRestsAndKeySigsAndProports().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getMRestsAndKeySigsAndProports().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof LayerForm) {
      LayerForm contentForm = (LayerForm) childForm;
      Layer contentNode = (Layer) contentForm.getMeiNode();
      contentNode.getBarLinesAndSyllablesAndGaps().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getBarLinesAndSyllablesAndGaps().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof ChordGroupForm) {
      ChordGroupForm contentForm = (ChordGroupForm) childForm;
      Chord contentNode = (Chord) contentForm.getMeiNode();
      contentNode.getRestoresAndArticsAndUnclears().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getRestoresAndArticsAndUnclears().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      if(contentNode.getArtics().isEmpty()) {
        contentNode.unsetArtics();
      }
      return contentNode;
    } else if (childForm instanceof BeamGroupForm) {
      BeamGroupForm contentForm = (BeamGroupForm) childForm;
      Beam contentNode = (Beam) contentForm.getMeiNode();
      contentNode.getFTremsAndChordsAndDamages().clear();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getFTremsAndChordsAndDamages().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof NoteForm) {
      NoteForm contentForm = (NoteForm) childForm;
      Note contentNode = (Note) contentForm.getMeiNode();
      if (contentNode.getArtics().isEmpty())
        contentNode.unsetArtics();
      return contentNode;
    } else if (childForm instanceof RestForm) {
      RestForm contentForm = (RestForm) childForm;
      Rest contentNode = (Rest) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof MRestForm) {
      MRestForm contentForm = (MRestForm) childForm;
      MRest contentNode = (MRest) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof SpaceForm) {
      SpaceForm contentForm = (SpaceForm) childForm;
      Space contentNode = (Space) contentForm.getMeiNode();
      return contentNode;
    } else if (childForm instanceof DynamForm) {
      DynamForm contentForm = (DynamForm) childForm;
      Dynam contentNode = (Dynam) contentForm.getMeiNode();
      for (BasicElement contentChildForm : contentForm.getChildren()) {
        contentNode.getContent().add(
            handleScoreChild(contentChildForm, saveAllVariants));
      }
      return contentNode;
    } else if (childForm instanceof TieForm) {
      TieForm contentForm = (TieForm) childForm;
View Full Code Here

TOP

Related Classes of info.textgrid.lab.noteeditor.mei2013.Score

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.