Versions Compared

Key

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

...

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 {

    // To work with Style Stores
   
    String[] getAvailableStoreNames();
   
    IStyleStore getStore(String storeName);
   
   
    // To work with categories, this can be a separate service
    // Available category keys are filled from Rules of all available Stores
   
    String[] getAvailableCategoryKeys();
   
    String getCategoryValue[] getAvailableCategoryValues(String categoryKey);
   
    String getCategoryCurrentValue(String categoryKey);
   
    void setCategoryCurrentValue(String categoryKey, String categoryValue);
   
    // Following methods are used to obtain cumulative IPlotterStyle
    // for particular plotter, region, object, action, and (possibly) categories
   
    IPlotterStyle getStyleForState(IPlotterState state);
}

IStyleStore interface:

All Rules that are added to a particular Style are assumed to have "AND" groupping 

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);
   
    booleanvoid hasStyleaddStyle(String styleName, IPlotterStyle style, IStyleRule rule);
   
    IPlotterStyle getStyle(String styleName);
   
    /**
     * Remove Style and allRule Rules associated with it from the Store
     */
    IPlotterStyle removeStyle(String styleName);
   
    String[] getAllStyleNames();
   
   
       // Create new RulesRule for this Store - orStore shouldacts weas havea Store-specific RuleFactory?

    Rule Factory
   
    IStyleRule createRule(int ruleType);

    IStyleRule createRuleFromDescription(String description);


       
   
    // Manage Rules

    IStyleRule[] getRulesForStyle(String styleName);
   
    void addRuleForStyle(String styleName, IStyleRule rule); - only one rule per style is allowed
   
    voidIStyleRule setRuleForStylegetRuleForStyle(String styleName, IStyleRule rule);
   
    void removeRuleForStylesetRuleForStyle(String styleName, IStyleRule rule);
   
    void removeAllRulesForStyleremoveRuleForStyle(String styleName);
   
    /**
     * Write all information from Store to the undelying persistent
     * facility: XML file, database, etc.
     */
    void commit();
          
    /**
     * Close all connections and free all resources.
     * Store is not usable after this method is executed.
     */
    void close();
          
}

IStyleRule interface:

Style Rule has type and value. Rule applies to the IPlotterState if state has approptiate type, and rule value is compatible with the state value. Rules can be logically groupped together with "OR" or "AND" operation.

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

contains expression that is evaluated at run-time

Code Block

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

public interface IStyleRule {

    public static String PATH // 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 ATTRIBUTE = 3; // Arbitrary "key=value" pair, evalyated by the Rule
                               // From AIDA object's annotation any entry with "plotterState." prefix in key
                               // will be stripped of this prefix and put into PlotterState with ATTRIBUTE
                               // type before obtaining Style from the StyleRegistry
     static int ACTION    = 4; // What is going to happen with the object: plotting, printing
     static int CATEGORY  = 5; // "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();

     // Should have some conventions for describing Rules (XML-based ?)
    = "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, including all added Rules
     Rule   
    boolean ruleApplies(IPlotterState state);

}


public interface IComplexStyleRule extends IStyleRule {

    // Operations that chain rules together
     static int OR  = 0;
     static int AND = 1;


     // Manage Rule Chaining

     void addRule(IStyleRule rule, int operation);

     int getNRules();

     int getRuleOperation(int n);

     IStyleRule getRule(int n);

     void removeRule(int n);
}

How to Evaluate Style Rules

...

IPlotterState interface:

Code Block
package hep.aida.ref.plotter.style.registry;/**
  * This object encapsulates information about relevant
  * IPlotterRegion, object, attributes, and actions.
  * It is used for obtaining implicit IPlotterStyle
  */
import java.util.Map;public interface IPlotterState {    static String ATTRIBUTE_KEY_PREFIX = "IPlotterState";
           
    Object getObject();   
    String  // IStyleRule types are used here
     String[] getValuesForType(int styleRuleTypegetObjectPath();
   
    int getOverlayIndex();
    int getOverlayTotal();
   
    int getRegionIndex();
    int getRegionTotal();
   
    String getAttribute(String key);
   
    Map getAttributes();   
   
    void clear();
}