use of android.filterfw.core.KeyValueMap in project android_frameworks_base by ParanoidAndroid.
the class FilterGraph method connectPorts.
private void connectPorts() {
int branchId = 1;
for (Entry<OutputPort, LinkedList<InputPort>> connection : mPreconnections.entrySet()) {
OutputPort outputPort = connection.getKey();
LinkedList<InputPort> inputPorts = connection.getValue();
if (inputPorts.size() == 1) {
outputPort.connectTo(inputPorts.get(0));
} else if (mAutoBranchMode == AUTOBRANCH_OFF) {
throw new RuntimeException("Attempting to connect " + outputPort + " to multiple " + "filter ports! Enable auto-branching to allow this.");
} else {
if (mLogVerbose)
Log.v(TAG, "Creating branch for " + outputPort + "!");
FrameBranch branch = null;
if (mAutoBranchMode == AUTOBRANCH_SYNCED) {
branch = new FrameBranch("branch" + branchId++);
} else {
throw new RuntimeException("TODO: Unsynced branches not implemented yet!");
}
KeyValueMap branchParams = new KeyValueMap();
branch.initWithAssignmentList("outputs", inputPorts.size());
addFilter(branch);
outputPort.connectTo(branch.getInputPort("in"));
Iterator<InputPort> inputPortIter = inputPorts.iterator();
for (OutputPort branchOutPort : ((Filter) branch).getOutputPorts()) {
branchOutPort.connectTo(inputPortIter.next());
}
}
}
mPreconnections.clear();
}
use of android.filterfw.core.KeyValueMap in project android_frameworks_base by ParanoidAndroid.
the class FrameFormat method mutableCopy.
public MutableFrameFormat mutableCopy() {
MutableFrameFormat result = new MutableFrameFormat();
result.setBaseType(getBaseType());
result.setTarget(getTarget());
result.setBytesPerSample(getBytesPerSample());
result.setDimensions(getDimensions());
result.setObjectClass(getObjectClass());
result.mMetaData = mMetaData == null ? null : (KeyValueMap) mMetaData.clone();
return result;
}
use of android.filterfw.core.KeyValueMap in project android_frameworks_base by ParanoidAndroid.
the class Filter method initWithAssignmentList.
public final void initWithAssignmentList(Object... keyValues) {
KeyValueMap valueMap = new KeyValueMap();
valueMap.setKeyValues(keyValues);
initWithValueMap(valueMap);
}
use of android.filterfw.core.KeyValueMap in project android_frameworks_base by ParanoidAndroid.
the class TextGraphReader method reset.
private void reset() {
mCurrentGraph = null;
mCurrentFilter = null;
mCommands.clear();
mBoundReferences = new KeyValueMap();
mSettings = new KeyValueMap();
mFactory = new FilterFactory();
}
use of android.filterfw.core.KeyValueMap in project android_frameworks_base by ParanoidAndroid.
the class TextGraphReader method readKeyValueAssignments.
private KeyValueMap readKeyValueAssignments(PatternScanner scanner, Pattern endPattern) throws GraphIOException {
// Our parser is a state-machine, and these are our states
final int STATE_IDENTIFIER = 0;
final int STATE_EQUALS = 1;
final int STATE_VALUE = 2;
final int STATE_POST_VALUE = 3;
final Pattern equalsPattern = Pattern.compile("=");
final Pattern semicolonPattern = Pattern.compile(";");
final Pattern wordPattern = Pattern.compile("[a-zA-Z]+[a-zA-Z0-9]*");
final Pattern stringPattern = Pattern.compile("'[^']*'|\\\"[^\\\"]*\\\"");
final Pattern intPattern = Pattern.compile("[0-9]+");
final Pattern floatPattern = Pattern.compile("[0-9]*\\.[0-9]+f?");
final Pattern referencePattern = Pattern.compile("\\$[a-zA-Z]+[a-zA-Z0-9]");
final Pattern booleanPattern = Pattern.compile("true|false");
int state = STATE_IDENTIFIER;
KeyValueMap newVals = new KeyValueMap();
String curKey = null;
String curValue = null;
while (!scanner.atEnd() && !(endPattern != null && scanner.peek(endPattern))) {
switch(state) {
case STATE_IDENTIFIER:
curKey = scanner.eat(wordPattern, "<identifier>");
state = STATE_EQUALS;
break;
case STATE_EQUALS:
scanner.eat(equalsPattern, "=");
state = STATE_VALUE;
break;
case STATE_VALUE:
if ((curValue = scanner.tryEat(stringPattern)) != null) {
newVals.put(curKey, curValue.substring(1, curValue.length() - 1));
} else if ((curValue = scanner.tryEat(referencePattern)) != null) {
String refName = curValue.substring(1, curValue.length());
Object referencedObject = mBoundReferences != null ? mBoundReferences.get(refName) : null;
if (referencedObject == null) {
throw new GraphIOException("Unknown object reference to '" + refName + "'!");
}
newVals.put(curKey, referencedObject);
} else if ((curValue = scanner.tryEat(booleanPattern)) != null) {
newVals.put(curKey, Boolean.parseBoolean(curValue));
} else if ((curValue = scanner.tryEat(floatPattern)) != null) {
newVals.put(curKey, Float.parseFloat(curValue));
} else if ((curValue = scanner.tryEat(intPattern)) != null) {
newVals.put(curKey, Integer.parseInt(curValue));
} else {
throw new GraphIOException(scanner.unexpectedTokenMessage("<value>"));
}
state = STATE_POST_VALUE;
break;
case STATE_POST_VALUE:
scanner.eat(semicolonPattern, ";");
state = STATE_IDENTIFIER;
break;
}
}
// Make sure end is expected
if (state != STATE_IDENTIFIER && state != STATE_POST_VALUE) {
throw new GraphIOException("Unexpected end of assignments on line " + scanner.lineNo() + "!");
}
return newVals;
}
Aggregations