Hi Rüdiger,
I think the problem is that you don't ever call
_omgraphics.generate(_projection) with the current projection. If you
don't generate() the OMGraphics, they don't know how to render
themselves on the map.
I looks like your layer does many things that are already coded into
the AbstractPlugIn, BeanContextAbstractPlugIn, and/or the
OMGraphicHandlerPlugIn. You could extend one of those classes (I'd
extend the OMGraphicHandlerPlugIn), creating your own PlugIn class that
implements just this method:
public OMGraphicList getRectangle(Projection p);
to do pretty much the same thing. Then, you just add your PlugIn to
the openmap.properties file just like a layer (openmap.layers
property). The LayerHandler will set it up for you in the application.
Cheers,
Don
On Monday, August 26, 2002, at 06:37 AM, Gubler, Rüdiger wrote:
>
> Hi,
>
> i have the following Layer added to OpenMap 4.5. The Indicatorlights
> shows that
> there is some calculation but nothing is shown.
>
> Whats wrong?
>
> package com.initka.bprocess.gis.display.layers;
>
> import java.text.Format;
> import java.awt.Color;
> import java.awt.event.ComponentListener;
> import java.awt.event.ComponentEvent;
> import java.awt.event.ActionListener;
> import java.awt.event.ActionEvent;
> import java.awt.event.MouseEvent;
> import javax.swing.SwingConstants;
>
> import com.bbn.openmap.Layer;
> import com.bbn.openmap.LatLonPoint;
> import com.bbn.openmap.proj.Projection;
> import com.bbn.openmap.event.ProjectionEvent;
> import com.bbn.openmap.event.MapMouseListener;
> import com.bbn.openmap.event.SelectMouseMode;
> import com.bbn.openmap.event.NavMouseMode;
> import com.bbn.openmap.event.NavMouseMode2;
> import com.bbn.openmap.event.LayerStatusEvent;
> import com.bbn.openmap.event.InfoDisplayEvent;
> import com.bbn.openmap.omGraphics.OMGraphic;
> import com.bbn.openmap.omGraphics.OMGraphicList;
> import com.bbn.openmap.omGraphics.OMCircle;
> import com.bbn.openmap.util.SwingWorker;
>
>
> public class VehicleLayer
> extends Layer
> implements ComponentListener, ActionListener, MapMouseListener
> {
> public static final String VM_VERSION =
> "$Revision: $";
> public static final String _redrawCommand =
> "redraw";
> protected Projection _projection = null;
> protected String _projID = null;
> protected OMGraphicList _omgraphics = null;
> private LayerWorker _currentWorker;
> private boolean _cancelled = false;
>
>
> public VehicleLayer()
> {
> }
>
> public String[] getMouseModeServiceList()
> {
> return new String[]
> {
> SelectMouseMode.modeID,
> NavMouseMode.modeID,
> NavMouseMode2.modeID
> };
> }
>
> public void paint( java.awt.Graphics g )
> {
> if (_omgraphics != null)
> {
> _omgraphics.render(g);
> }
> }
>
> public MapMouseListener getMapMouseListener()
> {
> return this;
> }
>
> public void dataChanged()
> {
> repaint();
> }
>
> public boolean getShowInfoLine()
> {
> return _showInfoLine;
> }
>
> public void projectionChanged( ProjectionEvent ev )
> {
> Projection newProj = ev.getProjection();
> String newPID = newProj.getProjectionID();
>
> if (newPID == _projID) // projection not really different
> {
> repaint();
> return;
> }
> _projection = newProj;
> _projID = newPID;
>
> // kill old list
> _omgraphics = null;
>
> // redo the layer
> computeLayer();
> }
>
> public void componentHidden( ComponentEvent e ) {}
> public void componentResized( ComponentEvent e ) {}
> public void componentMoved( ComponentEvent e ) {}
>
> public void componentShown(ComponentEvent e)
> {
> repaint();
> }
>
> public void actionPerformed (ActionEvent e)
> {
> String cmd = e.getActionCommand();
> if (cmd == _redrawCommand)
> {
> repaint();
> }
> }
>
> // No interrest but must be implemented
> public boolean mouseReleased( MouseEvent mouseEvent )
> {
> return false;
> }
>
> // No interrest but must be implemented
> public boolean mouseClicked( MouseEvent mouseEvent )
> {
> return false;
> }
>
> // No interrest but must be implemented
> public boolean mouseMoved( MouseEvent mouseEvent )
> {
> return false;
> }
>
> // No interrest but must be implemented
> public void mouseMoved(){}
>
> // No interrest but must be implemented
> public void mouseExited( MouseEvent mouseEvent ) {}
>
> // No interrest but must be implemented
> public void mouseEntered( MouseEvent mouseEvent ) {}
>
> // No interrest but must be implemented
> public boolean mouseDragged( MouseEvent mouseEvent )
> {
> return false;
> }
>
> // No interrest but must be implemented
> public boolean mousePressed( MouseEvent mouseEvent )
> {
> return false;
> }
>
> class LayerWorker extends SwingWorker
> {
>
> public LayerWorker ()
> {
> super();
> }
>
> /**
> * Compute the value to be returned by the <code>get</code> method.
> */
> public Object construct()
> {
> fireStatusUpdate(LayerStatusEvent.START_WORKING);
> try {
> OMGraphicList list = computeGraphics();
> return list;
> }
> catch (OutOfMemoryError e)
> {
> e.printStackTrace();
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
>
> // Something went wrong.
> _omgraphics = null;
> fireRequestMessage(new InfoDisplayEvent(this, "ERROR"));
> fireStatusUpdate(LayerStatusEvent.FINISH_WORKING);
> return null;
> }
>
> /**
> * Called on the event dispatching thread (not on the worker
> thread)
> * after the <code>construct</code> method has returned.
> */
> public void finished()
> {
> fireStatusUpdate(LayerStatusEvent.FINISH_WORKING);
> workerComplete(this);
> }
> }
>
> protected synchronized void workerComplete( LayerWorker worker )
> {
> if (!_cancelled)
> {
> _currentWorker = null;
> _omgraphics = (OMGraphicList)worker.get();
> repaint();
> }
> else
> {
> _cancelled = false;
> _currentWorker = new LayerWorker();
> _currentWorker.execute();
> }
> }
>
> protected synchronized void computeLayer()
> {
> if (_projection == null)
> {
> return;
> }
>
> if (isVisible())
> {
> if (_omgraphics != null)
> {
> // If we already have graphics, just slap 'em up there.
> // This is probably because this layer was hidden and
> // is now being shown.
> repaint();
> }
> else
> {
> if (_currentWorker == null)
> {
> // No graphics. If we're not already computing graphics,
> // then compute new graphics.
> _currentWorker = new LayerWorker();
> _currentWorker.execute();
> }
> else
> {
> // We're already computing. Set the cancel flag and
> // return. The DcwWorker management code will fire
> // up a new computation when the current worker stops.
> _cancelled = true;
> }
> }
> }
> }
>
> private OMGraphicList computeGraphics()
> {
> OMGraphicList list = new OMGraphicList();
>
> for( int x = -87800; x <= -86000; x++ )
> {
> for( int y = 40450; y <= 40480; y++ )
> {
>
> OMCircle omCircle = new OMCircle( ((float)y / 1000), ((float)x
> / 1000), 200 );
> omCircle.setFillPaint( Color.green );
> list.addOMGraphic( omCircle );
>
> OMCircle omCircle2 = new OMCircle( ((float)x / 1000),
> ((float)y / 1000), 200 );
> omCircle2.setFillPaint( Color.pink );
> list.addOMGraphic( omCircle2 );
>
> }
> }
>
> return list;
> }
>
> }
>
>
>
> Yours Rüdiger
>
>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, BBN Technologies, dietrick@bbn.com
10 Moulton Street, Cambridge, MA 02138
617-873-3031 [fax]-2794
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Mon Aug 26 09:34:32 2002
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT