All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fit.cssbox.layout.StackingContext Maven / Gradle / Ivy

Go to download

CSSBox is an (X)HTML/CSS rendering engine written in pure Java. Its primary purpose is to provide a complete information about the rendered page suitable for further processing. However, it also allows displaying the rendered document.

There is a newer version: 5.0.2
Show newest version
/*
 * StackingContext.java
 * Copyright (c) 2005-2013 Radek Burget
 *
 * CSSBox is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *  
 * CSSBox is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *  
 * You should have received a copy of the GNU Lesser General Public License
 * along with CSSBox. If not, see .
 *
 * Created on 15.2.2013, 14:25:24 by burgetr
 */
package org.fit.cssbox.layout;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Set;
import java.util.Vector;

/**
 * A stacking context. It gathers the information about child stacking contexts and their z-indices.
 * 
 * @author burgetr
 */
public class StackingContext extends HashMap> 
{
    private static final long serialVersionUID = -2945581861967274084L;

    /** The box that creates this stacking context */
    private ElementBox elementBox;
        
    
    public StackingContext(ElementBox element)
    {
        super();
        this.elementBox = element;
    }
    
    public ElementBox getElementBox()
    {
        return elementBox;
    }
    
    public Integer[] getZIndices()
    {
        Set zindices = keySet();
        Integer[] clevels = zindices.toArray(new Integer[0]); 
        Arrays.sort(clevels);
        return clevels;
    }
    
    public Vector getElementsForZIndex(int zindex)
    {
        return get(zindex);
    }
    
    public void registerChildContext(ElementBox element)
    {
        int zindex = element.hasZIndex() ? element.getZIndex() : 0; //put 'auto' z-indices into level 0
        Vector list = get(zindex);
        if (list == null)
        {
            list = new Vector();
            put(zindex, list);
        }
        list.add(element);
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy