def main(): activeLayers=getActiveLayers() if len(activeLayers)==0: JOptionPane.showMessageDialog(None, "Add and activate at least one vector layer in the view. Retry!", "Batch Transparency", JOptionPane.WARNING_MESSAGE) return else: numFLyrVect=0 for i in range(len(activeLayers)): if activeLayers[i].getClass().getCanonicalName()=="com.iver.cit.gvsig.fmap.layers.FLyrVect": numFLyrVect=numFLyrVect+1 if numFLyrVect==0: JOptionPane.showMessageDialog(None, "You have to add and activate at least one vector layer in the view. Retry!", "Batch Transparency", JOptionPane.WARNING_MESSAGE) return else: global frame, outCheckbox, fillCheckbox, slider frame = JFrame("Batch Transparency", defaultCloseOperation=JFrame.DISPOSE_ON_CLOSE, bounds=(100, 100, 450, 80), layout=FlowLayout(), resizable=0) outCheckbox = JCheckBox("outline", 1) fillCheckbox = JCheckBox("fill", 1) # Create a horizontal slider with min=0, max=100, value=50 slider = JSlider() slider.setPreferredSize(Dimension(200, 50)) slider.setValue(100) slider.setMajorTickSpacing(25) slider.setMinorTickSpacing(5) slider.setPaintTicks(1) slider.setPaintLabels(1) applyButton = JButton("Apply", actionPerformed=action) acceptButton = JButton("Accept", actionPerformed=accept) frame.add(outCheckbox) frame.add(fillCheckbox) frame.add(slider) frame.add(applyButton) frame.add(acceptButton) frame.show() return
def getGUI(sym_dict): global frame, outCheckbox, fillCheckbox, slider, colorTF, widthTF frame = JFrame("Border Symbology", defaultCloseOperation=JFrame.DISPOSE_ON_CLOSE, bounds=(100, 100, 450, 200), layout=FlowLayout(), resizable=0) colorL = JLabel('Color: ') colorTF = JTextField(20) color = sym_dict["color"] color = Color(color.getRed(), color.getGreen(), color.getBlue(), sym_dict["alpha"]) colorTF.setBackground(color) colorTF.setText(color.toString()) colorB = JButton('...', actionPerformed=colorChooser) frame.add(colorL) frame.add(colorTF) frame.add(colorB) widthL = JLabel('Width: ') widthTF = JTextField(3) widthTF.setText(str(sym_dict["width"])) frame.add(widthL) frame.add(widthTF) alphaL = JLabel('Transparency: ') frame.add(alphaL) # Create a horizontal slider with min=0, max=100, value=50 slider = JSlider() slider.setPreferredSize(Dimension(200, 50)) slider.setValue(sym_dict["alpha"]*100/255) slider.setMajorTickSpacing(25) slider.setMinorTickSpacing(5) slider.setPaintTicks(1) slider.setPaintLabels(1) applyButton = JButton("Apply", actionPerformed=action) acceptButton = JButton("Accept", actionPerformed=accept) frame.add(slider) frame.add(applyButton) frame.add(acceptButton) frame.show()
class FEA_ConfigPanel(JPanel): numThreads = 8 generateXLS = True generateCSV = True doNSLookup = True doWBLookup = True cbNSLookup = None cbGenerateExcel = None cbGenerateCSV = None cbWayback = None def __init__(self): self.initComponents() # get previous settings selected by the user if (ModuleSettings.getConfigSetting("FEA", "doNSLookup") != None) and ( ModuleSettings.getConfigSetting("FEA", "doNSLookup") != ""): if ModuleSettings.getConfigSetting("FEA", "doNSLookup"): self.cbNSLookup.setSelected(True) self.doNSLookup = True else: self.cbNSLookup.setSelected(False) self.doNSLookup = False if (ModuleSettings.getConfigSetting("FEA", "generateCSV") != None) and (ModuleSettings.getConfigSetting( "FEA", "generateCSV") != ""): if ModuleSettings.getConfigSetting("FEA", "generateCSV"): self.cbGenerateCSV.setSelected(True) self.generateCSV = True else: self.cbGenerateCSV.setSelected(False) self.generateCSV = False if (ModuleSettings.getConfigSetting("FEA", "generateXLS") != None) and (ModuleSettings.getConfigSetting( "FEA", "generateXLS") != ""): if ModuleSettings.getConfigSetting("FEA", "generateXLS"): self.cbGenerateExcel.setSelected(True) self.generateXLS = True else: self.cbGenerateExcel.setSelected(False) self.generateXLS = False if (ModuleSettings.getConfigSetting("FEA", "numThreads") != None) and ( ModuleSettings.getConfigSetting("FEA", "numThreads") != ""): self.numThreads = ModuleSettings.getConfigSetting( "FEA", "numThreads") self.numberThreadsSlider.setValue(self.numThreads) else: self.numThreads = self.numberThreadsSlider.getValue() def addStatusLabel(self, msg): gbc = GridBagConstraints() gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 0 gbc.gridy = 7 lab = JLabel(msg) self.add(lab, gbc) def getDoNSLookup(self): return self.doNSLookup def getGenerateCSV(self): return self.generateCSV def getGenerateXLS(self): return self.generateXLS def getDoWBLookup(self): return self.doWBLookup def getNumThreads(self): return self.numThreads def initComponents(self): self.setLayout(GridBagLayout()) gbc = GridBagConstraints() gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridx = 0 gbc.gridy = 0 descriptionLabel = JLabel("FEA - Forensics Email Analysis") self.add(descriptionLabel, gbc) gbc.gridy = 1 self.cbNSLookup = JCheckBox( "Perform DNS Lookup on email domains", actionPerformed=self.cbNSLookupActionPerformed) self.cbNSLookup.setSelected(True) self.add(self.cbNSLookup, gbc) # TODO: include option to browse for text file with list of emails to exclude from analysis numberThreadsLabel = JLabel( "Maximum number of threads for DNS Lookup task: ") gbc.gridy = 2 self.add(numberThreadsLabel, gbc) self.numberThreadsSlider = JSlider( JSlider.HORIZONTAL, 1, 16, 8, stateChanged=self.sliderActionPerformed) self.numberThreadsSlider.setMajorTickSpacing(1) self.numberThreadsSlider.setPaintLabels(True) self.numberThreadsSlider.setPaintTicks(True) self.numberThreadsSlider.setSnapToTicks(True) self.numberThreadsSlider.setToolTipText( "set maximum number of concurrent threads when performing DNS lookup on email domains" ) gbc.gridy = 5 gbc.gridwidth = 15 gbc.gridheight = 1 gbc.fill = GridBagConstraints.BOTH gbc.weightx = 0 gbc.weighty = 0 gbc.anchor = GridBagConstraints.NORTHWEST gbc.gridy = 3 self.add(self.numberThreadsSlider, gbc) self.cbGenerateExcel = JCheckBox( "Generate Excel format report (more detailed)", actionPerformed=self.cbGenerateExcelActionPerformed) self.cbGenerateExcel.setSelected(True) gbc.gridy = 4 self.add(self.cbGenerateExcel, gbc) self.cbGenerateCSV = JCheckBox( "Generate CSV format report (plaintext)", actionPerformed=self.cbGenerateCSVActionPerformed) self.cbGenerateCSV.setSelected(True) gbc.gridy = 5 self.add(self.cbGenerateCSV, gbc) gbc.gridy = 6 self.cbWayback = JCheckBox( "Perform Wayback Machine Lookup on email domains (WARNING: can be a slow process!)", actionPerformed=self.cbWaybackActionPerformed) self.cbWayback.setSelected(True) self.add(self.cbWayback, gbc) def cbWaybackActionPerformed(self, event): source = event.getSource() if (source.isSelected()): ModuleSettings.setConfigSetting("FEA", "doWBLookup", "true") self.doWBLookup = True else: ModuleSettings.setConfigSetting("FEA", "doNSLookup", "false") self.doWBLookup = False def cbNSLookupActionPerformed(self, event): source = event.getSource() if (source.isSelected()): ModuleSettings.setConfigSetting("FEA", "doNSLookup", "true") self.doNSLookup = True self.cbWayback.setEnabled(True) else: ModuleSettings.setConfigSetting("FEA", "doNSLookup", "false") self.doNSLookup = False self.cbWayback.setSelected(False) self.cbWayback.setEnabled(False) self.doWBLookup = False def cbGenerateExcelActionPerformed(self, event): source = event.getSource() if (source.isSelected()): ModuleSettings.setConfigSetting("FEA", "generateXLS", "true") self.generateXLS = True else: ModuleSettings.setConfigSetting("FEA", "generateXLS", "false") self.generateXLS = False def cbGenerateCSVActionPerformed(self, event): source = event.getSource() if (source.isSelected()): ModuleSettings.setConfigSetting("FEA", "generateCSV", "true") self.generateCSV = True else: ModuleSettings.setConfigSetting("FEA", "generateCSV", "false") self.generateCSV = False def sliderActionPerformed(self, event): source = event.getSource() self.numThreads = source.getValue() ModuleSettings.setConfigSetting("FEA", "numThreads", self.numThreads) self.addStatusLabel("number of threads set: " + str(self.numThreads))
class VadCheckModuleSettingsPanel(IngestModuleIngestJobSettingsPanel): # Note, we can't use a self.settings instance variable. # Rather, self.local_settings is used. # https://wiki.python.org/jython/UserGuide#javabean-properties # Jython Introspector generates a property - 'settings' on the basis # of getSettings() defined in this class. Since only getter function # is present, it creates a read-only 'settings' property. This auto- # generated read-only property overshadows the instance-variable - # 'settings' # We get passed in a previous version of the settings so that we can # prepopulate the UI # TODO: Update this for your UI def __init__(self, settings): #print("init: " + settings.getSetting("runVadTranscriber") + " " + settings.getSetting("minPercVoiced") + " " + settings.getSetting("minTotalVoiced")) #print("init local_settings: " + self.local_settings.getSetting("vadAggressivness") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced")) self.local_settings = GenericIngestModuleJobSettings() #initComponents will initialize sliders which will call lambdas for updating settings using current values in sliders #which would overwrite settings. self.initComponents() #print("init local_settings 2: " + self.local_settings.getSetting("vadAggressivness") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced")) #now safe to set settings self.local_settings = settings #print("init 2: " + self.local_settings.getSetting("runVadTranscriber") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced")) self.customizeComponents() _logger = Logger.getLogger(VadCheckModuleFactory.moduleName) def log(self, level, msg): self._logger.logp(level, self.__class__.__name__, inspect.stack()[1][3], msg) # def makeGuiCallback(self, key, guiGetAction): # def callback(event): # #self.log(Level.INFO, "setting key = " + key + " val =" + str(event.getSource().getValue())) # value = str(guiGetAction(event.getSource())) # print("setting key = " + key + " val =" + value) # self.local_settings.setSetting(key, value) # print("test in settings key = " + key + " val =" + self.local_settings.getSetting(key)) # return callback def initComponents(self): #print("initComponents 1: " + self.local_settings.getSetting("vadAggressivness") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced")) self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS)) self.label2 = JLabel() self.label2.setText("Minimum percentage of segments with speech") self.label3 = JLabel() self.label3.setText("Minimum total duration of segment with speech (s)") #sliderGetAction = lambda slider: slider.getValue() self.minPercVoiced = JSlider()#stateChanged=self.makeGuiCallback("minPercVoiced", sliderGetAction)) self.minPercVoiced.setMajorTickSpacing(20) self.minPercVoiced.setMinorTickSpacing(5) self.minPercVoiced.setPaintLabels(True) self.minPercVoiced.setPaintTicks(True) self.minTotalVoiced = JSlider()#stateChanged=self.makeGuiCallback("minTotalVoiced", sliderGetAction)) self.minTotalVoiced.setMajorTickSpacing(60) self.minTotalVoiced.setMaximum(180) self.minTotalVoiced.setMinorTickSpacing(10) self.minTotalVoiced.setPaintLabels(True) self.minTotalVoiced.setPaintTicks(True) #print("initComponents 2: " + self.local_settings.getSetting("vadAggressivness") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced")) #checkboxGetAction = lambda checkbox: checkbox.isSelected() self.runVadTranscriber = JCheckBox("Transcribe files with speech detected ? (slow)")#, #actionPerformed=self.makeGuiCallback("runVadTranscriber", checkboxGetAction)) self.showTextSegmentStartTime = JCheckBox("Show text segment start time ?") self.add(self.label2) self.add(self.minPercVoiced) self.add(self.label3) self.add(self.minTotalVoiced) self.add(self.showTextSegmentStartTime) self.add(self.runVadTranscriber) self.vadTranscriberLanguage = makeLanguageSelectionComboBox(self, "english") #this is needed because of https://bugs.jython.org/issue1749824 #class ComboActionListener(ActionListener): # def actionPerformed(self, e): # value = e.getSource().getSelectedItem() # self.local_settings.setSetting(key, value) #self.vadTranscriberLanguage.actionListener = ComboActionListener() #local_settings is of type https://github.com/sleuthkit/autopsy/blob/bbdea786db487c781edf2cf9032a2ba3166e97e0/Core/src/org/sleuthkit/autopsy/ingest/GenericIngestModuleJobSettings.java def customizeComponents(self): def setValue(key, default, stringToPythonObj, guiSetAction): string = self.local_settings.getSetting(key) #print("customizeComponents " + key + " stored value was " + str(string)) #print("string is None " + str(string is None) + " stringToPythonObj(string) " + str(stringToPythonObj(string))) checkedValue = default if string is None else stringToPythonObj(string) obj = getattr(self, key) guiSetAction(obj, checkedValue) #self.log(Level.INFO, "setValue for key " + key + " " + str(checkedValue)) sliderSetAction = lambda obj, val: obj.setValue(val) checkBoxSetAction = lambda obj, val: obj.setSelected(val) comboBoxSetAction = lambda obj, val: obj.setSelectedItem(val) setValue("minPercVoiced", minPercVoicedDefault, int, sliderSetAction) setValue("minTotalVoiced", minTotalVoicedDefault, int, sliderSetAction) setValue("runVadTranscriber", runVadTranscriberDefault, eval, checkBoxSetAction) setValue("showTextSegmentStartTime", showTextSegmentStartTimeDefault, eval, checkBoxSetAction) setValue("vadTranscriberLanguage", runVadTranscriberDefault, lambda x: x, comboBoxSetAction) # Return the settings used #note: exceptions thrown here will be caught and not logged. def getSettings(self): #print("getSettings: " + self.local_settings.getSetting("runVadTranscriber") + " " + self.local_settings.getSetting("minPercVoiced") + " " + self.local_settings.getSetting("minTotalVoiced")) self.local_settings.setSetting("minPercVoiced", str(self.minPercVoiced.getValue())) self.local_settings.setSetting("minTotalVoiced", str(self.minTotalVoiced.getValue())) self.local_settings.setSetting("runVadTranscriber", str(self.runVadTranscriber.isSelected())) self.local_settings.setSetting("showTextSegmentStartTime", str(self.showTextSegmentStartTime.isSelected())) self.local_settings.setSetting("vadTranscriberLanguage", str(self.vadTranscriberLanguage.getSelectedItem())) return self.local_settings