package nl.tudelft.simulation.examples.dsol.animation3d;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.ImageObserver;
import java.rmi.RemoteException;
import javax.naming.NamingException;
import nl.tudelft.simulation.dsol.animation.Locatable;
import nl.tudelft.simulation.dsol.animation.D2.Renderable2D;
import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
/**
* The Animation of a Ball.
*
* Copyright (c) 2003-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
* for project information https://simulation.tudelft.nl. The DSOL
* project is distributed under a three-clause BSD-style license, which can be found at
*
* https://simulation.tudelft.nl/dsol/3.0/license.html.
*
* @author Peter Jacobs
* @since 1.4
*/
public class BallAnimation extends Renderable2D
{
/**
* the color of the ballAnimation.
*/
private Color color = Color.ORANGE;
/**
* constructs a new BallAnimation.
* @param source Locatable; the source
* @param simulator SimulatorInterface.TimeDouble; the simulator
* @throws NamingException on error
* @throws RemoteException on error
*/
public BallAnimation(final Locatable source, final SimulatorInterface.TimeDouble simulator)
throws RemoteException, NamingException
{
super(source, simulator);
}
/** {@inheritDoc} */
@Override
public void paint(final Graphics2D graphics, final ImageObserver observer)
{
graphics.setColor(this.color);
graphics.fillOval(-(int) Ball.RADIUS, -(int) Ball.RADIUS, (int) (Ball.RADIUS * 2.0), (int) (Ball.RADIUS * 2.0));
graphics.setFont(graphics.getFont().deriveFont(Font.BOLD));
graphics.setColor(Color.GRAY);
graphics.drawString(getSource().toString(), (int) (Ball.RADIUS * -1.0), (int) (Ball.RADIUS * 1.0));
}
/**
* @return Returns the color.
*/
public Color getColor()
{
return this.color;
}
/**
* @param color Color; The color to set.
*/
public void setColor(final Color color)
{
this.color = color;
}
}