net.algart.drawing3d
Interface ColoringRule

All Known Implementing Classes:
SimpleColoringRule

public interface ColoringRule

Coloring rule: the tool, choosing the color for drawing an abstract object. The set of several coloring rules allows the main class Drawer3D of this toolkit to get colors for the passed collection of any objects (Collection<?>).

If you want to "teach" this toolkit to choose colors of drawn objects, you just need to provide necessary implementation of this interface, which will choose for them some concrete colors. This interface is used by Drawer3D.draw(java.util.Collection) for choosing colors of the passed objects, which are drawn with help of corresponding drawing rules.

The classes, implementing this interface, are thread-safe: they can be used simultaneously in several threads.

AlgART Laboratory 2010

Since:
JDK 1.5
Version:
1.0
Author:
Daniel Alievsky

Method Summary
Modifier and Type Method and Description
 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.
 

Method Detail

isApplicable

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. If this method returns false, you should not call getColor(Object) method of this interface for this object: it can throw an exception. If this method returns true, you can freely use 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.

Parameters:
item - the object which you want to draw; can be null, then this method returns false.
Returns:
true if this coloring rule can be used for this item.

getColor

java.awt.Color getColor(java.lang.Object item)
Returns the color of the specified object. If isApplicable(Object) returns false, this method usually throws ClassCastException, but other runtime exceptions are also possible.

Parameters:
item - some 3D object.
Returns:
color of this item.
Throws:
java.lang.NullPointerException - if the argument is null.