private void updateTextStyle (int percent) { // Set the style depending on the size of the bar if (percent < 50) { DOM.setElementProperty(textElement, "className", textClassName + " " + textFirstHalfClassName); } else { DOM.setElementProperty(textElement, "className", textClassName + " " + textSecondHalfClassName); } } }
/** This method is called when the dimensions of the parent element change. Subclasses should override this method as needed. * * Move the text to the center of the progress bar. * * @param width the new client width of the element * @param height the new client height of the element */ public void onResize (int width, int height) { if (textVisible) { int textWidth = DOM.getElementPropertyInt(textElement, "offsetWidth"); int left = (width / 2) - (textWidth / 2); DOM.setStyleAttribute(textElement, "left", left + "px"); } }
/** Set whether or not resize checking is enabled. If disabled, elements will still be resized on window events, but the timer * will not check their dimensions periodically. * * @param enabled true to enable the resize checking timer */ public void setResizeCheckingEnabled (boolean enabled) { if (enabled && !resizeCheckingEnabled) { resizeCheckingEnabled = true; if (windowHandler == null) { windowHandler = Window.addResizeHandler(this); } resizeCheckTimer.schedule(resizeCheckDelay); } else if (!enabled && resizeCheckingEnabled) { resizeCheckingEnabled = false; if (windowHandler != null) { windowHandler.removeHandler(); windowHandler = null; } resizeCheckTimer.cancel(); } }
/** Set the current progress. * * @param curProgress the current progress */ public void setProgress (double curProgress) { this.curProgress = Math.max(minProgress, Math.min(maxProgress, curProgress)); // Calculate percent complete int percent = (int)(100 * getPercent()); DOM.setStyleAttribute(barElement, "width", percent + "%"); DOM.setElementProperty(textElement, "innerHTML", generateText(curProgress)); updateTextStyle(percent); // Realign the text redraw(); }
/** Sets whether the text is visible over the bar. * * @param textVisible True to show text, false to hide it */ public void setTextVisible (boolean textVisible) { this.textVisible = textVisible; if (this.textVisible) { DOM.setStyleAttribute(textElement, "display", ""); redraw(); } else { DOM.setStyleAttribute(textElement, "display", "none"); } }
/** Sets the placeholder text displayed in the text box. * * @param text the placeholder text */ public void setPlaceholder (String text) { placeholder = (text != null ? text : ""); getElement().setPropertyString("placeholder", placeholder); } }
/** Redraw the progress bar when something changes the layout. */ public void redraw () { if (isAttached()) { int width = DOM.getElementPropertyInt(getElement(), "clientWidth"); int height = DOM.getElementPropertyInt(getElement(), "clientHeight"); onResize(width, height); } }
/** Set whether or not resize checking is enabled. If disabled, elements will still be resized on window events, but the timer * will not check their dimensions periodically. * * @param enabled true to enable the resize checking timer */ public void setResizeCheckingEnabled (boolean enabled) { if (enabled && !resizeCheckingEnabled) { resizeCheckingEnabled = true; if (windowHandler == null) { windowHandler = Window.addResizeHandler(this); } resizeCheckTimer.schedule(resizeCheckDelay); } else if (!enabled && resizeCheckingEnabled) { resizeCheckingEnabled = false; if (windowHandler != null) { windowHandler.removeHandler(); windowHandler = null; } resizeCheckTimer.cancel(); } }
/** Set the current progress. * * @param curProgress the current progress */ public void setProgress (double curProgress) { this.curProgress = Math.max(minProgress, Math.min(maxProgress, curProgress)); // Calculate percent complete int percent = (int)(100 * getPercent()); DOM.setStyleAttribute(barElement, "width", percent + "%"); DOM.setElementProperty(textElement, "innerHTML", generateText(curProgress)); updateTextStyle(percent); // Realign the text redraw(); }
/** Sets whether the text is visible over the bar. * * @param textVisible True to show text, false to hide it */ public void setTextVisible (boolean textVisible) { this.textVisible = textVisible; if (this.textVisible) { DOM.setStyleAttribute(textElement, "display", ""); redraw(); } else { DOM.setStyleAttribute(textElement, "display", "none"); } }
/** This method is called when the dimensions of the parent element change. Subclasses should override this method as needed. * * Move the text to the center of the progress bar. * * @param width the new client width of the element * @param height the new client height of the element */ public void onResize (int width, int height) { if (textVisible) { int textWidth = DOM.getElementPropertyInt(textElement, "offsetWidth"); int left = (width / 2) - (textWidth / 2); DOM.setStyleAttribute(textElement, "left", left + "px"); } }
private void updateTextStyle (int percent) { // Set the style depending on the size of the bar if (percent < 50) { DOM.setElementProperty(textElement, "className", textClassName + " " + textFirstHalfClassName); } else { DOM.setElementProperty(textElement, "className", textClassName + " " + textSecondHalfClassName); } } }
/** Sets the placeholder text displayed in the text box. * * @param text the placeholder text */ public void setPlaceholder (String text) { placeholder = (text != null ? text : ""); getElement().setPropertyString("placeholder", placeholder); } }
/** Redraw the progress bar when something changes the layout. */ public void redraw () { if (isAttached()) { int width = DOM.getElementPropertyInt(getElement(), "clientWidth"); int height = DOM.getElementPropertyInt(getElement(), "clientHeight"); onResize(width, height); } }
/** This method is called immediately after a widget becomes attached to the browser's document. */ @Override protected void onLoad () { // Reset the position attribute of the parent element DOM.setStyleAttribute(getElement(), "position", "relative"); ResizableWidgetCollection.get().add(this); redraw(); }
public void setBarStyleName (String barClassName) { DOM.setElementProperty(barElement, "className", barClassName); }
/** This method is called immediately after a widget becomes attached to the browser's document. */ @Override protected void onLoad () { // Reset the position attribute of the parent element DOM.setStyleAttribute(getElement(), "position", "relative"); ResizableWidgetCollection.get().add(this); redraw(); }
public void setBarStyleName (String barClassName) { DOM.setElementProperty(barElement, "className", barClassName); }