📄 gtkparser.java
字号:
/* Generated By:JavaCC: Do not edit this line. GtkParser.java */
/* ====================================================================
*
* Skin Look And Feel 6.7 License.
*
* Copyright (c) 2000-2006 L2FProd.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by L2FProd.com
* (http://www.L2FProd.com/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "Skin Look And Feel", "SkinLF" and "L2FProd.com" must not
* be used to endorse or promote products derived from this software
* without prior written permission. For written permission, please
* contact info@L2FProd.com.
*
* 5. Products derived from this software may not be called "SkinLF"
* nor may "SkinLF" appear in their names without prior written
* permission of L2FProd.com.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL L2FPROD.COM OR ITS CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*/
package com.l2fprod.gui.plaf.skin.impl.gtk.parser;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.Hashtable;
import java.util.Enumeration;
import com.l2fprod.gui.plaf.skin.impl.gtk.*;
import com.l2fprod.gui.plaf.skin.*;
public class GtkParser implements GtkParserConstants {
Hashtable styleTable, classTable;
URL directory;
public static void main(String[] args) throws Exception {
GtkParser parser = new GtkParser(new FileInputStream(args[0]));
parser.buildStructure();
}
public GtkParser(String filename) throws Exception {
this(new File(filename));
}
public GtkParser(File file) throws Exception {
this(SkinUtils.toURL(file));
}
public GtkParser(URL url) throws Exception {
this(url.openStream());
directory = url;
/* String urlpath = url.toString();
int index = urlpath.lastIndexOf("/");
if (index != -1)
directory = new URL(urlpath.substring(0, index) + "/");
else
directory = new URL(urlpath + "/../");
*/
//PENDING(fred): we could use directly the URL given because it could act as an url context...
// need testing...
}
public URL getDirectory() {
return directory;
}
/**
* Sets the Directory attribute of the GtkParser object
*
* @param dir The new Directory value
*/
public void setDirectory(URL dir) {
directory = dir;
}
public Hashtable getStyles() {
return styleTable;
}
public Hashtable getClasses() {
return classTable;
}
public GtkStyle getStyle(String name) {
return (GtkStyle)getStyles().get(name);
}
public GtkClass getClass(String name) {
return (GtkClass)getClasses().get(name);
}
final public void buildStructure() throws ParseException {
styleTable = new Hashtable();
classTable = new Hashtable();
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STYLE:
case CLASS:
case OTHER_TOKEN:
case WIDGET_CLASS:
case WIDGET:
;
break;
default:
jj_la1[0] = jj_gen;
break label_1;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STYLE:
styleDefinition();
break;
case CLASS:
classDefinition();
break;
case OTHER_TOKEN:
whatever();
break;
case WIDGET_CLASS:
widgetClassDefinition();
break;
case WIDGET:
widgetDefinition();
break;
default:
jj_la1[1] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
}
for (Enumeration e = getClasses().keys(); e.hasMoreElements(); ) {
Object key = e.nextElement();
GtkClass clas = (GtkClass)getClasses().get(key);
for (int i = 0, c = clas.styles.size(); i < c; i++)
clas.styles.set(i,
(GtkStyle)getStyles().get(clas.styles.get(i)));
}
}
final public void whatever() throws ParseException {
jj_consume_token(OTHER_TOKEN);
readString();
}
final public void widgetClassDefinition() throws ParseException {
jj_consume_token(WIDGET_CLASS);
readString();
jj_consume_token(STYLE);
readString();
}
final public void widgetDefinition() throws ParseException {
jj_consume_token(WIDGET);
readString();
jj_consume_token(STYLE);
readString();
}
final public void styleDefinition() throws ParseException {
GtkStyle style = new GtkStyle();
style.parser = this;
Token property, state = null;
String value = null;
jj_consume_token(STYLE);
style.name = readString();
jj_consume_token(LBRACK);
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case FONT:
;
break;
default:
jj_la1[2] = jj_gen;
break label_2;
}
jj_consume_token(FONT);
jj_consume_token(ASSIGN);
readString();
}
label_3:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case EXTRA:
;
break;
default:
jj_la1[3] = jj_gen;
break label_3;
}
property = jj_consume_token(EXTRA);
jj_consume_token(LCROC);
state = jj_consume_token(STATE_TYPE);
jj_consume_token(RCROC);
jj_consume_token(ASSIGN);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STRING_LITERAL:
value = readString();
break;
case LBRACK:
jj_consume_token(LBRACK);
value="{"; value = value + readFloat() + ",";
jj_consume_token(COMMA);
value = value + readFloat() + ",";
jj_consume_token(COMMA);
value = value + readFloat();
value += "}";
jj_consume_token(RBRACK);
break;
default:
jj_la1[4] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
style.setProperty(property.image + "[" + state + "]",
value);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case ENGINE:
jj_consume_token(ENGINE);
readString();
jj_consume_token(LBRACK);
GtkEngine engine = new GtkEngine();
style.engine = engine;
engine.style = style;
label_4:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case IMAGE:
;
break;
default:
jj_la1[5] = jj_gen;
break label_4;
}
imageDefinition(engine);
}
jj_consume_token(RBRACK);
break;
default:
jj_la1[6] = jj_gen;
;
}
jj_consume_token(RBRACK);
styleTable.put(style.name, style);
}
final public void imageDefinition(GtkEngine engine) throws ParseException {
GtkImage image = new GtkImage();
Token property = null;
Token value = null;
jj_consume_token(IMAGE);
jj_consume_token(LBRACK);
label_5:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case FUNCTION:
property = jj_consume_token(FUNCTION);
jj_consume_token(ASSIGN);
value = jj_consume_token(FUNCTION_TYPE);
image.setProperty(property.image, value.image);
break;
case RECOLORABLE:
property = jj_consume_token(RECOLORABLE);
jj_consume_token(ASSIGN);
value = jj_consume_token(BOOLEAN);
image.setProperty(property.image, value.image);
break;
case STATE:
property = jj_consume_token(STATE);
jj_consume_token(ASSIGN);
value = jj_consume_token(STATE_TYPE);
image.setProperty(property.image, value.image);
break;
case DETAIL:
property = jj_consume_token(DETAIL);
jj_consume_token(ASSIGN);
image.setProperty(property.image, readString());
break;
case FILE:
property = jj_consume_token(FILE);
jj_consume_token(ASSIGN);
image.setProperty(property.image, readString());
break;
case BORDER:
property = jj_consume_token(BORDER);
jj_consume_token(ASSIGN);
image.setProperty(property.image, borderDefinition());
break;
case STRETCH:
property = jj_consume_token(STRETCH);
jj_consume_token(ASSIGN);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -