All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ca.carleton.gcrc.olkit.multimedia.converter.threshold.ThresholdLogicalAnd Maven / Gradle / Ivy

Go to download

Library that converts multimedia files using command line tools such as avconv and ImageMagick

There is a newer version: 2.2.7
Show newest version
package ca.carleton.gcrc.olkit.multimedia.converter.threshold;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
import java.util.Vector;

import ca.carleton.gcrc.olkit.multimedia.converter.MultimediaConversionThreshold;

public class ThresholdLogicalAnd implements MultimediaConversionThreshold {

	private List children = new Vector(); 
	
	public void addThreshold(MultimediaConversionThreshold threshold) {
		children.add(threshold);
	}
	
	@Override
	public boolean isConversionRequired(String videoFormat, Long videoRate,
			String audioFormat, Long audioRate, Long imageWidth,
			Long imageHeight) {

		for(MultimediaConversionThreshold child : children) {
			if( false == child.isConversionRequired(videoFormat, videoRate, audioFormat, audioRate, imageWidth, imageHeight) ) {
				return false;
			}
		}
		
		return true;
	}

	@Override
	public boolean isResizeRequired(Long imageWidth, Long imageHeight) {
		for(MultimediaConversionThreshold child : children) {
			if( false == child.isResizeRequired(imageWidth, imageHeight) ) {
				return false;
			}
		}
		
		return true;
	}

	public String toString() {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		
		pw.print("and[");

		boolean first = true;
		for(MultimediaConversionThreshold child : children) {
			if( first ) {
				first = false;
			} else {
				pw.print("|");
			}
			pw.print( child.toString() );
		}
		
		pw.print("]");
		
		pw.flush();
		
		return sw.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy