當前位置: 首頁>>代碼示例>>Java>>正文


Java Image.getWidth方法代碼示例

本文整理匯總了Java中com.google.gwt.user.client.ui.Image.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java Image.getWidth方法的具體用法?Java Image.getWidth怎麽用?Java Image.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.user.client.ui.Image的用法示例。


在下文中一共展示了Image.getWidth方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getWidth

import com.google.gwt.user.client.ui.Image; //導入方法依賴的package包/類
/**
 * Returns the original width when when using IE.
 * 
 * @see com.google.gwt.user.client.ui.Image#getWidth()
 */
@Override
public int getWidth() {
    int superWidth = super.getWidth();
    logger.log(Level.INFO, "superWidth:" + superWidth);
    logger.log(Level.INFO, "isAttached():" + isAttached());
    if ( (superWidth <= 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 tempWidth = temp.getWidth();
        logger.log(Level.WARNING, "tempWidth:" + tempWidth);
        temp.removeFromParent();
        return tempWidth;
    }
    return superWidth;
}
 
開發者ID:NOAA-PMEL,項目名稱:LAS,代碼行數:26,代碼來源:IESafeImage.java

示例2: loadImage

import com.google.gwt.user.client.ui.Image; //導入方法依賴的package包/類
/**
         * Shows a resource as the {@code <img>} element.
         */
        public void loadImage(String url) {
            ClientUtils.setMembers(display, imgContainer);
            image = new Image();
            image.addLoadHandler(this);
            image.addErrorHandler(this);
            image.setUrl(url);
            drawHandler = imgContainer.addDrawHandler(this);
            resizedHandler = imgContainer.addResizedHandler(this);
            ClientUtils.fine(LOG, "loadImage url: %s, width: %s", url, image.getWidth());
            if (image.getWidth() == 0) {
                WidgetCanvas widgetCanvas = new WidgetCanvas(image);
                widgetCanvas.setVisible(false);
                widgetCanvas.setWidth(1);
                widgetCanvas.setHeight(1);
                widgetCanvas.draw();
                Img loadingImg = new Img("[SKIN]/loadingSmall.gif", 16, 16);
//                Img loadingImg = new Img("[SKIN]/shared/progressCursorTracker.gif", 16, 16);
                loadingImg.setAltText(i18n.ImportBatchDataSource_State_LOADING());
                loadingImg.setPrompt(i18n.ImportBatchDataSource_State_LOADING());
                loadingImg.setLayoutAlign(Alignment.CENTER);
                imgContainer.setMembers(loadingImg, widgetCanvas);
            }
            scheduleForRender();
        }
 
開發者ID:proarc,項目名稱:proarc,代碼行數:28,代碼來源:DigitalObjectPreview.java

示例3: 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

示例4: 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.getWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。