Java Code Examples for cz.vutbr.web.css.CSSFactory#createNodeData()

The following examples show how to use cz.vutbr.web.css.CSSFactory#createNodeData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BoxFactory.java    From CSSBox with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates the style definition for an anonymous box. It contains only the class name set to "Xanonymous"
 * and the display: property set according to the parametres.
 * @param display <code>display:</code> property value of the resulting style.
 * @return Resulting style definition
 */
public NodeData createAnonymousStyle(String display)
{
    NodeData ret = CSSFactory.createNodeData();
    
    Declaration cls = CSSFactory.getRuleFactory().createDeclaration();
    cls.unlock();
    cls.setProperty("class");
    cls.add(CSSFactory.getTermFactory().createString("Xanonymous"));
    ret.push(cls);
    
    Declaration disp = CSSFactory.getRuleFactory().createDeclaration();
    disp.unlock();
    disp.setProperty("display");
    disp.add(CSSFactory.getTermFactory().createIdent(display));
    ret.push(disp);
    
    return ret;
}
 
Example 2
Source File: Viewport.java    From CSSBox with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
    * Creates a new Viewport with the given initial size. The actual size may be increased during the layout. 
    *  
    * @param e The anonymous element representing the viewport.
    * @param ctx
    * @param factory The factory used for creating the child boxes.
    * @param root The root element of the rendered document.
    * @param width Preferred (minimal) width.
    * @param height Preferred (minimal) height.
    */
   public Viewport(Element e, VisualContext ctx, BoxFactory factory, Element root, float width, float height)
{
	super(e, ctx);
	ctx.setViewport(this);
	this.factory = factory;
	this.root = root;
	style = CSSFactory.createNodeData(); //Viewport starts with an empty style
       nested = new Vector<Box>();
       startChild = 0;
       endChild = 0;
	this.width = width;
	this.height = height;
       isblock = true;
       contblock = true;
       root = null;
       visibleRect = new Rectangle(0, 0, width, height);
}
 
Example 3
Source File: AnalyzerUtil.java    From jStyleParser with GNU Lesser General Public License v3.0 5 votes vote down vote up
static NodeData makeNodeData(final List<Declaration> decls)
{
	final NodeData main = CSSFactory.createNodeData();
       for (final Declaration d : decls)
           main.push(d);
       
       return main;
}
 
Example 4
Source File: StyleMap.java    From jStyleParser with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected NodeData createDataInstance()
{
	return CSSFactory.createNodeData();
}
 
Example 5
Source File: NodeDataVariantTest.java    From jStyleParser with GNU Lesser General Public License v3.0 4 votes vote down vote up
private long memoryUsage(Class<? extends NodeData> clazz) throws Exception {

		final int SAMPLE = 100;

		CSSFactory.registerNodeDataInstance(clazz);

		Object[] holder = new Object[SAMPLE];

		@SuppressWarnings("unused")
		Object throwAway = clazz.newInstance();

		long memoryUsageBefore, memoryUsageAfter;
		int i = 0;

		memoryUsageBefore = memoryUsage();
		for (i = 0; i < SAMPLE; i++)
			holder[i] = CSSFactory.createNodeData();
		memoryUsageAfter = memoryUsage();

		return Math.round((memoryUsageAfter - memoryUsageBefore)
				/ ((float) SAMPLE));

	}
 
Example 6
Source File: NodeDataVariantTest.java    From jStyleParser with GNU Lesser General Public License v3.0 3 votes vote down vote up
private long timeUsage(Class<? extends NodeData> clazz) throws Exception {

		final int SAMPLE = 100000;

		CSSFactory.registerNodeDataInstance(clazz);

		long timeBefore = System.currentTimeMillis();
		for (int i = 0; i < SAMPLE; i++)
			CSSFactory.createNodeData();
		long timeAfter = System.currentTimeMillis();

		return timeAfter - timeBefore;
	}