cds.aladin
Class SAMPManager

java.lang.Object
  extended by cds.aladin.SAMPManager
All Implemented Interfaces:
AppMessagingInterface, PlaneLoadListener

public class SAMPManager
extends java.lang.Object
implements AppMessagingInterface, PlaneLoadListener

Classe gérant toutes les connexions avec le hub SAMP (Simple Application Messaging Protocol, aussi appelé Stupid Alias Meaning PLASTIC) Cette classe se charge de la connexion avec le hub, et permet d'envoyer des messages au hub Le fait de faire passer tout ce qui est relatif à SAMP par une classe dédiée permet de passer relativement facilement d'une implémentation du protocole à une autre Les classes modifiées ou créées pour supporter SAMP sont les suivantes (package cds.aladin) : - Aladin : l'ajout des fonctionnalités SAMP est subordonné à la variable Aladin.PLASTIC_SUPPORT, qui pour le moment prend la valeur de Aladin.PROTO --> ajout d'un menu SAMP (variable MPLASTIC) permettant de s'inscrire/désinscrire auprès du hub (dans sous-menu SMPLASTIC) --> modif. dans méthode quit() : on se désincrit du hub avant de quitter l'appli --> modif. dans suiteInit() : mise à jour de l'état des items du sous-menu PLASTIC --> modif dans action(Event,Object) : gestion des évts inscription/désinscription --> ajout de la méthode setPlasticButtonMode() --> ajout de la méthode broadcastSelectedPlanes - Calque : --> modif. de selectAllObjectInPlans() : envoi d'un message "showObjects" lors de la sélection de tous les objets d'un plan - Localisation : --> modif. de la méthode setPos(...) pour permettre l'envoi du message pointAtCoords (cette méthode est appelée dans ViewSimple.mouseUp(Event,int,int) - SAMPManager (cette classe) : --> gère la registration/unregistration auprès du hub SAMP --> gère globalement l'envoi et la réception des messages SAMP On récupère le singleton de cette classe via la méthode statique getSingleton(Aladin) - Select : --> ajout d'items dans le popup pour permettre le broadcast de plans --> ajout des actions correspondant à ces items - View : --> ajout d'une méthode selectSourcesByRowNumber(PlanCatalog pc, int[] rowIdx) pour sélectionner des objets d'après leur numéro d'ordre dans leur plancatalog --> modif. de setMesure() pour envoyer le message "showObjects" lors de la sélection d'une ou plusieurs sources --> ajout de getSelectedSources() --> modif. de showSource(Source o) : ajout de l'envoi du message approprié - ViewSimple : --> petite modif dans mouseUp(Event,int,int)

Version:
0.1 Creation, Sept 2008
Author:
Thomas Boch [CDS]
See Also:
SAMP page on the IVOA web site

Nested Class Summary
 
Nested classes/interfaces inherited from interface cds.aladin.AppMessagingInterface
AppMessagingInterface.AbstractMessage
 
Field Summary
static java.lang.String LOCALHOST_PROP
           
 
Fields inherited from interface cds.aladin.AppMessagingInterface
ABSTRACT_MSG_LOAD_CHARAC_FROM_URL, ABSTRACT_MSG_LOAD_FITS, ABSTRACT_MSG_LOAD_SPECTRUM_FROM_URL, ABSTRACT_MSG_LOAD_VOT_FROM_URL, ICON_URL, NO_PLASTIC, PLASTIC_CAN_TRANSMIT, PLASTIC_CONNECTED_ALONE, PLASTIC_NOT_CONNECTED
 
Constructor Summary
SAMPManager(Aladin a)
          Constructeur
 
Method Summary
 boolean broadcastImage(PlanImage pi, java.lang.String[] recipients)
          "Diffusion" du PlanCatalog à toutes les applications Plastic
 boolean broadcastTable(PlanCatalog pc, java.lang.String[] recipients)
          "Diffusion" du PlanCatalog à toutes les applications SAMP
 java.lang.Object execute(java.lang.String method, java.util.Vector params)
           
 java.lang.String[] getAppsSupporting(AppMessagingInterface.AbstractMessage abstractMsg)
           
 java.lang.Object getAppWithName(java.lang.String s)
           
 java.lang.String getMessage(AppMessagingInterface.AbstractMessage abstractMsg)
           
 boolean getPlasticTrace()
           
 PlasticWidget getPlasticWidget()
           
 java.lang.String getProtocolName()
           
 boolean internalHubRunning()
           
 boolean isRegistered()
           
 boolean ping()
          ping the hub
 void planeLoaded(PlaneLoadEvent ple)
           
 void pointAtCoords(double ra, double dec)
           
 boolean register(boolean silent, boolean launchHubIfNeeded)
          Register with the SAMP hub
 void sendHighlightObjectsMsg(Source source)
          Envoie le message MSG_HIGHLIGHT_OBJECT au hub (si connecté)
 void sendMessageLoadCharac(java.lang.String url, java.lang.String name, java.util.List recipients)
           
 void sendMessageLoadImage(java.lang.String url, java.lang.String name, java.util.List recipients)
           
 void sendMessageLoadSpectrum(java.lang.String url, java.lang.String spectrumId, java.lang.String spectrumName, java.util.Map metadata, java.util.List recipients)
          si recipients==null --> broadcast
 void sendSelectObjectsMsg()
          Sends to the plastic hub the MSG_SELECT_OBJECTS message, with all currently selected sources
 void setPlasticTrace(boolean plasticTrace)
           
 void setPlasticWidget(PlasticWidget widget)
           
 boolean startInternalHub()
          lancement du hub PlasKit, en interne
 void stopInternalHub(boolean dontAsk)
           
 void trace(java.lang.String s)
           
 boolean unregister()
           
 boolean unregister(boolean force)
           
 boolean unregister(boolean force, boolean destroyInternalHub)
          Unregister from the SAMP hub
 void updateState()
          met à jour l'état courant (connecté ou non, etc)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALHOST_PROP

public static final java.lang.String LOCALHOST_PROP
See Also:
Constant Field Values
Constructor Detail

SAMPManager

public SAMPManager(Aladin a)
Constructeur

Method Detail

register

public boolean register(boolean silent,
                        boolean launchHubIfNeeded)
Register with the SAMP hub

Specified by:
register in interface AppMessagingInterface
Parameters:
launchHubIfNeeded - si silent==true, on essaye automatiquement de lancer un hub s'il n'en existe pas. Sinon, on passe par une boite de dialogue de confirmation
Returns:
true if Aladin was registered, false otherwise

execute

public java.lang.Object execute(java.lang.String method,
                                java.util.Vector params)
                         throws XmlRpcException
Throws:
XmlRpcException

unregister

public boolean unregister()
Specified by:
unregister in interface AppMessagingInterface

unregister

public boolean unregister(boolean force)
Specified by:
unregister in interface AppMessagingInterface

unregister

public boolean unregister(boolean force,
                          boolean destroyInternalHub)
Unregister from the SAMP hub

Specified by:
unregister in interface AppMessagingInterface
Parameters:
force - on force la désinscription
Returns:
true if Aladin is unregistered, false otherwise

isRegistered

public boolean isRegistered()
Specified by:
isRegistered in interface AppMessagingInterface

startInternalHub

public boolean startInternalHub()
lancement du hub PlasKit, en interne

Specified by:
startInternalHub in interface AppMessagingInterface
Returns:
true si tout s'est bien passé, false sinon

stopInternalHub

public void stopInternalHub(boolean dontAsk)
Specified by:
stopInternalHub in interface AppMessagingInterface

getAppWithName

public java.lang.Object getAppWithName(java.lang.String s)
Specified by:
getAppWithName in interface AppMessagingInterface

getProtocolName

public java.lang.String getProtocolName()
Specified by:
getProtocolName in interface AppMessagingInterface

sendMessageLoadImage

public void sendMessageLoadImage(java.lang.String url,
                                 java.lang.String name,
                                 java.util.List recipients)
Specified by:
sendMessageLoadImage in interface AppMessagingInterface

sendMessageLoadSpectrum

public void sendMessageLoadSpectrum(java.lang.String url,
                                    java.lang.String spectrumId,
                                    java.lang.String spectrumName,
                                    java.util.Map metadata,
                                    java.util.List recipients)
Description copied from interface: AppMessagingInterface
si recipients==null --> broadcast

Specified by:
sendMessageLoadSpectrum in interface AppMessagingInterface

sendMessageLoadCharac

public void sendMessageLoadCharac(java.lang.String url,
                                  java.lang.String name,
                                  java.util.List recipients)
Specified by:
sendMessageLoadCharac in interface AppMessagingInterface

getMessage

public java.lang.String getMessage(AppMessagingInterface.AbstractMessage abstractMsg)

getAppsSupporting

public java.lang.String[] getAppsSupporting(AppMessagingInterface.AbstractMessage abstractMsg)
Specified by:
getAppsSupporting in interface AppMessagingInterface

pointAtCoords

public void pointAtCoords(double ra,
                          double dec)
Specified by:
pointAtCoords in interface AppMessagingInterface

broadcastTable

public boolean broadcastTable(PlanCatalog pc,
                              java.lang.String[] recipients)
"Diffusion" du PlanCatalog à toutes les applications SAMP

Specified by:
broadcastTable in interface AppMessagingInterface
Parameters:
pc - le PlanCatalog à broadcaster
recipients - tableau des destinataires. Si null, on envoie à tout le monde

broadcastImage

public boolean broadcastImage(PlanImage pi,
                              java.lang.String[] recipients)
"Diffusion" du PlanCatalog à toutes les applications Plastic

Specified by:
broadcastImage in interface AppMessagingInterface
Parameters:
pi - le PlanImage à broadcaster
recipients - tableau des destinataires. Si null, on envoie à tout le monde

sendSelectObjectsMsg

public void sendSelectObjectsMsg()
Sends to the plastic hub the MSG_SELECT_OBJECTS message, with all currently selected sources

Specified by:
sendSelectObjectsMsg in interface AppMessagingInterface

internalHubRunning

public boolean internalHubRunning()
Specified by:
internalHubRunning in interface AppMessagingInterface

updateState

public void updateState()
met à jour l'état courant (connecté ou non, etc)

Specified by:
updateState in interface AppMessagingInterface

sendHighlightObjectsMsg

public void sendHighlightObjectsMsg(Source source)
Envoie le message MSG_HIGHLIGHT_OBJECT au hub (si connecté)

Specified by:
sendHighlightObjectsMsg in interface AppMessagingInterface
Parameters:
source - la source à montrer
See Also:
View.showSource(Source)

ping

public boolean ping()
ping the hub

Specified by:
ping in interface AppMessagingInterface

setPlasticWidget

public void setPlasticWidget(PlasticWidget widget)
Specified by:
setPlasticWidget in interface AppMessagingInterface

getPlasticWidget

public PlasticWidget getPlasticWidget()
Specified by:
getPlasticWidget in interface AppMessagingInterface

trace

public void trace(java.lang.String s)
Specified by:
trace in interface AppMessagingInterface

getPlasticTrace

public boolean getPlasticTrace()
Specified by:
getPlasticTrace in interface AppMessagingInterface
Returns:
Returns the sampTrace object.

setPlasticTrace

public void setPlasticTrace(boolean plasticTrace)
Specified by:
setPlasticTrace in interface AppMessagingInterface
Parameters:
plasticTrace - The plasticTrace value to set.

planeLoaded

public void planeLoaded(PlaneLoadEvent ple)
Specified by:
planeLoaded in interface PlaneLoadListener


Copyright © 2009 UDS/CNRS