Center map when rendering.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@834 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: NodeMapPanel.java,v 1.6 2001/12/18 08:39:20 mdb Exp $
|
// $Id: NodeMapPanel.java,v 1.7 2001/12/18 12:21:21 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.nodemap;
|
package com.threerings.nodemap;
|
||||||
|
|
||||||
@@ -73,7 +73,15 @@ public class NodeMapPanel extends JPanel
|
|||||||
{
|
{
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
if (_map != null) {
|
if (_map != null) {
|
||||||
|
// compute the offset necessary to center the map in the
|
||||||
|
// display
|
||||||
|
Dimension osize = getSize();
|
||||||
|
Dimension msize = _map.getSize();
|
||||||
|
int tx = (osize.width - msize.width)/2;
|
||||||
|
int ty = (osize.height - msize.height)/2;
|
||||||
|
g.translate(tx, ty);
|
||||||
_map.paint(g);
|
_map.paint(g);
|
||||||
|
g.translate(-tx, -ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user