scphEditor
Class EmbeddingFixed

java.lang.Object
  extended by scphEditor.EmbeddingFixed
All Implemented Interfaces:
IEmbedding

public class EmbeddingFixed
extends java.lang.Object
implements IEmbedding

An EmbeddingFixed object encapsulates presentation styles, in AWT terms, of an operator and its operands. The operator is assumed to have a fixed number of operands, e.g., if-then-else, unary operators.


Constructor Summary
EmbeddingFixed(java.lang.String[] templateOf)
          Creates an EmbeddingFixed object.
 
Method Summary
 int componentCount(int operandCount)
          Gives the component count of this embedding.
 int componentIndex(int operandIndex)
          Maps operand index to component index.
 ExpressionLayoutManager getNewLayout()
          Gives a new instance of MLMLayout2, the preferred layout manager here.
 int operandIndex(int componentIndex)
          Maps component index to operand index.
 java.lang.String symbol(int componentIndex)
          Gives the operator symbol at the component index, or null if there should be an operand at the component index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmbeddingFixed

public EmbeddingFixed(java.lang.String[] templateOf)
Creates an EmbeddingFixed object. Requires a template for the display of the operator. The template specifies where and what symbols are displayed, and also where operands occur. Examples: In general, the template is an array of strings: null where operands should occur, non-null strings where operator symbols should occur. Operands are sequentially placed, e.g., if operand#0 then operand#1 else operand#2.

Parameters:
templateOf - the template that specifies operator symbols and operand positions.
Method Detail

getNewLayout

public ExpressionLayoutManager getNewLayout()
Gives a new instance of MLMLayout2, the preferred layout manager here.

Specified by:
getNewLayout in interface IEmbedding
See Also:
MLMLayout2

symbol

public java.lang.String symbol(int componentIndex)
Description copied from interface: IEmbedding
Gives the operator symbol at the component index, or null if there should be an operand at the component index. If the component index is invalid (less than zero, or beyond component count), this method may choose to throw an exception.

Specified by:
symbol in interface IEmbedding
Parameters:
componentIndex - the component index.
Returns:
the operator symbol at that index, or null.

componentIndex

public int componentIndex(int operandIndex)
Description copied from interface: IEmbedding
Maps operand index to component index. If the operand index is invalid (less than zero, or beyond arity), this method may choose to throw an exception.

Specified by:
componentIndex in interface IEmbedding
Parameters:
operandIndex - the operand index.
Returns:
the component index.

operandIndex

public int operandIndex(int componentIndex)
Description copied from interface: IEmbedding
Maps component index to operand index. If the component index is invalid (less than zero, beyond component count, or no operand at the index), this method may choose to throw an exception.

Specified by:
operandIndex in interface IEmbedding
Parameters:
componentIndex - the component index.
Returns:
the operand index.

componentCount

public int componentCount(int operandCount)
Description copied from interface: IEmbedding
Gives the component count of this embedding. In other words, how many components an ExpressionView should prepare to contain, in order to accomodate the operands and the operator symbols. Since this may (or may not) depend on the actual number of operands, this method requires that information. Implementors are allowed to garbage-in-garbage-out in case the operand count is invalid, e.g., negative.

Specified by:
componentCount in interface IEmbedding
Parameters:
operandCount - the actual, present number of operands.
Returns:
the number of components needed.