def showImgWithFullWindow(width=None,height=None): """ This function shows the image from current IDV window while in GUI mode. optional arguments are width and height in pixels, they currently default to 600 and 400""" from java.util import Base64 ##only in java8 from javax.imageio import ImageIO from java.io import ByteArrayOutputStream from ucar.unidata.ui.ImageUtils import resize,toBufferedImage import java import java.awt.Robot as Robot import java.awt.Rectangle as Rectangle import java.awt.Toolkit as Toolkit from ucar.unidata.util import Misc VM=idv.getViewManager() myframe=VM.getDisplayWindow().getComponent() robotx = Robot(myframe.getGraphicsConfiguration().getDevice()) VM.toFront(); #robotx.delay(250) Misc.sleep(350) pause() img=robotx.createScreenCapture(Rectangle( myframe.getX(),myframe.getY(),myframe.getWidth(),myframe.getHeight())) if width != None and height != None: img=toBufferedImage(resize(img,width,height)); bos=ByteArrayOutputStream(); ImageIO.write(img, "png", Base64.getEncoder().wrap(bos)); data = bos.toString("UTF-8"); return {"display":"image","data":data}
def showImgWithFullWindow(width=None, height=None): """ This function shows the image from current IDV window while in GUI mode. optional arguments are width and height in pixels, they currently default to 600 and 400""" from java.util import Base64 ##only in java8 from javax.imageio import ImageIO from java.io import ByteArrayOutputStream from ucar.unidata.ui.ImageUtils import resize, toBufferedImage import java import java.awt.Robot as Robot import java.awt.Rectangle as Rectangle import java.awt.Toolkit as Toolkit from ucar.unidata.util import Misc VM = idv.getViewManager() myframe = VM.getDisplayWindow().getComponent() robotx = Robot(myframe.getGraphicsConfiguration().getDevice()) VM.toFront() #robotx.delay(250) Misc.sleep(350) pause() img = robotx.createScreenCapture( Rectangle(myframe.getX(), myframe.getY(), myframe.getWidth(), myframe.getHeight())) if width != None and height != None: img = toBufferedImage(resize(img, width, height)) bos = ByteArrayOutputStream() ImageIO.write(img, "png", Base64.getEncoder().wrap(bos)) data = bos.toString("UTF-8") return {"display": "image", "data": data}
def showImgWithLegend(width=None,height=None): """ This function shows the image and legend from current IDV window while in GUI mode. Optional arguments are width and height in pixels, they currently default to 600 and 400""" from java.util import Base64 ##only in java8 from javax.imageio import ImageIO from java.io import ByteArrayOutputStream from ucar.unidata.ui.ImageUtils import resize,toBufferedImage import java import java.awt.Robot as Robot import java.awt.Rectangle as Rectangle import java.awt.Toolkit as Toolkit from ucar.unidata.util import Misc VM=idv.getViewManager() VMC=VM.getContents() VMCC=VMC.getComponent(1) # the view and legend ; 0 is left most part of view window with controls for perspective views siz=VMCC.getSize() loc= VMCC.getLocationOnScreen() gc= VMCC.getGraphicsConfiguration() loc.x -= gc.getBounds().x loc.y -= gc.getBounds().y robotx=Robot(gc.getDevice()) VM.toFront() Misc.sleep(250) img = robotx.createScreenCapture(Rectangle(loc.x, loc.y,siz.width, siz.height)) if width != None and height != None: img=toBufferedImage(resize(img,width,height)); bos=ByteArrayOutputStream(); ImageIO.write(img, "png", Base64.getEncoder().wrap(bos)); data = bos.toString("UTF-8"); return {"display":"image","data":data}
def showImgWithLegend(width=None, height=None): """ This function shows the image and legend from current IDV window while in GUI mode. Optional arguments are width and height in pixels, they currently default to 600 and 400""" from java.util import Base64 ##only in java8 from javax.imageio import ImageIO from java.io import ByteArrayOutputStream from ucar.unidata.ui.ImageUtils import resize, toBufferedImage import java import java.awt.Robot as Robot import java.awt.Rectangle as Rectangle import java.awt.Toolkit as Toolkit from ucar.unidata.util import Misc VM = idv.getViewManager() VMC = VM.getContents() VMCC = VMC.getComponent( 1 ) # the view and legend ; 0 is left most part of view window with controls for perspective views siz = VMCC.getSize() loc = VMCC.getLocationOnScreen() gc = VMCC.getGraphicsConfiguration() loc.x -= gc.getBounds().x loc.y -= gc.getBounds().y robotx = Robot(gc.getDevice()) VM.toFront() Misc.sleep(250) img = robotx.createScreenCapture( Rectangle(loc.x, loc.y, siz.width, siz.height)) if width != None and height != None: img = toBufferedImage(resize(img, width, height)) bos = ByteArrayOutputStream() ImageIO.write(img, "png", Base64.getEncoder().wrap(bos)) data = bos.toString("UTF-8") return {"display": "image", "data": data}
def wgt_runave(grid, wgts, option=0): """generate a weighted running average: <div class=jython> Where:<br> grid = grid to average<br> wgts - comma separated list of weights<br> option - option for unsmoothed end points<br> 0 - set to missing<br> 1 - use symmetry<br> -1 - assume cyclic <br> </div> """ from ucar.unidata.util import Misc weights = Misc.parseFloats(wgts) opt = int(option) return GridMath.timeWeightedRunningAverage(grid, weights, opt)
def wgt_runave(grid, wgts, option=0): """generate a weighted running average: <div class=jython> Where:<br> grid = grid to average<br> wgts - comma separated list of weights<br> option - option for unsmoothed end points<br> 0 - set to missing<br> 1 - use symmetry<br> -1 - assume cyclic <br> </div> """ from ucar.unidata.util import Misc weights = Misc.parseFloats(wgts) opt = int(option) return GridMath.timeWeightedRunningAverage(grid,weights,opt)
def pauseEvery(value): Misc.pauseEvery(60 * value)
def pauseHours(value): Misc.sleep(60.0 * 60.0 * 1000.0 * value)
def pauseMinutes(value): Misc.sleep(60.0 * 1000.0 * value)
def pauseSeconds(value): Misc.sleep(1000.0 * value)