# label: Show Max # title: Show the maximum value within a box selection # description: Add a mouse module to the first plot's renderer that takes its dataset and prints the maximum value within the selected box. dom= getDocumentModel() plot= dom.plots[0].controller.dasPlot from org.das2.event import BoxSelectorMouseModule mm= BoxSelectorMouseModule.create( plot, 'show max' ) from org.virbo.dataset import DataSetUtil, SemanticOps from javax.swing import JOptionPane def boxSelected(event): xrange= event.XRange yrange= event.YRange ds= plot.getRenderer(0).dataSet if ( ds==None ): return isQube= DataSetUtil.isQube(ds); if ( isQube ): tds=SemanticOps.trim( ds, xrange, yrange ) else: tds=SemanticOps.trim( ds, xrange, null ) # this may cause problems else where... if ( tds.length()==0 ): # do nothing return max= -1e38 iter= org.virbo.dataset.QubeDataSetIterator( tds ) while ( iter.hasNext() ): iter.next() v= iter.getValue(tds) if ( v>max ): max= v JOptionPane.showMessageDialog( None, 'max=%f' % ( max ) ) mm.BoxSelected=boxSelected plot.dasMouseInputAdapter.primaryModule= mm