Class Biojs.Ruler
Version
1.0.1.
Extends
Biojs.
Defined in: Biojs.Ruler.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Biojs.Ruler(options)
Ruler is a component to deal with the definition and interaction of rules that follow the structure:
In [LOCATION] [ACTION] the [TARGET] with [CONDITION] [PARAMETERS]
The component receives a JSON structure defining the values of the different parts of the rule and it
generates forms and lists.
|
| Field Attributes | Field Name and Description |
|---|---|
| <inner> |
Array containing the supported event names
|
| <inner> |
Default values for the options
|
| Method Attributes | Method Name and Description |
|---|---|
|
addActiveRule(rule, n)
Add a rule to the active rules' set.
|
|
|
addRule(rule)
Add a rule to the new rule panel.
|
|
|
changeRules(rules)
Change the Rules' model.
|
|
|
constructor(options)
|
|
|
Get an array with the active rules
|
|
|
setAffectedByRule(id, number)
Set the number of affected values by a given rule
|
- Methods borrowed from class Biojs:
- addListener, extend, getId, listen, raiseEvent, setEventHandlers, setOptions
| Event Attributes | Event Name and Description |
|---|---|
|
onOrderChanged(actionPerformed)
|
|
|
onRuleCreated(actionPerformed)
|
|
|
onRuleEditing(actionPerformed)
|
|
|
onRuleRemoved(actionPerformed)
|
Class Detail
Biojs.Ruler(options)
Ruler is a component to deal with the definition and interaction of rules that follow the structure:
In [LOCATION] [ACTION] the [TARGET] with [CONDITION] [PARAMETERS]
The component receives a JSON structure defining the values of the different parts of the rule and it
generates forms and lists.
The component generates events when rules are created, removed or reordered.
Author: Gustavo A. Salazar.
Author: Gustavo A. Salazar.
var instance = new Biojs.Ruler({
target: "YourOwnDivId",
allowOrdering:true,
rules:{
"location": [
"all proteins",
"protein1",
"protein2",
"protein3",
"protein4"
],
"target": [
{
"name": "Proteins",
"action": [
{name:"Show",type:"single"},
{name:"Hide",type:"single"},
{name:"Highlight",type:"single"},
{name:"Color",type:"color"},
{name:"Color Range",type:"colorRange"},
{name:"Show Label",type:"select",options:["ID","Functional Class","Organism","Gene Name"]}
],
"conditions": [
{
"name": "interactions with",
"type": "selects",
"amount": 1,
"values": [
"protein1",
"protein2",
"protein3",
"protein4"
]
},
{
"name": "number of interactions",
"type": "numeric_comparison"
},
{
"name": "accession number",
"type": "text_comparison"
}
]
},
{
"name": "Interactions",
"action": [
{name:"Show",type:"single"},
{name:"Hide",type:"single"},
{name:"Highlight",type:"single"},
{name:"Color",type:"color"},
],
"conditions": [
{
"name": "protein",
"type": "selects",
"amount": 1,
"values": [
"protein1",
"protein2",
"protein3",
"protein4"
]
},
{
"name": "proteins",
"type": "selects",
"amount": 2,
"values": [
"protein1",
"protein2",
"protein3",
"protein4"
]
},
{
"name": "score",
"type": "numeric_comparison"
}
]
}
]
}
});
- Parameters:
- {Object} options
- An object with the options for the Ruler component.
- Options detailed:
- {string} target
- Identifier of the DIV tag where the component should be displayed.
- {boolean} [allowOrdering=true]
- The list of created rules can be reordered by drag&drop, it requires the jquery ui dependencies
- {Object} rules
- A json stucture defining, the rules, possible values, conditions, etc. An example of the structure here:
{ "location": [ "Some part of the page" ], "action": ["Action 1", "Action 2", "Action 3" ], "target": [ { "name": "First Target", "conditions": [ { "name": "Select from", "type": "selects", "amount": 1, "values": ["An Option","another option" ] }, { "name": "number", "type": "numeric_comparison" }, { "name": "some text", "type": "text_comparison" } ] } ] }
Field Detail
<inner>
eventTypes
Array containing the supported event names
<inner>
opt
Default values for the options
Method Detail
addActiveRule(rule, n)
Add a rule to the active rules' set. this method can be invoked from an external script, be careful when using by
following the rules' model.
instance.addActiveRule({location:"protein1", action:"Color", target:"Proteins", condition:"number of interactions", parameters:["==","2"], color:"#F00"});
- Parameters:
- {object} rule Optional
- A rule with predefined values as an Object that contain the fields: location, action, target, condition, parameters, color
- n
addRule(rule)
Add a rule to the new rule panel. this method can be invoked from an external script, be careful when using to
create rules that follow the rules' model.
instance.addRule({location:"protein1", action:"Color", target:"Proteins", condition:"number of interactions", parameters:["==","2"], color:"#F00"});
- Parameters:
- {object} rule Optional
- A rule with predefined values as an Object that contain the fields: location, action, target, condition, parameters, color
changeRules(rules)
Change the Rules' model. Warning: this method does not take care of rules that have been defined with a previous model.
instance.changeRules({
"location": [ "Some part of the page" ],
"action": ["Action 1", "Action 2", "Action 3" ],
"target": [ {
"name": "First Target",
"conditions": [ {
"name": "Select from",
"type": "selects",
"amount": 1,
"values": ["An Option","another option" ]
}, {
"name": "number",
"type": "numeric_comparison"
}, {
"name": "some text",
"type": "text_comparison"
} ]
} ]
});
- Parameters:
- {object} rules
- A json stucture defining, the rules, possible values, conditions, etc. See the example for the the constructor.
constructor(options)
- Parameters:
- options
getActiveRules()
Get an array with the active rules
instance.getActiveRules();
setAffectedByRule(id, number)
Set the number of affected values by a given rule
instance.setAffectedByRule('YourOwnDivId_rule_1',58);
- Parameters:
- {string} id
- The id of the rule wich affecte value is going to be set.
- {integer} number
- The amount of entities affected by the rule.
Event Detail
onOrderChanged(actionPerformed)
instance.onOrderChanged(
function( objEvent ) {
alert("Order has changed");
}
);
- Parameters:
- {function} actionPerformed
- A function which receives an Biojs.Event object as argument.
- Event object data:
- {Object} source
- The component which did triggered the event.
- {Array} rules
- Array with all the active rules. Each rule is an Object that contain the fields: location, action, target, condition, parameters, id, color
onRuleCreated(actionPerformed)
instance.onRuleCreated(
function( objEvent ) {
alert("New rule: In "+objEvent.new_rule.location+" "+objEvent.new_rule.action+" the "+objEvent.new_rule.target+" with "+objEvent.new_rule.condition+" "+objEvent.new_rule.parameters.join()+"");
}
);
- Parameters:
- {function} actionPerformed
- A function which receives an Biojs.Event object as argument.
- Event object data:
- {Object} source
- The component which did triggered the event.
- {Object} new_rule
- The rule that has been created. The rule Object contain the fields: location, action, target, condition, parameters(array), id, color
- {Array} rules
- Array with all the active rules. Each rule is an Object that contain the fields: location, action, target, condition, parameters, id, color
onRuleEditing(actionPerformed)
instance.onRuleEditing(
function( objEvent ) {
alert("Editing Rule: In "+objEvent.editing.location+" "+objEvent.editing.action+" the "+objEvent.editing.target+" with "+objEvent.editing.condition+" "+objEvent.editing.parameters.join()+"");
}
);
- Parameters:
- {function} actionPerformed
- A function which receives an Biojs.Event object as argument.
- Event object data:
- {Object} source
- The component which did triggered the event.
- {Object} editing
- The rule that has been selected to be edited. The rule Object contain the fields: location, action, target, condition, parameters(array), id, color
- {Array} rules
- Array with all the active rules. Each rule is an Object that contain the fields: location, action, target, condition, parameters, id, color
onRuleRemoved(actionPerformed)
instance.onRuleRemoved(
function( objEvent ) {
alert("Rule removed: In "+objEvent.removed.location+" "+objEvent.removed.action+" the "+objEvent.removed.target+" with "+objEvent.removed.condition+" "+objEvent.removed.parameters.join()+"");
}
);
- Parameters:
- {function} actionPerformed
- A function which receives an Biojs.Event object as argument.
- Event object data:
- {Object} source
- The component which did triggered the event.
- {Object} removed
- The rule that has been removed. The rule Object contain the fields: location, action, target, condition, parameters(array), id, color
- {Array} rules
- Array with all the active rules. Each rule is an Object that contain the fields: location, action, target, condition, parameters, id, color