make/jdk/src/classes/build/tools/generatenimbus/UIState.java
changeset 47389 18c850407be9
parent 47216 71c04702a3d5
equal deleted inserted replaced
47388:19b912843392 47389:18c850407be9
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package build.tools.generatenimbus;
    26 package build.tools.generatenimbus;
    27 
    27 
       
    28 import javax.xml.stream.XMLStreamException;
       
    29 import javax.xml.stream.XMLStreamReader;
    28 import java.util.Arrays;
    30 import java.util.Arrays;
    29 import java.util.Collections;
    31 import java.util.Collections;
    30 import java.util.Iterator;
    32 import java.util.Iterator;
    31 import java.util.List;
    33 import java.util.List;
    32 
    34 
    33 import javax.xml.bind.annotation.XmlAttribute;
    35 class UIState {
    34 import javax.xml.bind.annotation.XmlElement;
    36     private String stateKeys;
    35 
    37 
    36 class UIState {
       
    37     @XmlAttribute private String stateKeys;
       
    38     public String getStateKeys() { return stateKeys; }
    38     public String getStateKeys() { return stateKeys; }
    39 
    39 
    40     /** Indicates whether to invert the meaning of the 9-square stretching insets */
    40     /** Indicates whether to invert the meaning of the 9-square stretching insets */
    41     @XmlAttribute private boolean inverted;
    41     private boolean inverted;
    42 
    42 
    43     /** A cached string representing the list of stateKeys deliminated with "+" */
    43     /** A cached string representing the list of stateKeys deliminated with "+" */
    44     private String cachedName = null;
    44     private String cachedName = null;
    45 
    45 
    46     @XmlElement private Canvas canvas;
    46     private Canvas canvas;
    47     public Canvas getCanvas() { return canvas; }
    47     public Canvas getCanvas() { return canvas; }
    48 
    48 
    49     @XmlElement private UIStyle style;
    49     private UIStyle style;
    50     public UIStyle getStyle() { return style; }
    50     public UIStyle getStyle() { return style; }
       
    51 
       
    52     UIState(XMLStreamReader reader) throws XMLStreamException {
       
    53         stateKeys = reader.getAttributeValue(null, "stateKeys");
       
    54         inverted = Boolean.parseBoolean(reader.getAttributeValue(null, "inverted"));
       
    55         while (reader.hasNext()) {
       
    56             int eventType = reader.next();
       
    57             switch (eventType) {
       
    58                 case XMLStreamReader.START_ELEMENT:
       
    59                     switch (reader.getLocalName()) {
       
    60                         case "canvas":
       
    61                             canvas = new Canvas(reader);
       
    62                             break;
       
    63                         case "style":
       
    64                             style = new UIStyle(reader);
       
    65                             break;
       
    66                     }
       
    67                     break;
       
    68                 case XMLStreamReader.END_ELEMENT:
       
    69                     switch (reader.getLocalName()) {
       
    70                         case "state":
       
    71                             return;
       
    72                     }
       
    73                     break;
       
    74             }
       
    75         }
       
    76     }
    51 
    77 
    52     public boolean hasCanvas() {
    78     public boolean hasCanvas() {
    53         return ! canvas.isBlank();
    79         return ! canvas.isBlank();
    54     }
    80     }
    55 
    81