List of usage examples for com.google.gwt.dom.client Style setPaddingBottom
public void setPaddingBottom(double value, Unit unit)
From source file:com.github.gwtbootstrap.client.ui.WellNavList.java
License:Apache License
private void setStyle() { Style style = getElement().getStyle(); style.setPaddingTop(8, Unit.PX);//w w w . jav a 2s.c o m style.setPaddingBottom(8, Unit.PX); style.setPaddingLeft(0, Unit.PX); style.setPaddingRight(0, Unit.PX); }
From source file:com.haulmont.cuba.web.toolkit.ui.client.groupbox.CubaGroupBoxConnector.java
License:Apache License
protected void layoutGroupBox() { CubaGroupBoxWidget panel = getWidget(); LayoutManager layoutManager = getLayoutManager(); if (isBordersVisible()) { int captionWidth = layoutManager.getOuterWidth(panel.captionNode); int captionStartWidth = layoutManager.getInnerWidth(panel.captionStartDeco); int totalMargin = captionWidth + captionStartWidth; panel.captionNode.getStyle().setWidth(captionWidth, Unit.PX); panel.captionWrap.getStyle().setPaddingLeft(totalMargin, Unit.PX); panel.captionStartDeco.getStyle().setMarginLeft(0 - totalMargin, Unit.PX); }//from w w w.j av a 2s. co m Profiler.enter("CubaGroupBoxConnector.layout getHeights"); // Haulmont API get max height of caption components int top = layoutManager.getOuterHeight(panel.captionNode); top = Math.max(layoutManager.getOuterHeight(panel.captionStartDeco), top); top = Math.max(layoutManager.getOuterHeight(panel.captionEndDeco), top); int bottom = layoutManager.getInnerHeight(panel.bottomDecoration); Profiler.leave("PanelConnector.layout getHeights"); Style style = panel.getElement().getStyle(); int paddingTop = 0; int paddingBottom = 0; if (panel.hasAnyOuterMargin()) { Profiler.enter("PanelConnector.layout get values from styles"); // Clear previously set values style.clearPaddingTop(); style.clearPaddingBottom(); // Calculate padding from styles ComputedStyle computedStyle = new ComputedStyle(panel.getElement()); paddingTop = computedStyle.getIntProperty("padding-top"); paddingBottom = computedStyle.getIntProperty("padding-bottom"); Profiler.leave("PanelConnector.layout get values from styles"); } Profiler.enter("PanelConnector.layout modify style"); panel.captionWrap.getStyle().setMarginTop(-top, Style.Unit.PX); panel.bottomDecoration.getStyle().setMarginBottom(-bottom, Style.Unit.PX); style.setPaddingTop(top + paddingTop, Style.Unit.PX); style.setPaddingBottom(bottom + paddingBottom, Style.Unit.PX); Profiler.leave("PanelConnector.layout modify style"); // Update scroll positions Profiler.enter("PanelConnector.layout update scroll positions"); panel.contentNode.setScrollTop(panel.scrollTop); panel.contentNode.setScrollLeft(panel.scrollLeft); Profiler.leave("PanelConnector.layout update scroll positions"); // Read actual value back to ensure update logic is correct Profiler.enter("PanelConnector.layout read scroll positions"); panel.scrollTop = panel.contentNode.getScrollTop(); panel.scrollLeft = panel.contentNode.getScrollLeft(); Profiler.leave("PanelConnector.layout read scroll positions"); }
From source file:com.sciencegadgets.client.algebra.EquationHTML.java
License:Open Source License
/** * Matches the heights of all the children of an {@link TypeSGET#Equation}, * {@link TypeSGET#Term} or {@link TypeSGET#Sum} by:<br/> * 1.Lifting centers to the tallest denominator using padding-bottom<br/> * 2.Matching tops to tallest height with padding-top<br/> * <b>Note:</b> All children of these nodes are initially aligned at their * baseline//from w w w .j av a 2 s . c om */ private void matchHeightsAndAlign(Element curEl) { EquationNode curNode = displayMap.get(curEl); TypeSGET curType = null; if (curNode != null) { curType = curNode.getType(); } if (curEl.getChildCount() > 0) { for (int i = 0; i < curEl.getChildCount(); i++) { if (Node.ELEMENT_NODE == curEl.getChild(i).getNodeType()) { matchHeightsAndAlign((Element) curEl.getChild(i)); } } } if (!(TypeSGET.Equation.equals(curType) || TypeSGET.Term.equals(curType) || TypeSGET.Sum.equals(curType) || TypeSGET.Exponential.equals(curType))) { return; } LinkedList<Element> childrenHorizontal = new LinkedList<Element>(); LinkedList<Element> fractionChildrenHorizontal = new LinkedList<Element>(); addChildrenIfInline(curEl, childrenHorizontal, curType); double pxPerEm = getPxPerEm(curEl); // Fractions must be centered, find the tallest numerator or denominator // to match using padding to allow centering int tallestFracChild = 0; for (Element child : childrenHorizontal) { // Find the tallest denominator to match centers if (child.getClassName().contains(TypeSGET.Fraction.getCSSClassName())) { if (child.getFirstChildElement().getClassName().contains("fenced")) { child = child.getFirstChildElement(); } fractionChildrenHorizontal.add(child); for (int i = 0; i < 2; i++) { int fracChildHeight = ((Element) child.getChild(i)).getClientHeight(); if (fracChildHeight > tallestFracChild) { tallestFracChild = fracChildHeight; } } } } // Match fraction horizontal lines inline for (Element fractionChild : fractionChildrenHorizontal) { int numHeight = ((Element) fractionChild.getChild(0)).getClientHeight(); int denHeight = ((Element) fractionChild.getChild(2)).getClientHeight(); Style s = fractionChild.getStyle(); s.setPaddingTop((tallestFracChild - numHeight) / pxPerEm, Unit.EM); s.setPaddingBottom((tallestFracChild - denHeight) / pxPerEm, Unit.EM); // s.setBottom((tallestFracChild - denHeight) / pxPerEm, // Unit.EM); } // Find highest top and lowest bottom to match heights // int lowestBottom = 0; // int highestTop = 999999999; // for (Element child : childrenHorizontal) { // int childTop = child.getAbsoluteTop(); // if (childTop < highestTop) { // highestTop = childTop; // } // int childBottom = child.getAbsoluteBottom(); // if (childBottom > lowestBottom) { // lowestBottom = childBottom; // } // } // // highestTop = curEl.getAbsoluteTop(); // lowestBottom = curEl.getAbsoluteBottom(); // Lift exponents of fraction bases to top // if (TypeSGET.Exponential.equals(curType)) { // Element base = ((Element) curEl.getChild(0)); // Element exp = ((Element) curEl.getChild(1)); // int lift = (exp.getOffsetTop() - base.getOffsetTop()); // exp.getStyle().setBottom(lift / pxPerEm, Unit.EM); // Align inline siblings flush using padding at highest and lowest // } else { // for (Element child : childrenHorizontal) { // Style s = child.getStyle(); // // // Fractions with some padding don't need to be aligned // if (fractionChildrenHorizontal.contains(child)) { // if (!"0em".equals(s.getPaddingTop()) // || !"0em".equals(s.getPaddingBottom())) { // continue; // } // }else // if(child.getClassName().contains(TypeML.Operation.toString())) { // continue; // } // // int childTopPad = child.getAbsoluteTop() - highestTop; // int childBottomPad = lowestBottom - child.getAbsoluteBottom(); // // s.setPaddingTop(childTopPad / pxPerEm, Unit.EM); // s.setPaddingBottom(childBottomPad / pxPerEm, Unit.EM); // } // } }
From source file:com.sencha.gxt.widget.core.client.container.PortalLayoutContainer.java
License:sencha.com license
/** * Creates a portal layout container with the specified appearance and number * of columns.//from w w w . j a v a2 s.c om * * @param appearance the portal layout appearance * @param numColumns the number of columns managed by this portal */ public PortalLayoutContainer(PortalLayoutAppearance appearance, int numColumns) { this.appearance = appearance; this.numColumns = numColumns; handler = createHandler(); container = new CssFloatLayoutContainer(); container.setAdjustForScroll(true); initWidget(container); getElement().getStyle().setOverflow(Overflow.AUTO); for (int i = 0; i < numColumns; i++) { CssFloatLayoutContainer con = new CssFloatLayoutContainer(); Style columnStyle = con.getElement().getStyle(); columnStyle.setPaddingTop(spacing, Unit.PX); columnStyle.setPaddingRight((i < numColumns - 1) ? (spacing / 2) : spacing, Unit.PX); columnStyle.setPaddingBottom(0, Unit.PX); // bottom is set on the portlet columnStyle.setPaddingLeft((i > 0) ? (spacing / 2) : spacing, Unit.PX); container.insert(con, container.getWidgetCount()); } }
From source file:com.sencha.gxt.widget.core.client.container.PortalLayoutContainer.java
License:sencha.com license
/** * Sets the spacing between portlets (defaults to 10). * /* www. j ava 2 s .c o m*/ * @param spacing the spacing in pixels */ public void setSpacing(int spacing) { this.spacing = spacing; for (int i = 0; i < numColumns; i++) { CssFloatLayoutContainer con = getWidget(i); Style columnStyle = con.getElement().getStyle(); columnStyle.setPaddingTop(spacing, Unit.PX); columnStyle.setPaddingRight((i < numColumns - 1) ? (spacing / 2) : spacing, Unit.PX); columnStyle.setPaddingBottom(0, Unit.PX); // bottom is set on the portlet columnStyle.setPaddingLeft((i > 0) ? (spacing / 2) : spacing, Unit.PX); for (int j = 0; j < con.getWidgetCount(); j++) { Style portletStyle = con.getWidget(j).getElement().getStyle(); portletStyle.setMarginBottom(spacing, Unit.PX); } } }
From source file:com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout.java
License:Apache License
/** * Update the offset off the caption relative to the slot * <p>/*from w w w . j av a 2 s . c om*/ * For internal use only. May be removed or replaced in the future. * * @param caption * The caption element * @deprecated As of 7.2, call or override * {@link #updateCaptionOffset(Element)} instead */ @Deprecated public void updateCaptionOffset(com.google.gwt.user.client.Element caption) { Element captionWrap = caption.getParentElement(); Style captionWrapStyle = captionWrap.getStyle(); captionWrapStyle.clearPaddingTop(); captionWrapStyle.clearPaddingRight(); captionWrapStyle.clearPaddingBottom(); captionWrapStyle.clearPaddingLeft(); Style captionStyle = caption.getStyle(); captionStyle.clearMarginTop(); captionStyle.clearMarginRight(); captionStyle.clearMarginBottom(); captionStyle.clearMarginLeft(); // Get caption position from the classname CaptionPosition captionPosition = getCaptionPositionFromElement(captionWrap); if (captionPosition == CaptionPosition.LEFT || captionPosition == CaptionPosition.RIGHT) { int captionWidth; if (layoutManager != null) { captionWidth = layoutManager.getOuterWidth(caption) - layoutManager.getMarginWidth(caption); } else { captionWidth = caption.getOffsetWidth(); } if (captionWidth > 0) { if (captionPosition == CaptionPosition.LEFT) { captionWrapStyle.setPaddingLeft(captionWidth, Unit.PX); captionStyle.setMarginLeft(-captionWidth, Unit.PX); } else { captionWrapStyle.setPaddingRight(captionWidth, Unit.PX); captionStyle.setMarginRight(-captionWidth, Unit.PX); } } } if (captionPosition == CaptionPosition.TOP || captionPosition == CaptionPosition.BOTTOM) { int captionHeight; if (layoutManager != null) { captionHeight = layoutManager.getOuterHeight(caption) - layoutManager.getMarginHeight(caption); } else { captionHeight = caption.getOffsetHeight(); } if (captionHeight > 0) { if (captionPosition == CaptionPosition.TOP) { captionWrapStyle.setPaddingTop(captionHeight, Unit.PX); captionStyle.setMarginTop(-captionHeight, Unit.PX); } else { captionWrapStyle.setPaddingBottom(captionHeight, Unit.PX); captionStyle.setMarginBottom(-captionHeight, Unit.PX); } } } }
From source file:com.vaadin.client.ui.panel.PanelConnector.java
License:Apache License
void updateSizes() { VPanel panel = getWidget();//from ww w . j a v a 2 s. c o m LayoutManager layoutManager = getLayoutManager(); Profiler.enter("PanelConnector.layout getHeights"); int top = layoutManager.getOuterHeight(panel.captionNode); int bottom = layoutManager.getInnerHeight(panel.bottomDecoration); Profiler.leave("PanelConnector.layout getHeights"); Profiler.enter("PanelConnector.layout modify style"); Style style = panel.getElement().getStyle(); panel.captionNode.getParentElement().getStyle().setMarginTop(-top, Unit.PX); panel.bottomDecoration.getStyle().setMarginBottom(-bottom, Unit.PX); style.setPaddingTop(top, Unit.PX); style.setPaddingBottom(bottom, Unit.PX); Profiler.leave("PanelConnector.layout modify style"); // Update scroll positions Profiler.enter("PanelConnector.layout update scroll positions"); panel.contentNode.setScrollTop(panel.scrollTop); panel.contentNode.setScrollLeft(panel.scrollLeft); Profiler.leave("PanelConnector.layout update scroll positions"); // Read actual value back to ensure update logic is correct Profiler.enter("PanelConnector.layout read scroll positions"); panel.scrollTop = panel.contentNode.getScrollTop(); panel.scrollLeft = panel.contentNode.getScrollLeft(); Profiler.leave("PanelConnector.layout read scroll positions"); }
From source file:com.vaadin.client.ui.window.WindowConnector.java
License:Apache License
@Override public void layout() { LayoutManager lm = getLayoutManager(); VWindow window = getWidget();// w ww . j a v a 2 s. c o m ComponentConnector content = getContent(); boolean hasContent = (content != null); Element contentElement = window.contentPanel.getElement(); Style contentStyle = window.contents.getStyle(); int headerHeight = lm.getOuterHeight(window.header); contentStyle.setPaddingTop(headerHeight, Unit.PX); contentStyle.setMarginTop(-headerHeight, Unit.PX); int footerHeight = lm.getOuterHeight(window.footer); contentStyle.setPaddingBottom(footerHeight, Unit.PX); contentStyle.setMarginBottom(-footerHeight, Unit.PX); int minWidth = lm.getOuterWidth(window.header) - lm.getInnerWidth(window.header); int minHeight = footerHeight + headerHeight; getWidget().getElement().getStyle().setPropertyPx("minWidth", minWidth); getWidget().getElement().getStyle().setPropertyPx("minHeight", minHeight); /* * Must set absolute position if the child has relative height and * there's a chance of horizontal scrolling as some browsers will * otherwise not take the scrollbar into account when calculating the * height. */ if (hasContent) { Element layoutElement = content.getWidget().getElement(); Style childStyle = layoutElement.getStyle(); // IE8 needs some hackery to measure its content correctly WidgetUtil.forceIE8Redraw(layoutElement); if (content.isRelativeHeight() && !BrowserInfo.get().isIE9()) { childStyle.setPosition(Position.ABSOLUTE); Style wrapperStyle = contentElement.getStyle(); if (window.getElement().getStyle().getWidth().length() == 0 && !content.isRelativeWidth()) { /* * Need to lock width to make undefined width work even with * absolute positioning */ int contentWidth = lm.getOuterWidth(layoutElement); wrapperStyle.setWidth(contentWidth, Unit.PX); } else { wrapperStyle.clearWidth(); } } else { childStyle.clearPosition(); } } }
From source file:com.vaadin.tests.widgetset.client.WidgetUtilTestWidget.java
License:Apache License
private void setPadding(Element e) { Style borderStyle = e.getStyle(); borderStyle.setPaddingLeft(2.4, Unit.PX); borderStyle.setPaddingRight(3.5, Unit.PX); borderStyle.setPaddingTop(2.4, Unit.PX); borderStyle.setPaddingBottom(3.5, Unit.PX); }
From source file:org.dashbuilder.renderer.client.metric.MetricViewImpl.java
License:Apache License
public void applySettings(DisplayerSettings displayerSettings) { this.displayerSettings = displayerSettings; int w = displayerSettings.getChartWidth(); int h = displayerSettings.getChartHeight(); int mtop = displayerSettings.getChartMarginTop(); int mbottom = displayerSettings.getChartMarginBottom(); int mleft = displayerSettings.getChartMarginLeft(); int mright = displayerSettings.getChartMarginRight(); // Hero panel (size) Style style = heroPanel.getElement().getStyle(); style.setPadding(0, Style.Unit.PX); style.setWidth(w, Style.Unit.PX); style.setHeight(h, Style.Unit.PX); style.setTextAlign(Style.TextAlign.CENTER); style.setVerticalAlign(Style.VerticalAlign.MIDDLE); if (!StringUtils.isBlank(displayerSettings.getChartBackgroundColor())) { style.setBackgroundColor("#" + displayerSettings.getChartBackgroundColor()); }/* w w w.jav a 2s . c o m*/ // Center panel (paddings) style = centerPanel.getElement().getStyle(); style.setPaddingTop(mtop, Style.Unit.PX); style.setPaddingBottom(mbottom, Style.Unit.PX); style.setPaddingLeft(mleft, Style.Unit.PX); style.setPaddingRight(mright, Style.Unit.PX); // Title panel titlePanel.setVisible(displayerSettings.isTitleVisible()); titlePanel.setText(displayerSettings.getTitle()); }