00001 # Copyright (C) 2008-2009 Mark Hanegraaff 00002 # 00003 # This program is free software: you can redistribute it and/or modify 00004 # it under the terms of the GNU General Public License as published by 00005 # the Free Software Foundation, either version 3 of the License, or 00006 # (at your option) any later version. 00007 # 00008 # This program is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 # GNU General Public License for more details. 00012 # 00013 # You should have received a copy of the GNU General Public License 00014 # along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 00016 from objects.gui.displayer.entityDisplayer import entityDisplayer 00017 00018 ## The applicationEntityDisplayer is a specialized class which knows how to set additional drawing attributes for a given entity. 00019 # In particular, this class knows how to assign a color to an Endpoint based on which process is communicating with it 00020 # The idea was that EyeSpy would have different perspectives, (i.e. a link layer perspective, a security perspective, etc.) which 00021 # would color Endpoints in different ways. That features, does not currently exist in EyeSpy. 00022 class applicationEntityDisplayer(entityDisplayer): 00023 00024 ## Sets the display Configurator object. 00025 # @param dispConfigurator Configurator object used to determine how to set attributes. 00026 def setDisplayConfigurator(self, dispConfigurator): 00027 entityDisplayer.setDisplayConfigurator(self, dispConfigurator) 00028 00029 self.processColorDict = self.dispConfig.app_getProcessColorCodesDict() 00030 self.processDefaultColor = self.dispConfig.app_getProcessDefaultColor() 00031 00032 00033 ## Returns a Dictionary of attributes given a networkEntity object 00034 # @param networkEntity networkEntity object (object representing an Endpoint) 00035 # @return Dictionary of attributes 00036 def getAttrFromEntity(self, networkEntity): 00037 displayAttributes = entityDisplayer.getAttributesFromEntity(self,networkEntity) 00038 00039 netEntProcName = networkEntity.processName.lower() 00040 00041 if self.processColorDict.has_key(netEntProcName): 00042 displayAttributes['markerColor'] = self.processColorDict[netEntProcName] 00043 else: 00044 displayAttributes['markerColor'] = self.processDefaultColor 00045 00046 return displayAttributes 00047 00048 # now deal with color coding 00049 00050 00051 ## Returns a hash of attributes given a list of networkEntity objects 00052 # This is necessary because sometimes Endpoints can share the same geographical locations 00053 # @param entityList list of networkEntity objects (object representing an Endpoint) 00054 # @return Dictionary of attributes 00055 def getAttrFromList(self, entityList): 00056 displayAttributes = entityDisplayer.getAttributesFromList(self,entityList) 00057 00058 displayAttributes['markerColor'] = "#000000" 00059 00060 return displayAttributes 00061 00062 # applications specific attributes 00063
1.5.8