* @param g2 graphics context
* @param position the position of the piece to render
*/
@Override
public void render( Graphics2D g2, BoardPosition position, int cellSize, int margin, Board b) {
Planet planet = (Planet)position.getPiece();
if (planet == null) {
return; // nothing to render
}
int pieceSize = getPieceSize(cellSize, planet);
Point pos = getPosition(position, cellSize, pieceSize, margin);
Ellipse2D circle = new Ellipse2D.Float( pos.x, pos.y, pieceSize + 1, pieceSize + 1 );
int hlOffset = (int) (pieceSize / 2.3 + 0.5); //spec highlight offset
Color c = getPieceColor(planet);
RoundGradientPaint rgp = new RoundGradientPaint(
pos.x + hlOffset, pos.y + hlOffset, Color.white, SPEC_HIGHLIGHT_RADIUS, c );
g2.setPaint( rgp );
g2.fill( circle );
if ( planet.isUnderAttack() ) {
g2.setStroke(ATTACK_STROKE);
g2.setColor( ATTACK_COLOR );
g2.drawOval( pos.x, pos.y, pieceSize + 1, pieceSize + 1 );
}
if ( planet.isHighlighted() ) {
g2.setStroke(HIGHLIGHT_STROKE);
g2.setColor( HIGHLIGHT_COLOR );
g2.drawOval( pos.x, pos.y, pieceSize + 1, pieceSize + 1 );
}
int offset = (pieceSize<(0.6*cellSize))? -1 : cellSize/5;
if ( planet.getAnnotation() != null ) {
g2.setColor( Color.black );
g2.setFont( PLANET_FONT );
g2.drawString( planet.getAnnotation(), pos.x + 2*offset, pos.y + 3*offset);
}
}