Example #1
0
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}
Example #2
0
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}
Example #3
0
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}
Example #4
0
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}
Example #5
0
def pauseHours(value):
    Misc.sleep(60.0 * 60.0 * 1000.0 * value)
Example #6
0
def pauseMinutes(value):
    Misc.sleep(60.0 * 1000.0 * value)
Example #7
0
def pauseSeconds(value):
    Misc.sleep(1000.0 * value)
Example #8
0
def pauseHours(value):
    Misc.sleep(60.0 * 60.0 * 1000.0 * value)
Example #9
0
def pauseMinutes(value):
    Misc.sleep(60.0 * 1000.0 * value)
Example #10
0
def pauseSeconds(value):
    Misc.sleep(1000.0 * value)