package pl.wroc.pwr.imagechannel.basic; import pl.wroc.pwr.IOperator; import pl.wroc.pwr.imagechannel.IImageChannel; import pl.wroc.pwr.imagechannel.model.ImageChannel; public class MultiplyValue implements IOperator< IImageChannel >{ private IImageChannel inputChannel; private float value; private boolean inPlace; public MultiplyValue( IImageChannel channel, float value, boolean inPlace ) { this.inputChannel = channel; this.value = value; this.inPlace = inPlace; System.out.println("MultiplyValue on " + channel + " with value " + value + ", inPlace " + inPlace); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } public void setInPlace( boolean inPlace ) { this.inPlace = inPlace; } public void setValue( float value ) { this.value = value; } public IImageChannel apply( ) { if ( this.inputChannel == null ) { return null; } IImageChannel outputChannel = this.inPlace ? this.inputChannel : new ImageChannel( this.inputChannel.getSize( ) ); for ( int i = 0; i < this.inputChannel.getMaxIndex( ); i++ ) { outputChannel.setValue( i, this.inputChannel.getValue( i ) * this.value ); } return outputChannel; } }