/** * Adds a channel annotation for the channel with the given index. * * @param aChannelIdx * the index of channel to remove all annotations for, >=0 && < 32. * @param aStartIdx * the start index; * @param aEndIdx * the end index; * @param aData * the data. */ public void addChannelAnnotation( final int aChannelIdx, final long aStartTimestamp, final long aEndTimestamp, final Object aData ) { if ( ( aChannelIdx < 0 ) || ( aChannelIdx > ( Ols.MAX_CHANNELS - 1 ) ) ) { throw new IllegalArgumentException( "Invalid channel index: " + aChannelIdx + "! Should be between 0 and " + Ols.MAX_CHANNELS ); } ChannelAnnotations annotations = this.annotations.get( Integer.valueOf( aChannelIdx ) ); if ( annotations == null ) { annotations = new ChannelAnnotations( aChannelIdx ); this.annotations.put( Integer.valueOf( aChannelIdx ), annotations ); } annotations.addAnnotation( aStartTimestamp, aEndTimestamp, aData ); }
/** * Returns the channel annotations. * * @param aChannelIdx * the index of the channel to retrieve the annotations for, >= 0 && * < 32. * @param aTimeIndex * the time index to get the channel annotation for, >= 0. * @return the channel annotations, can be <code>null</code>. */ public ChannelAnnotation getChannelAnnotation( final int aChannelIdx, final int aTimeIndex ) { if ( ( aChannelIdx < 0 ) || ( aChannelIdx > ( Ols.MAX_CHANNELS - 1 ) ) ) { throw new IllegalArgumentException( "Invalid channel index: " + aChannelIdx + "! Should be between 0 and " + Ols.MAX_CHANNELS ); } final ChannelAnnotations channelAnnotations = this.annotations.get( Integer.valueOf( aChannelIdx ) ); if ( channelAnnotations == null ) { return null; } return channelAnnotations.getAnnotation( aTimeIndex ); }
/** * Returns the channel annotations. * * @param aChannelIdx * the index of the channel to retrieve the annotations for, >= 0 && * < 32. * @param aStartIdx * the start time/sample index to retrieve the channel annotations * for, >= 0; * @param aEndIdx * the end time/sample index to retrieve the channel annotations for, * >= 0. * @return the channel annotations, can be <code>null</code>. */ public Iterator<ChannelAnnotation> getChannelAnnotations( final int aChannelIdx, final int aStartIdx, final int aEndIdx ) { if ( ( aChannelIdx < 0 ) || ( aChannelIdx > ( Ols.MAX_CHANNELS - 1 ) ) ) { throw new IllegalArgumentException( "Invalid channel index: " + aChannelIdx + "! Should be between 0 and " + Ols.MAX_CHANNELS ); } final ChannelAnnotations channelAnnotations = this.annotations.get( Integer.valueOf( aChannelIdx ) ); if ( channelAnnotations == null ) { return Collections.<ChannelAnnotation> emptyList().iterator(); } return channelAnnotations.getAnnotations( aStartIdx, aEndIdx ); }