List of usage examples for com.google.gwt.user.client.ui Widget setHeight
public void setHeight(String height)
From source file:rocket.widget.client.splitter.HorizontalSplitterPanel.java
License:Apache License
/** * Lays out all added widgets summing their individual weights and then * assigns widths to each.//from ww w . ja v a 2s. c om */ protected void redraw0() { final int weightSum = this.sumWeights(); final InternalPanel panel = this.getPanel(); final int availableWidth = panel.getParentElement().getOffsetWidth(); final int splitterCount = (panel.getWidgetCount() - 1) / 2; final int splitterWidth = this.getSplitterSize(); final int allocatedWidgetWidth = availableWidth - splitterCount * splitterWidth; final float ratio = (float) allocatedWidgetWidth / weightSum; int left = 0; final Iterator<SplitterItem> items = this.getItems().iterator(); final Iterator<Widget> widgets = panel.iterator(); boolean more = widgets.hasNext(); while (more) { final Widget widget = widgets.next(); final SplitterItem item = items.next(); // set the widget position... final Element widgetElement = widget.getElement(); final InlineStyle widgetInlineStyle = InlineStyle.getInlineStyle(widgetElement); widgetInlineStyle.setString(Css.POSITION, "absolute"); widgetInlineStyle.setInteger(Css.LEFT, left, CssUnit.PX); widgetInlineStyle.setInteger(Css.TOP, 0, CssUnit.PX); widgetInlineStyle.setString(Css.OVERFLOW, "hidden"); // set the size(width/height)... widget.setHeight("100%"); // is the last widget ??? if (false == widgets.hasNext()) { widget.setWidth((availableWidth - left) + "px"); break; } // calculate the new width... final int weight = item.getSizeShare(); final int width = (int) (ratio * weight); widget.setWidth(width + "px"); left = left + width; final Widget splitter = (Widget) widgets.next(); // set the splitter position... final InlineStyle splitterInlineStyle = InlineStyle.getInlineStyle(splitter.getElement()); splitterInlineStyle.setString(Css.POSITION, "absolute"); splitterInlineStyle.setInteger(Css.LEFT, left, CssUnit.PX); splitterInlineStyle.setInteger(Css.TOP, 0, CssUnit.PX); splitterInlineStyle.setString(Css.OVERFLOW, "hidden"); // set the splitters size... splitter.setWidth(splitterWidth + "px"); splitter.setHeight("100%"); left = left + splitterWidth; more = widgets.hasNext(); } }
From source file:rocket.widget.client.splitter.VerticalSplitterPanel.java
License:Apache License
/** * This is the most important event handler that takes care of adjusting the * widths of the widgets before and after the splitter being moved. * /*from w w w .jav a 2 s .c o m*/ * @param splitter * @param event */ protected void onMouseMove(final MouseMoveEvent event) { Checker.notNull("parameter:event", event); while (true) { final Splitter splitter = (Splitter) event.getWidget(); // need to figure out if mouse has moved to the right or left... final int mouseY = event.getPageY(); final int splitterY = DOM.getAbsoluteTop(splitter.getElement()); // if the mouse has not moved vertically but vertically so exit... int delta = mouseY - splitterY; if (0 == delta) { break; } // grab the widgets before and after the splitter being dragged... final InternalPanel panel = this.getPanel(); final int panelIndex = panel.indexOf(splitter); final Widget beforeWidget = panel.get(panelIndex - 1); int beforeWidgetHeight = beforeWidget.getOffsetHeight() + delta; final Widget afterWidget = panel.get(panelIndex + 1); int afterWidgetHeight = afterWidget.getOffsetHeight() - delta; final int heightSum = beforeWidgetHeight + afterWidgetHeight; final List<SplitterItem> items = this.getItems(); // if the mouse moved left make sure the beforeWidget width is not // less than its minimumHeight. if (delta < 0) { final SplitterItem beforeWidgetItem = items.get(panelIndex / 2); final int minimumHeight = beforeWidgetItem.getMinimumSize(); if (beforeWidgetHeight < minimumHeight) { delta = minimumHeight - (beforeWidgetHeight - delta); beforeWidgetHeight = minimumHeight; afterWidgetHeight = heightSum - beforeWidgetHeight; } } // since the mouse moved right make sure the afterWidget width is // not less than its minimumHeight if (delta > 0) { final SplitterItem afterWidgetItem = items.get(panelIndex / 2 + 1); final int minimumHeight = afterWidgetItem.getMinimumSize(); if (afterWidgetHeight < minimumHeight) { delta = afterWidgetHeight + delta - minimumHeight; afterWidgetHeight = minimumHeight; beforeWidgetHeight = heightSum - afterWidgetHeight; } } // save! beforeWidget.setHeight(beforeWidgetHeight + "px"); afterWidget.setHeight(afterWidgetHeight + "px"); // update the coordinates of both the splitter and after widget... adjustYCoordinate(splitter, delta); adjustYCoordinate(afterWidget, delta); beforeWidget.setWidth("100%"); splitter.setWidth("100%"); afterWidget.setWidth("100%"); // its necessary to prevent the event to stop text selection in // opera. break; } }
From source file:rocket.widget.client.splitter.VerticalSplitterPanel.java
License:Apache License
/** * Lays out all added widgets summing their individual weights and then * assigns widths to each.//from w w w . j a va 2s . co m */ protected void redraw0() { final int weightSum = this.sumWeights(); final InternalPanel panel = this.getPanel(); final int availableHeight = DOM.getElementPropertyInt(panel.getParentElement(), "offsetHeight"); final int splitterCount = (panel.getWidgetCount() - 1) / 2; final int splitterHeight = this.getSplitterSize(); final int allocatedWidgetHeight = availableHeight - splitterCount * splitterHeight; final float ratio = (float) allocatedWidgetHeight / weightSum; int top = 0; final Iterator<SplitterItem> items = this.getItems().iterator(); final Iterator<Widget> widgets = panel.iterator(); boolean more = widgets.hasNext(); while (more) { final Widget widget = widgets.next(); final SplitterItem item = items.next(); // set the widget position... final InlineStyle widgetInlineStyle = InlineStyle.getInlineStyle(widget.getElement()); widgetInlineStyle.setString(Css.POSITION, "absolute"); widgetInlineStyle.setInteger(Css.LEFT, 0, CssUnit.PX); widgetInlineStyle.setInteger(Css.TOP, top, CssUnit.PX); widgetInlineStyle.setString(Css.OVERFLOW, "hidden"); // set the size(width/height)... widget.setWidth("100%"); // is the last widget ??? if (false == widgets.hasNext()) { widget.setHeight((availableHeight - top) + "px"); break; } // calculate the new width... final int weight = item.getSizeShare(); final int height = (int) (ratio * weight); widget.setHeight(height + "px"); top = top + height; final Widget splitter = (Widget) widgets.next(); // set the splitter position... final InlineStyle splitterInlineStyle = InlineStyle.getInlineStyle(splitter.getElement()); splitterInlineStyle.setString(Css.POSITION, "absolute"); splitterInlineStyle.setInteger(Css.LEFT, 0, CssUnit.PX); splitterInlineStyle.setInteger(Css.TOP, top, CssUnit.PX); splitterInlineStyle.setString(Css.OVERFLOW, "hidden"); // set the splitters size... splitter.setWidth("100%"); splitter.setHeight(splitterHeight + "px"); top = top + splitterHeight; more = widgets.hasNext(); } }
From source file:scrum.client.project.EstimationBarWidget.java
License:Open Source License
@Override protected void onUpdate() { EstimationBar bar = requirement == null ? null : requirement.getEstimationBar(); if (bar == null) bar = new EstimationBar(0, new ArrayList<Float>()); flowPanel.clear();//w w w.j av a 2 s .c om List<Float> estimations = bar.getWorkPerSprint(); int sprintOffset = bar.getSprintOffset(); for (int i = 0; i < estimations.size(); i++) { int barIndex; if ((i + sprintOffset) % 2 == 0) { barIndex = 0; } else { barIndex = 1; } Widget w = Gwt.createEmptyDiv("EstimationBarWidget-bar" + barIndex); w.setHeight("6px"); w.setWidth((factor * estimations.get(i)) + "px"); flowPanel.add(w); } String tip; int requiredSprints = estimations.size() <= 1 ? sprintOffset + 1 : sprintOffset + estimations.size(); tip = "Expected to be completed after " + requiredSprints + " sprint" + (requiredSprints == 1 ? "." : "s."); flowPanel.getElement().setTitle(tip); }
From source file:scrum.client.sprint.RequirementWorkIndicatorBarWidget.java
License:Open Source License
@Override protected void onUpdate() { Sprint sprint = requirement.getSprint(); int maxBarWidth = 125; // Gwt.getRootWidget().getOffsetWidth() / 10; int maxWorkInRequirement = 1; for (Requirement r : sprint.getRequirements()) { int work = r.getBurnedWork() + r.getRemainingWork(); if (work > maxWorkInRequirement) maxWorkInRequirement = work; }// www. j a v a 2s . co m int pixelsPerHour = maxBarWidth / maxWorkInRequirement; flowPanel.clear(); int burnedHours = requirement.getBurnedWork(); Widget burnedWidget = Gwt.createEmptyDiv("EstimationBarWidget-bar1"); burnedWidget.setHeight("6px"); burnedWidget.setWidth((pixelsPerHour * burnedHours) + "px"); flowPanel.add(burnedWidget); int remainingHours = requirement.getRemainingWork(); Widget remainingWidget = Gwt.createEmptyDiv("EstimationBarWidget-bar0"); remainingWidget.setHeight("6px"); remainingWidget.setWidth((pixelsPerHour * remainingHours) + "px"); flowPanel.add(remainingWidget); flowPanel.getElement().setTitle(burnedHours + " of " + (burnedHours + remainingHours) + " hours burned."); }