Commit 74cb02d3 authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Finished new parsing system

parent d1729feb
......@@ -277,64 +277,4 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
END OF TERMS AND CONDITIONS
\ No newline at end of file
......@@ -72,7 +72,7 @@ ERROR_VLT_NOTHEME_MSG|Could not find "theme.xml" inside the unpacked contents of
ERROR_VLC_LAUNCH_TITLE|Error
ERROR_VLC_LAUNCH_MSG|VLC media player could not be launched
ERROR_BROWSE_TITLE|Could not launch Browser
ERROR_BROWSE_MSG|Go to the following URL manually:\n%u
ERROR_BROWSE_MSG|The browser could not be launched.\n Please go to the following URL manually:\n%u
ERROR_ADD_SBMP_TITLE|Could not add SubBitmap
ERROR_ADD_SBMP_NOBMP|No parent Bitmap has been selected!
ERROR_ADD_SBMP_NOTBMP|The selected resource is not a Bitmap!
......
......@@ -91,15 +91,7 @@ public class Layout implements ActionListener{
maxwidth = XML.getIntAttributeValue(n, "maxwidth", maxwidth);
minheight = XML.getIntAttributeValue(n, "minheight", minheight);
maxheight = XML.getIntAttributeValue(n, "maxheight", maxheight);
NodeList nodes = n.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
if(nodes.item(i).getNodeName().equals("Anchor"))
items.add(new Anchor(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Button"))
items.add(new Button(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Checkbox"))
items.add(new Checkbox(nodes.item(i), s));
}
XML.parseChildItems(n, items, s);
}
/**
......
......@@ -22,7 +22,11 @@
package vlcskineditor;
import java.util.List;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import vlcskineditor.items.*;
/**
* XML Handler
......@@ -88,7 +92,12 @@ public class XML {
* @return If the attribute is set, the attribute's value is returned. Otherwise the given old value.
*/
public static String getStringAttributeValue(Node n, String name, String oldvalue) {
if(n.getAttributes().getNamedItem(name)!=null) return n.getAttributes().getNamedItem(name).getNodeValue();
if(n.getAttributes().getNamedItem(name)!=null) {
String value = n.getAttributes().getNamedItem(name).getNodeValue();
//The DTD turns all unset id-attributes to "none", but the skin editor needs unique ids
if(name.equals("id") && value.equals("none")) return oldvalue;
else return value;
}
else return oldvalue;
}
......@@ -119,4 +128,41 @@ public class XML {
if(n.getAttributes().getNamedItem(name)!=null) return Boolean.parseBoolean(n.getAttributes().getNamedItem(name).getNodeValue());
else return oldvalue;
}
/**
* Parses all child items of a XML node (used by Layouts/Groups/Panels)
* @param n The XML node
* @param children The list to which the children will be added
* @param s The parent Skin
*/
public static void parseChildItems(Node n, List<Item> children, Skin s) {
NodeList nodes = n.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
if(nodes.item(i).getNodeName().equals("Anchor"))
children.add(new Anchor(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Button"))
children.add(new Button(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Checkbox"))
children.add(new Checkbox(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Group"))
children.add(new Group(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Image"))
children.add(new Image(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Panel"))
children.add(new Panel(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Playtree"))
children.add(new Playtree(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Playlist")) {
((Element)nodes.item(i)).setAttribute("flat", "true");
children.add(new Playtree(nodes.item(i), s));
}
else if(nodes.item(i).getNodeName().equals("Slider"))
children.add(new Slider(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Text"))
children.add(new Text(nodes.item(i), s));
else if(nodes.item(i).getNodeName().equals("Video"))
children.add(new Video(nodes.item(i), s));
}
}
}
......@@ -72,23 +72,24 @@ public class Button extends Item implements ActionListener{
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
up = XML.getStringAttributeValue(n, "up", up);
down = XML.getStringAttributeValue(n, "down", down);
over = XML.getStringAttributeValue(n, "over", over);
over = XML.getStringAttributeValue(n, "over", over);
action = XML.getStringAttributeValue(n, "action", action);
tooltiptext = XML.getStringAttributeValue(n, "tooltiptext", tooltiptext);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
rightbottom = XML.getStringAttributeValue(n, "rightbottom", rightbottom);
xkeepratio = XML.getBoolAttributeValue(n, "xkeepratio", xkeepratio);
ykeepratio = XML.getBoolAttributeValue(n, "ykeepratio", ykeepratio);
tooltiptext = XML.getStringAttributeValue(n, "tooltiptext", tooltiptext);
visible = XML.getStringAttributeValue(n, "visible", visible);
help = XML.getStringAttributeValue(n, "help", help);
created = true;
up_res = s.getImageResource(up);
over_res = s.getImageResource(over);
down_res = s.getImageResource(down);
created = true;
}
/** Creates a new instance of Button
......
......@@ -30,6 +30,7 @@ import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
/**
* Represents a Group item
......@@ -46,6 +47,20 @@ public class Group extends Item implements ActionListener{
{
type = Language.get("GROUP");
}
/**
* Parses a Group from a givn XML node
* @param n The XML node
* @param s_ The parent skin
*/
public Group(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
XML.parseChildItems(n, items, s);
created=true;
}
/** Creates a new instance of Group */
public Group(String xmlcode, Skin s_) {
......
......@@ -30,6 +30,7 @@ import java.awt.image.BufferedImage;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
import vlcskineditor.resources.ImageResource;
/**
......@@ -58,6 +59,36 @@ public class Image extends Item implements ActionListener{
{
type = Language.get("IMAGE");
}
/**
* Parses an image from an XML node
* @param n The XML node
* @param s_ The parent skin
*/
public Image(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
image = XML.getStringAttributeValue(n, "image", image);
action = XML.getStringAttributeValue(n, "action", action);
action2 = XML.getStringAttributeValue(n, "action2", action2);
resize = XML.getStringAttributeValue(n, "resize", resize);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
rightbottom = XML.getStringAttributeValue(n, "rightbottom", rightbottom);
xkeepratio = XML.getBoolAttributeValue(n, "xkeepratio", xkeepratio);
ykeepratio = XML.getBoolAttributeValue(n, "ykeepratio", ykeepratio);
visible = XML.getStringAttributeValue(n, "visible", visible);
help = XML.getStringAttributeValue(n, "help", help);
image_res = s.getImageResource(image);
created = true;
}
/** Creates a new instance of Image
* @param xmlcode The XML code
......
......@@ -30,6 +30,7 @@ import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
/**
* Represents a Panel item
......@@ -50,7 +51,26 @@ public class Panel extends Item implements ActionListener{
{
type = Language.get("PANEL");
}
public Panel(Node n, Skin s_) {
s = s_;
width = XML.getIntAttributeValue(n, "width", width);
height = XML.getIntAttributeValue(n, "height", height);
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
rightbottom = XML.getStringAttributeValue(n, "rightbottom", rightbottom);
xkeepratio = XML.getBoolAttributeValue(n, "xkeepratio", xkeepratio);
ykeepratio = XML.getBoolAttributeValue(n, "ykeepratio", ykeepratio);
XML.parseChildItems(n, items, s);
created = true;
}
/** Creates a new instance of Panel */
public Panel(String xmlcode, Skin s_) {
s = s_;
......
......@@ -30,6 +30,8 @@ import java.awt.image.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import vlcskineditor.resources.ImageResource;
/**
......@@ -83,6 +85,56 @@ public class Playtree extends Item implements ActionListener{
{
type = Language.get("PLAYTREE");
}
/**
* Parses a playtree from a XML node
* @param n The XML node
* @param s_ The parent skin
*/
public Playtree(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
width = XML.getIntAttributeValue(n, "width", width);
height = XML.getIntAttributeValue(n, "height", height);
font = XML.getStringAttributeValue(n, "font", font);
bgimage = XML.getStringAttributeValue(n, "bgimage", bgimage);
itemimage = XML.getStringAttributeValue(n, "itemimage", itemimage);
openimage = XML.getStringAttributeValue(n, "openimage", openimage);
closedimage = XML.getStringAttributeValue(n, "closedimage", closedimage);
fgcolor = XML.getStringAttributeValue(n, "fgcolor", fgcolor);
playcolor = XML.getStringAttributeValue(n, "playcolor", playcolor);
bgcolor1 = XML.getStringAttributeValue(n, "bgcolor1", bgcolor1);
bgcolor2 = XML.getStringAttributeValue(n, "bgcolor2", bgcolor2);
selcolor = XML.getStringAttributeValue(n, "selcolor", selcolor);
flat = XML.getBoolAttributeValue(n, "flat", flat);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
rightbottom = XML.getStringAttributeValue(n, "rightbottom", rightbottom);
xkeepratio = XML.getBoolAttributeValue(n, "xkeepratio", xkeepratio);
ykeepratio = XML.getBoolAttributeValue(n, "ykeepratio", ykeepratio);
visible = XML.getStringAttributeValue(n, "visible", visible);
help = XML.getStringAttributeValue(n, "help", help);
NodeList nodes = n.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
if(nodes.item(i).getNodeName().equals("Slider")) {
slider = new Slider(nodes.item(i), s);
}
}
bgimage_res = s.getImageResource(bgimage);
openimage_res = s.getImageResource(openimage);
closedimage_res = s.getImageResource(closedimage);
itemimage_res = s.getImageResource(itemimage);
created = true;
}
/** Creates a new instance of Playtree
* @param xmlcode The XML code
......
......@@ -30,6 +30,8 @@ import java.awt.geom.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import vlcskineditor.resources.ImageResource;
/**
......@@ -73,8 +75,50 @@ public class Slider extends Item implements ActionListener{
{
type = Language.get("SLIDER");
}
/** Creates a new instance of Slider
/**
* Parses a slider from a XML node
* @param n The XML node
* @param s_ The parent skin
*/
public Slider(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
up = XML.getStringAttributeValue(n, "up", up);
down = XML.getStringAttributeValue(n, "down", down);
over = XML.getStringAttributeValue(n, "over", over);
points = XML.getStringAttributeValue(n, "points", points);
thickness = XML.getIntAttributeValue(n, "thickness", thickness);
value = XML.getStringAttributeValue(n, "value", value);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
rightbottom = XML.getStringAttributeValue(n, "rightbottom", rightbottom);
xkeepratio = XML.getBoolAttributeValue(n, "xkeepratio", xkeepratio);
ykeepratio = XML.getBoolAttributeValue(n, "ykeepratio", ykeepratio);
tooltiptext = XML.getStringAttributeValue(n, "tooltiptext", tooltiptext);
visible = XML.getStringAttributeValue(n, "visible", visible);
help = XML.getStringAttributeValue(n, "help", help);
NodeList nodes = n.getChildNodes();
for(int i=0;i<nodes.getLength();i++) {
if(nodes.item(i).getNodeName().equals("SliderBackground"))
sbg = new SliderBackground(nodes.item(i),s);
}
up_res = s.getImageResource(up);
over_res = s.getImageResource(over);
down_res = s.getImageResource(down);
updateBezier();
created = true;
}
/** Creates a new instance of Slider
* @param xmlcode The XML code
* @param s_ The parent skin
*/
......
......@@ -30,6 +30,7 @@ import java.awt.image.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
import vlcskineditor.resources.ImageResource;
/**
......@@ -63,6 +64,27 @@ public class SliderBackground extends Item implements ActionListener{
type = Language.get("SLIDERBG");
}
/**
* Parses a SliderBackground from a XML node
* @param n The XML node
* @param s_ The parent skin
*/
public SliderBackground(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
image = XML.getStringAttributeValue(n, "image", image);
nbhoriz = XML.getIntAttributeValue(n, "nbhoriz", nbhoriz);
nbvert = XML.getIntAttributeValue(n, "nbvert", nbvert);
padhoriz = XML.getIntAttributeValue(n, "padhoriz", padhoriz);
padvert = XML.getIntAttributeValue(n, "padvert", padvert);
image_res = s.getImageResource(image);
created = true;
}
/** Creates a new instance of SliderBackground
* @param xmlcode The XML code
* @param s_ The parent skin
......
......@@ -30,6 +30,7 @@ import java.awt.image.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
/**
* Text item
......@@ -58,6 +59,35 @@ public class Text extends Item implements ActionListener{
{
type = Language.get("TEXT");
}
/**
* Parses a text item from a XML node
* @param n The XML node
* @param s_ The parent skin
*/
public Text(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
font = XML.getStringAttributeValue(n, "font", font);
text = XML.getStringAttributeValue(n, "text", text);
alignment = XML.getStringAttributeValue(n, "alignment", alignment);
scrolling = XML.getStringAttributeValue(n, "scrolling", scrolling);
color = XML.getStringAttributeValue(n, "color", color);
width = XML.getIntAttributeValue(n, "width", width);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
rightbottom = XML.getStringAttributeValue(n, "rightbottom", rightbottom);
xkeepratio = XML.getBoolAttributeValue(n, "xkeepratio", xkeepratio);
ykeepratio = XML.getBoolAttributeValue(n, "ykeepratio", ykeepratio);
visible = XML.getStringAttributeValue(n, "visible", visible);
help = XML.getStringAttributeValue(n, "help", help);
created = true;
}
/** Creates a new instance of Text */
public Text(String xmlcode, Skin s_) {
......
......@@ -29,6 +29,7 @@ import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.border.*;
import org.w3c.dom.Node;
import vlcskineditor.history.ItemAddEvent;
/**
......@@ -53,6 +54,32 @@ public class Video extends Item implements ActionListener{
{
type = Language.get("VIDEO");
}
/**
* Parses a video from a XML node
* @param n The XML node
* @param s_ The parent skin
*/
public Video(Node n, Skin s_) {
s = s_;
id = XML.getStringAttributeValue(n, "id", Language.get("UNNAMED").replaceAll("%t",type).replaceAll("%i",String.valueOf(s.getNewId())));
width = XML.getIntAttributeValue(n, "width", width);
height = XML.getIntAttributeValue(n, "height", height);
autoresize = XML.getBoolAttributeValue(n, "autoresize", autoresize);
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
lefttop = XML.getStringAttributeValue(n, "lefttop", lefttop);
rightbottom = XML.getStringAttributeValue(n, "rightbottom", rightbottom);
xkeepratio = XML.getBoolAttributeValue(n, "xkeepratio", xkeepratio);
ykeepratio = XML.getBoolAttributeValue(n, "ykeepratio", ykeepratio);
visible = XML.getStringAttributeValue(n, "visible", visible);
help = XML.getStringAttributeValue(n, "help", help);
created = true;
}
/** Creates a new instance of Video */
public Video(String xmlcode, Skin s_) {
......
......@@ -73,7 +73,9 @@ public class Bitmap extends ImageResource implements ActionListener{
alphacolor = XML.getStringAttributeValue(n, "alphacolor", alphacolor);
nbframes = XML.getIntAttributeValue(n, "nbframes", nbframes);
fps = XML.getIntAttributeValue(n, "fps", fps);
updateImage();
NodeList children = n.getChildNodes();
for(int i=0;i<children.getLength();i++) {
Node child = children.item(i);
......
......@@ -72,7 +72,10 @@ public class SubBitmap extends ImageResource implements ActionListener{
x = XML.getIntAttributeValue(n, "x", x);
y = XML.getIntAttributeValue(n, "y", y);
width = XML.getIntAttributeValue(n, "width", width);
height = XML.getIntAttributeValue(n, "height", height);
height = XML.getIntAttributeValue(n, "height", height);
updateImage();
created = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment