A few people have been confused about how Keith Albin's stylesheet parser fits with the rest of the system. In particular, there is a "Main" program in the parser directory, but that "Main" program is just a test harness to make sure the parser can accept the grammar of the style sheet. Unlike the older stylesheet parser (used by the Red and Blue teams), Keith's stylesheet parser does not produce an intermediate XML file representation of the style sheet.
So what does it do? If you call it from that Main class, it does basically nothing ... it builds some internal data structures and then throws them away. But take a look at StyleSheetReader.java in the actionscript directory --- this is where the parser is really called. It builds those data structures in the readStyles method, and then uses the data structures in the applyStyles method.
I don't know this code inside-out, but I think the basic logic goes something like this: We read the style sheet and create some internal tables with (keyword, value) pairs (which may actually be triples ... there is something called a "modifier" and I'm not certain what that is). Then we read all the map "shapes" from an XML file. Then, for each of those shapes, applyStyles looks in the tables and figures out what attributes should apply, and sticks those attributes into the shape object. Then we generate code (actionscript or a data structure for the Java display engine, as the case may be) using the shape information and all its style attributes.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment