/** * Returns whether a channel label is set or not. * * @param aChannelIdx * the channel index to check whether its label is set, >= 0 && < 32. * @return <code>true</code> if there a non-empty label set for the given * channel index, <code>false</code> otherwise. */ public boolean isChannelLabelSet( final int aChannelIdx ) { if ( ( aChannelIdx < 0 ) || ( aChannelIdx > ( Ols.MAX_CHANNELS - 1 ) ) ) { throw new IllegalArgumentException( "Invalid channel index: " + aChannelIdx + "! Should be between 0 and " + Ols.MAX_CHANNELS ); } final Channel channel = getAllChannels()[aChannelIdx]; return channel.hasName(); }
@Override public Component getListCellRendererComponent( final JList aList, final Object aValue, final int aIndex, final boolean aIsSelected, final boolean aCellHasFocus ) { StringBuilder sb = new StringBuilder(); if ( ( aValue != null ) && ( aValue instanceof Channel ) ) { final Channel channel = ( Channel )aValue; sb.append( channel.getIndex() ); if ( channel.hasName() ) { sb.append( ", " ).append( channel.getLabel() ); } } return super.getListCellRendererComponent( aList, sb.toString(), aIndex, aIsSelected, aCellHasFocus ); } }
out.println( ( channel != null ) && channel.hasName() ? channel.getLabel() : "" );
/** * 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() ); } }