scrollable map component & painting units, goto-lines etc

"Luke Lindsay" <[email protected]> Tue, 13 Nov 2001 07:25:19 -0000
Newsgroups gmane.games.freeciv.java
Message-ID <[email protected]>
Brian,

How are you intending to handle the painting of active units, goto lines
etc?

The scrollable map component code I wrote was designed to paint a static
background.  To get the best perfomance, graphics elments that tend to move
or are animated should be drawn separately.  (I.e. the offscreen buffer,
TiledPainter.m_backgroundBuffer, should only store the graphics of terrain
tiles, cities, and perhaps inactive units; other elements should be painted
directly to the screen.) A good way to do this might be in the paint method
of MapComponent.java, e.g.

public void paint( Graphics g )
  {
    Graphics2D g2 = (Graphics2D)g;
    Rectangle r = getVisibleRect();
    m_painter.paint( g2, r );
	//Now paint units etc here.
  }

Luke