mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Identifier Framework and Message/Event Processing Overhaul (#455)
* WIP on new P25 message framer. * WIP on new P25 message framer. * Adds new 1/2 and 3/4 rate trellis decoders. Still trying to chase down why there is a sync pattern mismatch in the NID buffer queue. * WIP - new p25 message framer works correctly now. PDU's are dectected and decoded using the 1/2 and 3/4 rate trellis decoders. Packet Sequences are assembled. Need to add a new packet sequence message factory that can detect Motorola Auto Registration Service (ARS) formatted UDP/ID packets and SNDCP command packets. * WIP - removes nullify on channel results queue. * WIP - updates message framer for TSBK 1/2/3 processing. * WIP removing P25 sync pattern and nid bits from all message parsers. * WIP - merges identifier framework branch changes into this branch. * WIP on updating link control words to new format and identifier framework. * WIP - implements rest of link control words for extended formats * WIP - initial work on ISP/OSP TSBK message restructuring. * WIP - adds more TSBK ISP and OSP messages * WIP - finished updating most of the TSBK ISP and OSP messages. Converted all messages to no longer include the NID (nac + dataunitID) so that each message can simply hold the parsed values. Removed AliasList as an argument to each message and updated all messges to use the new IIdentifer and IAPCO25Channel interfaces. Removed legacy TDU and LDU link control messages and replaced with a single LinkControlWord class hierarchy. P25 decoder state is not yet updated for the new message structure. PDU message parsing is not fully implemented. * WIP - adds some Multi-Block trunking control messages with Alternate and Unconfirmed formats. * WIP - Fully implements AMBTC and UMBTC PDU message parsers. Some package restructuring. * WIP - Resolves Link control parsing in LDU1 and 2 messages. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. * WIP - finishes updating TSBK and Link Control messages. Adds support for moto link control messages for patch groups. Adds support for moto ARS service, IPV4 decoding, and UDP/IP packets. * WIP - finishes SNDCP packet data with header parsing. Compressed IP or UDP headers are not yet supported, but are logged as such. * WIP - converts all talkgroup identifiers to integers and updates alias list to create a per-protocol map of talkgroup id's to alias. Inserts a legacy talkgroup (ltr, p25, passport, mpt1327, mdc, etc.) conversion utility to convert existing legacy (string) talkgroups to new integer talkgroup format. Creates an audio packet manager to insert metadata into audio packets before streaming packets for playback, recording, and/or streaming. Creates identifier collection to manage current identifiers in each of the channel and decoder states. Creates simplified channel metadata to maintain the now playing display. Moves channel attributes (alias list, system, site, name) as configuration identifiers in the channel state. Many other refactoring and updates. * WIP - numerous updates to push use of identifier collection throughout the system. Updates the channel metadata and audio packet processing logic. Implements a large portion of the P25 decode state processing. Updates traffic channel management. Adds user preferences for timestamp and identifier formatting, however doesn't add a user interface yet. * WIP - initial implementation of user preferences editor window. * WIP - updates preferences editor window to close and dispose window but retain javafx event thread running. * WIP - fully updates p25 decoder state and traffic channel processing to use the new identifier framework. Cleans up channel event processing and removes channel model as the sole broadcaster of channel events. Channel processing manager now listens for all start/stop events and requestors dispatch event directly to the channel processing manager. Resolves issue in airspy that was causing user interface to lock-up. The issue appears to occur when the dongle is plugged into a usb port that can't fully support the data rate. sdrtrunk now recognizes these errors and warns the user that they should use another usb port. * WIP - updates alias action manager and adds new talkgroup range alias identifier. Updates playlist to incorporate a version number so that the playlist updater only runs when needed, to update a playlist to the correct version format. Updates user preferences to use the google event bus to broadcast preference update notifications to remove the need for listeners to register directly on the user preferences instance. * WIP - updates alias id editors to flag invalid values and moves legacy alias ids to legacy package. Updates event logging configuration to add traffic channel decode events and decoded message logging. Removes binary message logging since that is now replaced with demodulated bitstream recording. * Removes system properties from user preferences. Preferences are stored in the OS-dependent settings store (windows - registry) * Updates MapService to use new PlottableDecodeEvent instead of monitoring all of the decoded messages. Updates Fleetsync decoder and related messages to identifier framework. * Updates LTR-Net, Fleetsync and LJ1200 decoders to new identifier framework and adds support for user preferences for formatting of LTR-Net and fleetsync talkgroup identifiers. Breaks LTR-Net messages into various message types and uses a new message factory. Removes alias list from message processing for ltr-net, fleetsync and lj1200. * Updates LTR-Standard messages to Identifier framework. * Removes Plottable and IPlottable from codebase. * wip * WIP on MPT-1327 messages. * Updates MPT1327 decoder to identifier framework and new traffic channel manager. This decoder still needs to be updated with a new message parser factory and a sync detector like what is now used for P25. * Updates MDC1200 decoder and message to identifier framework. * Updates Tait1200 and Passport decoders to identifier framework. * Merges changes from master branch. * Removes legacy alias support classes. Updates passport message processor to only pass valid messages. Adds support to playlist updater for converting passport mobile ids to become passport talkgroup values. * Updates P25 decoder state and channel state to better track allocated traffic channels. Resolves issue in timestamp manager for trackig message timestamps. Resolves issue in airspy tuner that was causing the tuner to stop sending samples to the application. * Update P25 Decoder state to process SNDCP management messages and PDU messages. Updates P25 activity summary to display network and site details. Resolves issue with overlay panel that prevented enabled channels from rendering correctly when zoomed in. * Creates a new FilePreferences as part of the user preferences to begin the transition of SystemProperties over to user preferences and consolidate file preferences in one location. Updates playlist manager to use the new file preferences and to use default.xml as the new default playlist name, following conversion of a playlist_v2.xml format to the new format. In the near future, the user will be able to edit file locations and to create/use other playlists. Resolved an issue with all decoder states where not all identifiers were being included in decode events.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
public interface IPlottableUpdateListener
|
||||
{
|
||||
void entitiesUpdated();
|
||||
void addPlottableEntity(PlottableEntityHistory entity);
|
||||
void removePlottableEntity(PlottableEntityHistory entity);
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import io.github.dsheirer.settings.MapViewSetting;
|
||||
import io.github.dsheirer.settings.SettingsManager;
|
||||
@@ -30,10 +31,10 @@ import org.jdesktop.swingx.mapviewer.DefaultTileFactory;
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
import org.jdesktop.swingx.mapviewer.TileFactoryInfo;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.EventQueue;
|
||||
|
||||
public class MapPanel extends JPanel implements PlottableUpdateListener
|
||||
public class MapPanel extends JPanel implements IPlottableUpdateListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -42,11 +43,11 @@ public class MapPanel extends JPanel implements PlottableUpdateListener
|
||||
private JXMapViewer mMapViewer = new JXMapViewer();
|
||||
private PlottableEntityPainter mMapPainter;
|
||||
|
||||
public MapPanel(MapService mapService, IconManager iconManager, SettingsManager settingsManager)
|
||||
public MapPanel(MapService mapService, AliasModel aliasModel, IconManager iconManager, SettingsManager settingsManager)
|
||||
{
|
||||
mSettingsManager = settingsManager;
|
||||
mMapService = mapService;
|
||||
mMapPainter = new PlottableEntityPainter(iconManager);
|
||||
mMapPainter = new PlottableEntityPainter(aliasModel, iconManager);
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -115,29 +116,20 @@ public class MapPanel extends JPanel implements PlottableUpdateListener
|
||||
@Override
|
||||
public void entitiesUpdated()
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mMapViewer.repaint();
|
||||
}
|
||||
});
|
||||
EventQueue.invokeLater(() -> mMapViewer.repaint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlottableEntity(PlottableEntity entity)
|
||||
public void addPlottableEntity(PlottableEntityHistory entity)
|
||||
{
|
||||
mMapPainter.addEntity(entity);
|
||||
|
||||
entitiesUpdated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlottableEntity(PlottableEntity entity)
|
||||
public void removePlottableEntity(PlottableEntityHistory entity)
|
||||
{
|
||||
mMapPainter.removeEntity(entity);
|
||||
|
||||
entitiesUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -14,155 +15,78 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.module.decode.event.IDecodeEvent;
|
||||
import io.github.dsheirer.module.decode.event.PlottableDecodeEvent;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapService implements Listener<Message>
|
||||
public class MapService implements Listener<IDecodeEvent>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(MapService.class);
|
||||
|
||||
private int mMaxHistory = 2;
|
||||
private int mCullThresholdMinutes = 60;
|
||||
|
||||
private static final Color sDEFAULT_COLOR = Color.BLACK;
|
||||
|
||||
private List<PlottableUpdateListener> mListeners = new ArrayList<PlottableUpdateListener>();
|
||||
|
||||
private HashMap<String, PlottableEntity> mEntities =
|
||||
new HashMap<String, PlottableEntity>();
|
||||
|
||||
private List<IPlottableUpdateListener> mListeners = new ArrayList<IPlottableUpdateListener>();
|
||||
private Map<Identifier,PlottableEntityHistory> mEntityHistories = new HashMap<>();
|
||||
private IconManager mIconManager;
|
||||
|
||||
public MapService(IconManager resourceManager)
|
||||
{
|
||||
mIconManager = resourceManager;
|
||||
|
||||
// scheduler.scheduleAtFixedRate( new CullThread(), 5, 5, TimeUnit.MINUTES );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max plottables (locations) history setting that is applied
|
||||
* to all plottable entities
|
||||
*/
|
||||
public int getMaxHistory()
|
||||
{
|
||||
return mMaxHistory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max history trail for entities. Value is applied to all newly
|
||||
* created PlottableEntity and all existing entities.
|
||||
*/
|
||||
public void setMaxHistory(int maxHistory)
|
||||
{
|
||||
mMaxHistory = maxHistory;
|
||||
|
||||
/**
|
||||
* Update any existing entities with the new max history value
|
||||
*/
|
||||
for(PlottableEntity entity : mEntities.values())
|
||||
{
|
||||
entity.setMaxHistory(mMaxHistory);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(Message message)
|
||||
public void receive(IDecodeEvent decodeEvent)
|
||||
{
|
||||
Plottable plottable = message.getPlottable();
|
||||
|
||||
if(plottable != null)
|
||||
if(decodeEvent instanceof PlottableDecodeEvent)
|
||||
{
|
||||
PlottableEntity entity = mEntities.get(plottable.getID());
|
||||
PlottableDecodeEvent plottableDecodeEvent = (PlottableDecodeEvent)decodeEvent;
|
||||
Identifier from = plottableDecodeEvent.getIdentifierCollection().getFromIdentifier();
|
||||
|
||||
if(entity == null)
|
||||
if(from != null)
|
||||
{
|
||||
Alias alias = plottable.getAlias();
|
||||
PlottableEntityHistory entityHistory = mEntityHistories.get(from);
|
||||
|
||||
Color color = null;
|
||||
|
||||
if(alias != null)
|
||||
if(entityHistory == null)
|
||||
{
|
||||
color = alias.getDisplayColor();
|
||||
entityHistory = new PlottableEntityHistory(from, plottableDecodeEvent);
|
||||
mEntityHistories.put(from, entityHistory);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityHistory.add(plottableDecodeEvent);
|
||||
}
|
||||
|
||||
if(color == null)
|
||||
for(IPlottableUpdateListener listener : mListeners)
|
||||
{
|
||||
color = sDEFAULT_COLOR;
|
||||
}
|
||||
|
||||
entity = new PlottableEntity(plottable, color);
|
||||
|
||||
entity.setMaxHistory(mMaxHistory);
|
||||
|
||||
mEntities.put(plottable.getID(), entity);
|
||||
|
||||
for(PlottableUpdateListener listener : mListeners)
|
||||
{
|
||||
listener.addPlottableEntity(entity);
|
||||
listener.addPlottableEntity(entityHistory);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.addPlottable(plottable);
|
||||
|
||||
for(PlottableUpdateListener listener : mListeners)
|
||||
{
|
||||
listener.entitiesUpdated();
|
||||
;
|
||||
}
|
||||
mLog.warn("Received plottable decode event that does not contain a FROM identifier - cannot plot");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(PlottableUpdateListener listener)
|
||||
public void addListener(IPlottableUpdateListener listener)
|
||||
{
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(PlottableUpdateListener listener)
|
||||
public void removeListener(IPlottableUpdateListener listener)
|
||||
{
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
public class CullThread implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
long cutoffTime = System.currentTimeMillis() -
|
||||
(mCullThresholdMinutes * 1000);
|
||||
|
||||
Set<String> ids = Collections.unmodifiableSet(mEntities.keySet());
|
||||
|
||||
for(String id : ids)
|
||||
{
|
||||
PlottableEntity entity = mEntities.get(id);
|
||||
|
||||
if(entity.getCurrentPlottable().getTimestamp() < cutoffTime)
|
||||
{
|
||||
mEntities.remove(id);
|
||||
|
||||
/**
|
||||
* Let all listeners know we've removed (culled) an entity
|
||||
*/
|
||||
for(PlottableUpdateListener listener : mListeners)
|
||||
{
|
||||
listener.removePlottableEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Plottable implements Comparable<Plottable>
|
||||
{
|
||||
private long mTimestamp;
|
||||
private GeoPosition mGeoPosition;
|
||||
private String mID;
|
||||
private Alias mAlias;
|
||||
|
||||
HashMap<String,String> mAttributes = new HashMap<String,String>();
|
||||
|
||||
public Plottable()
|
||||
{
|
||||
}
|
||||
|
||||
public Plottable( long timestamp,
|
||||
GeoPosition position,
|
||||
String id,
|
||||
Alias alias,
|
||||
HashMap<String,String> attributes )
|
||||
{
|
||||
this( timestamp, position, id, alias );
|
||||
mAttributes = attributes;
|
||||
}
|
||||
|
||||
public Plottable( long timestamp,
|
||||
GeoPosition position,
|
||||
String id,
|
||||
Alias alias )
|
||||
{
|
||||
mTimestamp = timestamp;
|
||||
mGeoPosition = position;
|
||||
mID = id;
|
||||
mAlias = alias;
|
||||
}
|
||||
|
||||
public long getTimestamp()
|
||||
{
|
||||
return mTimestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp( long timestamp )
|
||||
{
|
||||
mTimestamp = timestamp;
|
||||
}
|
||||
|
||||
public GeoPosition getGeoPosition()
|
||||
{
|
||||
return mGeoPosition;
|
||||
}
|
||||
|
||||
public void setGeoPosition( GeoPosition position )
|
||||
{
|
||||
mGeoPosition = position;
|
||||
}
|
||||
|
||||
public String getID()
|
||||
{
|
||||
return mID;
|
||||
}
|
||||
|
||||
public void setID( String id )
|
||||
{
|
||||
mID = id;
|
||||
}
|
||||
|
||||
public Alias getAlias()
|
||||
{
|
||||
return mAlias;
|
||||
}
|
||||
|
||||
public void setAlias( Alias alias )
|
||||
{
|
||||
mAlias = alias;
|
||||
}
|
||||
|
||||
public HashMap<String,String> getAttributes()
|
||||
{
|
||||
return mAttributes;
|
||||
}
|
||||
|
||||
public void addAttribute( String key, String value )
|
||||
{
|
||||
mAttributes.put( key, value );
|
||||
}
|
||||
|
||||
public void removeAttribute( String key )
|
||||
{
|
||||
mAttributes.remove( key );
|
||||
}
|
||||
|
||||
public void clearAttributes()
|
||||
{
|
||||
mAttributes.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparisons for sorting of plottables is based on timestamps
|
||||
*/
|
||||
@Override
|
||||
public int compareTo( Plottable o )
|
||||
{
|
||||
if( mTimestamp == o.mTimestamp )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if( mTimestamp < o.mTimestamp )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class PlottableEntity implements Comparable<PlottableEntity>
|
||||
{
|
||||
private TreeSet<Plottable> mPlottables = new TreeSet<Plottable>();
|
||||
|
||||
private Alias mAlias;
|
||||
private Color mColor;
|
||||
private String mID;
|
||||
|
||||
private int mMaxHistory = 2;
|
||||
|
||||
/**
|
||||
* Constructs the entity using the group and alias from the plottable and
|
||||
* adds the plottable as the first plottable entry in the history
|
||||
*/
|
||||
public PlottableEntity( Plottable plottable, Color color )
|
||||
{
|
||||
addPlottable( plottable );
|
||||
mColor = color;
|
||||
}
|
||||
|
||||
public int getMaxHistory()
|
||||
{
|
||||
return mMaxHistory;
|
||||
}
|
||||
|
||||
public void setMaxHistory( int maxHistory )
|
||||
{
|
||||
if( maxHistory >= 1 )
|
||||
{
|
||||
mMaxHistory = maxHistory;
|
||||
}
|
||||
}
|
||||
|
||||
public Plottable getCurrentPlottable()
|
||||
{
|
||||
return mPlottables.last();
|
||||
}
|
||||
|
||||
public GeoPosition getCurrentGeoPosition()
|
||||
{
|
||||
return getCurrentPlottable().getGeoPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the plottable to this entity
|
||||
*/
|
||||
public void addPlottable( Plottable plottable )
|
||||
{
|
||||
/**
|
||||
* Grab the entity settings from the latest plot
|
||||
*/
|
||||
mAlias = plottable.getAlias();
|
||||
mID = plottable.getID();
|
||||
|
||||
/**
|
||||
* Add the plottable to the list
|
||||
*/
|
||||
mPlottables.add( plottable );
|
||||
|
||||
while( mPlottables.size() > mMaxHistory )
|
||||
{
|
||||
mPlottables.remove( mPlottables.first() );
|
||||
}
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
if( mAlias == null )
|
||||
{
|
||||
return mID;
|
||||
}
|
||||
else
|
||||
{
|
||||
return mAlias.getName();
|
||||
}
|
||||
}
|
||||
|
||||
public String getMapIconName()
|
||||
{
|
||||
if( mAlias != null )
|
||||
{
|
||||
return mAlias.getIconName();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Color for rendering this entity (label, route, etc.)
|
||||
*/
|
||||
public Color getColor()
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
|
||||
public void setColor( Color color )
|
||||
{
|
||||
mColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default id to use in the label
|
||||
*/
|
||||
public String getID()
|
||||
{
|
||||
return mID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the alias for this entity
|
||||
*/
|
||||
public Alias getAlias()
|
||||
{
|
||||
return mAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable sorted (time order) list of plottables
|
||||
*/
|
||||
public Set<Plottable> getPlottables()
|
||||
{
|
||||
return Collections.unmodifiableSet( mPlottables );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all plottables from this entity
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
mPlottables.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares by alias name
|
||||
*/
|
||||
@Override
|
||||
public int compareTo( PlottableEntity o )
|
||||
{
|
||||
return this.getAlias().getName().compareTo( o.getAlias().getName() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import io.github.dsheirer.identifier.Identifier;
|
||||
import io.github.dsheirer.identifier.IdentifierCollection;
|
||||
import io.github.dsheirer.module.decode.event.PlottableDecodeEvent;
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Plottable entity history with location history.
|
||||
*/
|
||||
public class PlottableEntityHistory
|
||||
{
|
||||
private List<GeoPosition> mLocationHistory = new ArrayList<>();
|
||||
private PlottableDecodeEvent mCurrentEvent;
|
||||
private Identifier mIdentifier;
|
||||
|
||||
/**
|
||||
* Constructs a plottable entity history
|
||||
*/
|
||||
public PlottableEntityHistory(Identifier identifier, PlottableDecodeEvent event)
|
||||
{
|
||||
mIdentifier = identifier;
|
||||
add(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Location history for this entity
|
||||
*/
|
||||
public List<GeoPosition> getLocationHistory()
|
||||
{
|
||||
return Collections.unmodifiableList(mLocationHistory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier for this plottable
|
||||
*/
|
||||
public Identifier getIdentifier()
|
||||
{
|
||||
return mIdentifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier collection from the latest event for this plottable
|
||||
*/
|
||||
public IdentifierCollection getIdentifierCollection()
|
||||
{
|
||||
return mCurrentEvent.getIdentifierCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the entity history with a location from the latest decode event
|
||||
*/
|
||||
public void add(PlottableDecodeEvent event)
|
||||
{
|
||||
mCurrentEvent = event;
|
||||
mLocationHistory.add(event.getLocation());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,15 +16,17 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import org.jdesktop.swingx.JXMapViewer;
|
||||
import org.jdesktop.swingx.painter.AbstractPainter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -31,21 +34,21 @@ import java.util.Set;
|
||||
public class PlottableEntityPainter extends AbstractPainter<JXMapViewer>
|
||||
{
|
||||
private PlottableEntityRenderer mRenderer;
|
||||
private Set<PlottableEntity> mEntities = new HashSet<PlottableEntity>();
|
||||
private Set<PlottableEntityHistory> mEntities = new HashSet<>();
|
||||
|
||||
public PlottableEntityPainter(IconManager iconManager)
|
||||
public PlottableEntityPainter(AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
mRenderer = new PlottableEntityRenderer(iconManager);
|
||||
mRenderer = new PlottableEntityRenderer(aliasModel, iconManager);
|
||||
setAntialiasing(true);
|
||||
setCacheable(false);
|
||||
}
|
||||
|
||||
public void addEntity(PlottableEntity entity)
|
||||
public void addEntity(PlottableEntityHistory entity)
|
||||
{
|
||||
mEntities.add(entity);
|
||||
}
|
||||
|
||||
public void removeEntity(PlottableEntity entity)
|
||||
public void removeEntity(PlottableEntityHistory entity)
|
||||
{
|
||||
mEntities.remove(entity);
|
||||
}
|
||||
@@ -55,7 +58,7 @@ public class PlottableEntityPainter extends AbstractPainter<JXMapViewer>
|
||||
mEntities.clear();
|
||||
}
|
||||
|
||||
private Set<PlottableEntity> getEntities()
|
||||
private Set<PlottableEntityHistory> getEntities()
|
||||
{
|
||||
return Collections.unmodifiableSet(mEntities);
|
||||
}
|
||||
@@ -67,9 +70,9 @@ public class PlottableEntityPainter extends AbstractPainter<JXMapViewer>
|
||||
|
||||
g.translate(-viewportBounds.getX(), -viewportBounds.getY());
|
||||
|
||||
Set<PlottableEntity> entities = getEntities();
|
||||
Set<PlottableEntityHistory> entities = getEntities();
|
||||
|
||||
for(PlottableEntity entity : entities)
|
||||
for(PlottableEntityHistory entity : entities)
|
||||
{
|
||||
mRenderer.paintPlottableEntity(g, map, entity, true);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
* Copyright (C) 2014-2018 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -14,96 +15,117 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
* *****************************************************************************
|
||||
*/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.alias.AliasList;
|
||||
import io.github.dsheirer.alias.AliasModel;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import org.jdesktop.swingx.JXMapViewer;
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.ImageIcon;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
public class PlottableEntityRenderer
|
||||
{
|
||||
private AliasModel mAliasModel;
|
||||
private IconManager mIconManager;
|
||||
|
||||
public PlottableEntityRenderer(IconManager iconManager)
|
||||
public PlottableEntityRenderer(AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mIconManager = iconManager;
|
||||
}
|
||||
|
||||
public void paintPlottableEntity(Graphics2D g, JXMapViewer viewer, PlottableEntity entity, boolean antiAliasing)
|
||||
public void paintPlottableEntity(Graphics2D g, JXMapViewer viewer, PlottableEntityHistory entity, boolean antiAliasing)
|
||||
{
|
||||
Graphics2D graphics = (Graphics2D) g.create();
|
||||
List<GeoPosition> locationHistory = entity.getLocationHistory();
|
||||
|
||||
if(antiAliasing)
|
||||
if(!locationHistory.isEmpty() && locationHistory.get(locationHistory.size() - 1).isValid())
|
||||
{
|
||||
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
Graphics2D graphics = (Graphics2D)g.create();
|
||||
|
||||
if(antiAliasing)
|
||||
{
|
||||
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
}
|
||||
|
||||
Alias alias = getAlias(entity);
|
||||
/**
|
||||
* Use the entity's preferred color for lines and labels
|
||||
*/
|
||||
Color color = (alias != null ? alias.getDisplayColor() : Color.YELLOW);
|
||||
graphics.setColor(color);
|
||||
|
||||
/**
|
||||
* Paint the route first, so the icon and label overlay it
|
||||
*/
|
||||
paintRoute(graphics, viewer, entity, color);
|
||||
|
||||
|
||||
/**
|
||||
* Convert the lat/long geoposition to an x/y point on the viewer
|
||||
*/
|
||||
|
||||
Point2D point = viewer.getTileFactory().geoToPixel(locationHistory.get(locationHistory.size() - 1), viewer.getZoom());
|
||||
|
||||
/**
|
||||
* Paint the icon at the current location
|
||||
*/
|
||||
ImageIcon icon = getIcon(alias);
|
||||
paintIcon(graphics, point, icon);
|
||||
|
||||
/**
|
||||
* Paint the label offset to the right of the icon
|
||||
*/
|
||||
String label = (alias != null ? alias.getName() : entity.getIdentifier().toString());
|
||||
paintLabel(graphics, point, label, (int)(icon.getIconWidth() / 2), 0);
|
||||
|
||||
/**
|
||||
* Cleanup
|
||||
*/
|
||||
graphics.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional alias that matches the identifier for the entity history
|
||||
*/
|
||||
private Alias getAlias(PlottableEntityHistory entityHistory)
|
||||
{
|
||||
AliasList aliasList = mAliasModel.getAliasList(entityHistory.getIdentifierCollection());
|
||||
|
||||
if(aliasList != null)
|
||||
{
|
||||
return aliasList.getAlias(entityHistory.getIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the entity's preferred color for lines and labels
|
||||
*/
|
||||
graphics.setColor(entity.getColor());
|
||||
|
||||
/**
|
||||
* Convert the lat/long geoposition to an x/y point on the viewer
|
||||
*/
|
||||
Point2D point = viewer.getTileFactory().geoToPixel(
|
||||
entity.getCurrentGeoPosition(), viewer.getZoom());
|
||||
|
||||
/**
|
||||
* Paint the route first, so the icon and label overlay it
|
||||
*/
|
||||
paintRoute(graphics, viewer, entity);
|
||||
|
||||
/**
|
||||
* Paint the icon at the current location
|
||||
*/
|
||||
ImageIcon icon = getIcon(entity);
|
||||
|
||||
paintIcon(graphics, point, icon);
|
||||
|
||||
/**
|
||||
* Paint the label offset to the right of the icon
|
||||
*/
|
||||
paintLabel(graphics, point, entity, (int) (icon.getIconWidth() / 2), 0);
|
||||
|
||||
/**
|
||||
* Cleanup
|
||||
*/
|
||||
graphics.dispose();
|
||||
return null;
|
||||
}
|
||||
|
||||
private ImageIcon getIcon(PlottableEntity entity)
|
||||
private ImageIcon getIcon(Alias alias)
|
||||
{
|
||||
return mIconManager.getIcon(entity.getMapIconName(), IconManager.DEFAULT_ICON_SIZE);
|
||||
String iconName = (alias != null ? alias.getIconName() : null);
|
||||
return mIconManager.getIcon(iconName, IconManager.DEFAULT_ICON_SIZE);
|
||||
}
|
||||
|
||||
private void paintIcon(Graphics2D graphics,
|
||||
Point2D point,
|
||||
ImageIcon icon)
|
||||
private void paintIcon(Graphics2D graphics, Point2D point, ImageIcon icon)
|
||||
{
|
||||
graphics.drawImage(icon.getImage(),
|
||||
(int) point.getX() - (icon.getIconWidth() / 2),
|
||||
(int) point.getY() - (icon.getIconHeight() / 2),
|
||||
null);
|
||||
|
||||
graphics.drawImage(icon.getImage(), (int)point.getX() - (icon.getIconWidth() / 2),
|
||||
(int)point.getY() - (icon.getIconHeight() / 2), null);
|
||||
}
|
||||
|
||||
private void paintLabel(Graphics2D graphics,
|
||||
Point2D point,
|
||||
PlottableEntity entity,
|
||||
int xOffset,
|
||||
int yOffset)
|
||||
private void paintLabel(Graphics2D graphics, Point2D point, String label, int xOffset, int yOffset)
|
||||
{
|
||||
graphics.drawString(entity.getLabel(),
|
||||
(int) point.getX() + xOffset,
|
||||
(int) point.getY() + yOffset);
|
||||
graphics.drawString(label, (int)point.getX() + xOffset, (int)point.getY() + yOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,47 +133,41 @@ public class PlottableEntityRenderer
|
||||
* using black as a wider background route, and the entity's preferred color
|
||||
* as a narrower foreground route.
|
||||
*/
|
||||
private void paintRoute(Graphics2D graphics,
|
||||
JXMapViewer viewer,
|
||||
PlottableEntity entity)
|
||||
private void paintRoute(Graphics2D graphics, JXMapViewer viewer, PlottableEntityHistory entity, Color color)
|
||||
{
|
||||
Set<Plottable> plottables = entity.getPlottables();
|
||||
List<GeoPosition> locations = entity.getLocationHistory();
|
||||
|
||||
if(plottables.size() > 1)
|
||||
if(!locations.isEmpty())
|
||||
{
|
||||
// Draw the route with a black background line
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.setStroke(new BasicStroke(3));
|
||||
|
||||
drawRoute(plottables, graphics, viewer);
|
||||
drawRoute(locations, graphics, viewer);
|
||||
|
||||
// Draw the route again, in the entity's preferred color
|
||||
graphics.setColor(entity.getColor());
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(1));
|
||||
|
||||
drawRoute(plottables, graphics, viewer);
|
||||
drawRoute(locations, graphics, viewer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a route from a list of plottables
|
||||
*/
|
||||
private void drawRoute(Set<Plottable> plottables,
|
||||
Graphics2D g,
|
||||
JXMapViewer viewer)
|
||||
private void drawRoute(List<GeoPosition> locations, Graphics2D g, JXMapViewer viewer)
|
||||
{
|
||||
Point2D lastPoint = null;
|
||||
|
||||
for(Plottable plottable : plottables)
|
||||
for(GeoPosition location : locations)
|
||||
{
|
||||
// convert geo-coordinate to world bitmap pixel
|
||||
Point2D currentPoint = viewer.getTileFactory()
|
||||
.geoToPixel(plottable.getGeoPosition(), viewer.getZoom());
|
||||
Point2D currentPoint = viewer.getTileFactory().geoToPixel(location, viewer.getZoom());
|
||||
|
||||
if(lastPoint != null)
|
||||
{
|
||||
g.drawLine((int) lastPoint.getX(), (int) lastPoint.getY(),
|
||||
(int) currentPoint.getX(), (int) currentPoint.getY());
|
||||
g.drawLine((int)lastPoint.getX(), (int)lastPoint.getY(), (int)currentPoint.getX(), (int)currentPoint.getY());
|
||||
}
|
||||
|
||||
lastPoint = currentPoint;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
public interface PlottableUpdateListener
|
||||
{
|
||||
public void entitiesUpdated();
|
||||
|
||||
public void addPlottableEntity( PlottableEntity entity );
|
||||
|
||||
public void removePlottableEntity( PlottableEntity entity );
|
||||
}
|
||||
Reference in New Issue
Block a user