当前位置: 首页>>代码示例>>Java>>正文


Java CSSUnits类代码示例

本文整理汇总了Java中org.fit.cssbox.css.CSSUnits的典型用法代码示例。如果您正苦于以下问题:Java CSSUnits类的具体用法?Java CSSUnits怎么用?Java CSSUnits使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CSSUnits类属于org.fit.cssbox.css包,在下文中一共展示了CSSUnits类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: VisualContext

import org.fit.cssbox.css.CSSUnits; //导入依赖的package包/类
public VisualContext(VisualContext parent, BoxFactory factory)
{
    this.parent = parent;
    this.factory = factory;
    rootContext = (parent == null) ? this : parent.rootContext;
    em = CSSUnits.medium_font;
    rem = em;
    ex = 0.6 * em;
    ch = 0.8 * ch; //just an initial guess, updated in updateForGraphics()
    dpi = org.fit.cssbox.css.CSSUnits.dpi;
    font = new Font(Font.SERIF, Font.PLAIN, (int) CSSUnits.medium_font);
    fontSize = CSSUnits.points(CSSUnits.medium_font);
    fontWeight = CSSProperty.FontWeight.NORMAL;
    fontStyle = CSSProperty.FontStyle.NORMAL;
    fontVariant = CSSProperty.FontVariant.NORMAL;
    textDecoration = new ArrayList<CSSProperty.TextDecoration>(2); //it is not very probable to have more than two decorations
    color = Color.BLACK;
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:19,代码来源:VisualContext.java

示例2: getBorderWidth

import org.fit.cssbox.css.CSSUnits; //导入依赖的package包/类
/**
 * Reads the value of a border width specified by a CSS property.
 * @param dec a CSS decoder used for converting the values
 * @param property the property name, e.g. "border-top-width"
 * @return the border width in pixels
 */
public int getBorderWidth(CSSDecoder dec, String property)
{
    if (style != null)
    {
        CSSProperty.BorderWidth prop = style.getProperty(property);
        if (prop == CSSProperty.BorderWidth.length)
        {
            TermLengthOrPercent w = style.getValue(TermLengthOrPercent.class, property);
            if (w == null)
                return CSSUnits.MEDIUM_BORDER;
            else
            {
                double pxw = dec.getContext().pxLength(w);
                if (pxw > 0 && pxw < 1)
                    return 1; //thinner borders should be drawn with 1px line
                else
                    return (int) pxw;
            }
        }
        else
            return CSSUnits.convertBorderWidth(prop);
    }
    else
        return 0;
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:32,代码来源:ElementBox.java

示例3: drawBorder

import org.fit.cssbox.css.CSSUnits; //导入依赖的package包/类
private void drawBorder(Graphics2D g, int x1, int y1, int x2, int y2, int width, 
                        int right, int down, String side, boolean reverse)
{
    TermColor tclr = style.getSpecifiedValue(TermColor.class, "border-"+side+"-color");
    CSSProperty.BorderStyle bst = style.getProperty("border-"+side+"-style");
    if (bst != CSSProperty.BorderStyle.HIDDEN && (tclr == null || !tclr.isTransparent()))
    {
        //System.out.println("Elem: " + this + "side: " + side + "color: " + tclr);
        Color clr = null;
        if (tclr != null)
            clr = CSSUnits.convertColor(tclr.getValue());
        if (clr == null)
        {
            clr = ctx.getColor();
            if (clr == null)
                clr = Color.BLACK;
        }
        g.setColor(clr);
        g.setStroke(new CSSStroke(width, bst, reverse));
        g.draw(new Line2D.Double(x1 + right, y1 + down, x2 + right, y2 + down));
    }
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:23,代码来源:ElementBox.java

示例4: loadBackground

import org.fit.cssbox.css.CSSUnits; //导入依赖的package包/类
/**
 * Loads the background information from the style
 */
protected void loadBackground()
{
    CSSProperty.BackgroundColor bg = style.getProperty("background-color");
    if (bg == CSSProperty.BackgroundColor.color)
    {
        TermColor bgc = style.getSpecifiedValue(TermColor.class, "background-color");
        if (bgc.isTransparent())
            bgcolor = null;
        else
            bgcolor = CSSUnits.convertColor(bgc.getValue());
    }
    else
        bgcolor = null;

    bgimages = loadBackgroundImages(style);
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:20,代码来源:ElementBox.java

示例5: VisualContext

import org.fit.cssbox.css.CSSUnits; //导入依赖的package包/类
public VisualContext(VisualContext parent, BoxFactory factory)
{
    this.parent = parent;
    this.factory = factory;
    font = new Font(Font.SERIF, Font.PLAIN, (int)((CSSUnits.medium_font * 72) / dpi)); //convert medium font to pixels
    fontWeight = CSSProperty.FontWeight.NORMAL;
    fontStyle = CSSProperty.FontStyle.NORMAL;
    fontVariant = CSSProperty.FontVariant.NORMAL;
    textDecoration = new ArrayList<CSSProperty.TextDecoration>(2); //it is not very probable to have more than two decorations
    em = CSSUnits.medium_font;
    ex = 0.6 * em;
    dpi = org.fit.cssbox.css.CSSUnits.dpi;
    color = Color.BLACK;
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:15,代码来源:VisualContext.java

示例6: getBorderWidth

import org.fit.cssbox.css.CSSUnits; //导入依赖的package包/类
/**
 * Reads the value of a border width specified by a CSS property.
 * @param dec a CSS decoder used for converting the values
 * @param property the property name, e.g. "border-top-width"
 * @return the border width in pixels
 */
public int getBorderWidth(CSSDecoder dec, String property)
{
    if (style != null)
    {
        CSSProperty.BorderWidth prop = style.getProperty(property);
        if (prop == CSSProperty.BorderWidth.length)
            return dec.getLength(style.getValue(TermLengthOrPercent.class, property), false, CSSUnits.MEDIUM_BORDER, 0, 0);
        else
            return CSSUnits.convertBorderWidth(prop);
    }
    else
        return 0;
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:20,代码来源:ElementBox.java

示例7: writeBorderSVG

import org.fit.cssbox.css.CSSUnits; //导入依赖的package包/类
private void writeBorderSVG(ElementBox eb, int x1, int y1, int x2, int y2, String side, int width, int right, int down)
{
    TermColor tclr = eb.getStyle().getValue(TermColor.class, "border-"+side+"-color");
    CSSProperty.BorderStyle bst = eb.getStyle().getProperty("border-"+side+"-style");
    if (bst != CSSProperty.BorderStyle.HIDDEN && (tclr == null || !tclr.isTransparent()))
    {
        Color clr = null;
        if (tclr != null)
            clr = CSSUnits.convertColor(tclr.getValue());
        if (clr == null)
        {
            clr = eb.getVisualContext().getColor();
            if (clr == null)
                clr = Color.BLACK;
        }

        String stroke = "";
        if (bst == CSSProperty.BorderStyle.SOLID)
        {
            stroke = "stroke-width:" + width;
        }
        else if (bst == CSSProperty.BorderStyle.DOTTED)
        {
            stroke = "stroke-width:" + width + ";stroke-dasharray:" + width + "," + width;
        }
        else if (bst == CSSProperty.BorderStyle.DASHED)
        {
            stroke = "stroke-width:" + width + ";stroke-dasharray:" + (3*width) + "," + width;
        }
        else if (bst == CSSProperty.BorderStyle.DOUBLE)
        {
            //double is not supported yet, we'll use single
            stroke = "stroke-width:" + width;
        }
        else //default or unsupported - draw a solid line
        {
            stroke = "stroke-width:" + width;
        }
        
        String coords = "M " + (x1+right) + "," + (y1+down) + " L " + (x2+right) + "," + (y2+down);
        String style = "fill:none;stroke:" + colorString(clr) + ";" + stroke;
        out.println("<path style=\"" + style + "\" d=\"" + coords + "\" />");  
    }
}
 
开发者ID:radkovo,项目名称:CSSBox,代码行数:45,代码来源:SVGRenderer.java


注:本文中的org.fit.cssbox.css.CSSUnits类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。