Commit 923882ef authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Remove deprecated API from resources

parent f58ace30
......@@ -1246,7 +1246,7 @@ public class Main extends JFrame implements ActionListener, TreeSelectionListene
String p = JOptionPane.showInputDialog(this, Language.get("DUPLICATE_MSG"), "%oldid%_copy");
if(r.getClass()==Bitmap.class) {
Bitmap b = (Bitmap)r;
Bitmap b2 = new Bitmap(b.returnCode(""),s);
Bitmap b2 = new Bitmap((Bitmap)b);
b2.renameForCopy(p);
s.resources.add(b2);
s.updateResources();
......@@ -1254,7 +1254,7 @@ public class Main extends JFrame implements ActionListener, TreeSelectionListene
}
else if(r.getClass()==SubBitmap.class) {
SubBitmap sb = (SubBitmap)r;
SubBitmap sb2 = new SubBitmap(sb.returnCode(""),s,sb.getParentBitmap());
SubBitmap sb2 = new SubBitmap(sb);
sb2.renameForCopy(p);
sb.getParentBitmap().SubBitmaps.add(sb2);
s.updateResources();
......@@ -1262,7 +1262,7 @@ public class Main extends JFrame implements ActionListener, TreeSelectionListene
}
else {
vlcskineditor.resources.Font f = (vlcskineditor.resources.Font)r;
vlcskineditor.resources.Font f2 = new vlcskineditor.resources.Font(f.returnCode(""),s);
vlcskineditor.resources.Font f2 = new vlcskineditor.resources.Font((vlcskineditor.resources.Font)f);
f2.renameForCopy(p);
s.resources.add(f2);
s.updateResources();
......
......@@ -85,55 +85,7 @@ public class Bitmap extends ImageResource implements ActionListener{
}
}
}
/**
* Creates a new Bitmap from xml code
* @param xmlcode The XML code from which the Bitmap should be created. One line per tag.
* @param s_ The skin in which the Bitmap is used. This is necessary in order that the image file can be located relatively to the skin file.
*/
public Bitmap(String xmlcode, Skin s_) {
s = s_;
id = XML.getValue(xmlcode,"id");
file = XML.getValue(xmlcode,"file");
if(xmlcode.indexOf("alphacolor=\"")!=-1) {
alphacolor = XML.getValue(xmlcode,"alphacolor");
}
if(xmlcode.indexOf("nbframes=\"")!=-1) {
nbframes = Integer.parseInt(XML.getValue(xmlcode,"nbframes"));
}
if(xmlcode.indexOf("fps=\"")!=-1) {
fps = Integer.parseInt(XML.getValue(xmlcode,"fps"));
}
if (xmlcode.indexOf("\n")!=-1) {
String[] lines = xmlcode.split("\n");
for(int i=1;i<lines.length-1;i++) {
if(lines[i].startsWith("<SubBitmap")) SubBitmaps.add(new SubBitmap(lines[i],s,this));
}
}
updateImage();
}
/**
* Creates a new Bitmap from given attributes
* @param id_ The ID of the new Bitmap
* @param file_ The relative path to the image file.
* @param alphacolor_ The alphacolor of the Bitmap. Format is #RRGGBB.
* @param nbframes_ If the Bitmap is animated this defines the number of frames.
* @param fps_ If the Bitmap is animated this defines the frames displayed per second.
* @param s_ The skin in which the Bitmap is used.
* This is necessary in order that the image file can be located relatively to the skin file.
*/
public Bitmap(String id_, String file_, String alphacolor_, int nbframes_, int fps_, Skin s_) {
s=s_;
id=id_;
file=file_;
alphacolor=alphacolor_;
nbframes=nbframes_;
fps=fps_;
updateImage();
}
/**
* Creates a new Bitmap from a given file.
* @param s_ The skin in which the Bitmap is used.
......@@ -150,7 +102,24 @@ public class Bitmap extends ImageResource implements ActionListener{
id = id_t;
s.updateResources();
updateImage();
}
}
/**
* Creates a copy of a bitmap
* @param b The bitmap to copy
*/
public Bitmap(Bitmap b) {
s = b.s;
id = b.id;
file = b.file;
alphacolor = b.alphacolor;
nbframes = b.nbframes;
fps = b.fps;
updateImage();
for(SubBitmap sb:b.SubBitmaps) SubBitmaps.add(new SubBitmap(sb));
}
/**
* Regenerates the image represented by the Bitmap object.
*/
......@@ -199,6 +168,7 @@ public class Bitmap extends ImageResource implements ActionListener{
}
return true;
}
@Override
public void update() {
BitmapEditEvent be = new BitmapEditEvent(this);
......@@ -217,6 +187,7 @@ public class Bitmap extends ImageResource implements ActionListener{
fireResourceChangedEvent(oldID);
}
@Override
public void showOptions() {
if(frame==null) {
frame = new JFrame(Language.get("WIN_BITMAP_TITLE"));
......
......@@ -25,6 +25,7 @@ package vlcskineditor.resources;
import vlcskineditor.*;
import javax.swing.*;
import javax.swing.tree.*;
import org.w3c.dom.Node;
/**
* Represents a BitmapFont
......@@ -32,27 +33,46 @@ import javax.swing.tree.*;
* You can't create or edit a BitmapFont in the editor nor are they displayed in the preview!</i>
* @author Daniel Dreibrodt
*/
public class BitmapFont extends Resource{
public class BitmapFont extends Resource {
String file;
final String TYPE_DEFAULT = "digits";
String ftype = TYPE_DEFAULT;
private boolean created = false;
{
type = "BitmapFont";
}
/** Creates a new instance of BitmapFont */
public BitmapFont(String xmlcode, Skin s_) {
/**
* Creates a BitmapFont from a XML node
* @param n The XML node
* @param s_ The parent skin
*/
public BitmapFont(Node n, Skin s_) {
s = s_;
id = XML.getValue(xmlcode,"id");
file = XML.getValue(xmlcode,"file");
if(xmlcode.indexOf("type=\"")!=-1) {
ftype = XML.getValue(xmlcode,"type");
}
id = XML.getStringAttributeValue(n, "id", id);
file = XML.getStringAttributeValue(n, "file", file);
ftype = XML.getStringAttributeValue(n, "type", ftype);
created = true;
}
/**
* Creates a copy of a BitmapFont
* @param f The BitmapFont to copy
*/
public BitmapFont(BitmapFont f) {
s = f.s;
id = f.id;
file = f.file;
ftype = f.ftype;
created = true;
}
public void update() {
}
public void showOptions() {
JOptionPane.showMessageDialog(s.m, "BitmapFonts are not yet supported.");
}
......
......@@ -67,34 +67,6 @@ public class Font extends Resource implements ActionListener{
updateFont();
}
/**
* Creates a Font from XML.
* @param xmlcode The XML code from which the Font should be created. One line per tag.
* @param s_ The Skin in which the Font is used.
*/
public Font(String xmlcode, Skin s_) {
s = s_;
id = XML.getValue(xmlcode,"id");
file = XML.getValue(xmlcode,"file");
if(xmlcode.indexOf("size=\"")!=-1) {
size = Integer.parseInt(XML.getValue(xmlcode,"size"));
}
updateFont();
}
/**
* Creates a new Font from the given attributes.
* @param id_ The ID of the Font.
* @param file_ The relative path to the font file.
* @param size_ The Font's size.
* @param s_ The Skin in which the Font is used.
*/
public Font(String id_,String file_,int size_, Skin s_) {
s=s_;
id=id_;
file=file_;
size=size_;
updateFont();
}
/**
* Creates a new Font from a given file.
* @param s_ The skin in which the Font is used.
......@@ -111,6 +83,7 @@ public class Font extends Resource implements ActionListener{
s.expandResource(id);
updateFont();
}
/**
* Creates a new Font from user input.
* @param s_ The skin in which the Font is used.
......@@ -123,6 +96,19 @@ public class Font extends Resource implements ActionListener{
s.expandResource(id);
showOptions();
}
/**
* Creates a copy of a font
* @param f The font to copy
*/
public Font(Font f) {
s = f.s;
id = f.id;
file = f.file;
size = f.size;
updateFont();
}
public boolean updateFont() {
try {
f = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT,new File(s.skinfolder+file));
......
......@@ -73,28 +73,15 @@ public class SubBitmap extends ImageResource implements ActionListener{
y = XML.getIntAttributeValue(n, "y", y);
width = XML.getIntAttributeValue(n, "width", width);
height = XML.getIntAttributeValue(n, "height", height);
nbframes = XML.getIntAttributeValue(n, "nbframes", nbframes);
fps = XML.getIntAttributeValue(n, "fps", fps);
updateImage();
created = true;
}
/**
* Creates a new SubBitmap from XML.
* @param xmlcode The XML code from which the SubBitmap should be created. One line per tag.
* @param s_ The skin in which the SubBitmap is used.
* @param parent_ The parent Bitmap. This is necessary to create the image represented by the SubBitmap.
*/
public SubBitmap(String xmlcode, Skin s_, Bitmap parent_) {
parent=parent_;
s=s_;
id = XML.getValue(xmlcode,"id");
x = XML.getIntValue(xmlcode,"x");
y = XML.getIntValue(xmlcode,"y");
width = XML.getIntValue(xmlcode,"width");
height = XML.getIntValue(xmlcode,"height");
created = true;
}
/**
* Creates a new SubBitmap from user input.
* @param s_ The skin in which the SubBitmap is used.
......@@ -110,6 +97,24 @@ public class SubBitmap extends ImageResource implements ActionListener{
height = 1;
showOptions();
}
/**
* Creates a copy of a SubBitmap
* @param b The SubBitmap to copy
*/
public SubBitmap(SubBitmap b) {
s = b.s;
id = b.id;
parent = b.parent;
x = b.x;
y = b.y;
width = b.width;
height = b.height;
nbframes = b.nbframes;
fps = b.fps;
created = true;
}
/**
* Regenerates the image represented by the SubBitmap object.
*/
......@@ -119,6 +124,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
fireResourceChangedEvent(id);
}
}
@Override
public void update() {
if(!created) {
......
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