List of usage examples for com.vaadin.client ComputedStyle ComputedStyle
public ComputedStyle(Element elem)
From source file:info.magnolia.ui.vaadin.gwt.client.layout.thumbnaillayout.widget.ThumbnailsSizeKeeper.java
License:Open Source License
private void updateCalculatedOffsetSizes() { ComputedStyle cs;/*from w w w.j a v a2 s.c o m*/ int[] padding; int[] border; int[] margin; if (thumbnailParent.getChildCount() > 0) { final Element firstThumbnail = Element.as(thumbnailParent.getFirstChild()); cs = new ComputedStyle(firstThumbnail); padding = cs.getPadding(); border = cs.getBorder(); margin = cs.getMargin(); } else { final Element stub = Element.as(DOM.createDiv()); stub.addClassName("thumbnail"); thumbnailParent.appendChild(stub); cs = new ComputedStyle(stub); padding = cs.getPadding(); border = cs.getBorder(); margin = cs.getMargin(); thumbnailParent.removeChild(stub); } horizontalDecorations = padding[1] + padding[3] + border[1] + border[3] + margin[1] + margin[3]; verticalDecorations = padding[0] + padding[2] + border[0] + border[2] + margin[0] + margin[2]; this.unscaledWidth = baseWidth + horizontalDecorations; this.unscaledHeight = baseHeight + verticalDecorations; this.calculatedWidth = scaleDimension(baseWidth, ratio); this.calculatedHeight = scaleDimension(baseHeight, ratio); }
From source file:info.magnolia.ui.vaadin.gwt.client.richtext.TextAreaStretcherConnector.java
License:Open Source License
private void updateSize() { if (!getState().isCollapsed) { stretchControl.replaceClassName("icon-open-fullscreen-2", "icon-close-fullscreen-2"); stretchControl.replaceClassName(COLLAPSED, STRETCHED); form.asWidget().addStyleName("textarea-stretched"); Style style = textWidget.getElement().getStyle(); style.setPosition(Style.Position.ABSOLUTE); Element header = getDialogHeaderElement(); ComputedStyle headerCS = new ComputedStyle(header); int top = form.getAbsoluteTop() - dialog.getAbsoluteTop(); top = isOverlay ? top : top + headerCS.getPadding()[0] + headerCS.getPadding()[2]; int left = isOverlay ? 0 : form.getAbsoluteLeft(); style.setLeft(left, Style.Unit.PX); style.setTop(top, Style.Unit.PX); stretchTextArea(style);// w ww . j a v a 2 s.c om style.setZIndex(5); if (!isOverlay && !isRichTextEditor) { stretchControl.getStyle().setTop(top + 5, Style.Unit.PX); stretchControl.getStyle().setLeft( left + textWidget.getOffsetWidth() - stretchControl.getOffsetWidth() - 5, Style.Unit.PX); } hideOtherStretchers(); } else { stretchControl.replaceClassName(STRETCHED, COLLAPSED); stretchControl.replaceClassName("icon-close-fullscreen-2", "icon-open-fullscreen-2"); form.asWidget().removeStyleName(TEXTAREA_STRETCHED); clearTraces(); } }
From source file:org.vaadin.addons.portallayout.gwt.client.portal.strategy.StackHeightRedistributionStrategy.java
License:Apache License
@Override public void redistributeHeights(PortalLayoutConnector portalConnector) { Profiler.enter("PLC.recalcHeight"); Iterator<ComponentConnector> it = portalConnector.getCurrentChildren().iterator(); List<ComponentConnector> relativeHeightPortlets = new ArrayList<ComponentConnector>(); double totalPercentage = 0; int totalFixedHeightConsumption = 0; while (it.hasNext()) { ComponentConnector cc = it.next(); PortletConnector portletConnector = PortalLayoutUtil.getPortletConnectorForContent(cc); if (portletConnector != null) { if (portletConnector.hasRelativeHeight()) { totalPercentage += Util.parseRelativeSize(portletConnector.getState().height); relativeHeightPortlets.add(cc); } else { PortletChrome portletWidget = portletConnector.getPortletChrome(); totalFixedHeightConsumption += cc.getLayoutManager() .getOuterHeight(portletWidget.getAssociatedSlot().getElement()); }//from www. ja v a 2s .c o m } } if (totalPercentage > 0) { totalPercentage = Math.max(totalPercentage, 100); int totalPortalHeight = portalConnector.getLayoutManager() .getInnerHeight(portalConnector.getWidget().getElement()); boolean isSpacing = portalConnector.getState().spacing; int spacingConsumption = 0; if (isSpacing && portalConnector.getView().getWidgetCount() > 0) { Element spacingEl = portalConnector.getWidget().getElement().getChild(0).cast(); spacingConsumption += new ComputedStyle(spacingEl).getIntProperty("height") * portalConnector.getView().getWidgetCount() - 1; } int reservedForRelativeSize = totalPortalHeight - totalFixedHeightConsumption - spacingConsumption; double ratio = reservedForRelativeSize / (double) totalPortalHeight * 100d; for (ComponentConnector cc : relativeHeightPortlets) { PortletConnector portletConnector = PortalLayoutUtil.getPortletConnectorForContent(cc); if (!portletConnector.isCollapsed()) { float percentageHeight = Util.parseRelativeSize(portletConnector.getState().height); double slotHeight = (percentageHeight / totalPercentage * ratio); int headerHeight = portletConnector.getPortletChrome().getHeader().getOffsetHeight(); double headerHeightPercentage = (double) headerHeight / totalPortalHeight * 100d; String slotHeightStr = Math.max(slotHeight, headerHeightPercentage) + "%"; portletConnector.getPortletChrome().getAssociatedSlot().setHeight(slotHeightStr); } } } Profiler.leave("PLC.recalcHeight"); }