/** Adds a new recording to the currently selected sample. */ public static void addNewRecording() { if (SampleController.getSelectedSampleIndex() > -1) { FHX2_Recording newRecording = null; FHX2_Sample selectedSample = IOController.getFile() .getRequiredPart() .getSample(SampleController.getSelectedSampleIndex()); if (selectedSample.getNumOfRecordings() > 0) { FHX2_Recording prevRecording = selectedSample.getRecording(selectedSample.getNumOfRecordings() - 1); int year = selectedSample.getNextAvailableRecordingYear(prevRecording.getEndYear() + 1); if (year != 0) { newRecording = new FHX2_Recording(year, year); } } else { int firstyear = selectedSample.getNextAvailableRecordingYear(); int lastyear = selectedSample.getSampleLastYear() - 1; if (firstyear != 0 && lastyear != 0) { newRecording = new FHX2_Recording(firstyear, lastyear); } } if (newRecording != null) { selectedSample.addRecording(newRecording); } } SampleController.setSelectedSampleIndex(SampleController.getSelectedSampleIndex()); }
/** * Add the a recording to the selected sample starting in the first event year and ending in the * last year of the sample. * * @param recording */ public static void addRecordingFromFirstEventToEnd() { if (SampleController.getSelectedSampleIndex() > -1) { FHX2_Recording newRecording = new FHX2_Recording(); FHX2_Sample selectedSample = IOController.getFile() .getRequiredPart() .getSample(SampleController.getSelectedSampleIndex()); @SuppressWarnings("unchecked") ArrayList<FHX2_Event> events = (ArrayList<FHX2_Event>) selectedSample.getEvents().clone(); if (events.size() == 0) return; Collections.sort(events, new CompareEventYears()); FHX2_Event event = events.get(0); int firstyear = event.getEventYear(); int lastyear = selectedSample.getSampleLastYear(); // Handle year 0 if (firstyear == 0) firstyear++; if (lastyear == 0) lastyear--; newRecording.setStartYear(firstyear); newRecording.setEndYear(lastyear); selectedSample.addRecording(newRecording); } SampleController.setSelectedSampleIndex(SampleController.getSelectedSampleIndex()); }
/** * Add the a recording to the selected sample starting in the first event year and ending in the * last year of the sample. * * @param recording */ public static void addRecordingFromBeginningToEnd() { if (SampleController.getSelectedSampleIndex() > -1) { FHX2_Recording newRecording = new FHX2_Recording(); FHX2_Sample selectedSample = IOController.getFile() .getRequiredPart() .getSample(SampleController.getSelectedSampleIndex()); int firstyear = selectedSample.getSampleFirstYear(); int lastyear = selectedSample.getSampleLastYear(); // Handle year 0 if (firstyear == 0) firstyear++; if (lastyear == 0) lastyear--; newRecording.setStartYear(firstyear); newRecording.setEndYear(lastyear); selectedSample.addRecording(newRecording); } SampleController.setSelectedSampleIndex(SampleController.getSelectedSampleIndex()); }