Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 Style Rules that should also be saved/retrieved to/from the store:

...

Multiple stores might be loaded at once: System Store, Personal Store, Group Store, Experiment Store. Their information is grouped and managed by a #Style Style Registry

Style Rules

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 Style Order) for a given plot object.

...

  • does isVisible() belong to IBaseStyle?
  • can we plot an object by passing only an IDataStyle (rather than an IPlotterStyle)?

 

Ideas for Implementation

 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:

  • Object type: from the object itself
  • Object path: from AIDA tree, from initial user plotting request, or from the object
  • Plot order: from the current IPlotterRegion - is it overlay, if not how many objects are already plotted there
  • Action: program that is trying perform action should know what it is doing - plotting, printing, etc.
    • Action looks a lot like Category: "printing" -> "printing=true"
  • Category: this is an external parameter and has to come from separate service.
    • Can be part of Style Registry functionality, or independent service

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.

IStyleRegistry interface:

IPlotterStyle in StyleRegistry is identified by a name (styleName). Style names have to be unique.

Code Block

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);
}

IStyleRule interface:

Code Block

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);
}

IPlotterState interface:

Code Block

/**
 * 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);
   
}