本文整理汇总了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;
}
示例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;
}
示例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));
}
}
示例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);
}
示例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;
}
示例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;
}
示例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 + "\" />");
}
}