/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
//
// Known element names
//
"defaultsProperty";
//
// Known attribute names
//
/**
* Lazily created, used for anything we don't understand.
*/
/**
* Indicates the depth of how many elements we've encountered but don't
* understand. This is used when forwarding to beans persistance to know
* when we hsould stop forwarding.
*/
private int _depth;
/**
* Factory that new styles are added to.
*/
/**
* Array of state infos for the current style. These are pushed to the
* style when </style> is received.
*/
/**
* Current style.
*/
/**
* Current state info.
*/
/**
* Bindings for the current InputMap
*/
/**
* ID for the input map. This is cached as
* the InputMap is created AFTER the inputMapProperty has ended.
*/
/**
* Object references outside the scope of persistance.
*/
/**
* Based URL used to resolve paths.
*/
/**
* Based class used to resolve paths.
*/
/**
* List of ColorTypes. This is populated in startColorType.
*/
/**
* defaultsPropertys are placed here.
*/
/**
* List of SynthStyle.Painters that will be applied to the current style.
*/
/**
* List of SynthStyle.Painters that will be applied to the current state.
*/
SynthParser() {
}
/**
* Parses a set of styles from <code>inputStream</code>, adding the
* resulting styles to the passed in DefaultSynthStyleFactory.
* Resources are resolved either from a URL or from a Class. When calling
* this method, one of the URL or the Class must be null but not both at
* the same time.
*
* @param inputStream XML document containing the styles to read
* @param factory DefaultSynthStyleFactory that new styles are added to
* @param urlResourceBase the URL used to resolve any resources, such as Images
* @param classResourceBase the Class used to resolve any resources, such as Images
* @param defaultsMap Map that UIDefaults properties are placed in
*/
throws ParseException, IllegalArgumentException {
throw new IllegalArgumentException(
"You must supply an InputStream, StyleFactory and Class or URL");
}
try {
try {
newSAXParser();
} catch (ParserConfigurationException e) {
}
catch (SAXException se) {
}
catch (IOException ioe) {
}
} finally {
reset();
}
}
/**
* Returns the path to a resource.
*/
if (_classResourceBase != null) {
} else {
try {
} catch (MalformedURLException mue) {
return null;
}
}
}
/**
* Clears our internal state.
*/
private void reset() {
_depth = 0;
_stateInfos.clear();
_colorTypes.clear();
}
/**
* Returns true if we are forwarding to persistance.
*/
private boolean isForwarding() {
return (_depth > 0);
}
/**
* Handles beans persistance.
*/
_handler = new DocumentHandler();
if (_urlResourceBase != null) {
// getHandler() is never called before parse() so it is safe
// to create a URLClassLoader with _resourceBase.
//
// getResource(".") is called to ensure we have the directory
// containing the resources in the case the resource base is a
// .class file.
} else {
}
}
}
return _handler;
}
/**
* If <code>value</code> is an instance of <code>type</code> it is
* returned, otherwise a SAXException is thrown.
*/
}
return value;
}
/**
* Returns an object created with id=key. If the object is not of
* type type, this will throw an exception.
*/
}
}
}
}
/**
* Registers an object by name. This will throw an exception if an
* object has already been registered under the given name.
*/
}
}
else {
}
}
}
/**
* Convenience method to return the next int, or throw if there are no
* more valid ints.
*/
if (!tok.hasMoreTokens()) {
throw new SAXException(errorMsg);
}
try {
} catch (NumberFormatException nfe) {
throw new SAXException(errorMsg);
}
}
/**
* Convenience method to return an Insets object.
*/
}
//
// The following methods are invoked from startElement/stopElement
//
clone();
}
}
}
_style = new ParsedSynthStyle();
}
}
private void endStyle() {
if (size > 0) {
}
if (size > 0) {
_stateInfos.clear();
}
}
int state = 0;
_stateInfo = null;
}
}
}
attributes.getValue(i));
while (tokenizer.hasMoreTokens()) {
intern();
if (stateString == "ENABLED") {
}
else if (stateString == "MOUSE_OVER") {
}
else if (stateString == "PRESSED") {
}
else if (stateString == "DISABLED") {
}
else if (stateString == "FOCUSED") {
}
else if (stateString == "SELECTED") {
}
else if (stateString == "DEFAULT") {
}
else if (stateString != "AND") {
}
}
}
}
if (_stateInfo == null) {
}
}
private void endState() {
if (size > 0) {
}
_stateInfo = null;
}
int size = 0;
}
}
}
try {
} catch (NumberFormatException nfe) {
throw new SAXException("Invalid font size: " +
attributes.getValue(i));
}
}
attributes.getValue(i));
while (tok.hasMoreTokens()) {
if (token == "BOLD") {
}
else if (token == "ITALIC") {
}
}
}
}
throw new SAXException("You must define a name for the font");
}
if (size == 0) {
throw new SAXException("You must define a size for the font");
}
}
throw new SAXException("Name, size and style are not for use " +
"with idref");
}
if (_stateInfo != null) {
}
}
}
_colorTypes.clear();
}
}
}
try {
int argb;
boolean hasAlpha;
if (length < 8) {
// Just RGB, or some portion of it.
hasAlpha = false;
} else if (length == 8) {
// Single character alpha: #ARRGGBB.
hasAlpha = true;
} else if (length == 9) {
// Color has alpha and is of the form
// #AARRGGBB.
// The following split decoding is mandatory due to
// Integer.decode() behavior which won't decode
// hexadecimal values higher than #7FFFFFFF.
// Thus, when an alpha channel is detected, it is
// decoded separately from the RGB channels.
hasAlpha = true;
} else {
throw new SAXException("Invalid Color value: "
+ value);
}
} catch (NumberFormatException nfe) {
}
}
else {
try {
} catch (NoSuchFieldException nsfe) {
} catch (IllegalAccessException iae) {
}
}
}
attributes.getValue(i));
while (tokenizer.hasMoreTokens()) {
if (classIndex == -1) {
classIndex = 0;
}
else {
try {
0, classIndex));
} catch (ClassNotFoundException cnfe) {
throw new SAXException("Unknown class: " +
}
classIndex++;
}
try {
} catch (NoSuchFieldException nsfe) {
throw new SAXException("Unable to find color type: " +
typeName);
} catch (IllegalAccessException iae) {
throw new SAXException("Unable to find color type: " +
typeName);
}
}
}
}
throw new SAXException("color: you must specificy a value");
}
int max = 0;
counter--) {
}
}
}
counter--) {
}
}
}
// Type of the value: 0=idref, 1=boolean, 2=dimension, 3=insets,
// 4=integer,5=string
int iType = 0;
iType = 0;
}
iType = 1;
}
iType = 2;
}
iType = 3;
}
iType = 4;
}
iType = 5;
}
else {
"idref, boolean, dimension, insets or integer");
}
}
}
}
}
switch (iType) {
case 0: // idref
break;
case 1: // boolean
}
else {
}
break;
case 2: // dimension
value = new DimensionUIResource(
break;
case 3: // insets
break;
case 4: // integer
try {
} catch (NumberFormatException nfe) {
}
break;
case 5: //string
break;
}
}
"key and value");
}
if (property == ELEMENT_DEFAULTS_PROPERTY) {
}
else if (_stateInfo != null) {
}
}
}
}
}
SynthGraphicsUtils.class);
}
}
throw new SAXException("graphicsUtils: you must supply an idref");
}
}
}
int top = 0;
int bottom = 0;
int left = 0;
int right = 0;
try {
Insets.class);
}
}
}
}
}
}
} catch (NumberFormatException nfe) {
throw new SAXException("insets: bad integer value for " +
attributes.getValue(i));
}
}
}
}
}
int type = -1;
ParsedSynthStyle.class);
}
}
}
else {
}
}
}
}
throw new SAXException("bind: you must specify a style, type " +
"and key");
}
try {
} catch (PatternSyntaxException pse) {
"regular expression");
}
}
boolean paintCenter = true;
boolean stretch = true;
int direction = -1;
boolean center = false;
boolean stretchSpecified = false;
boolean paintCenterSpecified = false;
}
}
}
}
": sourceInsets must be top left bottom right");
}
": destinationInsets must be top left bottom right");
}
paintCenterSpecified = true;
}
stretchSpecified = true;
}
if (value == "EAST") {
}
else if (value == "NORTH") {
}
else if (value == "SOUTH") {
}
else if (value == "WEST") {
}
else if (value == "TOP") {
}
else if (value == "LEFT") {
}
else if (value == "BOTTOM") {
}
else if (value == "RIGHT") {
}
else if (value == "HORIZONTAL") {
}
else if (value == "VERTICAL") {
}
else if (value == "HORIZONTAL_SPLIT") {
}
else if (value == "VERTICAL_SPLIT") {
}
else {
}
}
}
}
if (type == ELEMENT_PAINTER) {
throw new SAXException(type +
": you must specify an idref");
}
throw new SAXException(
"property: you must specify sourceInsets");
}
throw new SAXException("property: you must specify a path");
}
throw new SAXException("The attributes: sourceInsets, " +
"destinationInsets, paintCenter and stretch " +
" are not legal when center is true");
}
}
if (_stateInfo != null) {
}
}
}
return;
}
}
}
}
}
}
throw new SAXException("imageIcon: you must specify a path");
}
}
toLowerCase()));
}
}
}
}
_inputMapID = null;
}
}
}
}
if (_inputMapID != null) {
size()])));
}
_inputMapID = null;
}
if (_inputMapID == null) {
// Not in an inputmap, bail.
return;
}
}
}
}
throw new SAXException(
"bindKey: you must supply a key and action");
}
}
}
//
// SAX methods, these forward to the DocumentHandler if we don't know
// the element name.
//
throws IOException, SAXException {
if (isForwarding()) {
}
return null;
}
if (isForwarding()) {
}
}
if (isForwarding()) {
}
}
if (isForwarding()) {
}
}
if (isForwarding()) {
getHandler().startDocument();
}
}
if (isForwarding()) {
getHandler().endDocument();
}
}
throws SAXException {
if (name == ELEMENT_STYLE) {
}
else if (name == ELEMENT_STATE) {
}
else if (name == ELEMENT_FONT) {
}
else if (name == ELEMENT_COLOR) {
}
else if (name == ELEMENT_PAINTER) {
}
else if (name == ELEMENT_IMAGE_PAINTER) {
}
else if (name == ELEMENT_PROPERTY) {
}
else if (name == ELEMENT_DEFAULTS_PROPERTY) {
}
else if (name == ELEMENT_SYNTH_GRAPHICS) {
}
else if (name == ELEMENT_INSETS) {
}
else if (name == ELEMENT_BIND) {
}
else if (name == ELEMENT_BIND_KEY) {
}
else if (name == ELEMENT_IMAGE_ICON) {
}
else if (name == ELEMENT_OPAQUE) {
}
else if (name == ELEMENT_INPUT_MAP) {
}
else if (name != ELEMENT_SYNTH) {
if (_depth++ == 0) {
getHandler().startDocument();
}
}
}
if (isForwarding()) {
_depth--;
if (!isForwarding()) {
getHandler().startDocument();
}
}
else {
if (name == ELEMENT_STYLE) {
endStyle();
}
else if (name == ELEMENT_STATE) {
endState();
}
else if (name == ELEMENT_INPUT_MAP) {
endInputMap();
}
}
}
throws SAXException {
if (isForwarding()) {
}
}
throws SAXException {
if (isForwarding()) {
}
}
throws SAXException {
if (isForwarding()) {
}
}
if (isForwarding()) {
getHandler().warning(e);
}
}
if (isForwarding()) {
getHandler().error(e);
}
}
if (isForwarding()) {
getHandler().fatalError(e);
}
throw e;
}
/**
* ImageIcon that lazily loads the image until needed.
*/
super();
}
super.paintIcon(c, g, x, y);
}
}
public int getIconWidth() {
return super.getIconWidth();
}
return 0;
}
public int getIconHeight() {
return super.getIconHeight();
}
return 0;
}
}
return super.getImage();
}
}
}