Hi,
I had the trouble a while ago, and someone from the list said that this
behaviour (item being rendered underneath the map layer) is due to how the
rendering pipeline works, i.e. not much chance to use a GlassPane. He also said
that there may be a decoration layer in GeoTools 2.7, but I couldn't see it in
M3 yet. Your only chance would be to subclass JMapPane and override
onRenderingComplete(). Here's how I did it (dukeImg is a bitmap object defined
outside the method):
public void onRenderingCompleted() {
// call this to draw the map to screen
super.onRenderingCompleted();
// draw your bitmap
Graphics g = this.getGraphics();
g.drawImage(dukeImg, 700, 500, null);
}
This will result in the bitmap been drawn on top of the map layer, but the
performance is quite poor. I need to display dynamic information, i.e. a lot of
re-draws involved, which creates quite a bit of flickering. I'll wait and see
whether that decoration layer materializes...
Cheers,
Alex
Dr Alexander von Lünen
Leverhulme Research Fellow
Dept. of Geography
University of Portsmouth
Buckingham Building, Lion Terrace
Portsmouth, PO1 3HE, UK
tel: +44-(0)23-9284-2500
fax: +44-(0)23-9284-2512
>>> Štěpán Cais<[email protected]> 27/10/2010 20:01 >>>
Hello,
I am working with GeoTools 2.7 M3 and I want to draw simple shapes over
map without redrawing the map context (this is because the map is not
repainted very often but the painted shapes are). I used GlassPane, but the
map context repaint GlassPane every time - it means, that my glass pane was
under the painted map. Do anybody know, what to do with it? I need my shapes
(I am drawing them into the GlassPane) above the map. I am sending a code
snipet for example.
The GlassPane class:
public class MyGlassPane extends JComponent {
public MyGlassPane() {
setOpaque(false);
}
protected void paintComponent(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, 150, 150);
g.fillRect(150, 150, 150, 150);
g.fillRect(300, 300, 150, 150);
}
The class which is responsible for loading map, setting map options, adding
layers into map etc. :
public class GeoViewer {
.
.
.
final MapContext map = new DefaultMapContext();
map.setTitle("GeoViewer");
map.addLayer(reader, rasterStyle);
.
.
.
frame = new MyFrame(map);
frame.setSize(800, 600);
frame.setVisible(true);
MyGlassPane glassPane = new MyGlassPane();
frame.setGlassPane(glassPane);
.
.
.
this.frame.getMapPane().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
frame.getGlassPane().setVisible(true);
}
}
}
Thanks for any respons.
Regards Stepan
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users