/** * Determines whether or not there are annotations available for the signal * element. * * @return <code>true</code> if there are any annotations available for the * channel, <code>false</code> otherwise. */ private boolean hasAnnotations() { return !getChannel().getAnnotations().isEmpty(); } }
for ( Annotation<?> annotation : this.channel.getAnnotations() )
/** * Finds the first annotation that starts and ends after the given timestamp. * * @param aTimestamp * the timestamp to search for annotations, >= 0L. * @return an annotation matching the given timestamp criteria, * <code>null</code> if not found. */ public DataAnnotation<?> getAnnotationAfter( final long aTimestamp ) { SortedSet<Annotation<?>> annotations = new TreeSet<Annotation<?>>( this.channel.getAnnotations() ); for ( Annotation<?> annotation : annotations ) { if ( !( annotation instanceof DataAnnotation<?> ) ) { continue; } final DataAnnotation<?> ann = ( DataAnnotation<?> )annotation; final long annStartTime = ann.getStartTimestamp(); final long annEndTime = ann.getEndTimestamp(); if ( ( annStartTime >= aTimestamp ) && ( annEndTime >= aTimestamp ) ) { return ann; } } return null; }
SortedSet<Annotation<?>> annotations = new TreeSet<Annotation<?>>( this.channel.getAnnotations() ); for ( Annotation<?> annotation : annotations )
/** * Finds the annotation that starts before the given timestamp, and ends at or * after the given timestamp. * * @param aTimestamp * the timestamp to search for annotations, >= 0L. * @return an annotation matching the given timestamp criteria, * <code>null</code> if not found. */ public DataAnnotation<?> getAnnotation( final long aTimestamp ) { DataAnnotation<?> result = null; for ( Annotation<?> annotation : this.channel.getAnnotations() ) { if ( !( annotation instanceof DataAnnotation<?> ) ) { continue; } final DataAnnotation<?> ann = ( DataAnnotation<?> )annotation; final long annStartTime = ann.getStartTimestamp(); final long annEndTime = ann.getEndTimestamp(); if ( ( annStartTime <= aTimestamp ) && ( annEndTime >= aTimestamp ) ) { result = ann; break; } } return result; }
/** * Creates a new {@link ChannelImpl} instance based on a given channel. * * @param aChannel * the channel to copy, cannot be <code>null</code>; * @param aRetainAnnotation * <code>true</code> if any annotations should be retained, * <code>false</code> otherwise. */ public ChannelImpl( final Channel aChannel, final boolean aRetainAnnotation ) { if ( aChannel == null ) { throw new IllegalArgumentException( "Channel cannot be null!" ); } this.propertyChangeSupport = new PropertyChangeSupport( this ); this.index = aChannel.getIndex(); this.mask = aChannel.getMask(); this.label = aChannel.hasName() ? aChannel.getLabel() : null; this.enabled = aChannel.isEnabled(); this.annotations = new CopyOnWriteArrayList<Annotation<?>>(); if ( aRetainAnnotation ) { this.annotations.addAll( aChannel.getAnnotations() ); } }