[OpenMap Users] Fail to repaint correctly in OMGraphicHandlerLayer

From: <robert.m.dabell_at_L-3com.com>
Date: Tue, 29 May 2007 13:26:50 -0600

I am experiencing a sporadic problem in a Layer derived from the OMGraphHandlerLayer. In my application there is a set of OMGraphics that independantly move on this layer and occasionally there is a asynchronous call to prepare and repaint. Occasionally all or part of the set of OMGraphics disappear until the next repaint. I have tried a myriad of things to fix the problem and have searched through past correspondence to see if anyone else has experienced similair problems but to no avail.

I have written a simple application that I believe recreates the problem that I have been experiencing. The code is included below. It draws a bunch of stars and circles on a map with no other layers. Every second, the circles move to the east by one degree. A prepare and repaint occurs with a click to the map. The behavior that I experience when clicking on the application the stars are stationary and always draw, the circles usually redraw in their new location but occasionally will not redraw but disappear altogether. I have found something that will exacerbate the problem by adding in a repaint policy that delays slightly before calling repaint. One is included but is commented out when it would be added to the MapBean.

Could someone try this and let me know if they also see the same problem?

Mark DaBell

The code is as follows.

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import com.bbn.openmap.*;
import com.bbn.openmap.event.*;
import com.bbn.openmap.gui.*;
import com.bbn.openmap.layer.*;
import com.bbn.openmap.omGraphics.*;

class DelayedMapBeanRepaintPolicy extends StandardMapBeanRepaintPolicy {
  long threshold = 100;
  public void repaint(Layer layer) {
    if (map != null) {
      }catch(Exception e){}

class ObjectLayer extends OMGraphicHandlerLayer implements ActionListener, MapMouseListener{
  OMGraphicList list = new OMGraphicList();
  OMCircle circle = new OMCircle(10,10,5);
  Timer timer = new Timer(1000, this);
  public ObjectLayer(){
    BasicStroke starStroke = new BasicStroke(3f);
    Color starColor = new Color(248,218,7);
    for(int i = -90; i<=90; i+=10){
      for(int j = -180; j<=170;j+=10){
        list.add(new OMCircle((float)i,(float)j,5));
        OMPoly star = new OMPoly((float)i,(float)j,new int[]{0,5,-8,8,-5,0},
            new int[]{-8,7,-2,-2,7,-8}, OMPoly.COORDMODE_ORIGIN);
  public void actionPerformed(ActionEvent event){
    for(int i = 0; i<list.size(); i++){
      OMGraphic g = list.getOMGraphicAt(i);
      if (g instanceof OMCircle){
        OMCircle omc = ((OMCircle)g);
        LatLonPoint point = omc.getLatLon();

        ((OMCircle)g).setLatLon(point.getLatitude(), point.getLongitude()+1);
  public MapMouseListener getMapMouseListener() {
    return this;
  public String[] getMouseModeServiceList() {

    return new String[] { SelectMouseMode.modeID, NavMouseMode2.modeID};
  public boolean mouseClicked(MouseEvent e) {

    return false;
  public boolean mouseDragged(MouseEvent e) {

    return false;
  public void mouseEntered(MouseEvent e) {}
  public void mouseExited(MouseEvent e) {}
  public void mouseMoved() {}
  public boolean mouseMoved(MouseEvent e) {
    return false;
  public boolean mousePressed(MouseEvent e) {
    return false;
  public boolean mouseReleased(MouseEvent e) {
    return false;

public class TestOM extends JPanel{
  MapBean mapbean = new MapBean();
  MapHandler handler = new MapHandler();
  LayerHandler layerhandler;
  NavigatePanel navpanel;
  JToolBar toolpanel = null;
  DelayedMapBeanRepaintPolicy delayedPolicy = new DelayedMapBeanRepaintPolicy();
  public TestOM(){
    this.setLayout(new BorderLayout());
    //to add the custom DelayRepaintPolicy uncomment this line.
    ObjectLayer ol = new ObjectLayer();
    OMToolSet toolset = new OMToolSet();
    navpanel = toolset.getNavigatePanel();
    handler.add(new MouseModePanel());

    toolpanel = new JToolBar();

    toolpanel.setLayout(new FlowLayout(FlowLayout.LEADING));
    toolpanel.add(new JLabel("Scale:"));
    add(toolpanel, BorderLayout.NORTH);

    layerhandler = new LayerHandler();
  public MouseModeButtonPanel getMouseModeButtonPanel(){
    MouseDelegator md = new MouseDelegator();
    md.addMouseMode(new SelectMouseMode());
    md.addMouseMode(new NavMouseMode2());
    MouseModeButtonPanel mmbp = new MouseModeButtonPanel();
    return mmbp;
  public static void main(String[] args){
    TestOM test = new TestOM();
    JFrame frame = new JFrame();

[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue May 29 2007 - 15:39:47 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:08 EDT