A one shot component for tiling an area with a background tiler.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3011 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
//
|
||||||
|
// $Id: TiledArea.java,v 1.1 2004/05/21 07:36:17 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.media.util;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A component that can be inserted into a user interface to fill a
|
||||||
|
* particular area using a {@link BackgroundTiler}.
|
||||||
|
*/
|
||||||
|
public class TiledArea extends JComponent
|
||||||
|
{
|
||||||
|
public TiledArea (BufferedImage imgsrc)
|
||||||
|
{
|
||||||
|
this(new BackgroundTiler(imgsrc));
|
||||||
|
}
|
||||||
|
|
||||||
|
public TiledArea (BackgroundTiler tiler)
|
||||||
|
{
|
||||||
|
_tiler = tiler;
|
||||||
|
setOpaque(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void paintComponent (Graphics g)
|
||||||
|
{
|
||||||
|
super.paintComponent(g);
|
||||||
|
_tiler.paint(g, 0, 0, getWidth(), getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public Dimension getPreferredSize ()
|
||||||
|
{
|
||||||
|
return new Dimension(_tiler.getNaturalWidth(),
|
||||||
|
_tiler.getNaturalHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BackgroundTiler _tiler;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user