Exemple #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}
Exemple #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}
Exemple #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}
Exemple #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}
Exemple #5
0
def showImg(width=400,height=300):
    """ This function shows the image from current IDV frame, optional arguments are width and height in pixels, they
    currently default to 400 and 300"""
    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
    pause()
    img=getImage() 
    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}
Exemple #6
0
def showImg(width=None,height=None):
    """ This function shows the image from current IDV frame, optional arguments are width and height in pixels, they
    currently default to 400 and 300"""
    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
    pause()
    #imgx=getImage() currently not working with new changes to idv
    img=idv.getViewManager().getMaster().getImage(True)
    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}
Exemple #7
0
def showImg(width=None, height=None):
    """ This function shows the image from current IDV frame, optional arguments are width and height in pixels, they
    currently default to 400 and 300"""
    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
    pause()
    #imgx=getImage() currently not working with new changes to idv
    img = idv.getViewManager().getMaster().getImage(True)
    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}