Example usage for com.google.gwt.dom.client Style setFontSize

List of usage examples for com.google.gwt.dom.client Style setFontSize

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style setFontSize.

Prototype

public void setFontSize(double value, Unit unit) 

Source Link

Usage

From source file:org.eclipse.che.ide.ui.smartTree.Tree.java

License:Open Source License

private void ensureFocusElement() {
    if (focusEl != null) {
        focusEl.removeFromParent();// www  .j  a va2s .c  o m
    }
    focusEl = getElement().appendChild(focusImpl.createFocusable());
    focusEl.addClassName(treeStyles.styles().noFocusOutline());
    if (focusEl.hasChildNodes()) {
        focusEl.getFirstChildElement().addClassName(treeStyles.styles().noFocusOutline());
        Style focusElStyle = focusEl.getFirstChildElement().getStyle();
        focusElStyle.setBorderWidth(0, Style.Unit.PX);
        focusElStyle.setFontSize(1, Style.Unit.PX);
        focusElStyle.setPropertyPx("lineHeight", 1);
    }
    focusEl.getStyle().setLeft(0, Style.Unit.PX);
    focusEl.getStyle().setTop(0, Style.Unit.PX);
    focusEl.getStyle().setPosition(Style.Position.ABSOLUTE);

    //subscribe for Event.FOCUSEVENTS
    int bits = DOM.getEventsSunk((Element) focusEl.cast()); //do not remove redundant cast, GWT tests will fail
    DOM.sinkEvents((Element) focusEl.cast(), bits | Event.FOCUSEVENTS);
}

From source file:org.gwtbootstrap3.client.ui.FormLabel.java

License:Apache License

/**
 * @return a new icon element. We only create this when {@link #iconElement} is null or the
 *         {@link #showRequiredIndicator} has changed.
 *///from w ww .j  a v  a  2 s .c  o  m
protected Element createIconElement() {
    Element e = Document.get().createElement(ElementTags.I);
    e.addClassName(Styles.FONT_AWESOME_BASE);
    e.addClassName(IconType.STAR.getCssName());
    Style s = e.getStyle();
    s.setFontSize(6, Unit.PX);
    s.setPaddingLeft(2, Unit.PX);
    s.setPaddingRight(5, Unit.PX);
    s.setColor("#b94a48");
    Element sup = Document.get().createElement("sup");
    sup.appendChild(e);
    return sup;
}

From source file:org.jbpm.form.builder.ng.model.common.panels.FieldSetPanel.java

License:Apache License

public FieldSetPanel() {
    super();//  ww w  .jav a 2s  . c  o  m
    Style divStyle = getElement().getStyle();
    Style lgndStyle = legend.getStyle();

    divStyle.setBorderWidth(2, Unit.PX);
    divStyle.setBorderStyle(BorderStyle.SOLID);
    divStyle.setMarginTop(0.5, Unit.EM);
    divStyle.setMarginBottom(0.5, Unit.EM);
    divStyle.setMarginRight(0, Unit.PX);
    divStyle.setMarginLeft(0, Unit.PX);
    divStyle.setPaddingTop(0, Unit.PX);
    divStyle.setPaddingBottom(0, Unit.PX);
    divStyle.setPaddingRight(0.5, Unit.EM);
    divStyle.setPaddingLeft(0.5, Unit.EM);

    lgndStyle.setFontSize(100.0, Unit.PCT);
    lgndStyle.setFontWeight(FontWeight.NORMAL);
    lgndStyle.setMarginTop(-0.5, Unit.EM);
    lgndStyle.setMarginRight(0, Unit.PX);
    lgndStyle.setMarginLeft(0, Unit.PX);
    lgndStyle.setMarginBottom(0, Unit.PX);
    lgndStyle.setBackgroundColor("white");
    lgndStyle.setColor("black");
    lgndStyle.setFloat(Style.Float.LEFT);
    lgndStyle.setPaddingTop(0, Unit.PX);
    lgndStyle.setPaddingBottom(0, Unit.PX);
    lgndStyle.setPaddingRight(2, Unit.PX);
    lgndStyle.setPaddingLeft(2, Unit.PX);

    getElement().appendChild(legend);
}

From source file:org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.dom.TextAreaDOMElement.java

License:Apache License

public TextAreaDOMElement(final TextArea widget, final GridLayer gridLayer, final GridWidget gridWidget,
        final SessionManager sessionManager,
        final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
        final Function<GridCellTuple, Command> hasNoValueCommand,
        final Function<GridCellValueTuple, Command> hasValueCommand) {
    super(widget, gridLayer, gridWidget);
    this.sessionManager = sessionManager;
    this.sessionCommandManager = sessionCommandManager;
    this.hasNoValueCommand = hasNoValueCommand;
    this.hasValueCommand = hasValueCommand;

    final Style style = widget.getElement().getStyle();
    style.setWidth(100, Style.Unit.PCT);
    style.setHeight(100, Style.Unit.PCT);
    style.setPaddingLeft(2, Style.Unit.PX);
    style.setPaddingRight(2, Style.Unit.PX);
    style.setPaddingTop(2, Style.Unit.PX);
    style.setPaddingBottom(2, Style.Unit.PX);
    style.setFontSize(10, Style.Unit.PX);
    style.setProperty("resize", "none");

    getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingTop(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingBottom(5, Style.Unit.PX);
    getContainer().setWidget(widget);/* w  w  w . jav a2  s.  c  om*/
}

From source file:org.komodo.web.client.panels.vdb.VdbEditPanel.java

License:Apache License

private Widget createObjectPropertiesPanel() {
    Style objPropPanelStyle = objectPropertiesPanel.getElement().getStyle();

    /*/*from  w  w w . j  a v  a 2  s  .  c  o  m*/
     * Want to position the properties panel so its always to the right
     * of the diagram panel, even when zoomed in. Float: left fails to
     * work at this point since zoom in enough and the properties
     * panel jumps down below.
     */

    /*
     * Set the position of the properties panel to absolute so that we
     * are now in charge of its location
     */
    objPropPanelStyle.setPosition(Position.ABSOLUTE);

    /*
     * Set its position as being on same level as diagram panel
     */
    objPropPanelStyle.setTop(0, Unit.EM);

    /*
     * Move it to the right of the diagram panel which is the
     * diagram panel width + border width + an extra 2 units
     * to account for the vertical scrollbar width
     */
    objPropPanelStyle.setLeft(DIAGRAM_PANEL_WIDTH + BORDER_WIDTH + 2, Unit.EM);

    /*
     * Set its width and height to appropriate values
     */
    objPropPanelStyle.setWidth((DIAGRAM_PANEL_WIDTH * 3) / 5, Unit.EM);
    objPropPanelStyle.setHeight(EDIT_PANEL_HEIGHT, Unit.EM);

    /*
     * Set its background colour to a subtle shade that just frames the panel
     */
    objPropPanelStyle.setBackgroundColor("#fAfAfA"); //$NON-NLS-1$

    /*
     * Set overflow to use scrollbars if required
     */
    objPropPanelStyle.setOverflow(Overflow.AUTO);

    /*
     * Add the title
     */
    Label propertyTitle = new Label("Property Editor"); //$NON-NLS-1$
    Style titleStyle = propertyTitle.getElement().getStyle();

    /*
     * Centre the title
     * Set its font size and make it bold
     * Set its height as this ensures a value we can know when
     * passing on the remaining content area to the sub panels, ie.
     * SUB_PANEL_HEIGHT = DIAGRAM_PANEL_HEIGHT
     *                                          - PROPERTY_TITLE_HEIGHT + (BORDER_WIDTH * 2)
     */
    titleStyle.setTextAlign(TextAlign.CENTER);
    titleStyle.setFontSize(1, Unit.EM);
    titleStyle.setFontWeight(FontWeight.BOLD);
    titleStyle.setLineHeight(PROPERTY_TITLE_HEIGHT, Unit.EM);
    titleStyle.setHeight(PROPERTY_TITLE_HEIGHT, Unit.EM);
    objectPropertiesPanel.add(propertyTitle);

    return objectPropertiesPanel;
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.ListBoxDOMElement.java

License:Apache License

public ListBoxDOMElement(final ListBox widget, final GridLayer gridLayer, final GridWidget gridWidget) {
    super(widget, gridLayer, gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100, Style.Unit.PCT);
    style.setHeight(HEIGHT, Style.Unit.PX);
    style.setPaddingLeft(2, Style.Unit.PX);
    style.setPaddingRight(2, Style.Unit.PX);
    style.setFontSize(10, Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0, Style.Unit.PX);
    style.setPaddingBottom(0, Style.Unit.PX);
    style.setProperty("WebkitBoxSizing", "border-box");
    style.setProperty("MozBoxSizing", "border-box");
    style.setProperty("boxSizing", "border-box");
    style.setProperty("lineHeight", "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX);
    getContainer().setWidget(widget);/*from w  w w .j av  a2 s .  c  om*/
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.TextBoxDOMElement.java

License:Apache License

public TextBoxDOMElement(final TextBox widget, final GridLayer gridLayer, final GridWidget gridWidget) {
    super(widget, gridLayer, gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100, Style.Unit.PCT);
    style.setHeight(HEIGHT, Style.Unit.PX);
    style.setPaddingLeft(2, Style.Unit.PX);
    style.setPaddingRight(2, Style.Unit.PX);
    style.setFontSize(10, Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0, Style.Unit.PX);
    style.setPaddingBottom(0, Style.Unit.PX);
    style.setProperty("WebkitBoxSizing", "border-box");
    style.setProperty("MozBoxSizing", "border-box");
    style.setProperty("boxSizing", "border-box");
    style.setProperty("lineHeight", "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX);
    getContainer().setWidget(widget);//  w  ww.j av  a  2 s .  c  om
}

From source file:org.waveprotocol.wave.client.editor.content.paragraph.DefaultParagraphHtmlRenderer.java

License:Apache License

@Override
public void updateRendering(HasImplNodelets element, String type, String listStyle, int indent,
        Alignment alignment, Direction direction) {

    Element implNodelet = element.getImplNodelet();
    ParagraphBehaviour behaviour = ParagraphBehaviour.of(type);
    boolean toListItem = behaviour == ParagraphBehaviour.LIST;
    boolean isListItem = implNodelet.getTagName().equalsIgnoreCase(LIST_IMPL_TAGNAME);

    if (isListItem != toListItem) {
        Element newNodelet = createNodeletInner(toListItem);
        DomHelper.replaceElement(implNodelet, newNodelet);
        element.setBothNodelets(newNodelet);
        // Ideally onRepair shouldn't require a ContentElement
        ParagraphHelper.INSTANCE.onRepair((ContentElement) element);

        implNodelet = newNodelet;/*from  w  ww.jav a 2  s  .c o m*/
    }

    //// Type logic ////

    double fontSize = -1;
    FontWeight fontWeight = null;
    implNodelet.removeClassName(NUMBERED_CLASSNAME);

    switch (behaviour) {
    case LIST:
        if (Paragraph.LIST_STYLE_DECIMAL.equals(listStyle)) {
            implNodelet.addClassName(NUMBERED_CLASSNAME);
        }
        break;
    case HEADING:
        fontWeight = FontWeight.BOLD;
        double headingNum = Integer.parseInt(type.substring(1));
        // Do this with CSS instead.
        // h1 -> 1.75, h4 -> 1, others linearly in between.
        double factor = 1 - (headingNum - 1) / (Paragraph.NUM_HEADING_SIZES - 1);
        fontSize = MIN_HEADING_SIZE_EM + factor * (MAX_HEADING_SIZE_EM - MIN_HEADING_SIZE_EM);
        break;
    }

    //// Indent logic ////

    for (String bulletType : BULLET_CLASSNAMES) {
        implNodelet.removeClassName(bulletType);
    }

    if (behaviour == ParagraphBehaviour.LIST) {
        if (listStyle == null) {
            implNodelet.addClassName(bulletClassName(indent));
        }
        indent++;
    }

    int margin = indent * INDENT_UNIT_SIZE_PX;

    //// Update actual values ////

    // NOTE(danilatos): For these, it might be more efficient to check that the
    // value has changed before changing it. This is not currently  known.

    Style style = implNodelet.getStyle();

    if (fontSize != -1) {
        style.setFontSize(fontSize, Unit.EM);
    } else {
        style.clearFontSize();
    }

    if (fontWeight != null) {
        style.setFontWeight(fontWeight);
    } else {
        style.clearFontWeight();
    }

    if (alignment != null) {
        style.setProperty("textAlign", alignment.cssValue());
    } else {
        style.clearProperty("textAlign");
    }

    if (direction != null) {
        style.setProperty("direction", direction.cssValue());
    } else {
        style.clearProperty("direction");
    }

    if (margin == 0) {
        style.clearMarginLeft();
        style.clearMarginRight();
    } else {
        if (direction == Direction.RTL) {
            style.setMarginRight(margin, Unit.PX);
            style.clearMarginLeft();
        } else {
            style.setMarginLeft(margin, Unit.PX);
            style.clearMarginRight();
        }
    }
}