Search in sources :

Example 21 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class VirtualCell method getHeightLength.

/**
 * <p>getHeightLength.</p>
 *
 * @return a {@link org.loboevolution.html.style.HtmlLength} object.
 */
public HtmlLength getHeightLength() {
    final RTableCell cell = this.actualCell;
    final String heightText = cell.getHeightText();
    HTMLElementImpl elem = cell.getCellElement();
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) elem.getOwnerDocument();
    HtmlLength length = heightText == null ? null : new HtmlLength(heightText, doc);
    if (length != null) {
        length.divideBy(cell.getRowSpan());
    }
    return length;
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) HtmlLength(org.loboevolution.html.style.HtmlLength)

Example 22 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class ComputedCSSStyleDeclaration method getFontSize.

public String getFontSize() {
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) element.getDocumentNode();
    HTMLElementImpl parent = (HTMLElementImpl) element.getParentElement();
    int fontSize = -1;
    if (parent != null) {
        AbstractCSSProperties currentStyle = parent.getCurrentStyle();
        fontSize = FontValues.getPixelSize(currentStyle.getFontSize(), null, doc.getDefaultView(), -1);
    }
    if (fontSize == -1) {
        fontSize = Float.valueOf(FontValues.getFontSize(style.getFontSize(), doc.getDefaultView(), null)).intValue();
    }
    return fontSize + "px";
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)

Example 23 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class HtmlRendererContext method onContextMenu.

/**
 * This method must be overridden to implement a context menu.
 *
 * @param element a {@link org.loboevolution.html.dom.HTMLElement} object.
 * @param event a {@link java.awt.event.MouseEvent} object.
 * @return a boolean.
 */
public boolean onContextMenu(HTMLElement element, MouseEvent event) {
    HTMLElementImpl elem = (HTMLElementImpl) element;
    HTMLImageElementImpl elmImg = new HTMLImageElementImpl();
    if (elem.getCurrentStyle() != null && Strings.isNotBlank(elem.getCurrentStyle().getBackgroundImage())) {
        final String backgroundImageText = elem.getCurrentStyle().getBackgroundImage();
        String start = "url(";
        int startIdx = start.length() + 1;
        int closingIdx = backgroundImageText.lastIndexOf(')') - 1;
        String quotedUri = backgroundImageText.substring(startIdx, closingIdx);
        elmImg.setSrc(quotedUri);
        element = elmImg;
    }
    HtmlContextMenu menu = new HtmlContextMenu(element, this);
    if (element instanceof HTMLImageElementImpl) {
        JPopupMenu popupMenuImage = menu.popupMenuImage(htmlPanel.getBrowserPanel());
        popupMenuImage.show(event.getComponent(), event.getX(), event.getY());
        return false;
    } else if (element instanceof HTMLLinkElementImpl) {
        JPopupMenu popupMenuLink = menu.popupMenuLink(htmlPanel.getBrowserPanel());
        popupMenuLink.show(event.getComponent(), event.getX(), event.getY());
        return false;
    } else if (element instanceof HTMLElementImpl) {
        JPopupMenu popupMenuAbstract = menu.popupMenuAbstractUI();
        popupMenuAbstract.show(event.getComponent(), event.getX(), event.getY());
        return false;
    }
    return true;
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) HTMLLinkElementImpl(org.loboevolution.html.dom.domimpl.HTMLLinkElementImpl) HtmlContextMenu(org.loboevolution.html.gui.HtmlContextMenu) HTMLImageElementImpl(org.loboevolution.html.dom.domimpl.HTMLImageElementImpl)

Example 24 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class ComputedCSSStyleDeclaration method getHeight.

public String getHeight() {
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) element.getDocumentNode();
    HTMLElementImpl parent = (HTMLElementImpl) element.getParentElement();
    int availSize = -1;
    if (parent != null) {
        AbstractCSSProperties currentStyle = parent.getCurrentStyle();
        availSize = HtmlValues.getPixelSize(currentStyle.getHeight(), null, doc.getDefaultView(), -1);
    }
    if (availSize == -1) {
        HtmlRendererContext htmlRendererContext = doc.getHtmlRendererContext();
        HtmlPanel htmlPanel = htmlRendererContext.getHtmlPanel();
        Dimension preferredSize = htmlPanel.getPreferredSize();
        availSize = preferredSize.height;
    }
    final int height = HtmlValues.getPixelSize(style.getHeight(), null, doc.getDefaultView(), -1, availSize);
    return height + "px";
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) HtmlRendererContext(org.loboevolution.http.HtmlRendererContext) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) HtmlPanel(org.loboevolution.html.gui.HtmlPanel)

Example 25 with HTMLElementImpl

use of org.loboevolution.html.dom.domimpl.HTMLElementImpl in project LoboEvolution by LoboEvolution.

the class ComputedCSSStyleDeclaration method getWidth.

public String getWidth() {
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) element.getDocumentNode();
    HTMLElementImpl parent = (HTMLElementImpl) element.getParentElement();
    int availSize = -1;
    if (parent != null) {
        AbstractCSSProperties currentStyle = parent.getCurrentStyle();
        availSize = HtmlValues.getPixelSize(currentStyle.getWidth(), null, doc.getDefaultView(), -1);
    }
    if (availSize == -1) {
        HtmlRendererContext htmlRendererContext = doc.getHtmlRendererContext();
        HtmlPanel htmlPanel = htmlRendererContext.getHtmlPanel();
        Dimension preferredSize = htmlPanel.getPreferredSize();
        availSize = preferredSize.width;
    }
    final int width = HtmlValues.getPixelSize(style.getWidth(), null, doc.getDefaultView(), -1, availSize);
    return width + "px";
}
Also used : HTMLElementImpl(org.loboevolution.html.dom.domimpl.HTMLElementImpl) HtmlRendererContext(org.loboevolution.http.HtmlRendererContext) HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) HtmlPanel(org.loboevolution.html.gui.HtmlPanel)

Aggregations

HTMLElementImpl (org.loboevolution.html.dom.domimpl.HTMLElementImpl)39 HTMLDocumentImpl (org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)13 Test (org.junit.Test)11 LoboUnitTest (org.loboevolution.driver.LoboUnitTest)11 AbstractCSSProperties (org.loboevolution.html.style.AbstractCSSProperties)6 HtmlInsets (org.loboevolution.html.style.HtmlInsets)4 CSS3Properties (org.loboevolution.html.node.css.CSS3Properties)3 RenderState (org.loboevolution.html.renderstate.RenderState)3 HtmlLength (org.loboevolution.html.style.HtmlLength)3 BorderInfo (org.loboevolution.info.BorderInfo)3 CSSStyleDeclarationImpl (com.gargoylesoftware.css.dom.CSSStyleDeclarationImpl)2 ModelNode (org.loboevolution.html.dom.nodeimpl.ModelNode)2 HtmlPanel (org.loboevolution.html.gui.HtmlPanel)2 ListStyle (org.loboevolution.html.style.ListStyle)2 HtmlRendererContext (org.loboevolution.http.HtmlRendererContext)2 CSSStyleSheetImpl (com.gargoylesoftware.css.dom.CSSStyleSheetImpl)1 java.awt (java.awt)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1