This is a collection of thoughts on AIDA Styles and on their use in the new plotter.
This is an object that can save and retrieve styles from a store (xml file on disk, database table). The basic xml style definition is the AIDA one. Next to the style itself we also identified the need to define Style Rules that should also be saved/retrieved to/from the store:
<styleStore> <styles> <style> ....... <rules> <rule> ....... </rule> </rules> </style> </styles> </styleStore> |
Multiple stores might be loaded at once: System Store, Personal Store, Group Store, Experiment Store. Their information is grouped and managed by a Style Registry
It should be possible to define rules on how to attach a style to a particular plot object. Multiple rules might be applied to a given style. It should be possible to apply rules to:
A style registry combines the styles and rules from different style stores and provides the right set of styles (with the appropriate Style Order) for a given plot object.
We have to define the order in which the styles are applied to an object:
GUI front end for viewing and editing individual styles or combinations of styles.
We already have a first version of the style editor. We need to add the possibility to view the information contained in a style registry, i.e. the chain of styles contributing to a given object and the set of rules that have contributed to it.
Let's leave Style Store out of this discussion just for the moment.
So Style Registry is created and is getting populated by (or just acts as a manager/façade for) the Style Stores, but it has access to Style/Rules information.
Just before object is plotted/printed and we know the object's path in a Tree, object's type, order of the object in particular IPlotterRegion, etc. All this information is used to query the Style Registry and create a cumulative IPlotterStyle for the implicit parameters.
Information that we need:
If any styles are passed explicitly to the plotter, this cumulative style will be set as parent (or merged in).
I've set three interfaces that might do the job (below), have a look.
IPlotterStyle in StyleRegistry is identified by a name (styleName). Style names have to be unique.
public interface IStyleRegistry { // Following methods are used for setup and save/restore of IStyleRegistry void addStyle(String styleName, IPlotterStyle style); boolean hasStyle(String styleName); IPlotterStyle getStyle(String styleName); String[] getAllNames(); IStyleRule[] getRulesForStyle(String styleName); void addRuleForStyle(String styleName, IStyleRule rule); void setRuleForStyle(String styleName, IStyleRule rule); void removeRuleForStyle(String styleName, IStyleRule rule); void removeAllRulesForStyle(String styleName); // Following methods are used to obtain cumulative IPlotterStyle // for particular region, object, and action IPlotterStyle getStyleForState(IPlotterState state); } |
public interface IStyleRule { // Possible types of Style Rules static int CLASS = 0; // Class of the object: hep.aida.IHistogram1D static int PATH = 1; // Position of the object in a Tree static int ORDER = 2; // Order in the IPlotterRegion: specific number, or cyclical static int ACTION = 3; // What is going to happen with the object: plotting, printing static int CATEGORY = 4; // "experiment=GLAST", "quality=preliminary" // ACTION seems like a sub-type of CATEGORY: "printing=true" int getType(); /** * Priority determines the order in which corresponding IPlotterStyle * should be used when assembling the cumulative IPlotterStyle */ int getPriority(); String getValue(); /** * Determines if this rule should be used. * * If type=CATEGORY, same rule as for AIDA options should be applied: * have to pass "key=value" pair as value, for only "key" -> "key=true", */ boolean ruleApplies(int type, String value); /** * Or maybe it is better to hide this type/"key=value" complexity and do this: */ boolean ruleApplies(IPlotterState state); } |
/** * This object encapsulates information about relevant * IPlotterRegion, object, action, and category. * It is used for obtaining implicit IPlotterStyle */public interface IPlotterState { // IStyleRule types are used here String getValueForType(int styleRuleType); } |