Changeset 102
- Timestamp:
- 14/05/08 10:28:03 (7 months ago)
- Files:
-
- trunk/src/vlcskineditor/GlobalVariables.java (modified) (1 diff)
- trunk/src/vlcskineditor/Helper.java (added)
- trunk/src/vlcskineditor/Main.java (modified) (2 diffs)
- trunk/src/vlcskineditor/Skin.java (modified) (4 diffs)
- trunk/src/vlcskineditor/package.html (modified) (1 diff)
- trunk/src/vlcskineditor/resources/Bitmap.java (modified) (9 diffs)
- trunk/src/vlcskineditor/resources/Font.java (modified) (7 diffs)
- trunk/src/vlcskineditor/resources/SubBitmap.java (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/vlcskineditor/GlobalVariables.java
r85 r102 378 378 update(); 379 379 frame.setVisible(false); 380 frame.dispose(); 381 frame = null; 380 382 } 381 383 else if(e.getSource().equals(help_btn)) { trunk/src/vlcskineditor/Main.java
r101 r102 47 47 48 48 //The version identification of the current build. 49 public final String VERSION = "0.7.0 .b";49 public final String VERSION = "0.7.0 dev"; 50 50 //The directory in which the VLC executable is found 51 51 String vlc_dir = ""; … … 787 787 } 788 788 catch (IOException ex) { 789 789 JOptionPane.showMessageDialog(this,"VLC Media Player could not be launched","Error",JOptionPane.ERROR_MESSAGE); 790 790 } 791 791 } trunk/src/vlcskineditor/Skin.java
r99 r102 23 23 package vlcskineditor; 24 24 25 import vlcskineditor.history.*; 25 import java.awt.Desktop; 26 import java.awt.Dimension; 27 import java.awt.FlowLayout; 28 import java.awt.event.ActionEvent; 29 import java.awt.event.ActionListener; 30 import java.awt.image.BufferedImage; 31 import java.io.BufferedReader; 32 import java.io.File; 33 import java.io.FileReader; 34 import java.io.FileWriter; 35 import java.util.LinkedList; 36 import javax.swing.BorderFactory; 37 import javax.swing.JButton; 38 import javax.swing.JFrame; 39 import javax.swing.JLabel; 40 import javax.swing.JOptionPane; 41 import javax.swing.JPanel; 42 import javax.swing.JTextField; 43 import javax.swing.JTree; 44 import javax.swing.border.EtchedBorder; 45 import javax.swing.tree.DefaultMutableTreeNode; 46 import javax.swing.tree.TreePath; 47 import javax.xml.parsers.DocumentBuilder; 48 import javax.xml.parsers.DocumentBuilderFactory; 49 import org.w3c.dom.Document; 50 import org.w3c.dom.Element; 51 import org.w3c.dom.NamedNodeMap; 52 import org.w3c.dom.Node; 53 import org.w3c.dom.NodeList; 54 import vlcskineditor.history.ThemeEditEvent; 26 55 import vlcskineditor.resources.Bitmap; 27 56 import vlcskineditor.resources.BitmapFont; 57 import vlcskineditor.resources.Font; 28 58 import vlcskineditor.resources.SubBitmap; 29 import java.awt.*;30 import java.awt.event.*;31 import java.awt.image.*;32 import java.io.*;33 import javax.swing.*;34 import javax.swing.tree.*;35 import java.util.*;36 import javax.swing.border.EtchedBorder;37 59 38 60 /** … … 104 126 skinfolder = f.getParentFile().getAbsolutePath()+File.separator; 105 127 try { 106 //System.out.println("Creating Buffered Reader..."); 128 parse(f); 129 //parseXML(f); 130 } 131 catch (Exception ex) { 132 ex.printStackTrace(); 133 String stackTrace =""; 134 for (int i=0;i<ex.getStackTrace().length;i++) { 135 stackTrace+=ex.getStackTrace()[i].toString()+"\n"; 136 } 137 JOptionPane.showMessageDialog(null,ex.toString()+"\n\n"+stackTrace,ex.getMessage(),JOptionPane.ERROR_MESSAGE); 138 update(); 139 } 140 update(); 141 } 142 /** 143 * Parses the given file line by line, expecting each xml-tag to be in his own single line 144 * @param f The file that should be parsed 145 * @throws java.lang.Exception 146 */ 147 private void parse(File f) throws Exception { 148 //System.out.println("Creating Buffered Reader..."); 107 149 BufferedReader br = new BufferedReader(new FileReader(f)); 108 150 //System.out.println("Ready..."); … … 182 224 } 183 225 //</editor-fold> 184 else if(line.startsWith("<Font")) resources.add(new vlcskineditor.resources.Font(line,this));226 else if(line.startsWith("<Font")) resources.add(new Font(line,this)); 185 227 else if(line.startsWith("<BitmapFont")) resources.add(new BitmapFont(line,this)); 186 228 //<editor-fold defaultstate="collapsed" desc=" Window tag "> … … 209 251 } 210 252 br.close(); 211 //System.out.println("Buffered Reader was closed"); 212 } 213 catch (Exception ex) { 214 String stackTrace =""; 215 for (int i=0;i<ex.getStackTrace().length;i++) { 216 stackTrace+=ex.getStackTrace()[i].toString()+"\n"; 217 } 218 JOptionPane.showMessageDialog(null,ex.toString()+"\n\n"+stackTrace,ex.getMessage(),JOptionPane.ERROR_MESSAGE); 219 update(); 220 } 221 update(); 222 } 223 /** Parses the XML Code into the skinfile **/ 253 //System.out.println("Buffered Reader was closed"); 254 255 } 256 /** 257 * Parses the skin file via Java's XMLReader 258 * @param f The file that should be parsed 259 * @throws java.lang.Exception 260 */ 261 private void parseXML(File f) throws Exception{ 262 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); 263 DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); 264 Document doc = docBuilder.parse(f); 265 266 if(!doc.getDoctype().getName().equals("Theme")) 267 throw new Exception("Selected file is not a valid VLC skin file!"); 268 269 NodeList nodes = doc.getElementsByTagName("*"); 270 for(int i=0;i<nodes.getLength();i++) { 271 Element e = (Element)nodes.item(i); 272 parseElement(e); 273 } 274 } 275 private void parseElement(Element e) throws Exception{ 276 String tag = e.getTagName(); 277 if(tag.equals("Theme")) { 278 if(e.hasAttribute("version")) theme_version = e.getAttribute("version"); 279 if(Double.parseDouble(theme_version)!=2.0) 280 throw new Exception("The version of the theme used in the selected skin is not yet supported!"); 281 } 282 else if(tag.equals("ThemeInfo")) { 283 if(e.hasAttribute("author")) themeinfo_author = e.getAttribute("author"); 284 if(e.hasAttribute("name")) themeinfo_name = e.getAttribute("name"); 285 if(e.hasAttribute("email")) themeinfo_email = e.getAttribute("email"); 286 if(e.hasAttribute("webpage")) themeinfo_webpage = e.getAttribute("webpage"); 287 } 288 else if(tag.equals("Bitmap")) { 289 resources.add(new Bitmap(e,this)); 290 } 291 else if(tag.equals("SubBitmap")) { 292 Node p = e.getParentNode(); 293 String id = p.getAttributes().getNamedItem("id").getNodeValue(); 294 Bitmap b = (Bitmap)getResource(id); 295 b.SubBitmaps.add(new SubBitmap(e,this,b)); 296 } 297 else if(tag.equals("Font")) { 298 resources.add(new Font(e,this)); 299 } 300 } 301 /** Saves the XML Code into the skinfile **/ 224 302 public void save() { 225 303 try { trunk/src/vlcskineditor/package.html
r68 r102 6 6 <body> 7 7 8 The VLC Skin Editor's package8 The VLC Skin Editor's main package 9 9 10 10 11 @author Daniel Dreibrodt <mailto:daniel_DOT_dreibrodt_AT_g mx_DOT_de>12 @version 0. 6.011 @author Daniel Dreibrodt <mailto:daniel_DOT_dreibrodt_AT_googlemail_DOT_com> 12 @version 0.7.0 13 13 14 14 trunk/src/vlcskineditor/resources/Bitmap.java
r101 r102 34 34 import java.awt.event.*; 35 35 import java.io.*; 36 import org.w3c.dom.Element; 36 37 37 38 /** … … 59 60 60 61 /** 62 * Creates a new Bitmap from a W3C DOM element 63 * @param e The W3C DOM element 64 * @param s_ The skin in which the Bitmap is used 65 */ 66 public Bitmap(Element e, Skin s_) { 67 type = "Bitmap"; 68 s = s_; 69 if(e.hasAttribute("id")) id = e.getAttribute("id"); 70 if(e.hasAttribute("file")) file = e.getAttribute("file"); 71 if(e.hasAttribute("alphacolor")) alphacolor = e.getAttribute("alphacolor"); 72 if(e.hasAttribute("nbframes")) nbframes = Integer.valueOf(e.getAttribute("nbframes")); 73 if(e.hasAttribute("fps")) fps = Integer.valueOf(e.getAttribute("fps")); 74 updateImage(); 75 } 76 77 /** 61 78 * Creates a new Bitmap from xml code 62 79 * @param xmlcode The XML code from which the Bitmap should be created. One line per tag. 63 * @param s_ The skin in which the Bitmap is used. 64 * This is necessary in order that the image file can be located relatively to the skin file. 80 * @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. 65 81 */ 66 82 public Bitmap(String xmlcode, Skin s_) { … … 130 146 * Regenerates the image represented by the Bitmap object. 131 147 */ 132 public voidupdateImage() {148 public boolean updateImage() { 133 149 try { 134 150 image = ImageIO.read(new File(s.skinfolder+file)); … … 165 181 catch(Exception ex) { 166 182 ex.printStackTrace(); 167 JOptionPane.showMessageDialog(null,ex.getMessage()+"\n"+s.skinfolder+file,"Bitmap \""+id+"\" caused an error",JOptionPane.ERROR_MESSAGE); 168 showOptions(); 169 return; 170 } 183 //JOptionPane.showMessageDialog(null,ex.getMessage()+"\n"+s.skinfolder+file,"Bitmap \""+id+"\" caused an error",JOptionPane.ERROR_MESSAGE); 184 //showOptions(); 185 image = new BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB); 186 Graphics2D g = (Graphics2D)image.getGraphics(); 187 g.setColor(new Color(255,0,0,128)); 188 g.fillRect(0, 0, 32, 32); 189 return false; 190 } 191 return true; 171 192 } 172 193 public void update() { … … 180 201 s.updateResources(); 181 202 s.expandResource(id); 182 } 183 updateImage(); 203 } 184 204 be.setNew(); 185 205 s.m.hist.addEvent(be); … … 212 232 fps_tf.setToolTipText("Only used in animated bitmaps; it is the number of frames (images) per seconds of the animation."); 213 233 ok_btn = new JButton("OK"); 214 ok_btn.addActionListener(this); 215 ok_btn.setPreferredSize(new Dimension(70,25)); 234 ok_btn.addActionListener(this); 216 235 cancel_btn = new JButton("Cancel"); 217 cancel_btn.addActionListener(this); 218 cancel_btn.setPreferredSize(new Dimension(70,25)); 236 cancel_btn.addActionListener(this); 219 237 help_btn = new JButton("Help"); 220 help_btn.addActionListener(this); 221 help_btn.setPreferredSize(new Dimension(70,25)); 222 238 help_btn.addActionListener(this); 239 JLabel attr_l = new JLabel("* Attributes marked with a star must be specified."); 223 240 224 241 JPanel general = new JPanel(null); 225 242 general.add(id_l); 226 243 general.add(id_tf); 227 id_l.setBounds(5,15,75,24);228 id_tf.setBounds(85,15,150,24);229 244 general.add(file_l); 230 245 general.add(file_tf); 231 246 general.add(file_btn); 232 file_l.setBounds(5,45,75,24);233 file_tf.setBounds(85,45,150,24);234 file_btn.setBounds(240,45,100,24);235 247 general.add(alphacolor_l); 236 248 general.add(alphacolor_tf); 237 249 general.add(alphacolor_btn); 238 alphacolor_l.setBounds(5,75,75,24);239 alphacolor_tf.setBounds(85,75,150,24);240 alphacolor_btn.setBounds(240,75,100,24);241 250 general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes")); 242 general.setMinimumSize(new Dimension(345,110));243 general.setPreferredSize(new Dimension(345,110));244 general.setMaximumSize(new Dimension(345,110));245 251 frame.add(general); 252 253 //Distance of textfields to WEST edge of container 254 Component[] labels = { id_l, file_l, alphacolor_l, nbframes_l, fps_l}; 255 int tf_dx = Helper.maxWidth(labels)+10; 256 //Max. textfield width 257 int tf_wd = 200; 258 //Width of buttons 259 Component[] btns = { file_btn, alphacolor_btn }; 260 int btn_wd = Helper.maxWidth(btns); 261 262 SpringLayout general_layout = new SpringLayout(); 263 general.setLayout(general_layout); 264 265 general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general); 266 general_layout.putConstraint(SpringLayout.WEST, id_l, 5, SpringLayout.WEST, general); 267 general_layout.putConstraint(SpringLayout.WEST, id_tf, tf_dx, SpringLayout.WEST, general); 268 general_layout.putConstraint(SpringLayout.NORTH, id_tf, 0, SpringLayout.NORTH, id_l); 269 general_layout.putConstraint(SpringLayout.EAST, id_tf, 0, SpringLayout.EAST, file_btn); 270 271 general_layout.putConstraint(SpringLayout.NORTH, file_l, 10, SpringLayout.SOUTH, id_l); 272 general_layout.putConstraint(SpringLayout.WEST, file_l, 5, SpringLayout.WEST, general); 273 general_layout.putConstraint(SpringLayout.WEST, file_tf, tf_dx, SpringLayout.WEST, general); 274 general_layout.putConstraint(SpringLayout.NORTH, file_tf, 0, SpringLayout.NORTH, file_l); 275 file_tf.setPreferredSize(new Dimension(tf_wd-btn_wd,file_tf.getPreferredSize().height)); 276 file_btn.setPreferredSize(new Dimension(btn_wd,file_btn.getPreferredSize().height)); 277 general_layout.putConstraint(SpringLayout.WEST, file_btn, 5, SpringLayout.EAST, file_tf); 278 general_layout.putConstraint(SpringLayout.NORTH, file_btn, 0, SpringLayout.NORTH, file_l); 279 general_layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, file_btn); 280 281 general_layout.putConstraint(SpringLayout.NORTH, alphacolor_l, 10, SpringLayout.SOUTH, file_l); 282 general_layout.putConstraint(SpringLayout.WEST, alphacolor_l, 5, SpringLayout.WEST, general); 283 general_layout.putConstraint(SpringLayout.WEST, alphacolor_tf, tf_dx, SpringLayout.WEST, general); 284 general_layout.putConstraint(SpringLayout.NORTH, alphacolor_tf, 0, SpringLayout.NORTH, alphacolor_l); 285 alphacolor_tf.setPreferredSize(new Dimension(tf_wd-btn_wd,alphacolor_tf.getPreferredSize().height)); 286 alphacolor_btn.setPreferredSize(new Dimension(btn_wd,alphacolor_btn.getPreferredSize().height)); 287 general_layout.putConstraint(SpringLayout.WEST, alphacolor_btn, 5, SpringLayout.EAST, alphacolor_tf); 288 general_layout.putConstraint(SpringLayout.NORTH, alphacolor_btn, 0, SpringLayout.NORTH, alphacolor_l); 289 general_layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, alphacolor_btn); 290 291 general_layout.putConstraint(SpringLayout.SOUTH, general, 10, SpringLayout.SOUTH, alphacolor_l); 246 292 247 293 JPanel animation = new JPanel(null); … … 249 295 animation.add(nbframes_tf); 250 296 animation.add(fps_l); 251 animation.add(fps_tf); 252 nbframes_l.setBounds(5,15,150,24); 253 nbframes_tf.setBounds(160,15,150,24); 254 fps_l.setBounds(5,45,150,24); 255 fps_tf.setBounds(160,45,150,24); 256 animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes")); 257 animation.setMinimumSize(new Dimension(345,80)); 258 animation.setPreferredSize(new Dimension(345,80)); 259 animation.setMaximumSize(new Dimension(345,80)); 297 animation.add(fps_tf); 298 animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes")); 299 300 SpringLayout ani_layout = new SpringLayout(); 301 animation.setLayout(ani_layout); 302 303 nbframes_tf.setPreferredSize(new Dimension(tf_wd,nbframes_tf.getPreferredSize().height)); 304 305 ani_layout.putConstraint(SpringLayout.NORTH, nbframes_l, 5, SpringLayout.NORTH, animation); 306 ani_layout.putConstraint(SpringLayout.WEST, nbframes_l, 5, SpringLayout.WEST, animation); 307 ani_layout.putConstraint(SpringLayout.WEST, nbframes_tf, tf_dx, SpringLayout.WEST, animation); 308 ani_layout.putConstraint(SpringLayout.NORTH, nbframes_tf, 0, SpringLayout.NORTH, nbframes_l); 309 ani_layout.putConstraint(SpringLayout.EAST, animation, 5, SpringLayout.EAST, nbframes_tf); 310 311 ani_layout.putConstraint(SpringLayout.NORTH, fps_l, 10, SpringLayout.SOUTH, nbframes_l); 312 ani_layout.putConstraint(SpringLayout.WEST, fps_l, 5, SpringLayout.WEST, animation); 313 ani_layout.putConstraint(SpringLayout.WEST, fps_tf, tf_dx, SpringLayout.WEST, animation); 314 ani_layout.putConstraint(SpringLayout.NORTH, fps_tf, 0, SpringLayout.NORTH, fps_l); 315 ani_layout.putConstraint(SpringLayout.EAST, fps_tf, 0, SpringLayout.EAST, nbframes_tf); 316 317 ani_layout.putConstraint(SpringLayout.SOUTH, animation, 10, SpringLayout.SOUTH, fps_l); 318 319 260 320 frame.add(animation); 261 321 … … 263 323 frame.add(cancel_btn); 264 324 frame.add(help_btn); 265 frame.add(new JLabel("Attributes marked with a star must be specified.")); 266 267 frame.setMinimumSize(new Dimension(355,260)); 268 frame.setPreferredSize(new Dimension(355,260)); 269 frame.setMaximumSize(new Dimension(355,260)); 325 frame.add(attr_l); 326 327 SpringLayout layout = new SpringLayout(); 328 frame.setLayout(layout); 329 330 layout.putConstraint(SpringLayout.NORTH, general, 5, SpringLayout.NORTH, frame.getContentPane()); 331 layout.putConstraint(SpringLayout.WEST, general, 5, SpringLayout.WEST, frame.getContentPane()); 332 333 layout.putConstraint(SpringLayout.NORTH, animation, 5, SpringLayout.SOUTH, general); 334 layout.putConstraint(SpringLayout.WEST, animation, 5, SpringLayout.WEST, frame.getContentPane()); 335 336 337 layout.putConstraint(SpringLayout.NORTH, attr_l, 5, SpringLayout.SOUTH, animation); 338 layout.putConstraint(SpringLayout.WEST, attr_l, 5, SpringLayout.WEST, frame.getContentPane()); 339 layout.putConstraint(SpringLayout.EAST, attr_l, 5, SpringLayout.EAST, frame.getContentPane()); 340 341 342 layout.putConstraint(SpringLayout.NORTH, ok_btn, 5, SpringLayout.SOUTH, attr_l); 343 layout.putConstraint(SpringLayout.NORTH, cancel_btn, 5, SpringLayout.SOUTH, attr_l); 344 layout.putConstraint(SpringLayout.NORTH, help_btn, 5, SpringLayout.SOUTH, attr_l); 345 346 layout.putConstraint(SpringLayout.WEST, ok_btn, 5, SpringLayout.WEST, frame.getContentPane()); 347 layout.putConstraint(SpringLayout.WEST, cancel_btn, 5, SpringLayout.EAST, ok_btn); 348 layout.putConstraint(SpringLayout.WEST, help_btn, 5, SpringLayout.EAST, cancel_btn); 349 350 layout.putConstraint(SpringLayout.SOUTH, frame.getContentPane(), 5, SpringLayout.SOUTH, ok_btn); 351 layout.putConstraint(SpringLayout.EAST, frame.getContentPane(), 5, SpringLayout.EAST, general); 270 352 271 353 frame.pack(); … … 326 408 return; 327 409 } 328 update(); 329 frame.setVisible(false); 330 frame.dispose(); 331 frame = null; 410 update(); 411 if(updateImage()) { 412 frame.setVisible(false); 413 frame.dispose(); 414 frame = null; 415 } 416 else { 417 JOptionPane.showMessageDialog(frame,"The given bitmap file could not be loaded!","File not valid",JOptionPane.ERROR_MESSAGE); 418 } 332 419 } 333 420 else if(e.getSource().equals(help_btn)) { trunk/src/vlcskineditor/resources/Font.java
r99 r102 31 31 import java.awt.event.*; 32 32 import java.io.*; 33 import org.w3c.dom.Element; 33 34 /** 34 35 * Handles font resources … … 50 51 public java.awt.Font f; 51 52 53 public Font(Element e, Skin s_) { 54 type = "Font"; 55 s = s_; 56 if(e.hasAttribute("id")) id = e.getAttribute("id"); 57 if(e.hasAttribute("file")) file = e.getAttribute("file"); 58 if(e.hasAttribute("size")) size = Integer.parseInt(e.getAttribute("size")); 59 } 60 52 61 /** 53 62 * Creates a Font from XML. … … 110 119 showOptions(); 111 120 } 112 public voidupdateFont() {121 public Integer updateFont() { 113 122 try { 114 123 f = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT,new File(s.skinfolder+file)); 115 f = f.deriveFont((float)size); 124 f = f.deriveFont((float)size); 116 125 } 117 126 catch(Exception e) { 118 127 if(file.indexOf(".otf")==-1) { 119 JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE);128 //JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE); 120 129 f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); 121 showOptions(); 130 //showOptions(); 131 return 0; 122 132 } 123 133 else { 124 JOptionPane.showMessageDialog(frame,"You have chosen an OpenType font, VLC will display it correctly but the Skin Editor can not display it.\nYou will see another font instead.","Notice",JOptionPane.INFORMATION_MESSAGE);134 //JOptionPane.showMessageDialog(frame,"You have chosen an OpenType font, VLC will display it correctly but the Skin Editor can not display it.\nYou will see another font instead.","Notice",JOptionPane.INFORMATION_MESSAGE); 125 135 try { 126 136 f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); 127 137 f = f.deriveFont(12); 128 138 } 129 catch(Exception ex) { 139 catch(Exception ex) { 130 140 ex.printStackTrace(); 131 f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); 141 f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size); 132 142 } 143 return 2; 133 144 } 134 145 } 146 return 1; 135 147 } 136 148 public void update() { … … 141 153 id=id_tf.getText(); 142 154 s.updateResources(); 143 s.expandResource(id); 144 updateFont(); 155 s.expandResource(id); 145 156 fe.setNew(); 146 157 s.m.hist.addEvent(fe); … … 150 161 frame = new JFrame("Font settings"); 151 162 frame.setResizable(false); 152 frame.setLayout(new FlowLayout());153 163 JLabel id_l = new JLabel("ID*:"); 154 164 id_tf = new JTextField(); … … 163 173 size_tf.setDocument(new NumbersOnlyDocument()); 164 174 ok_btn = new JButton("OK"); 165 ok_btn.addActionListener(this); 166 ok_btn.setPreferredSize(new Dimension(70,25)); 175 ok_btn.addActionListener(this); 167 176 cancel_btn = new JButton("Cancel"); 168 cancel_btn.addActionListener(this); 169 cancel_btn.setPreferredSize(new Dimension(70,25)); 177 cancel_btn.addActionListener(this); 170 178 help_btn = new JButton("Help"); 171 help_btn.addActionListener(this); 172 help_btn.setPreferredSize(new Dimension(70,25));173 174 JPanel general = new JPanel(null); 179 help_btn.addActionListener(this); 180 JLabel attr_l = new JLabel("* Attributes marked with a star must be specified."); 181 182 JPanel general = new JPanel(null); 175 183 general.add(id_l); 176 general.add(id_tf); 177 id_l.setBounds(5,15,75,24); 178 id_tf.setBounds(85,15,150,24); 184 general.add(id_tf); 179 185 general.add(file_l); 180 186 general.add(file_tf); 181 187 general.add(file_btn); 182 file_l.setBounds(5,45,75,24);183 file_tf.setBounds(85,45,150,24);184 file_btn.setBounds(240,45,100,24);185 188 general.add(size_l); 186 189 general.add(size_tf); 187 size_l.setBounds(5,75,75,24);188 size_tf.setBounds(85,75,150,24);189 190 190 191 general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes")); 191 general.setMinimumSize(new Dimension(345,110)); 192 general.setPreferredSize(new Dimension(345,110)); 193 general.setMaximumSize(new Dimension(345,110)); 194 frame.add(general); 195 192 193 SpringLayout general_layout = new SpringLayout(); 194 general.setLayout(general_layout); 195 196 //Textfield distance to WEST border of container 197 Component[] labels = { id_l, file_l, size_l }; 198 int tf_dx = Helper.maxWidth(labels)+10; 199 //Maximal textfield width 200 int tf_wd = 200; 201 //Button width 202 int btn_wd = file_btn.getPreferredSize().width; 203 204 general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general); 205 general_layout.putConstraint(SpringLayout.WEST, id_l, 5, SpringLayout.WEST, general); 206 general_layout.putConstraint(SpringLayout.WEST, id_tf, tf_dx, SpringLayout.WEST, general); 207 general_layout.putConstraint(SpringLayout.NORTH, id_tf, 0, SpringLayout.NORTH, id_l); 208 general_layout.putConstraint(SpringLayout.EAST, id_tf, 0, SpringLayout.EAST, file_btn); 209 210 general_layout.putConstraint(SpringLayout.NORTH, file_l, 10, SpringLayout.SOUTH, id_l); 211 general_layout.putConstraint(SpringLayout.WEST, file_l, 5, SpringLayout.WEST, general); 212 general_layout.putConstraint(SpringLayout.WEST, file_tf, tf_dx, SpringLayout.WEST, general); 213 general_layout.putConstraint(SpringLayout.NORTH, file_tf, 0, SpringLayout.NORTH, file_l); 214 file_tf.setPreferredSize(new Dimension(tf_wd-btn_wd,file_tf.getPreferredSize().height)); 215 general_layout.putConstraint(SpringLayout.WEST, file_btn, 5, SpringLayout.EAST, file_tf); 216 general_layout.putConstraint(SpringLayout.NORTH, file_btn, 0, SpringLayout.NORTH, file_l); 217 general_layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, file_btn); 218 219 general_layout.putConstraint(SpringLayout.NORTH, size_l, 10, SpringLayout.SOUTH, file_l); 220 general_layout.putConstraint(SpringLayout.WEST, size_l, 5, SpringLayout.WEST, general); 221 general_layout.putConstraint(SpringLayout.WEST, size_tf, tf_dx, SpringLayout.WEST, general); 222 general_layout.putConstraint(SpringLayout.NORTH, size_tf, 0, SpringLayout.NORTH, size_l); 223 general_layout.putConstraint(SpringLayout.EAST, size_tf, 0, SpringLayout.EAST, file_btn); 224 225 general_layout.putConstraint(SpringLayout.SOUTH, general, 10, SpringLayout.SOUTH, size_l); 226 227 frame.add(general); 228 frame.add(attr_l); 196 229 frame.add(ok_btn); 197 230 frame.add(cancel_btn); 198 frame.add(help_btn); 199 frame.add(new JLabel("Attributes marked with a star must be specified.")); 200 201 frame.setMinimumSize(new Dimension(355,175)); 202 frame.setPreferredSize(new Dimension(355,175)); 203 frame.setMaximumSize(new Dimension(355,175)); 204 205 frame.pack(); 231 frame.add(help_btn); 232 233 SpringLayout layout = new SpringLayout(); 234 frame.setLayout(layout); 235 236 layout.putConstraint(SpringLayout.NORTH, general, 5, SpringLayout.NORTH, frame.getContentPane()); 237 layout.putConstraint(SpringLayout.WEST, general, 5, SpringLayout.WEST, frame.getContentPane()); 238 //layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, frame.getContentPane()); 239 240 layout.putConstraint(SpringLayout.NORTH, attr_l, 5, SpringLayout.SOUTH, general); 241 layout.putConstraint(SpringLayout.WEST, attr_l, 5, SpringLayout.WEST, frame.getContentPane()); 242 layout.putConstraint(SpringLayout.EAST, attr_l, 5, SpringLayout.EAST, frame.getContentPane()); 243 244 245 layout.putConstraint(SpringLayout.NORTH, ok_btn, 5, SpringLayout.SOUTH, attr_l); 246 layout.putConstraint(SpringLayout.NORTH, cancel_btn, 5, SpringLayout.SOUTH, attr_l); 247 layout.putConstraint(SpringLayout.NORTH, help_btn, 5, SpringLayout.SOUTH, attr_l); 248 249 layout.putConstraint(SpringLayout.WEST, ok_btn, 5, SpringLayout.WEST, frame.getContentPane()); 250 layout.putConstraint(SpringLayout.WEST, cancel_btn, 5, SpringLayout.EAST, ok_btn); 251 layout.putConstraint(SpringLayout.WEST, help_btn, 5, SpringLayout.EAST, cancel_btn); 252 253 layout.putConstraint(SpringLayout.SOUTH, frame.getContentPane(), 5, SpringLayout.SOUTH, ok_btn); 254 layout.putConstraint(SpringLayout.EAST, frame.getContentPane(), 5, SpringLayout.EAST, general); 255 256 frame.pack(); 206 257 } 207 258 id_tf.setText(id); … … 239 290 return; 240 291 } 241 update(); 242 frame.setVisible(false); 243 frame.dispose(); 244 frame = null; 292 update(); 293 int i = updateFont(); 294 if(i==0) JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE); 295 else if(i==2) JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE); 296 else if(i==1) { 297 frame.setVisible(false); 298 frame.dispose(); 299 frame = null; 300 } 245 301 } 246 302 else if(e.getSource().equals(help_btn)) { trunk/src/vlcskineditor/resources/SubBitmap.java
r99 r102 30 30 import java.awt.image.*; 31 31 import java.awt.event.*; 32 import org.w3c.dom.Element; 32 33 import vlcskineditor.history.SubBitmapAddEvent; 33 34 /** … … 50 51 JFrame frame = null; 51 52 JTextField id_tf, x_tf, y_tf, width_tf, height_tf, nbframes_tf, fps_tf; 52 JButton file_btn,ok_btn, cancel_btn, help_btn;53 JButton ok_btn, cancel_btn, help_btn; 53 54 JFileChooser fc; 54 55 … … 56 57 57 58 SubBitmapEditWindow sbew = null; 59 /** 60 * Creates a new SubBitmap from a DOM Element 61 * @param e The DOM Element 62 * @param s_ The skin in which the SubBitmap is used 63 * @param parent_ The parent Bitmap. This is necessary to create the image represented by the SubBitmap. 64 */ 65 66 public SubBitmap(Element e, Skin s_, Bitmap parent_) { 67 s = s_; 68 parent = parent_; 69 type = "Bitmap"; 70 if(e.hasAttribute("id")) id = e.getAttribute("id"); 71 if(e.hasAttribute("x")) x = Integer.parseInt(e.getAttribute("x")); 72 if(e.hasAttribute("y")) y = Integer.parseInt(e.getAttribute("y")); 73 if(e.hasAttribute("width")) width = Integer.parseInt(e.getAttribute("width")); 74 if(e.hasAttribute("height")) height = Integer.parseInt(e.getAttribute("height")); 75 created = true; 76 } 58 77 59 78 /** … … 94 113 */ 95 114 public void updateImage() { 96 if(parent.image != null) image = parent.image.getSubimage(x,y,width,height); 115 if(parent.image != null) image = parent.image.getSubimage(x,y,width,height); 97 116 } 98 117 public void update() { … … 157 176 fps_tf.setToolTipText("Only used in animated bitmaps; it is the number of frames (images) per seconds of the animation."); 158 177 ok_btn = new JButton("OK"); 159 ok_btn.addActionListener(this); 160 ok_btn.setPreferredSize(new Dimension(70,25)); 178 ok_btn.addActionListener(this); 161 179 cancel_btn = new JButton("Cancel"); 162 cancel_btn.addActionListener(this); 163 cancel_btn.setPreferredSize(new Dimension(70,25)); 180 cancel_btn.addActionListener(this); 164 181 help_btn = new JButton("Help"); 165 182 help_btn.addActionListener(this); 166 help_btn.setPreferredSize(new Dimension(70,25)); 183 JLabel attr_l = new JLabel("* Attributes marked with a star must be specified."); 184 185 //Distance of textfields to WEST edge of container 186 Component[] labels = { id_l, x_l, y_l, width_l, height_l, nbframes_l, fps_l}; 187 int tf_dx = Helper.maxWidth(labels)+10; 188 //Max. textfield width 189 int tf_wd = 200; 167 190 168 191 JPanel general = new JPanel(null); 169 192 general.add(id_l); 170 193 general.add(id_tf); 171 id_l.setBounds(5,15,75,24); 172 id_tf.setBounds(85,15,150,24); 173 general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes")); 174 general.setMinimumSize(new Dimension(345,50)); 175 general.setPreferredSize(new Dimension(345,50)); 176 general.setMaximumSize(new Dimension(345,50)); 194 id_tf.setPreferredSize(new Dimension(tf_wd,id_tf.getPreferredSize().height)); 195 general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes")); 196 SpringLayout general_layout = new SpringLayout(); 197 general.setLayout(general_layout); 198 general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general); 199 general_layout.putConstraint(SpringLayout.WEST, id_l, 5, SpringLayout.WEST, general); 200 general_layout.putConstraint(SpringLayout.WEST, id_tf, tf_dx, SpringLayout.WEST, general); 201 general_layout.putConstraint(SpringLayout.NORTH, id_tf, 0, SpringLayout.NORTH, id_l); 202 general_layout.putConstraint(SpringLayout.EAST, general, 5, SpringLayout.EAST, id_tf); 203 general_layout.putConstraint(SpringLayout.SOUTH, general, 10, SpringLayout.SOUTH, id_l); 177 204 frame.add(general); 178 205 … … 180 207 bounds.add(x_l); 181 208 bounds.add(x_tf); 209 x_tf.setPreferredSize(new Dimension(tf_wd,x_tf.getPreferredSize().height)); 182 210 bounds.add(y_l); 183 211 bounds.add(y_tf); 212 y_tf.setPreferredSize(new Dimension(tf_wd,y_tf.getPreferredSize().height)); 184 213 bounds.add(width_l); 185 214 bounds.add(width_tf); 215 width_tf.setPreferredSize(new Dimension(tf_wd,width_tf.getPreferredSize().height)); 186 216 bounds.add(height_l); 187 217 bounds.add(height_tf); 188 x_l.setBounds(5,15,75,24); 189 x_tf.setBounds(85,15,150,24); 190 y_l.setBounds(5,45,75,24); 191 y_tf.setBounds(85,45,150,24); 192 width_l.setBounds(5,75,75,24); 193 width_tf.setBounds(85,75,150,24); 194 height_l.setBounds(5,105,75,24); 195 height_tf.setBounds(85,105,150,24); 196 bounds.setMinimumSize(new Dimension(345,145)); 197 bounds.setPreferredSize(new Dimension(345,145)); 198 bounds.setMaximumSize(new Dimension(345,145)); 218 height_tf.setPreferredSize(new Dimension(tf_wd,height_tf.getPreferredSize().height)); 199 219 bounds.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Position and Dimension Attributes")); 220 SpringLayout bounds_layout = new SpringLayout(); 221 bounds.setLayout(bounds_layout); 222 bounds_layout.putConstraint(SpringLayout.NORTH, x_l, 5, SpringLayout.NORTH, bounds); 223 bounds_layout.putConstraint(SpringLayout.WEST, x_l, 5, SpringLayout.WEST, bounds); 224 bounds_layout.putConstraint(SpringLayout.WEST, x_tf, tf_dx, SpringLayout.WEST, bounds); 225 bounds_layout.putConstraint(SpringLayout.NORTH, x_tf, 0, SpringLayout.NORTH, x_l); 226 bounds_layout.putConstraint(SpringLayout.EAST, bounds, 5, SpringLayout.EAST, x_tf); 227 bounds_layout.putConstraint(SpringLayout.NORTH, y_l, 10, SpringLayout.SOUTH, x_l); 228 bounds_layout.putConstraint(SpringLayout.WEST, y_l, 5, SpringLayout.WEST, bounds); 229 bounds_layout.putConstraint(SpringLayout.WEST, y_tf, tf_dx, SpringLayout.WEST, bounds); 230 bounds_layout.putConstraint(SpringLayout.NORTH, y_tf, 0, SpringLayout.NORTH, y_l); 231 bounds_layout.putConstraint(SpringLayout.EAST, y_tf, 0, SpringLayout.EAST, x_tf); 232 bounds_layout.putConstraint(SpringLayout.NORTH, width_l, 10, SpringLayout.SOUTH, y_l); 233 bounds_layout.putConstraint(SpringLayout.WEST, width_l, 5, SpringLayout.WEST, bounds); 234 bounds_layout.putConstraint(SpringLayout.WEST, width_tf, tf_dx, SpringLayout.WEST, bounds); 235 bounds_layout.putConstraint(SpringLayout.NORTH, width_tf, 0, SpringLayout.NORTH, width_l); 236 bounds_layout.putConstraint(SpringLayout.EAST, width_tf, 0, SpringLayout.EAST, x_tf); 237 bounds_layout.putConstraint(SpringLayout.NORTH, height_l, 10, SpringLayout.SOUTH, width_l); 238 bounds_layout.putConstraint(SpringLayout.WEST, height_l, 5, SpringLayout.WEST, bounds); 239 bounds_layout.putConstraint(SpringLayout.WEST, height_tf, tf_dx, SpringLayout.WEST, bounds); 240 bounds_layout.putConstraint(SpringLayout.NORTH, height_tf, 0, SpringLayout.NORTH, height_l); 241 bounds_layout.putConstraint(SpringLayout.EAST, height_tf, 0, SpringLayout.EAST, x_tf); 242 bounds_layout.putConstraint(SpringLayout.SOUTH, bounds, 10, SpringLayout.SOUTH, height_l); 200 243 frame.add(bounds); 201 244 … … 204 247 animation.add(nbframes_tf); 205 248 animation.add(fps_l); 206 animation.add(fps_tf); 207 nbframes_l.setBounds(5,15,150,24); 208 nbframes_tf.setBounds(160,15,150,24); 209 fps_l.setBounds(5,45,150,24); 210 fps_tf.setBounds(160,45,150,24); 211 animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes")); 212 animation.setMinimumSize(new Dimension(345,80)); 213 animation.setPreferredSize(new Dimension(345,80)); 214 animation.setMaximumSize(new Dimension(345,80)); 249 animation.add(fps_tf); 250 animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes")); 251 SpringLayout ani_layout = new SpringLayout(); 252 animation.setLayout(ani_layout); 253 nbframes_tf.setPreferredSize(new Dimension(tf_wd,nbframes_tf.getPreferredSize().height)); 254 ani_layout.putConstraint(SpringLayout.NORTH, nbframes_l, 5, SpringLayout.NORTH, animation); 255 ani_layout.putConstraint(SpringLayout.WEST, nbframes_l, 5, SpringLayout.WEST, animation); 256 ani_layout.putConstraint(SpringLayout.WEST, nbframes_tf, tf_dx, SpringLayout.WEST, animation); 257 ani_layout.putConstraint(SpringLayout.NORTH, nbframes_tf, 0, SpringLayout.NORTH, nbframes_l); 258 ani_layout.putConstraint(SpringLayout.EAST, animation, 5, SpringLayout.EAST, nbframes_tf); 259 ani_layout.putConstraint(SpringLayout.NORTH, fps_l, 10, SpringLayout.SOUTH, nbframes_l); 260 ani_layout.putConstraint(SpringLayout.WEST, fps_l, 5, SpringLayout.WEST, animation); 261 ani_layout.putConstraint(SpringLayout.WEST, fps_tf, tf_dx, SpringLayout.WEST, animation); 262 ani_layout.putConstraint(SpringLayout.NORTH, fps_tf, 0, SpringLayout.NORTH, fps_l); 263 ani_layout.putConstraint(SpringLayout.EAST, fps_tf, 0, SpringLayout.EAST, nbframes_tf); 264 ani_layout.putConstraint(SpringLayout.SOUTH, animation, 10, SpringLayout.SOUTH, fps_l); 215 265 frame.add(animation); 216 266 … … 218 268 frame.add(cancel_btn); 219 269 frame.add(help_btn); 220 frame.add(new JLabel("* must be specified.")); 221 222 frame.setMinimumSize(new Dimension(355,355)); 223 frame.setPreferredSize(new Dimension(355,355)); 224 frame.setMaximumSize(new Dimension(355,355)); 225 226 frame.pack(); 227 270 frame.add(attr_l); 271 272 SpringLayout layout = new SpringLayout(); 273 frame.setLayout(layout); 274 275 layout.putConstraint(SpringLayout.NORTH, general, 5, SpringLayout.NORTH, frame.getContentPane()); 276 layout.putConstraint(SpringLayout.WEST, general, 5, SpringLayout.WEST, frame.getContentPane()); 277 278 layout.putConstraint(SpringLayout.NORTH, bounds, 5, SpringLayout.SOUTH, general); 279 layout.putConstraint(SpringLayout.WEST, bounds, 5, SpringLayout.WEST, frame.getContentPane()); 280 281 layout.putConstraint(SpringLayout.NORTH, animation, 5, SpringLayout.SOUTH, bounds); 282 layout.putConstraint(SpringLayout.WEST, animation, 5, SpringLayout.WEST, frame.getContentPane()); 283 284 layout.putConstraint(SpringLayout.NORTH, attr_l, 5, SpringLayout.SOUTH, animation); 285 layout.putConstraint(SpringLayout.WEST, attr_l, 5, SpringLayout.WEST, frame.getContentPane()); 286 layout.putConstraint(SpringLayout.EAST, attr_l, 5, SpringLayout.EAST, frame.getContentPane()); 287 288 289 layout.putConstraint(SpringLayout.NORTH, ok_btn, 5, SpringLayout.SOUTH, attr_l); 290 layout.putConstraint(SpringLayout.NORTH, cancel_btn, 5, SpringLayout.SOUTH, attr_l); 291 layout.putConstraint(SpringLayout.NORTH, help_btn, 5, SpringLayout.SOUTH, attr_l); 292 293 layout.putConstraint(SpringLayout.WEST, ok_btn, 5, SpringLayout.WEST, frame.getContentPane()); 294 layout.putConstraint(SpringLayout.WEST, cancel_btn, 5, SpringLayout.EAST, ok_btn); 295 layout.putConstraint(SpringLayout.WEST, help_btn, 5, SpringLayout.EAST, cancel_btn); 296 297 layout.putConstraint(SpringLayout.SOUTH, frame.getContentPane(), 5, SpringLayout.SOUTH, ok_btn); 298 layout.putConstraint(SpringLayout.EAST, frame.getContentPane(), 5, SpringLayout.EAST, general); 299 300 frame.pack(); 228 301 } 229 302 id_tf.setText(id); … … 254 327 } 255 328 } 256 if(Integer.parseInt( width_tf.getText())<1) {257 JOptionPane.showMessageDialog(frame," Width must be greater 0!","Widthnot valid",JOptionPane.INFORMATION_MESSAGE);329 if(Integer.parseInt(height_tf.getText())<1) { 330 JOptionPane.showMessageDialog(frame,"height must be greater 0!","height not valid",JOptionPane.INFORMATION_MESSAGE); 258 331 return; 259 332 } … … 262 335 return; 263 336 } 264 if(Integer.parseInt(x_tf.getText())+Integer.parseInt( width_tf.getText())>parent.image.getWidth()) {337 if(Integer.parseInt(x_tf.getText())+Integer.parseInt(height_tf.getText())>parent.image.getHeight()) { 265 338 JOptionPane.showMessageDialog(frame,"Specified dimensions are outside the parent bitmap!","Dimension not valid",JOptionPane.INFORMATION_MESSAGE); 266 339 return; … … 303 376 x_tf.removeKeyListener(sbew); 304 377 y_tf.removeKeyListener(sbew); 305 width_tf.removeKeyListener(sbew);378 height_tf.removeKeyListener(sbew); 306 379 height_tf.removeKeyListener(sbew); 307 380 frame.removeWindowListener(sbew); … … 312 385 public String returnCode(String indent) { 313 386 String code=indent+"<SubBitmap id=\""+id+"\" x=\""+String.valueOf(x)+"\" y=\""+String.valueOf(y)+"\""; 314 code+=" width=\""+String.valueOf(width)+"\" height=\""+String.valueOf(height)+"\"";387 code+=" height=\""+String.valueOf(height)+"\" height=\""+String.valueOf(height)+"\""; 315 388 if (nbframes!=NBFRAMES_DEFAULT) code+=" nbframes=\""+String.valueOf(nbframes)+"\""; 316 389 if (fps!=FPS_DEFAULT) code+=" fps=\""+String.valueOf(fps)+"\"";
