|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.algart.drawing3d.SimpleColoringRule
public class SimpleColoringRule extends java.lang.Object implements ColoringRule
Simple implementation of ColoringRule
interface, which returns some given color
for all inheritors of some given class.
More precisely, this rule works with some fixed requiredClass, passed to the constructor,
and isApplicable(Object item)
method returns true if and only if
requiredClass.isInstance(item).
The method getColor(Object)
of this class always returns the fixed color,
also passed to the constructor.
This class is thread-safe: it can be used simultaneously in several threads.
AlgART Laboratory 2010
Constructor and Description |
---|
SimpleColoringRule(java.lang.Class<?> requiredClass,
java.awt.Color color)
Creates new instance of this class. |
Modifier and Type | Method and Description |
---|---|
java.awt.Color |
getColor()
Returns the color, which will be returned by getColor(Object) method. |
java.awt.Color |
getColor(java.lang.Object item)
Returns the color of the specified object. |
boolean |
isApplicable(java.lang.Object item)
Checks whether this coloring rule is applicable to the given object (item), i.e. this coloring rule "knows" which color should be used for drawing this object. |
void |
setColor(java.awt.Color color)
Sets the color, which will be returned by getColor(Object) method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleColoringRule(java.lang.Class<?> requiredClass, java.awt.Color color)
isApplicable(Object item)
method is equivalent to
requiredClass
- the class, which will be checked by isApplicable(Object)
method.
Cannot be changed in future.color
- the color, which will be returned by getColor(Object)
method.Method Detail |
---|
public java.awt.Color getColor()
getColor(Object)
method.
public void setColor(java.awt.Color color)
getColor(Object)
method.
color
- new current color.public boolean isApplicable(java.lang.Object item)
ColoringRule
ColoringRule.getColor(Object)
method of this interface
for this object: it can throw an exception.
If this method returns true, you can freely use ColoringRule.getColor(Object)
method.
If this method returns false for the given item for all coloring rules, available
in Drawer3D
object, then this item is not drawn by the
Drawer3D.draw(java.util.Collection)
method.
The argument of this method can be null; in this case, this method returns false.
isApplicable
in interface ColoringRule
item
- the object which you want to draw; can be null, then this method returns false.public java.awt.Color getColor(java.lang.Object item)
ColoringRule
ColoringRule.isApplicable(Object)
returns false, this method usually throws
ClassCastException, but other runtime exceptions are also possible.
getColor
in interface ColoringRule
item
- some 3D object.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |