src/main/java/ca/phon/plugins/praat/export/TextGridExporter.java
/**
	 * Copy textgrid data from the old textgrid object to the new one.
	 * Will only copy tiers which exist in the new textgrid.  The method
	 * returns true if any TextGrid data is copied, <code>false</code>
	 * otherwise.
	 *
	 * @param oldTextGrid
	 * @param textGrid
	 * @param record
	 *
	 * throws PraatException
	 */
Copy textgrid data from the old textgrid object to the new one.
Will only copy tiers which exist in the new textgrid.  The method
returns true if any TextGrid data is copied, false
otherwise.




Copy textgrid data from the old textgrid object to the new one . Will only copy tiers which exist in the new textgrid . The method returns true if any TextGrid data is copied false otherwise .
private boolean copyRecordData(TextGrid oldTextGrid, TextGrid textGrid, Record record)
		throws PraatException {
		boolean retVal = false;
		final MediaSegment mediaSeg = record.getSegment().getGroup(0);
		if(mediaSeg == null ||
				(mediaSeg.getEndValue() - mediaSeg.getStartValue()) <= 0) {
			return retVal;
		}
		double startTime = mediaSeg.getStartValue() / 1000.0;
		double endTime = mediaSeg.getEndValue() / 1000.0;
		final TextGrid recordTextGrid = oldTextGrid.extractPart(startTime, endTime, true);
		for(long tierIdx = 1; tierIdx <= recordTextGrid.numberOfTiers(); tierIdx++) {
			try {
				final IntervalTier oldTier = recordTextGrid.checkSpecifiedTierIsIntervalTier(tierIdx);
				final IntervalTier newTier = findIntervalTier(textGrid, oldTier.getName().toString());
				if(newTier != null) {
					for(long intervalIdx = 1; intervalIdx <= oldTier.numberOfIntervals(); intervalIdx++) {
						final TextInterval oldInterval = oldTier.interval(intervalIdx);
						newTier.addInterval(oldInterval.getXmin(), oldInterval.getXmax(), oldInterval.getText());
						retVal = true;
					}
				}
			} catch (PraatException pe) {
				final TextTier oldTier = recordTextGrid.checkSpecifiedTierIsPointTier(tierIdx);
				final TextTier newTier = findPointTier(textGrid, oldTier.getName().toString());
				if(newTier != null) {
					for(long pointIdx = 1; pointIdx <= oldTier.numberOfPoints(); pointIdx++) {
						final TextPoint textPoint = oldTier.point(pointIdx);
						newTier.addPoint(textPoint.getNumber(), textPoint.getText());
						retVal = true;
					}
				}
			}
		}
		return retVal;
	}
private boolean copyRecordData ( TextGrid oldTextGrid , TextGrid textGrid , Record record ) throws PraatException { boolean retVal = false ; final MediaSegment mediaSeg = record . getSegment ( ) . getGroup ( 0 ) ; if ( mediaSeg == null || ( mediaSeg . getEndValue ( ) - mediaSeg . getStartValue ( ) ) <= 0 ) { return retVal ; } double startTime = mediaSeg . getStartValue ( ) / 1000.0 ; double endTime = mediaSeg . getEndValue ( ) / 1000.0 ; final TextGrid recordTextGrid = oldTextGrid . extractPart ( startTime , endTime , true ) ; for ( long tierIdx = 1 ; tierIdx <= recordTextGrid . numberOfTiers ( ) ; tierIdx ++ ) { try { final IntervalTier oldTier = recordTextGrid . checkSpecifiedTierIsIntervalTier ( tierIdx ) ; final IntervalTier newTier = findIntervalTier ( textGrid , oldTier . getName ( ) . toString ( ) ) ; if ( newTier != null ) { for ( long intervalIdx = 1 ; intervalIdx <= oldTier . numberOfIntervals ( ) ; intervalIdx ++ ) { final TextInterval oldInterval = oldTier . interval ( intervalIdx ) ; newTier . addInterval ( oldInterval . getXmin ( ) , oldInterval . getXmax ( ) , oldInterval . getText ( ) ) ; retVal = true ; } } } catch ( PraatException pe ) { final TextTier oldTier = recordTextGrid . checkSpecifiedTierIsPointTier ( tierIdx ) ; final TextTier newTier = findPointTier ( textGrid , oldTier . getName ( ) . toString ( ) ) ; if ( newTier != null ) { for ( long pointIdx = 1 ; pointIdx <= oldTier . numberOfPoints ( ) ; pointIdx ++ ) { final TextPoint textPoint = oldTier . point ( pointIdx ) ; newTier . addPoint ( textPoint . getNumber ( ) , textPoint . getText ( ) ) ; retVal = true ; } } } } return retVal ; }
Copy textgrid data from the old textgrid object to the new one.
Copy textgrid data from the old textgrid object to the new one .