Package com.volantis.mcs.layouts

Examples of com.volantis.mcs.layouts.FormatVisitorAdapter


    }

    private Map buildContainerNameToPositionMap(final Format rootFormat) {

        final Map fragmentToCounter = new HashMap();
        FormatVisitorAdapter visitor = new FormatVisitorAdapter() {
            public boolean visitFormat(final Format format, final Object object) {
                if (format instanceof Pane || format instanceof Region) {
                    final Fragment fragment = format.getEnclosingFragment();
                    if (fragment != null) {
                        final String containerName = format.getName();

                        Counter counter =
                            (Counter) fragmentToCounter.get(fragment);
                        if (counter == null) {
                            counter = new Counter();
                            fragmentToCounter.put(fragment, counter);
                        }

                        final Map map = (Map) object;
                        List fragments = (List) map.get(containerName);
                        if (fragments == null) {
                            fragments = new LinkedList();
                            map.put(containerName, fragments);
                        }
                        fragments.add(new ContainerPosition(fragment,
                            counter.getCount()));

                        counter.increment();
                    }
                }
                return false;
            }
        };
        final Map containerNameToFragments = new HashMap();
        try {
            if (rootFormat != null) {
                visitor.visitFormatChildren(rootFormat, containerNameToFragments);
            }
        } catch (FormatVisitorException e) {
            e.printStackTrace();
            throw new IllegalStateException("Cannot traverse format hierarchy");
        }
View Full Code Here


    }

    public StyleSheet build(Layout layout) {
        final StyleSheet styleSheet = styleSheetFactory.createStyleSheet();

        FormatVisitorAdapter visitor = new FormatVisitorAdapter() {

            public boolean visitFormat(Format format, Object object) {

                FormatRuleBuilder builder =
                        builderSelector.selectBuilder(format);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.layouts.FormatVisitorAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.