Package com.salas.bb.views.stylesheets.domain

Examples of com.salas.bb.views.stylesheets.domain.IRule


        String text = "~ { font: bold; }";
        Map rules = Parser.parseRules(text);

        assertEquals(1, rules.size());

        IRule rule = (IRule)rules.get("~");
        assertNotNull(rule);
        assertTrue(rule.getFont().isBold());
    }
View Full Code Here


        String text = "el { font: bold; }";
        Map rules = Parser.parseRules(text);

        assertEquals(1, rules.size());

        IRule rule = (IRule)rules.get("el");
        assertNotNull(rule);
        assertTrue(rule.getFont().isBold());
    }
View Full Code Here

        String text = "el.cl { font: bold; }";
        Map rules = Parser.parseRules(text);

        assertEquals(1, rules.size());

        IRule rule = (IRule)rules.get("el.cl");
        assertNotNull(rule);
        assertTrue(rule.getFont().isBold());
    }
View Full Code Here

        String text = ".cl { font: bold; }";
        Map rules = Parser.parseRules(text);

        assertEquals(1, rules.size());

        IRule rule = (IRule)rules.get(".cl");
        assertNotNull(rule);
        assertTrue(rule.getFont().isBold());
    }
View Full Code Here

            "el.cl { color: #000004; }";
        Map rules = Parser.parseRules(text);

        assertEquals(4, rules.size());

        IRule rule;
        rule = (IRule)rules.get("~");
        assertTrue(rule.getColor().equals(Color.decode("#000001")));

        rule = (IRule)rules.get("el");
        assertTrue(rule.getColor().equals(Color.decode("#000002")));

        rule = (IRule)rules.get(".cl");
        assertTrue(rule.getColor().equals(Color.decode("#000003")));

        rule = (IRule)rules.get("el.cl");
        assertTrue(rule.getColor().equals(Color.decode("#000004")));
    }
View Full Code Here

            String[] tags = new String[0]; // TODO fetch tags

            panel.setBackground(isSelected ? getSelectionBackground() : getBackground());
            box.setBackground(isSelected ? getSelectionBackground() : getBackground());

            IRule rule = stylesheet.getRule(el, tags);
            if (rule != null)
            {
                // Update font
                Font fnt = rule.getFont();
                boolean bold = fnt != null && fnt.isBold();
                if (defFont.isBold() != bold) setFont(defFont.deriveFont(bold ? Font.BOLD : Font.PLAIN));

                // Update color
                if (!isSelected)
                {
                    Color color = rule.getColor();
                    if (color == null) color = Color.BLACK;
                    setForeground(color);
                }

                // Assign icon
                Icon icon = rule.getIcon();
                setIcon(icon);
            }

//            checkbox.setFocusPainted(false);
//            checkbox.setBorderPainted(true);
View Full Code Here

                panel.add(box, cc.xy(1, 1));
                box.setSelected(node.isSelected());
                if (!leafFolders) el = "item";
            }

            IRule rule = getRule(el, tags);
            if (rule != null)
            {
                // Update font
                Font fnt = rule.getFont();
                boolean bold = fnt != null && fnt.isBold();

                Font curFont = getFont();
                if (curFont.isBold() != bold) setFont(curFont.deriveFont(bold ? Font.BOLD : Font.PLAIN));

                // Update color
                if (!sel)
                {
                    Color color = rule.getColor();
                    if (color == null) color = Color.BLACK;
                    setForeground(color);
                }

                // Assign icon
                Icon icon = rule.getIcon();
                setIcon(icon);
                setClosedIcon(icon);
                setOpenIcon(icon);
                setLeafIcon(icon);
            }
View Full Code Here

     * @throws IOException if loading of icon failed.
     */
    public Icon getIcon(String el, String[] classes)
        throws IOException
    {
        IRule rule = getRule(el, classes);
        return rule != null ? rule.getIcon() : null;
    }
View Full Code Here

     *
     * @return rule.
     */
    public IRule getRule(String el, String[] classes)
    {
        IRule rule;

        if (classes == null || classes.length == 0)
        {
            rule = getRule(el);
        } else
        {
            IRule rootClass;
            IRule elemDef, elemClass;

            Map rootClasses = getElementClasses(null, false);

            // Get root rules
            rule = getRule(rootClasses, null);
View Full Code Here

     *
     * @return rule.
     */
    private IRule getRule(String el)
    {
        IRule rule;

        Map rootClasses = getElementClasses(null, false);

        // Get root rules
        rule = getRule(rootClasses, null);

        // Get element rules
        if (el != null)
        {
            Map elemClasses = getElementClasses(el, false);
            rule = rule.overrideWith(getRule(elemClasses, null));
        }

        return rule;
    }
View Full Code Here

TOP

Related Classes of com.salas.bb.views.stylesheets.domain.IRule

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.