src/jtwod/engine/drawable/Text.java
@Override
    public final void render(Graphics graphics, Scene<ParentEngine> scene)
    {
        super.render(graphics, scene);
        Font resetFont = graphics.getFont();
        Color resetColor = graphics.getColor();


        graphics.setFont(this.font);
        graphics.setColor(this.color);

        switch (this.center) {
            case Horizontally:
                graphics.drawChars(
                    this.text.toCharArray(),
                    0,
                    this.text.length(),
                    (
                        this.parentDimensions.getWidth() / 2
                    ) - (
                        graphics.getFontMetrics().stringWidth(text) / 2
                    ) + parentStart.getX(),
                    this.getPosition().getY()
                );

                // Update clickable shape.
                this.clickableShape.setPosition(
                    new Vector(
                        (
                            this.parentDimensions.getWidth() / 2
                        ) - (
                            graphics.getFontMetrics().stringWidth(text) / 2
                        ) + parentStart.getX(),

                        this.getPosition().getY()
                    ).plus(
                        0,
                        -(graphics.getFontMetrics().getHeight() / 2)
                    )
                );
                this.clickableShape.setSize(
                    new Dimensions(
                        graphics.getFontMetrics().stringWidth(text),
                        graphics.getFontMetrics().getHeight() / 2
                    )
                );
                break;
            case Vertically:
                graphics.drawChars(
                    this.text.toCharArray(),
                    0,
                    this.text.length(),
                    this.getPosition().getX(),
                    (
                        this.parentDimensions.getHeight() / 2
                    ) - (
                        graphics.getFontMetrics().getHeight() / 2
                    ) + parentStart.getY() + (graphics.getFontMetrics().getHeight() / 2)
                );

                // Update clickable shape.
                this.clickableShape.setPosition(
                    new Vector(
                        this.getPosition().getX(),
                        (
                            (
                                this.parentDimensions.getHeight()
                                - graphics.getFontMetrics().getHeight()
                            ) / 2
                        ) + graphics.getFontMetrics().getAscent() + this.parentStart.getY()
                    ).plus(
                        0,
                        -(graphics.getFontMetrics().getHeight() / 2)
                    )
                );
                this.clickableShape.setSize(
                    new Dimensions(
                        graphics.getFontMetrics().stringWidth(text),
                        graphics.getFontMetrics().getHeight() / 2
                    )
                );
                break;
            case Parent:
                Rectangle2D textBounds = graphics.getFontMetrics().getStringBounds(text, graphics);

                graphics.drawChars(
                    this.text.toCharArray(),
                    0,
                    this.text.length(),
                    (
                        this.parentDimensions.getWidth() / 2
                    ) - (
                        (int)textBounds.getWidth() / 2
                    ) + this.parentStart.getX(),
                    (
                        (
                            this.parentDimensions.getHeight()
                          - graphics.getFontMetrics().getHeight()
                        ) / 2
                    ) + graphics.getFontMetrics().getAscent() + this.parentStart.getY()
                );

                // Update clickable shape.
                this.clickableShape.setPosition(
                    new Vector(
                        (
                            this.parentDimensions.getWidth() / 2
                        ) - (
                            (int)textBounds.getWidth() / 2
                        ) + this.parentStart.getX(),
                        (
                            (
                                this.parentDimensions.getHeight()
                                - graphics.getFontMetrics().getHeight()
                            ) / 2
                        ) + graphics.getFontMetrics().getAscent() + this.parentStart.getY()
                    ).plus(
                        0,
                        -(graphics.getFontMetrics().getHeight() / 2)
                    )
                );
                this.clickableShape.setSize(
                    new Dimensions(
                        graphics.getFontMetrics().stringWidth(text),
                        graphics.getFontMetrics().getHeight() / 2
                    )
                );
                break;
            case None:
                graphics.drawChars(
                    this.text.toCharArray(),
                    0,
                    this.text.length(),
                    this.getPosition().getX(),
                    this.getPosition().getY()
                );

                // Update clickable shape.
                this.clickableShape.setPosition(
                    new Vector(
                        this.getPosition().getX(),
                        this.getPosition().getY()
                    ).plus(
                        0,
                        -(graphics.getFontMetrics().getHeight() / 2)
                    )
                );
                this.clickableShape.setSize(
                    new Dimensions(
                        graphics.getFontMetrics().stringWidth(text),
                        graphics.getFontMetrics().getHeight() / 2
                    )
                );
                break;
        }

        graphics.setFont(resetFont);
        graphics.setColor(resetColor);
    }
/**
     * Render the text out to the scene.
     *
     * @param graphics The Graphics object to use.
     * @param scene The scene to draw the Graphics out to.
     */
Render the text out to the scene.
@param graphics The Graphics object to use.
@param scene The scene to draw the Graphics out to.
Render the text out to the scene . @param graphics The Graphics object to use . @param scene The scene to draw the Graphics out to .
@Override
    public final void render(Graphics graphics, Scene<ParentEngine> scene)
    {
        super.render(graphics, scene);
        Font resetFont = graphics.getFont();
        Color resetColor = graphics.getColor();
        graphics.setFont(this.font);
        graphics.setColor(this.color);
        switch (this.center) {
            case Horizontally:
                graphics.drawChars(
                    this.text.toCharArray(),
                    0,
                    this.text.length(),
                    (
                        this.parentDimensions.getWidth() / 2
                    ) - (
                        graphics.getFontMetrics().stringWidth(text) / 2
                    ) + parentStart.getX(),
                    this.getPosition().getY()
                );
                this.clickableShape.setPosition(
                    new Vector(
                        (
                            this.parentDimensions.getWidth() / 2
                        ) - (
                            graphics.getFontMetrics().stringWidth(text) / 2
                        ) + parentStart.getX(),
                        this.getPosition().getY()
                    ).plus(
                        0,
                        -(graphics.getFontMetrics().getHeight() / 2)
                    )
                );
                this.clickableShape.setSize(
                    new Dimensions(
                        graphics.getFontMetrics().stringWidth(text),
                        graphics.getFontMetrics().getHeight() / 2
                    )
                );
                break;
            case Vertically:
                graphics.drawChars(
                    this.text.toCharArray(),
                    0,
                    this.text.length(),
                    this.getPosition().getX(),
                    (
                        this.parentDimensions.getHeight() / 2
                    ) - (
                        graphics.getFontMetrics().getHeight() / 2
                    ) + parentStart.getY() + (graphics.getFontMetrics().getHeight() / 2)
                );
                this.clickableShape.setPosition(
                    new Vector(
                        this.getPosition().getX(),
                        (
                            (
                                this.parentDimensions.getHeight()
                                - graphics.getFontMetrics().getHeight()
                            ) / 2
                        ) + graphics.getFontMetrics().getAscent() + this.parentStart.getY()
                    ).plus(
                        0,
                        -(graphics.getFontMetrics().getHeight() / 2)
                    )
                );
                this.clickableShape.setSize(
                    new Dimensions(
                        graphics.getFontMetrics().stringWidth(text),
                        graphics.getFontMetrics().getHeight() / 2
                    )
                );
                break;
            case Parent:
                Rectangle2D textBounds = graphics.getFontMetrics().getStringBounds(text, graphics);
                graphics.drawChars(
                    this.text.toCharArray(),
                    0,
                    this.text.length(),
                    (
                        this.parentDimensions.getWidth() / 2
                    ) - (
                        (int)textBounds.getWidth() / 2
                    ) + this.parentStart.getX(),
                    (
                        (
                            this.parentDimensions.getHeight()
                          - graphics.getFontMetrics().getHeight()
                        ) / 2
                    ) + graphics.getFontMetrics().getAscent() + this.parentStart.getY()
                );
                this.clickableShape.setPosition(
                    new Vector(
                        (
                            this.parentDimensions.getWidth() / 2
                        ) - (
                            (int)textBounds.getWidth() / 2
                        ) + this.parentStart.getX(),
                        (
                            (
                                this.parentDimensions.getHeight()
                                - graphics.getFontMetrics().getHeight()
                            ) / 2
                        ) + graphics.getFontMetrics().getAscent() + this.parentStart.getY()
                    ).plus(
                        0,
                        -(graphics.getFontMetrics().getHeight() / 2)
                    )
                );
                this.clickableShape.setSize(
                    new Dimensions(
                        graphics.getFontMetrics().stringWidth(text),
                        graphics.getFontMetrics().getHeight() / 2
                    )
                );
                break;
            case None:
                graphics.drawChars(
                    this.text.toCharArray(),
                    0,
                    this.text.length(),
                    this.getPosition().getX(),
                    this.getPosition().getY()
                );
                this.clickableShape.setPosition(
                    new Vector(
                        this.getPosition().getX(),
                        this.getPosition().getY()
                    ).plus(
                        0,
                        -(graphics.getFontMetrics().getHeight() / 2)
                    )
                );
                this.clickableShape.setSize(
                    new Dimensions(
                        graphics.getFontMetrics().stringWidth(text),
                        graphics.getFontMetrics().getHeight() / 2
                    )
                );
                break;
        }
        graphics.setFont(resetFont);
        graphics.setColor(resetColor);
    }
@ Override public final void render ( Graphics graphics , Scene < ParentEngine > scene ) { super . render ( graphics , scene ) ; Font resetFont = graphics . getFont ( ) ; Color resetColor = graphics . getColor ( ) ; graphics . setFont ( this . font ) ; graphics . setColor ( this . color ) ; switch ( this . center ) { case Horizontally : graphics . drawChars ( this . text . toCharArray ( ) , 0 , this . text . length ( ) , ( this . parentDimensions . getWidth ( ) / 2 ) - ( graphics . getFontMetrics ( ) . stringWidth ( text ) / 2 ) + parentStart . getX ( ) , this . getPosition ( ) . getY ( ) ) ; this . clickableShape . setPosition ( new Vector ( ( this . parentDimensions . getWidth ( ) / 2 ) - ( graphics . getFontMetrics ( ) . stringWidth ( text ) / 2 ) + parentStart . getX ( ) , this . getPosition ( ) . getY ( ) ) . plus ( 0 , - ( graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ) ; this . clickableShape . setSize ( new Dimensions ( graphics . getFontMetrics ( ) . stringWidth ( text ) , graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ; break ; case Vertically : graphics . drawChars ( this . text . toCharArray ( ) , 0 , this . text . length ( ) , this . getPosition ( ) . getX ( ) , ( this . parentDimensions . getHeight ( ) / 2 ) - ( graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) + parentStart . getY ( ) + ( graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ; this . clickableShape . setPosition ( new Vector ( this . getPosition ( ) . getX ( ) , ( ( this . parentDimensions . getHeight ( ) - graphics . getFontMetrics ( ) . getHeight ( ) ) / 2 ) + graphics . getFontMetrics ( ) . getAscent ( ) + this . parentStart . getY ( ) ) . plus ( 0 , - ( graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ) ; this . clickableShape . setSize ( new Dimensions ( graphics . getFontMetrics ( ) . stringWidth ( text ) , graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ; break ; case Parent : Rectangle2D textBounds = graphics . getFontMetrics ( ) . getStringBounds ( text , graphics ) ; graphics . drawChars ( this . text . toCharArray ( ) , 0 , this . text . length ( ) , ( this . parentDimensions . getWidth ( ) / 2 ) - ( ( int ) textBounds . getWidth ( ) / 2 ) + this . parentStart . getX ( ) , ( ( this . parentDimensions . getHeight ( ) - graphics . getFontMetrics ( ) . getHeight ( ) ) / 2 ) + graphics . getFontMetrics ( ) . getAscent ( ) + this . parentStart . getY ( ) ) ; this . clickableShape . setPosition ( new Vector ( ( this . parentDimensions . getWidth ( ) / 2 ) - ( ( int ) textBounds . getWidth ( ) / 2 ) + this . parentStart . getX ( ) , ( ( this . parentDimensions . getHeight ( ) - graphics . getFontMetrics ( ) . getHeight ( ) ) / 2 ) + graphics . getFontMetrics ( ) . getAscent ( ) + this . parentStart . getY ( ) ) . plus ( 0 , - ( graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ) ; this . clickableShape . setSize ( new Dimensions ( graphics . getFontMetrics ( ) . stringWidth ( text ) , graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ; break ; case None : graphics . drawChars ( this . text . toCharArray ( ) , 0 , this . text . length ( ) , this . getPosition ( ) . getX ( ) , this . getPosition ( ) . getY ( ) ) ; this . clickableShape . setPosition ( new Vector ( this . getPosition ( ) . getX ( ) , this . getPosition ( ) . getY ( ) ) . plus ( 0 , - ( graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ) ; this . clickableShape . setSize ( new Dimensions ( graphics . getFontMetrics ( ) . stringWidth ( text ) , graphics . getFontMetrics ( ) . getHeight ( ) / 2 ) ) ; break ; } graphics . setFont ( resetFont ) ; graphics . setColor ( resetColor ) ; }
Render the text out to the scene.
Render the text out to the scene .
// Update clickable shape. // Update clickable shape. // Update clickable shape. // Update clickable shape.