/** * Returns the channel label. * * @param aChannelIdx * the index of the channel to retrieve the label for, >= 0 && < * {@value nl.lxtreme.ols.api.Ols#MAX_CHANNELS}. * @return the channel's label, can be <code>null</code>. */ public String getChannelLabel( 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 ); } return getAllChannels()[aChannelIdx].getLabel(); }
/** * 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(); }
/** * Sets the channel label. * * @param aChannelIdx * the index of the channel to set the label for, >= 0 && < 32; * @param aLabel * the label to set, may be <code>null</code>. */ public void setChannelLabel( final int aChannelIdx, final String aLabel ) { if ( ( aChannelIdx < 0 ) || ( aChannelIdx > ( Ols.MAX_CHANNELS - 1 ) ) ) { throw new IllegalArgumentException( "Invalid channel index: " + aChannelIdx + "! Should be between 0 and " + Ols.MAX_CHANNELS ); } getAllChannels()[aChannelIdx].setLabel( aLabel ); }
/** * Sets all channel labels directly. * * @param aLabels * the array of labels to set, cannot be <code>null</code>. */ public void setChannelLabels( final String[] aLabels ) { if ( aLabels.length != Ols.MAX_CHANNELS ) { throw new IllegalArgumentException( "Invalid channel labels! Should have exact " + Ols.MAX_CHANNELS + " items!" ); } for ( int i = 0; i < aLabels.length; i++ ) { getAllChannels()[i].setLabel( aLabels[i] ); } }