Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

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:

  • object type: hep.aida.IHistogram1D, org.myproject.MyData1D
  • object path: with path expressions like "MC/**"
  • plot order: a specific order position, 0, 7 or a cyclical recurrence (3) -> every third plot
  • action: like printing (plots for printing might require less details)
  • category: "experiment=GLAST, quality=preliminary"

Style Registry

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:

  • passed style (when plotting)
  • explicit in annotation (like labels)
  • implicit:
    • action
    • category
    • plot order
    • path
    • type

Style Editor

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.

Comments to AIDA Styles

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

 

Ideas for Implementation

...

  • 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 or not, and if it is - how many objects are already plotted there
  • Attribute: arbitrary attributes in a form of "key=value" pair can be added
  • Action: program that is trying perform performing 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 a separate service. We must be able to keep track of multiple categories and their current values, e.g. "experiment=BaBar" _and_ "quality=draft"
    • Can be part of Style Registry functionality, or independent service
    • Example: selected by user from the list of available Categories - PAW style plots, GLAST style plots
    • Action looks a lot like Category: "printing" -> "printing=true"

If any styles are passed explicitly to the plotter, this implicit cumulative style will be set as parent (or merged in as a lower priority Style).

I've set three interfaces that might do the job (below), have a look.

IStyleRegistry interface:

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

Also StyleRegistry can manage the Categories: list of all available keys and set of current values.

Code Block

package hep.aida.ref.plotter.style.registry;

import hep.aida.IPlotterStyle;

public interface IStyleRegistry {    
   
    // Following methods are// usedTo forwork setupwith and save/restore of IStyleRegistryStyle Stores
   
    voidString[] addStyle(String styleName, IPlotterStyle stylegetAvailableStoreNames();
   
    booleanIStyleStore hasStylegetStore(String styleNamestoreName);
   
   
    // To work with categories, this can be a separate service
    IPlotterStyle getStyle(String styleName); // Available category keys are filled from Rules of all available Stores
   
    String[] getAllNamesgetAvailableCategoryKeys();
   
    IStyleRuleString[] getRulesForStylegetAvailableCategoryValues(String styleNamecategoryKey);
   
    void addRuleForStyle(String styleName, IStyleRule rule);
   
    void setRuleForStyleString getCategoryCurrentValue(String styleName, IStyleRule rulecategoryKey);
   
    void removeRuleForStylesetCategoryCurrentValue(String styleName, IStyleRule rule);
   
    void removeAllRulesForStyle(String styleName);
   categoryKey, String categoryValue);
   
    // Following methods are used to obtain cumulative IPlotterStyle
    // for particular plotter, region, object, action, and category(possibly) categories
   
    IPlotterStyle getStyleForState(IPlotterState state);
}

...

IStyleStore interface:

Style Rule has type and value. Also it has a priority - defines the order in which Style that corresponds to this Rule will be used if Rule does apply.

 

Code Block

package hep.aida.ref.plotter.style.registry;

import hep.aida.IPlotterStyle;

/**
 * This interface can be implemented as "In-Memory" copy of persistent
 * facility, or as keeping live connections and committing any change
 * immediately.
 */

public interface IStyleStore {
   
    // Key for AIDA type of object that the Style is going to be used with
    public static String STYLE_PREVIEW_TYPE = "STYLE_PREVIEW_TYPE";
   
    // Key for Style name
    public static String STYLE_STORE_NAME = "STYLE_STORE_NAME";
           
    String getStoreName();
   
    String getStoreType();
   
    boolean isReadOnly();
   
   
    // Manage Styles
   
    boolean hasStyle(String styleName);
   
    void addStyle(String styleName, IPlotterStyle style);
   
    void addStyle(String styleName, IPlotterStyle style, IStyleRule rule);
   
    IPlotterStyle getStyle(String styleName);
   
    /**
     * Remove Style and Rule associated with it from the Store
     */
    IPlotterStyle removeStyle(String styleName);
   
    String[] getAllStyleNames();
   
   
    // Create new Rule for this Store - Store acts as a Rule Factory
   
    IStyleRule createRule();
   
   
    // Manage Rules - only one rule per style is allowed
   
    IStyleRule getRuleForStyle(String styleName);
   
    void setRuleForStyle(String styleName, IStyleRule rule);
   
    void removeRuleForStyle(String styleName
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();
   
    /**
     * PriorityWrite all determinesinformation thefrom orderStore into whichthe correspondingundelying IPlotterStylepersistent
     * shouldfacility: beXML usedfile, when assembling the cumulative IPlotterStyledatabase, etc.
     */
    intvoid getPrioritycommit();
             
    String getValue();
   
    /**
     * DeterminesClose ifall thisconnections ruleand shouldfree beall usedresources.
     * Store is not usable after this method is executed.
     * 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 all this type/"key=value" complexity and do this:
     *//
    void close();
          
}

IStyleRule interface:

Style Rule contains expression that is evaluated at run-time

Code Block

package hep.aida.ref.plotter.style.registry;

public interface IStyleRule {

    public static String PATH = "Path";
    public static String OBJECT = "Object";
    public static String OBJECTTYPE = "ObjectType";
    public static String NULL = "Null";
    public static String ATTRIBUTE = "attribute(\"\")";
    public static String OVERLAYINDEX = "OverlayIndex";
    public static String OVERLAYTOTAL = "OverlayTotal";
    public static String REGIONINDEX = "RegionIndex";
    public static String REGIONTOTAL = "RegionTotal";
       
    String getDescription();
   
    // Evaluates the Rule   
    boolean ruleApplies(IPlotterState state);
}

How to Evaluate Style Rules

  • CLASS
    • Plotted object is exactly instance of specified class
    • Plotted object is derived from specified class
  • PATH
    • Path contains specified sub-path
      • Case sensitive
      • NOT Case sensitive
    • Regular expression
  • ORDER
    • Absolute number of overlaid plots, like 3-rd
    • Position in the recurring sequence, like 4-th out of 7
  • ATTRIBUTE: match "key=value" pair
    • Case sensitive
    • NOT Case sensitive
  • ACTION: match action name
    • Case sensitive
    • NOT Case sensitive
  • CATEGORY: match "key=value" pair
    • Case sensitive
    • NOT Case sensitive

IPlotterState interface:

Code Block

package hep.aida.ref.plotter.style.registry;

/**
 * This object encapsulates information about relevant
 * IPlotterRegion, object, action, and categoryactions.
 * It is used for obtaining implicit IPlotterStyle
 */

import java.util.Map;

public interface IPlotterState {

    static String ATTRIBUTE_KEY_PREFIX = "IPlotterState";
           
    Object getObject();   
    String getObjectPath();
   
    int getOverlayIndex();
    // IStyleRule types are used hereint getOverlayTotal();
   
    int getRegionIndex();
    int getRegionTotal();
   
    String getValueForType(int styleRuleType);
   getAttribute(String key);
   
    Map getAttributes();   
   
    void clear();
}