use of tc.oc.pgm.filters.FilterNode in project PGM by PGMDev.
the class RegionFilterApplicationParser method parse.
public void parse(Element el) throws InvalidXMLException {
Region region = parseRegion(el);
Component message = XMLUtils.parseFormattedText(el, "message");
boolean earlyWarning = XMLUtils.parseBoolean(el.getAttribute("early-warning"), false);
Filter effectFilter = filterParser.parseFilterProperty(el, "filter");
Kit kit = factory.getKits().parseKitProperty(el, "kit");
if (kit != null) {
add(el, new RegionFilterApplication(RFAScope.EFFECT, region, effectFilter, kit, false));
}
kit = factory.getKits().parseKitProperty(el, "lend-kit");
if (kit != null) {
add(el, new RegionFilterApplication(RFAScope.EFFECT, region, effectFilter, kit, true));
}
Attribute attrVelocity = el.getAttribute("velocity");
if (attrVelocity != null) {
// Legacy support
String velocityText = attrVelocity.getValue();
if (velocityText.charAt(0) == '@')
velocityText = velocityText.substring(1);
Vector velocity = XMLUtils.parseVector(attrVelocity, velocityText);
add(el, new RegionFilterApplication(RFAScope.EFFECT, region, effectFilter, velocity));
}
for (String tag : RFAScope.byTag.keySet()) {
Filter filter;
if (useId()) {
filter = filterParser.parseFilterProperty(el, tag);
} else {
// Legacy syntax allows a list of filter names in the attribute
Node node = Node.fromAttr(el, tag);
if (node == null) {
filter = null;
} else {
List<Filter> filters = new ArrayList<>();
for (String name : Splitter.on(" ").split(node.getValue())) {
filters.add(filterParser.parseReference(node, name));
}
switch(filters.size()) {
case 0:
filter = null;
break;
case 1:
filter = filters.get(0);
break;
default:
filter = new FilterNode(filters, Collections.<Filter>emptyList(), Collections.<Filter>emptyList());
}
}
}
if (filter != null) {
for (RFAScope scope : RFAScope.byTag.get(tag)) {
add(el, new RegionFilterApplication(scope, region, filter, message, earlyWarning));
}
}
}
}
Aggregations