Examples of Measure


Examples of org.apache.myfaces.tobago.layout.Measure

    final boolean showLabelRight = UIToolBar.LABEL_RIGHT.equals(labelPosition);
    final boolean showLabel = showLabelBottom || showLabelRight;
    // two separate buttons for the command and the sub menu
    final boolean separateButtons = hasAnyCommand(command) && dropDownMenu != null;

    final Measure paddingTop = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-top");
    final Measure paddingMiddle = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-middle");
    final Measure paddingBottom = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-bottom");
    final Measure paddingLeft = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-left");
    final Measure paddingCenter = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-center");
    final Measure paddingRight = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-right");
    final Measure iconBigHeight = resources.getThemeMeasure(facesContext, toolBar, "custom.icon-big-height");
    final Measure iconSmallHeight = resources.getThemeMeasure(facesContext, toolBar, "custom.icon-small-height");
    final Measure iconBigWidth = resources.getThemeMeasure(facesContext, toolBar, "custom.icon-big-width");
    final Measure iconSmallWidth = resources.getThemeMeasure(facesContext, toolBar, "custom.icon-small-width");

    // label style
    final Style labelStyle;
    if (showLabel) {
      labelStyle = new Style();
View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

    final boolean showLabelRight = UIToolBar.LABEL_RIGHT.equals(labelPosition);
    final boolean showLabel = showLabelBottom || showLabelRight;

    final ResourceManager resources = getResourceManager();

    final Measure paddingTop = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-top");
    final Measure paddingMiddle = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-middle");
    final Measure paddingBottom = resources.getThemeMeasure(facesContext, toolBar, "custom.padding-bottom");
    final Measure iconHeight = iconBig
        ? resources.getThemeMeasure(facesContext, toolBar, "custom.icon-big-height")
        : resources.getThemeMeasure(facesContext, toolBar, "custom.icon-small-height");
    final Measure labelHeight = resources.getThemeMeasure(facesContext, toolBar, "custom.label-height");

    Measure result = paddingTop;
    if (showIcon) {
      result = result.add(iconHeight);
      if (showLabel && showLabelBottom) {
        result = result.add(paddingMiddle);
        result = result.add(labelHeight);
      }
    } else {
      if (showLabel) {
        result = result.add(labelHeight);
      } else {
        // both off: use some reasonable defaults
        result = result.add(16);
      }
    }
    result = result.add(paddingBottom);
    return result;
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

  }

  @Override
  public Measure getHeight(FacesContext facesContext, Configurable component) {
    UISelectOneRadio select = (UISelectOneRadio) component;
    Measure heightOfOne = super.getHeight(facesContext, component);
    if (select.isInline()) {
      return heightOfOne;
    } else {
      List<SelectItem> items = RenderUtils.getItemsToRender((UISelectOne) component);
      return heightOfOne.multiply(items.size());
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

    final AbstractUILink link = (AbstractUILink) component;
    final LabelWithAccessKey label = new LabelWithAccessKey(link);
    final String text = label.getText();
    final String image = link.getImage();

    Measure width = PixelMeasure.ZERO;
    if (text != null) {
      final Measure m = RenderUtils.calculateStringWidth(facesContext, link, text);
      width = width.add(m);
    }
    if ((text != null && image != null)) {
      width = width.add(4);
    }
View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

  @Override
  public Measure getPreferredWidth(FacesContext facesContext, Configurable component) {

    UIButton button = (UIButton) component;
    Measure width = Measure.ZERO;
    boolean image = button.getImage() != null;
    if (image) {
      width = getResourceManager().getThemeMeasure(facesContext, button, "imageWidth");
    }
    LabelWithAccessKey label = new LabelWithAccessKey(button);

    width = width.add(RenderUtils.calculateStringWidth(facesContext, button, label.getText()));
    Measure padding = getResourceManager().getThemeMeasure(facesContext, button, "paddingWidth");
    // left padding, right padding and when an image and an text then a middle padding.
    width = width.add(padding.multiply(image && label.getText() != null ? 3 : 2));

    return width;
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

    if (title == null && diff > 0) {
      title = Integer.toString(100 * model.getValue() / diff) + " %";
    }

    final Style style = new Style(facesContext, progress);
    final Measure width = style.getWidth();
    final Measure valueWidth = diff > 0 ? width.multiply(model.getValue()).divide(diff) : width;

    final Style valueStyle = new Style();
    valueStyle.setHeight(style.getHeight());
    valueStyle.setWidth(valueWidth);

View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    ResourceManager resourceManager = ResourceManagerFactory.getResourceManager(facesContext);
    String contextPath = facesContext.getExternalContext().getRequestContextPath();
    String sheetId = sheet.getClientId(facesContext);

    Measure sheetHeight;
    if (style.getHeight() == null) {
      // FIXME: nullpointer if height not defined
      LOG.error("no height in parent container, setting to 100");
      sheetHeight = Measure.valueOf(100);
    } else {
      sheetHeight = style.getHeight();
    }
    Measure footerHeight = getFooterHeight(facesContext, sheet);
    Measure headerHeight = getHeaderHeight(facesContext, sheet);
    String selectable = sheet.getSelectable();

    Application application = facesContext.getApplication();
    SheetState state = sheet.getSheetState(facesContext);
    List<Integer> columnWidths = sheet.getWidthList();

    final List<Integer> selectedRows = getSelectedRows(sheet, state);
    final List<UIColumn> renderedColumnList = sheet.getRenderedColumns();

    writer.startElement(HtmlElements.INPUT, null);
    writer.writeIdAttribute(sheetId + WIDTHS_POSTFIX);
    writer.writeNameAttribute(sheetId + WIDTHS_POSTFIX);
    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
    writer.writeAttribute(HtmlAttributes.VALUE, StringUtils.joinWithSurroundingSeparator(columnWidths), false);
    writer.endElement(HtmlElements.INPUT);

    writer.startElement(HtmlElements.INPUT, null);
    writer.writeIdAttribute(sheetId + SCROLL_POSTFIX);
    writer.writeNameAttribute(sheetId + SCROLL_POSTFIX);
    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
    Integer[] scrollPosition = sheet.getScrollPosition();
    if (scrollPosition != null) {
      String scroll = scrollPosition[0] + ";" + scrollPosition[1];
      writer.writeAttribute(HtmlAttributes.VALUE, scroll, false);
    } else {
      writer.writeAttribute(HtmlAttributes.VALUE, "", false);
    }
    writer.endElement(HtmlElements.INPUT);

    if (!UISheet.NONE.equals(selectable)) {
      writer.startElement(HtmlElements.INPUT, null);
      writer.writeIdAttribute(sheetId + SELECTED_POSTFIX);
      writer.writeNameAttribute(sheetId + SELECTED_POSTFIX);
      writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
      writer.writeAttribute(
          HtmlAttributes.VALUE, StringUtils.joinWithSurroundingSeparator(selectedRows), true);
      writer.endElement(HtmlElements.INPUT);
    }

    final boolean showHeader = sheet.isShowHeader();
    final boolean ie6SelectOneFix = showHeader
        && ClientProperties.getInstance(facesContext).getUserAgent().isMsie6()
            && ComponentUtils.findDescendant(sheet, UISelectOne.class) != null;
// BEGIN RENDER BODY CONTENT
    Style bodyStyle = new Style();
    bodyStyle.setPosition(Position.RELATIVE);
    Measure tableBodyWidth = sheet.getCurrentWidth().subtractNotNegative(getContentBorder(facesContext, sheet));
    bodyStyle.setWidth(tableBodyWidth);
    if (sheet.isPagingVisible()) {
      sheetHeight = sheetHeight.subtract(footerHeight);
    }
    if (ie6SelectOneFix) {
      bodyStyle.setTop(headerHeight);
    }
    if (showHeader) {
      sheetHeight = sheetHeight.subtract(headerHeight);
    }
    bodyStyle.setHeight(sheetHeight);

    writer.startElement(HtmlElements.DIV, null);
    writer.writeIdAttribute(sheetId + ComponentUtils.SUB_SEPARATOR + "data_div");
    writer.writeClassAttribute(Classes.create(sheet, "body"));

    if (!showHeader || ie6SelectOneFix) {
      bodyStyle.setPaddingTop(Measure.ZERO);
    }

    writer.writeStyleAttribute(bodyStyle);
    bodyStyle.setHeight(null);
    bodyStyle.setTop(null);
    Style sheetBodyStyle = new Style(bodyStyle);
    final boolean needVerticalScrollbar = needVerticalScrollbar(facesContext, sheet, style);
    if (needVerticalScrollbar) {
      tableBodyWidth = tableBodyWidth.subtractNotNegative(getVerticalScrollbarWeight(facesContext, sheet));
    }
    sheetBodyStyle.setWidth(tableBodyWidth);

    writer.startElement(HtmlElements.TABLE, null);
    writer.writeAttribute(HtmlAttributes.CELLSPACING, 0);
View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

      int first = sheet.getFirst();
      int rows = sheet.hasRows()
          ? Math.min(sheet.getRowCount(), first + sheet.getRows()) - first
          : sheet.getRowCount();
      LOG.error("20; // FIXME: make dynamic (was removed by changing the layout");
      final Measure rowPadding = getCustomMeasure(facesContext, sheet, "rowPadding");
      Measure heightNeeded = getFooterHeight(facesContext, sheet)
              .add(rowPadding.add(20/*fixme*/).multiply(rows))
              .add(20); // FIXME: make dynamic (was removed by changing the layouting
      return heightNeeded.greaterThan(style.getHeight());
    } else {
      return false;
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

  }

  @Override
  public Measure getPreferredHeight(FacesContext facesContext, Configurable component) {
    final UISheet sheet = (UISheet) component;
    Measure headerHeight = getHeaderHeight(facesContext, sheet);
    Measure rowHeight = getRowHeight(facesContext, sheet);
    Measure footerHeight = getFooterHeight(facesContext, sheet);
    int rows = sheet.getRows();

    if (LOG.isDebugEnabled()) {
      LOG.debug(headerHeight + " " + footerHeight + " " + rowHeight + " " + rows);
    }
View Full Code Here

Examples of org.apache.myfaces.tobago.layout.Measure

  private void encodeHeader(
      FacesContext facesContext, TobagoResponseWriter writer, UITabGroup tabGroup, int activeIndex)
      throws IOException {

    Measure width = tabGroup.getCurrentWidth();
    Measure headerHeight = getResourceManager().getThemeMeasure(facesContext, tabGroup, "headerHeight");
    Measure toolBarWidth = getResourceManager().getThemeMeasure(facesContext, tabGroup, "toolBarWidth");
    Style header = new Style();
    header.setPosition(Position.RELATIVE);
    header.setWidth(width.subtractNotNegative(toolBarWidth));
    header.setHeight(headerHeight);
    writer.startElement(HtmlElements.DIV, tabGroup);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.