scphEditor
Interface IEmbedding

All Known Implementing Classes:
EmbeddingFixed, EmbeddingNary

public interface IEmbedding

An IEmbedding object encapsulates presentation formatting data of an operator and its operands. They include:

E.g., consider the if-then-else operator.


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()
          Returns a new instance of the preferred layout manager.
 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.
 

Method Detail

getNewLayout

ExpressionLayoutManager getNewLayout()
Returns a new instance of the preferred layout manager.


componentIndex

int componentIndex(int operandIndex)
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.

Parameters:
operandIndex - the operand index.
Returns:
the component index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - when it is blatantly obvious to me that the operand index is invalid.

operandIndex

int operandIndex(int componentIndex)
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.

Parameters:
componentIndex - the component index.
Returns:
the operand index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - when it is blatantly obvious to me that the component index is invalid.

symbol

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. If the component index is invalid (less than zero, or beyond component count), this method may choose to throw an exception.

Parameters:
componentIndex - the component index.
Returns:
the operator symbol at that index, or null.
Throws:
java.lang.ArrayIndexOutOfBoundsException - when it is blatantly obvious to me that the component index is invalid.

componentCount

int componentCount(int operandCount)
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.

Parameters:
operandCount - the actual, present number of operands.
Returns:
the number of components needed.