Example usage for com.google.gwt.resources.client ImageResource getWidth

List of usage examples for com.google.gwt.resources.client ImageResource getWidth

Introduction

In this page you can find the example usage for com.google.gwt.resources.client ImageResource getWidth.

Prototype

int getWidth();

Source Link

Document

Returns the width of the image.

Usage

From source file:org.rstudio.core.client.widget.Wizard.java

License:Open Source License

@Override
protected Widget createMainWidget() {
    WizardResources res = WizardResources.INSTANCE;
    WizardResources.Styles styles = res.styles();

    VerticalPanel mainWidget = new VerticalPanel();
    mainWidget.addStyleName(styles.mainWidget());

    headerPanel_ = new LayoutPanel();
    headerPanel_.addStyleName(styles.headerPanel());

    // layout constants
    final int kTopMargin = 5;
    final int kLeftMargin = 8;
    final int kCaptionWidth = 400;
    final int kCaptionHeight = 30;
    final int kPageUILeftMargin = 123;

    // first page caption
    subCaptionLabel_ = new Label(firstPage_.getPageCaption());
    subCaptionLabel_.addStyleName(styles.headerLabel());
    headerPanel_.add(subCaptionLabel_);//from   ww w  .  j  a v a 2 s.c o m
    headerPanel_.setWidgetLeftWidth(subCaptionLabel_, kTopMargin, Unit.PX, kCaptionWidth, Unit.PX);
    headerPanel_.setWidgetTopHeight(subCaptionLabel_, kLeftMargin, Unit.PX, kCaptionHeight, Unit.PX);

    // second page back button
    ImageResource bkImg = res.wizardBackButton();
    backButton_ = new Label("Back");
    backButton_.addStyleName(styles.wizardBackButton());
    backButton_.addStyleName(ThemeResources.INSTANCE.themeStyles().handCursor());
    headerPanel_.add(backButton_);
    headerPanel_.setWidgetLeftWidth(backButton_, kTopMargin - 2, Unit.PX, bkImg.getWidth(), Unit.PX);
    headerPanel_.setWidgetTopHeight(backButton_, kTopMargin - 2, Unit.PX, bkImg.getHeight(), Unit.PX);
    backButton_.setVisible(false);
    backButton_.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            goBack();
        }
    });

    // second page caption label
    pageCaptionLabel_ = new Label();
    pageCaptionLabel_.addStyleName(styles.headerLabel());
    headerPanel_.add(pageCaptionLabel_);
    headerPanel_.setWidgetLeftWidth(pageCaptionLabel_, kPageUILeftMargin, Unit.PX, kCaptionWidth, Unit.PX);
    headerPanel_.setWidgetTopHeight(pageCaptionLabel_, kLeftMargin, Unit.PX, kCaptionHeight, Unit.PX);
    pageCaptionLabel_.setVisible(false);

    mainWidget.add(headerPanel_);

    // main body panel for transitions
    bodyPanel_ = new LayoutPanel();
    bodyPanel_.addStyleName(styles.wizardBodyPanel());
    bodyPanel_.getElement().getStyle().setProperty("overflowX", "hidden");
    mainWidget.add(bodyPanel_);

    // add first page (and all sub-pages recursively)
    addAndInitializePage(firstPage_, true);

    setNextButtonState(firstPage_);

    return mainWidget;
}

From source file:org.rstudio.studio.client.workbench.views.console.ConsoleClearButton.java

License:Open Source License

@Inject
public ConsoleClearButton(final EventBus events, Commands commands) {
    // The SimplePanel wrapper is necessary for the toolbar button's "pushed"
    // effect to work.
    SimplePanel panel = new SimplePanel();
    panel.getElement().getStyle().setPosition(Position.RELATIVE);

    commands_ = commands;/* w  w  w.  ja  v  a  2  s  .  c  o m*/
    ImageResource icon = commands_.consoleClear().getImageResource();
    ToolbarButton button = new ToolbarButton(icon, commands.consoleClear());
    width_ = icon.getWidth() + 6;
    height_ = icon.getHeight();
    panel.setWidget(button);

    initWidget(panel);
    setVisible(true);
}

From source file:org.rstudio.studio.client.workbench.views.console.ConsoleInterruptButton.java

License:Open Source License

@Inject
public ConsoleInterruptButton(final EventBus events, Commands commands) {
    fadeInHelper_ = new DelayFadeInHelper(this);

    // The SimplePanel wrapper is necessary for the toolbar button's "pushed"
    // effect to work.
    SimplePanel panel = new SimplePanel();
    panel.getElement().getStyle().setPosition(Position.RELATIVE);

    commands_ = commands;//from  ww w.  ja  v a  2 s .  c  o  m
    ImageResource icon = commands_.interruptR().getImageResource();
    ToolbarButton button = new ToolbarButton(icon, commands.interruptR());
    width_ = icon.getWidth() + 6;
    height_ = icon.getHeight();
    panel.setWidget(button);

    initWidget(panel);
    setVisible(false);

    events.addHandler(BusyEvent.TYPE, new BusyHandler() {
        public void onBusy(BusyEvent event) {
            if (event.isBusy()) {
                fadeInHelper_.beginShow();
                commands_.interruptR().setEnabled(true);
                events.fireEvent(new ConsoleBusyEvent(true));
            }
        }
    });

    /*
    JJ says:
    It is possible that the client could miss the busy = false event (if the
    client goes out of network coverage and then the server suspends before
    it can come back into coverage). For this reason I think that the icon's
    controller logic should subscribe to the ConsolePromptEvent and clear it
    whenenver a prompt occurs.
    */
    events.addHandler(ConsolePromptEvent.TYPE, new ConsolePromptHandler() {
        public void onConsolePrompt(ConsolePromptEvent event) {
            fadeInHelper_.hide();
            commands_.interruptR().setEnabled(false);
            events.fireEvent(new ConsoleBusyEvent(false));
        }
    });
}

From source file:org.rstudio.studio.client.workbench.views.console.ConsoleInterruptProfilerButton.java

License:Open Source License

@Inject
public ConsoleInterruptProfilerButton(final EventBus events, Commands commands) {
    fadeInHelper_ = new DelayFadeInHelper(this);

    // The SimplePanel wrapper is necessary for the toolbar button's "pushed"
    // effect to work.
    SimplePanel panel = new SimplePanel();
    panel.getElement().getStyle().setPosition(Position.RELATIVE);

    ImageResource icon = new ImageResource2x(FileIconResources.INSTANCE.iconProfiler2x());
    Image button = CreateProfilerButton();

    width_ = icon.getWidth() + 6;
    height_ = icon.getHeight();/*w ww.  j  a  v  a2 s.  co m*/
    panel.setWidget(button);

    initWidget(panel);
    setVisible(false);

    events.addHandler(RprofEvent.TYPE, new RprofEvent.Handler() {
        @Override
        public void onRprofEvent(RprofEvent event) {
            switch (event.getEventType()) {
            case START:
                fadeInHelper_.beginShow();
                break;
            case STOP:
                fadeInHelper_.hide();
                break;
            default:
                break;
            }
        }
    });
}

From source file:sk.seges.acris.widget.client.table.PagingOptions.java

License:Apache License

protected void applyImage(Image image, ImageResource imageResource) {
    image.setUrlAndVisibleRect(imageResource.getURL(), imageResource.getLeft(), imageResource.getTop(),
            imageResource.getWidth(), imageResource.getHeight());
}