pedviz.view.rules
Class ColorRule

java.lang.Object
  extended by pedviz.view.rules.Rule
      extended by pedviz.view.rules.ColorRule

public class ColorRule
extends Rule

With this Rule you can define the color for a node, dependent on a given trait. It provides also the possibility to using up to 4 colors in the same symbol, how it's usual in pedigree drawing.

Author:
Lukas Forer

Field Summary
 
Fields inherited from class pedviz.view.rules.Rule
BOTH, ONLY_2D, ONLY_3D
 
Constructor Summary
ColorRule(java.lang.String userData, java.lang.Object value, java.awt.Color color)
          Constructs a new ColorRule with the given trait id, trait value and the given color.
 
Method Summary
 void addRule(java.lang.String userData, java.lang.Object value, java.awt.Color color)
          Adds a new trait to this rule.
 void applyRule(NodeView nodeview)
          Override this method, with it you get the NodeView and can adapt it.
 boolean isEnabled(int index)
          Returns true, if the rule with the given index is enabled.
 void setColor(int index, java.awt.Color color)
          Sets the color for the rule with the given index.
 void setCondition(int index, java.lang.String trait, java.lang.Object value)
          Sets the condition for the rule width the given index.
 void setEnabled(int index, boolean enabled)
          Enables or disables the rule with the given index.
 
Methods inherited from class pedviz.view.rules.Rule
getMode, isEnabled, setEnabled, setMode
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorRule

public ColorRule(java.lang.String userData,
                 java.lang.Object value,
                 java.awt.Color color)
Constructs a new ColorRule with the given trait id, trait value and the given color.

Parameters:
userData - trait identification
value - trait value
color - color
Method Detail

addRule

public void addRule(java.lang.String userData,
                    java.lang.Object value,
                    java.awt.Color color)
Adds a new trait to this rule. If you have two rules, the symbol will be divided. At 3 and 4 rules, the symbol will be quartered.

Parameters:
userData - trait identification
value - trait value
color - color

applyRule

public void applyRule(NodeView nodeview)
Description copied from class: Rule
Override this method, with it you get the NodeView and can adapt it. The class NodeView provides the method getNode() for getting a reference to the Node. *

Specified by:
applyRule in class Rule

setEnabled

public void setEnabled(int index,
                       boolean enabled)
Enables or disables the rule with the given index.

Parameters:
index - Index
enabled -

setCondition

public void setCondition(int index,
                         java.lang.String trait,
                         java.lang.Object value)
Sets the condition for the rule width the given index.

Parameters:
index - Index
trait - Trait
value - Value

setColor

public void setColor(int index,
                     java.awt.Color color)
Sets the color for the rule with the given index.

Parameters:
index - Index
color - Color

isEnabled

public boolean isEnabled(int index)
Returns true, if the rule with the given index is enabled.

Parameters:
index - Index
Returns:
true, if the rule with the given index is enabled.