artofillusion.procedural
Class Module

java.lang.Object
  extended by artofillusion.procedural.Module
Direct Known Subclasses:
AbsModule, BiasModule, BlendModule, BlurModule, BrickModule, CellsModule, CheckerModule, ClipModule, ColorDarkenModule, ColorDifferenceModule, ColorLightenModule, ColorModule, ColorProductModule, ColorScaleModule, ColorSumModule, CommentModule, CompareModule, CoordinateModule, CosineModule, DifferenceModule, ExpModule, ExprModule, FunctionModule, GainModule, GridModule, HLSModule, HSVModule, ImageModule, InterpModule, JitterModule, LogModule, MarbleModule, MaxModule, MinModule, ModModule, NoiseModule, NumberModule, OutputModule, ParameterModule, PolarModule, PowerModule, ProductModule, RandomModule, RatioModule, RGBModule, ScaleShiftModule, SineModule, SpectrumModule, SphericalModule, SqrtModule, SumModule, TransformModule, TurbulenceModule, ViewAngleModule, WoodModule

public class Module
extends java.lang.Object

This represents a module in a procedure. This is an abstract class, whose subclasses represent specific kinds of modules.


Field Summary
 Module[] linkFrom
           
 int[] linkFromIndex
           
 
Constructor Summary
Module(java.lang.String name, IOPort[] input, IOPort[] output, java.awt.Point position)
           
 
Method Summary
 void calcSize()
          Calculate the size on the screen of this module.
 boolean checkFeedback()
          This method is used to check feedback loops in a procedure.
 void draw(java.awt.Graphics2D g, boolean selected)
          Draw the module on the screen.
 Module duplicate()
          Create a duplicate of this module.
 boolean edit(BFrame fr, Scene theScene)
          This is an old form of edit() that exists only to maintain compatibility with old plugins.
 boolean edit(ProcedureEditor editor, Scene theScene)
          This should display a user interface for editing the module, and return true if the module is changed.
 double getAverageValue(int which, double blur)
          Get the average value of the specified output port.
 java.awt.Rectangle getBounds()
          Get the boundary rectangle for this module.
 IOPort getClickedPort(java.awt.Point pos)
          Determine whether the specified point is over an IOPort, and if so, return the port.
 void getColor(int which, RGBColor color, double blur)
          Get the color of the specified output port.
 int getInputIndex(IOPort port)
          Get the index of a particular input port.
 IOPort[] getInputPorts()
          Get a list of the input ports for this module.
 java.lang.String getName()
          Get the name of this module.
 int getOutputIndex(IOPort port)
          Get the index of a particular output port.
 IOPort[] getOutputPorts()
          Get a list of the output ports for this module.
 double getValueError(int which, double blur)
          Get the uncertainty in the value of the specified output port.
 void getValueGradient(int which, Vec3 grad, double blur)
          Get the gradient of the value of the specified output port.
 void init(PointInfo p)
          This method initializes the module in preparation for evaluating the procedure at a new point.
 boolean inputConnected(int which)
          Determine whether an input port is connected to anything.
 void layout()
          Layout the module's onscreen representation.
 void readFromStream(java.io.DataInputStream out, Scene theScene)
          Read in the module's parameters from an input stream.
 void setInput(IOPort which, IOPort port)
          Specify the module and port which one of the input ports is connected to.
 void setPosition(int x, int y)
          Move this module to a new location.
 void writeToStream(java.io.DataOutputStream out, Scene theScene)
          Write out the module's parameters to an output stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

linkFrom

public Module[] linkFrom

linkFromIndex

public int[] linkFromIndex
Constructor Detail

Module

public Module(java.lang.String name,
              IOPort[] input,
              IOPort[] output,
              java.awt.Point position)
Method Detail

getName

public java.lang.String getName()
Get the name of this module.


getBounds

public java.awt.Rectangle getBounds()
Get the boundary rectangle for this module.


setPosition

public void setPosition(int x,
                        int y)
Move this module to a new location.


getInputPorts

public IOPort[] getInputPorts()
Get a list of the input ports for this module.


getOutputPorts

public IOPort[] getOutputPorts()
Get a list of the output ports for this module.


getInputIndex

public int getInputIndex(IOPort port)
Get the index of a particular input port.


getOutputIndex

public int getOutputIndex(IOPort port)
Get the index of a particular output port.


inputConnected

public boolean inputConnected(int which)
Determine whether an input port is connected to anything.


getClickedPort

public IOPort getClickedPort(java.awt.Point pos)
Determine whether the specified point is over an IOPort, and if so, return the port.


setInput

public void setInput(IOPort which,
                     IOPort port)
Specify the module and port which one of the input ports is connected to.


calcSize

public void calcSize()
Calculate the size on the screen of this module. The default implementation makes it large enough to display the name of the module.


layout

public void layout()
Layout the module's onscreen representation. This should be called any time the module is moved or resized.


draw

public void draw(java.awt.Graphics2D g,
                 boolean selected)
Draw the module on the screen. This draws the outline and the ports, then calls drawContents() to draw the contents.


checkFeedback

public boolean checkFeedback()
This method is used to check feedback loops in a procedure.


edit

public boolean edit(ProcedureEditor editor,
                    Scene theScene)
This should display a user interface for editing the module, and return true if the module is changed. The default implementation does nothing.

Parameters:
editor - the ProcedureEditor in which this module is being edited
theScene - the Scene to which this module belongs
Returns:
true if the edits were accepted, false if they should be cancelled. Returning false will cause all edits to be reverted automatically. The module does not need to do that itself.

edit

public boolean edit(BFrame fr,
                    Scene theScene)
This is an old form of edit() that exists only to maintain compatibility with old plugins. Subclasses should override the other form, not this one.


init

public void init(PointInfo p)
This method initializes the module in preparation for evaluating the procedure at a new point. The default implementation does nothing. Subclasses whose output depends on the point should override this method.


getAverageValue

public double getAverageValue(int which,
                              double blur)
Get the average value of the specified output port. If the specified output port does not have a value type of NUMBER, the result is undefined. Blur specifies the amount of smoothing to use. Subclasses which can return values should override this method.


getValueError

public double getValueError(int which,
                            double blur)
Get the uncertainty in the value of the specified output port. If the specified output port does not have a value type of NUMBER, the result is undefined. Blur specifies the amount of smoothing to use. Subclasses which can return values should override this method.


getValueGradient

public void getValueGradient(int which,
                             Vec3 grad,
                             double blur)
Get the gradient of the value of the specified output port. If the specified output port does not have a value type of NUMBER, the result is undefined. Blur specifies the amount of smoothing to use. Subclasses which can return values should override this method.


getColor

public void getColor(int which,
                     RGBColor color,
                     double blur)
Get the color of the specified output port. If the specified output port does not have a value type of COLOR, the result is undefined. Blur specifies the amount of smoothing to use. Subclasses which can return colors should override this method.


duplicate

public Module duplicate()
Create a duplicate of this module. Subclasses with adjustable parameters should override this.


writeToStream

public void writeToStream(java.io.DataOutputStream out,
                          Scene theScene)
                   throws java.io.IOException
Write out the module's parameters to an output stream. Subclasses with editable parameters should override this method.

Throws:
java.io.IOException

readFromStream

public void readFromStream(java.io.DataInputStream out,
                           Scene theScene)
                    throws java.io.IOException
Read in the module's parameters from an input stream. Subclasses with editable parameters should override this method.

Throws:
java.io.IOException


Copyright © 1999-2011 by Peter Eastman.