/** * SunriseCanvas displays a world map showing the sunrise and sunset terminators.<p> * * Copyright &copy; 1996-98 Martin Minow. All Rights Reserved.<p> * World map copyright &copy; 1992-97 Apple Computer Inc. All Rights Reserved. * Used by permission.<p> * * Permission to use, copy, modify, and redistribute this software and its * documentation for personal, non-commercial use is hereby granted provided that * this copyright notice and appropriate documentation appears in all copies. This * software may not be distributed for fee or as part of commercial, "shareware," * and/or not-for-profit endevors including, but not limited to, CD-ROM collections, * online databases, and subscription services without specific license.<p> * * @author <a href="mailto:minow@merrymeet.com">Martin Minow</a> * @version 1.1 (from SunClock 1.1) * 1997.11.12. * Set tabs every 4 characters. */import java.awt.*;import java.awt.image.*;import java.util.*;/* * For Java 1.0.2 compatibility, this must be a Canvas subclass */public class SunriseCanvas extends java.awt.Canvas{	protected SunrisePixels		sunrisePixels;	protected int					imageWidth;	protected int					imageHeight;	protected Date					instant			= new Date();		public SunriseCanvas(			Image			worldMapImage		)	{		sunrisePixels = new SunrisePixels(worldMapImage, this);				imageWidth			= sunrisePixels.getImageWidth();		imageHeight			= sunrisePixels.getImageHeight();	}	public void setDate(			Date			instant		)	{		this.instant		= instant;		sunrisePixels.setDate(instant);		repaint();	}	public Date getDate()	{		return (instant);	}	public void update(			Graphics			g		)	{		paint(g);	}	public synchronized void paint(			Graphics			g		)	{		/*		 * Center the image in the drawing area at the bottom.		 */		Dimension	d		= super.size();		/* Java 1.0.2 compatibility	*/		int			x		= (d.width - imageWidth) / 2;		int			y		= (d.height - imageHeight);		g.drawImage(sunrisePixels.getImage(), x, y, this);	}	public Dimension preferredSize()	{		return (new Dimension(imageWidth, imageHeight));	}	public Dimension getPreferredSize()	{		return (preferredSize());	}	public Dimension minimumSize()	{		return (preferredSize());	}	public Dimension getMinimumSize()	{		return (preferredSize());	}}