net.algart.drawing3d
Interface ShapingRule

All Known Implementing Classes:
BunkerWallShapingRule, SphereShapingRule

public interface ShapingRule

Shaping rule: the converter of an abstract object to 3D figure, that can be drawn by this toolkit. The set of several shaping rules allows the main class Drawer3D of this toolkit to draw a collection of absolutely random objects (Collection<?>).

If you want to "teach" this toolkit to draw a new type of objects, you just need to provide necessary implementation of this interface, which will convert them to 3D figures, "known" to this toolkit. This interface is used by Drawer3D.draw(java.util.Collection) for conversion of the passed objects (Object type) into 3D figures (Shape3D), which are drawn with help of corresponding drawing rules.

The classes, implementing this interface, are usually immutable and always 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
 Shape3D getShape(java.lang.Object item)
          Returns the newly created shape of the specified 3D object.
 boolean isApplicable(java.lang.Object item)
          Checks whether this shaping rule is applicable to the given object (item), i.e. this shaping rule "knows" which 3D shape describes this object.
 

Method Detail

isApplicable

boolean isApplicable(java.lang.Object item)
Checks whether this shaping rule is applicable to the given object (item), i.e. this shaping rule "knows" which 3D shape describes this object. If this method returns false, you should not call getShape(Object) method of this interface for this object: it can throw an exception. If this method returns true, you can freely use getShape(Object) method.

If this method returns false for the given item for all shaping rules, available in Drawer3D object, and if this item does not implement Shape3D interface itself, 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 shaping rule can be used for this item.

getShape

Shape3D getShape(java.lang.Object item)
Returns the newly created shape of the specified 3D object. If isApplicable(Object) returns false, this method usually throws ClassCastException, but other runtime exceptions are also possible.

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


Hot at AlgART: HTML для чайников | Trinity for non-Christians | Диалог с Богом | Religion and Geometry