cz.cuni.jagrlib
Class Piece

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultProperty
      extended by cz.cuni.jagrlib.Piece
All Implemented Interfaces:
Breakable, Property, Template
Direct Known Subclasses:
AdditiveNoise, AlphaGenerator, AlphaMatrix, AlphaWorker, AnimationWorker, AnisotropicMicrofacet, ArithmeticCodec, AudioFilter, AudioFilterWorker, AudioReplay, BezierCurve, BezierRegular, BezierWorker, BlinnMicrofacet, BlueScreen, BrepToImage, BufferedBitStream, Colormap332, Colormaps, ColorReduce, ColorReduceRound, ColorReduceWorker, CompressionWorker, CornellBox, CSG2BrepImpl, DataMatrix, DeadZoneQuantizer, DefaultBlockQuantizer, DefaultDiscreteTransform, DefaultFileFormat, DefaultFunctionR2ToR2, DefaultGeometrySearch, DefaultGraphicsViewer, DefaultImageFunction, DefaultImageSynthesizer, DefaultInputListener, DefaultIntFunction, DefaultLightSource, DefaultRasterGraphics, DefaultRealFunction, DefaultRender3D, DefaultSolid, DefaultValueTransferFunction, DepthSort, EffectBlur, EffectPixelize, Ellipse, EllipseWorker, FaceRenderFlat, Features, FeatureWarpingWorker, Filter1DNotch, FloodFillPoint, FloodFillWorker, FresnelConductor, FresnelDielectric, GlobalIlluminationWorker, GLWindow, GLWorker, GridRenderWorker, HDRMap, HuffmanCodec, CheckerTexture, ImageCompositionWorker, ImageCompressionWorker, ImageCompute, ImageConvert, ImageCrop, ImageFilterWorker, ImageKDTree, ImageTransition, IntervalArray, JavaBitStream, JavaText, JitteringSynthesizer, LambertianModel, LineAntialias, LineAntialiasSimple, LineAntiWorker, LinearQuantizer, LineBresenham, LineClipAntiWorker, LineClipping, LineClipWorker, LineWorker, LineWorkerStar, Lissajous, LZWCodec, MonteCarloFF, OrderedDither, OrderSerpentine, OrderSFC, OverwriteClassificator, PhotonMap, PhotonTracing, PolygonClip, PolygonClipWorker, PolygonFill, PolygonFillAnti, PolygonFillAntiWorker, PolygonFillWorker, PolylineAntialias, PolylineAntiWorker, ProjectionWorker, Radiosity, RadiosityEquations, RadiosityHierarch, RankFilter, Render3DWorker, SampleColormap, SampleRasterSearch, SampleRenderWorker, Search2DWorker, SFCDither, SimpleGLGraphics, SimpleSLEDataStore, SLEHierarchical, SLEProgressive, SLERelaxation, SolidColorBrush, SolidColorPen, SpotTexture, StaticCamera, StaticCSGScene, StraightRoulette, SuperShootGather, Test3DScene, TextWorker, TriangleWarpingWorker, VEFDS, WarpEngine, WarpingWorker, XTransitionList, ZigZagCodec, ZLIBCodec

public abstract class Piece
extends DefaultProperty
implements Template, Breakable

Basic piece for buildnig computer graphics algorithms (compositions).

Instances of Piece object act as nodes in graph of execution while instances of Channel object are connecting them as graph edges.

Since:
0.01
See Also:
Piece.java, Template

Field Summary
protected  java.util.Map<java.lang.String,Channel> channels
          Map of actually connected Channels (connected Plugs).
protected  InfoModule info
          XML-persistent data about this module instance.
protected  ProgressListener pl
          Progress listener object.
protected  java.util.Map<java.lang.String,Plug> plugs
          Map of Plugs (potential Channels).
static RegPiece reg
          Static registration instance for this class.
static java.lang.Class<?> TEMPLATE_TYPE
          Static instance of Class object for Template.
protected  boolean userBreak
          External break did occur?
 
Fields inherited from interface cz.cuni.jagrlib.Template
ALL_PLUGS, C_1D, C_2D, C_3D, C_ALPHA, C_BINARY, C_BREP, C_CAMERA, C_CIRCLE, C_CLIP, C_COMPRESSION, C_CURVE, C_DATA, C_DRAW, C_EDITOR, C_ELLIPSE, C_FILL, C_FILTER, C_FLOAT, C_FUNCTION, C_IMAGE, C_INTEGER, C_IO, C_LIGHT, C_LINE, C_METRIC, C_POLYGON, C_PROJECTION, C_RADIOSITY, C_RASTER, C_RENDER, C_SAMPLE, C_SCENE, C_SET, C_SOLID, C_TEXT, C_TRANSFORM, C_VECTOR, C_VIEWER, C_WORKER, CAT_EMPTY, EMPTY, IFACE, JAGRLIB, JAGRLIB2, MANIPULATOR_COMBO, MANIPULATOR_CUSTOM, MANIPULATOR_DEFAULT, MANIPULATOR_MULTILINE, PL_ALPHAMASK, PL_BITMASK, PL_CAUSTIC, PL_CODEC, PL_COLORMAP, PL_COMPARE, PL_DATA, PL_DIRECT, PL_EDITOR, PL_FILTER, PL_FUNCTION, PL_IMAGE, PL_IMPORT, PL_INPUT, PL_INTERSECTION, PL_LIGHTSOURCE, PL_ORDER, PL_OUTPUT, PL_PALETTE, PL_PHOTON, PL_PROPERTY, PL_QUANTIZER, PL_RASTER, PL_RENDER, PL_SHADOW, PL_STREAM, PL_TRANSFORM, PL_TRIGGER, PL_VOLUME, PL_WINDOW, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_STRING
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Constructor Summary
protected Piece()
          Default constructor: creates an empty instance (it should be assigned later).
 
Method Summary
protected  java.lang.String className()
           
 void connect(java.lang.String key, Piece other, java.lang.String otherKey)
          Connects the Piece to the other one through the given Plug.
 Plug findPlug(Plug pl)
          Finds Plug compatible with the given one.
 Plug findPlug(java.lang.String inputInterface, java.lang.String outputInterface, boolean cloneable, boolean multi)
          Finds Plug with the given parameters.
 InfoModule getInfo()
           
 java.lang.Object getInterface(java.lang.String key)
          Returns executable interface for the given channel.
 java.lang.Object getInterface(java.lang.String key, java.lang.String type)
          Returns executable interface for the given channel.
 Plug getPlug(java.lang.String key)
          Find a plug from its name.
 RegPiece getReg(int ord)
          Retrieves registration object (RegPiece) from a statically declared class member ("RegPiece reg" or "RegPiece[] reg").
 int init(int phase)
          Module initialization - called before any Worker.run().
 boolean isCompatible(Piece temp)
          Compatibility test: can I implement the given template?
 boolean isCompatible(Piece temp, java.util.Map<java.lang.String,java.lang.String> plugMap)
          Compatibility test: can I implement the given template?
 boolean isConnected(java.lang.String key)
          Tests whether the given plug is being used (connected).
protected  void logError(java.lang.String message)
          Writes error message (via LogFile) including the class's name.
protected  void logWarning(java.lang.String message)
          Writes warning message (via LogFile) including the class's name.
 java.lang.Object myInterface(Plug _plug)
          Returns interface of this Template object (callable from outside using the given Plug).
 void newInputPlug(java.lang.String key, java.lang.String _inputInterface)
          Connects a new input Plug.
 void newOptOutputPlug(java.lang.String key, java.lang.String _outputInterface)
          Connects a new optional output Plug.
 void newOutputPlug(java.lang.String key, java.lang.String _outputInterface)
          Connects a new output Plug.
 void newPlug(java.lang.String key, boolean _mandatory, boolean _multi, boolean _cloneable, java.lang.String _inputInterface, java.lang.String _outputInterface)
          Connects a new Plug.
 int noTemplates()
          Returns number of registration templates.
 void propBegin(java.lang.String name, java.lang.String type, java.lang.String descr, boolean visual)
          Starts definition of single property.
 void propBounds(java.lang.Object min, java.lang.Object max)
          Minimum and maximum allowed values (for comparable types only, non-mandatory).
 void propDefault(java.lang.Object value)
          Default value (non-mandatory).
 void propEnd()
          Finishes definition of the property.
 void propEnum(java.lang.String label, java.lang.Object value, java.lang.String descr)
          Adds next enum label (for list-box GUI).
 void propManipulator(int manipulatorType)
          Sets visual manipulator for GUI editing of the property.
 void propManipulator(java.lang.String className)
          Sets visual manipulator for GUI editing of the property.
 void setProgressListener(ProgressListener pl)
          Sets progress state listener.
 void setRegStrings(java.lang.String _name, java.lang.String _template, java.lang.String _category, java.lang.String _description)
          Sets registration strings for the module.
static int setTemplate(Template t, int ord)
          General-purpose registration routine.
 int setTemplateDynamic(Template t, int ord)
          Invokes statically declared method "setTemplate(Template,int)" for the given Piece instance.
 void stop()
          Tries to stop the thread/computation..
 
Methods inherited from class cz.cuni.jagrlib.DefaultProperty
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, get, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, set, stringProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userBreak

protected volatile boolean userBreak
External break did occur?


pl

protected ProgressListener pl
Progress listener object.


plugs

protected java.util.Map<java.lang.String,Plug> plugs
Map of Plugs (potential Channels).

See Also:
Plug

channels

protected java.util.Map<java.lang.String,Channel> channels
Map of actually connected Channels (connected Plugs).
Used in composition-execution mode.

See Also:
Channel

info

protected InfoModule info
XML-persistent data about this module instance.


reg

public static final RegPiece reg
Static registration instance for this class. Automatically initialized in class-loading time.


TEMPLATE_TYPE

public static final java.lang.Class<?> TEMPLATE_TYPE
Static instance of Class object for Template.

Constructor Detail

Piece

protected Piece()
Default constructor: creates an empty instance (it should be assigned later).
Uses template[0] as default (should be changed for multi-template modules?).

Method Detail

getInfo

public InfoModule getInfo()

newPlug

public void newPlug(java.lang.String key,
                    boolean _mandatory,
                    boolean _multi,
                    boolean _cloneable,
                    java.lang.String _inputInterface,
                    java.lang.String _outputInterface)
Connects a new Plug. General routine.

Specified by:
newPlug in interface Template
Parameters:
key - New plug's key.
_mandatory - Is that plug mandatory (has to be connected)?
_multi - Can that plug be used in multi-channels?
_cloneable - Is that plug "cloneable" (=generic)? If yes, ordinal numbers (starting from 0) will be appended to its name.
_inputInterface - Fully qualified identifier of input (implemented) interface.
_outputInterface - Fully qualified identifier of output (required) interface.

newInputPlug

public void newInputPlug(java.lang.String key,
                         java.lang.String _inputInterface)
Connects a new input Plug. Common-use routine: creates mandatory, non-cloneable, multi plug.

Specified by:
newInputPlug in interface Template
Parameters:
key - New plug's key.
_inputInterface - Fully qualified identifier of input (implemented) interface.

newOutputPlug

public void newOutputPlug(java.lang.String key,
                          java.lang.String _outputInterface)
Connects a new output Plug. Common-use routine: creates mandatory, non-cloneable, multi plug.

Specified by:
newOutputPlug in interface Template
Parameters:
key - New plug's key.
_outputInterface - Fully qualified identifier of output (required) interface.

newOptOutputPlug

public void newOptOutputPlug(java.lang.String key,
                             java.lang.String _outputInterface)
Connects a new optional output Plug. Common-use routine: creates optional, non-cloneable, multi plug.

Specified by:
newOptOutputPlug in interface Template
Parameters:
key - New plug's key.
_outputInterface - Fully qualified identifier of output (required) interface.

setRegStrings

public void setRegStrings(java.lang.String _name,
                          java.lang.String _template,
                          java.lang.String _category,
                          java.lang.String _description)
Sets registration strings for the module.

Specified by:
setRegStrings in interface Template

stop

public void stop()
Tries to stop the thread/computation.. The process should yield itself. For Runnable implementators: Thread.interrupt() will be called afterwards.

Specified by:
stop in interface Breakable

setProgressListener

public void setProgressListener(ProgressListener pl)
Sets progress state listener.

Specified by:
setProgressListener in interface Breakable

getPlug

public Plug getPlug(java.lang.String key)
Find a plug from its name.


findPlug

public Plug findPlug(java.lang.String inputInterface,
                     java.lang.String outputInterface,
                     boolean cloneable,
                     boolean multi)
Finds Plug with the given parameters.

Parameters:
inputInterface - Fully qualified input interface name (or null).
outputInterface - Fully qualified output interface name (or null).
cloneable - Should the Plug be cloneable?
multi - Should the Plug have the multi-channel property?
Returns:
The compatible Plug or null.

findPlug

public Plug findPlug(Plug pl)
Finds Plug compatible with the given one. Checks Plug interfaces only, neither names nor input/output flags are relevant.

Parameters:
pl - Plug template (interfaces are important here .. names, order, input/output are irrelevant).
Returns:
The compatible Plug or null.

isCompatible

public boolean isCompatible(Piece temp)
Compatibility test: can I implement the given template?

Parameters:
temp - Object which plays a role of an template.
Returns:
Returns true if I'm compatible with the temp object.

isCompatible

public boolean isCompatible(Piece temp,
                            java.util.Map<java.lang.String,java.lang.String> plugMap)
Compatibility test: can I implement the given template?

Parameters:
temp - Object which plays a role of an template.
plugMap - Mapping from temp's plugs into my ones (null for identity).
Returns:
Returns true if I'm compatible with the temp object.

myInterface

public java.lang.Object myInterface(Plug _plug)
Returns interface of this Template object (callable from outside using the given Plug).

Parameters:
_plug - The required Plug.
Returns:
Interface object to be called through the given Plug.

isConnected

public boolean isConnected(java.lang.String key)
Tests whether the given plug is being used (connected).


getInterface

public java.lang.Object getInterface(java.lang.String key)
Returns executable interface for the given channel.

Parameters:
key - String key (identical to Plug's one).
Returns:
Executable interface Object.

getInterface

public java.lang.Object getInterface(java.lang.String key,
                                     java.lang.String type)
Returns executable interface for the given channel. Checks for the interface type.

Parameters:
key - String key (identical to Plug's one).
type - Fully qualified interface type.
Returns:
Executable interface Object.
Throws:
BadInterfaceException

connect

public void connect(java.lang.String key,
                    Piece other,
                    java.lang.String otherKey)
             throws BadInterfaceException
Connects the Piece to the other one through the given Plug. Checks the Plug compatibility (throws the BadInterfaceException).

Parameters:
key - Local key.
other - The other Piece.
otherKey - The other Piece's key.
Throws:
BadInterfaceException - in case the Plugs are not compatible.

init

public int init(int phase)
Module initialization - called before any Worker.run(). Individual phases (starting at 0) will be called until maximum requested phase number is reached.

Parameters:
phase - Current phase number.
Returns:
Number of phases needed to initialize this module.

logError

protected void logError(java.lang.String message)
Writes error message (via LogFile) including the class's name.


logWarning

protected void logWarning(java.lang.String message)
Writes warning message (via LogFile) including the class's name.


noTemplates

public int noTemplates()
Returns number of registration templates.


getReg

public RegPiece getReg(int ord)
Retrieves registration object (RegPiece) from a statically declared class member ("RegPiece reg" or "RegPiece[] reg").

Parameters:
ord - Ordinal number of template to use..
See Also:
noTemplates()

setTemplateDynamic

public int setTemplateDynamic(Template t,
                              int ord)
Invokes statically declared method "setTemplate(Template,int)" for the given Piece instance.


setTemplate

public static int setTemplate(Template t,
                              int ord)
General-purpose registration routine. Sets all plugs, strings, etc. to the given Template.


propBegin

public void propBegin(java.lang.String name,
                      java.lang.String type,
                      java.lang.String descr,
                      boolean visual)
Starts definition of single property.

Specified by:
propBegin in interface Template
Parameters:
name - String identifier (unique inside one module class).
type - Value type - full Java class identifier.
descr - Brief textual description (for human eyes only).
visual - Should be this property represented visually in GUI?
See Also:
propEnd()

propDefault

public void propDefault(java.lang.Object value)
Default value (non-mandatory).

Specified by:
propDefault in interface Template

propBounds

public void propBounds(java.lang.Object min,
                       java.lang.Object max)
Minimum and maximum allowed values (for comparable types only, non-mandatory).

Specified by:
propBounds in interface Template

propManipulator

public void propManipulator(int manipulatorType)
Sets visual manipulator for GUI editing of the property. For predefined manipulators.

Specified by:
propManipulator in interface Template

propManipulator

public void propManipulator(java.lang.String className)
Sets visual manipulator for GUI editing of the property. For user-defined manipulators.

Specified by:
propManipulator in interface Template
Parameters:
className - Class name (either fully-qualified or local in package cz.cuni.jagrlib.gui).

propEnum

public void propEnum(java.lang.String label,
                     java.lang.Object value,
                     java.lang.String descr)
Adds next enum label (for list-box GUI).

Specified by:
propEnum in interface Template
Parameters:
label - Textual label to appear in the listbox.
value - Associated property value (real-value).
descr - Optional item's description (for human eyes only).

propEnd

public void propEnd()
Finishes definition of the property. Every property-definition segment started by propBegin(java.lang.String, java.lang.String, java.lang.String, boolean) must be properly closed by propEnd().

Specified by:
propEnd in interface Template
See Also:
propBegin(java.lang.String, java.lang.String, java.lang.String, boolean)

className

protected final java.lang.String className()