Package bibliothek.gui.dock.util.font

Examples of bibliothek.gui.dock.util.font.GenericFontModifier


    public void setFont( String key, String... modifications ){
        if( modifications.length == 0 ){
            setFont( key, (FontModifier)null );
        }
        else{
            GenericFontModifier modifier = new GenericFontModifier();
            for( String modification : modifications ){
                String[] entry = split( modification );
                String entryKey = entry[0];
                String entryValue = entry[1];
               
                boolean italic = "i".equals( entryKey );
                boolean bold = "b".equals( entryKey );
                boolean size = "s".equals( entryKey );
               
                if( italic || bold ){
                    GenericFontModifier.Modify modify;
                   
                    if( "+".equals( entryValue )){
                        modify = GenericFontModifier.Modify.ON;
                    }
                    else if( "-".equals( entryValue )){
                        modify = GenericFontModifier.Modify.OFF;
                    }
                    else if( "!".equals( entryValue )){
                        modify = GenericFontModifier.Modify.REVERSE;
                    }
                    else{
                        throw new IllegalArgumentException( "illegal value, must be one of '+', '-' or '!': " + modification );
                    }
                   
                    if( italic )
                        modifier.setItalic( modify );
                    else
                        modifier.setBold( modify );
                }
                else if( size ){
                    String number;
                   
                    if( entryValue.startsWith( "+" )){
                        modifier.setSizeDelta( true );
                        number = entryValue.substring( 1 ).trim();
                    }
                    else if( entryValue.startsWith( "-" )){
                        modifier.setSizeDelta( true );
                        number = entryValue.substring( 1 ).trim();
                    }
                    else{
                        modifier.setSizeDelta( false );
                        number = entryValue;
                    }
                   
                    int parsed = Integer.parseInt( number );
                    if( entryValue.startsWith( "-" )){
                        parsed = -parsed;
                    }
                   
                    modifier.setSize( parsed );
                }
                else{
                    throw new IllegalArgumentException( "unknown key: " + modification );
                }
            }
View Full Code Here

TOP

Related Classes of bibliothek.gui.dock.util.font.GenericFontModifier

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.