scphEditor
Class EmbeddingNary

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

public class EmbeddingNary
extends java.lang.Object
implements IEmbedding

An EmbeddingNary object encapsulates presentation styles, in AWT terms, of an operator and its operands. The operator is assumed to be n-ary and infix - the indexing methods will compute indexes accordingly.


Constructor Summary
EmbeddingNary(java.lang.String symbolOf)
          Creates an EmbeddingNary 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

EmbeddingNary

public EmbeddingNary(java.lang.String symbolOf)
Creates an EmbeddingNary object. Requires a string containing the operator symbol.

Parameters:
symbolOf - the operator symbol.
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.