当前位置: 首页>>代码示例>>Java>>正文


Java Image.getHeight方法代码示例

本文整理汇总了Java中com.google.gwt.user.client.ui.Image.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Image.getHeight方法的具体用法?Java Image.getHeight怎么用?Java Image.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.user.client.ui.Image的用法示例。


在下文中一共展示了Image.getHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHeight

import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
/**
 * Returns the original height when using IE.
 * 
 * @see com.google.gwt.user.client.ui.Image#getHeight()
 */
@Override
public int getHeight() {
    int superHeight = super.getHeight();
    logger.log(Level.INFO, "superHeight:" + superHeight);
    logger.log(Level.INFO, "isAttached():" + isAttached());
    if ( (superHeight <= 0) ) {
        // If this is being run under IE the default answer may be 0 when it
        // shouldn't be, so return the height from a hidden and attached
        // temp image
        Image temp = new Image(this.getUrl());
        temp.getElement().getStyle().setVisibility(Visibility.HIDDEN);
        RootPanel.get().add(temp);
        logger.log(Level.WARNING, "temp.isAttached():" + temp.isAttached());
        int tempHeight = temp.getHeight();
        logger.log(Level.WARNING, "tempHeight:" + tempHeight);
        temp.removeFromParent();
        return tempHeight;
    }
    return superHeight;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:26,代码来源:IESafeImage.java

示例2: scaleImage

import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
private ImageData scaleImage(Image image, double scaleToRatio) {
    Canvas canvasTmp = Canvas.createIfSupported();
    Context2d context = canvasTmp.getContext2d();

    int imageHeight = image.getHeight();

    double ch = (imageHeight * scaleToRatio);
    int imageWidth = image.getWidth();
    
    double cw = (imageWidth * scaleToRatio);

    canvasTmp.setCoordinateSpaceHeight((int) ch);
    canvasTmp.setCoordinateSpaceWidth((int) cw);

    // TODO: make a temp imageElement?
    ImageElement imageElement = ImageElement.as(image.getElement());

    // s = source
    // d = destination
    double sx = 0;
    double sy = 0;
    int imageElementWidth = imageElement.getWidth();
    if (imageElementWidth <= 0) {
        imageElementWidth = imageWidth;
    }
    double sw = imageElementWidth;
    int imageElementHeight = imageElement.getHeight();
    if (imageElementHeight <= 0) {
        imageElementHeight = imageHeight;
    }
    double sh = imageElementHeight;

    double dx = 0;
    double dy = 0;
    double dw = imageElementWidth;
    double dh = imageElementHeight;

    // tell it to scale image
    context.scale(scaleToRatio, scaleToRatio);

    // draw image to canvas
    context.drawImage(imageElement, sx, sy, sw, sh, dx, dy, dw, dh);

    // get image data
    double w = dw * scaleToRatio;
    double h = dh * scaleToRatio;
    ImageData imageData = null;
    try {
        imageData = context.getImageData(0, 0, w, h);
    } catch (Exception e) {
        // no image data. we'll try againg...
        String b = e.getLocalizedMessage();
    }

    int ht = (int) h + 10;
    int wt = (int) w + 10;
    
    // Clear the div, clear the drawing canvas then reinsert.  Otherwise, ghosts of the previous image appear.
    canvasDiv.clear();
            
    imageCanvasContext.clearRect(0, 0, imageCanvas.getCoordinateSpaceWidth(), imageCanvas.getCoordinateSpaceHeight());
    
    canvasDiv.add(imageCanvas, 0, 0);
    canvasDiv.add(drawingCanvas, 0, 0);
    
    imageCanvas.setCoordinateSpaceHeight(ht);
    imageCanvas.setCoordinateSpaceWidth(wt);
    
    drawingCanvas.setCoordinateSpaceHeight(ht);
    drawingCanvas.setCoordinateSpaceWidth(wt);
    
    canvasDiv.setSize(wt + "px", ht + "px");

    return imageData;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:76,代码来源:OutputPanel.java

示例3: setWidgetPixPosition

import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
/**
 * set position of a widget as the widget is centered on the given position.
 * @param p_w
 * @param p_wgtPixPosition position in pixel
 */
public void setWidgetPixPosition(Image p_w, AnPair p_wgtPixPosition)
{
  super.setWidgetPosition( p_w, p_wgtPixPosition.getX() - p_w.getWidth() / 2, p_wgtPixPosition
      .getY()
      - p_w.getHeight() / 2 );
  // p_w.setVisible( true );
}
 
开发者ID:kroc702,项目名称:fullmetalgalaxy,代码行数:13,代码来源:WgtBoardLayerBase.java


注:本文中的com.google.gwt.user.client.ui.Image.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。