Trait Ordering in the Code

Hi, the Reference Manual describes the trait ordering - innermost (e.g. Basic Piece) first, proceeding outwards (downwards), but with exceptions for Area-of-Effect and Draw-Under. As a Java rookie, is that ordering specified in any particular location in the VASSAL Java code, or does it come from various locations/interactions, or inherent in Java Swing?

Neither. Trait ordering isn’t predefined. The trait order for a piece is defined by the order which you, the editor of the module, have set for them. In the code, nearly all traits are decorators which hold a pointer to the next trait in the trait stack.

Sorry I wasn’t very clear, I meant to ask which bit of code runs down the list of traits (as created by the module editor) and executes each trait in turn as the piece is drawn?

Drawing is done via GamePiece::draw(). Each trait will have it’s own implementation, so there is no single place which traverses the trait stack during drawing.

E.g., Pivot does this:

@Override
public void draw(Graphics g, int x, int y, Component obs, double zoom) {
  getInner().draw(g, x, y, obs, zoom);
}

I see how that works now. Thanks Joel for your quick reply as always!