Changeset 91
- Timestamp:
- 29/12/07 18:56:49 (11 months ago)
- Files:
-
- trunk/src/vlcskineditor/Main.java (modified) (9 diffs)
- trunk/src/vlcskineditor/Resource.java (modified) (1 diff)
- trunk/src/vlcskineditor/Skin.java (modified) (4 diffs)
- trunk/src/vlcskineditor/icons/copy.png (added)
- trunk/src/vlcskineditor/icons/edit-redo.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/edit-undo.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/editor.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/exit.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/help.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/items.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/new.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/open.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/preview.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/resources.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/save.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/sliderbg_btt.png (modified) (1 prop)
- trunk/src/vlcskineditor/icons/sliderbg_ltr.png (modified) (1 prop)
- trunk/src/vlcskineditor/resources/Bitmap.java (modified) (1 diff)
- trunk/src/vlcskineditor/resources/SubBitmap.java (modified) (1 diff)
- trunk/src/vlcskineditor/resources/SubBitmapEditWindow.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/vlcskineditor/Main.java
r88 r91 33 33 import javax.swing.border.*; 34 34 import java.util.zip.*; 35 import javax.imageio.*; 36 import vlcskineditor.resources.Bitmap; 35 import javax.imageio.*; 37 36 import vlcskineditor.items.*; 38 37 import com.ice.tar.*; 39 38 import com.ice.jni.registry.*; 40 39 import vlcskineditor.history.*; 40 import vlcskineditor.resources.Bitmap; 41 import vlcskineditor.resources.SubBitmap; 41 42 42 43 … … 62 63 JTree res_tree,win_tree,items_tree; 63 64 DefaultTreeModel res_tree_model, win_tree_model, items_tree_model; 64 JButton res_add_bitmap, res_add_font, res_ edit, res_del;65 JButton res_add_bitmap, res_add_font, res_duplicate, res_edit, res_del; 65 66 JPopupMenu res_add_bitmap_pu; 66 67 JMenuItem res_add_bitmap_pu_b, res_add_bitmap_pu_s; … … 78 79 public ImageIcon add_bitmap_icon = createIcon("icons/add_bitmap.png"); 79 80 public ImageIcon add_font_icon = createIcon("icons/add_font.png"); 81 public ImageIcon copy_icon = createIcon("icons/copy.png"); 80 82 public ImageIcon edit_icon = createIcon("icons/edit.png"); 81 83 public ImageIcon edit_undo_icon = createIcon("icons/edit-undo.png"); … … 268 270 res_add_font.setPreferredSize(new Dimension(24,24)); 269 271 res_add_font.addActionListener(this); 272 res_duplicate = new JButton("",copy_icon); 273 res_duplicate.setToolTipText("Create copy of the selected item"); 274 res_duplicate.setPreferredSize(new Dimension(24,24)); 275 res_duplicate.addActionListener(this); 270 276 res_edit = new JButton("",edit_icon); 271 277 res_edit.setToolTipText("Edit the selected item"); … … 280 286 resources.add(res_add_bitmap); 281 287 resources.add(res_add_font); 288 resources.add(res_duplicate); 282 289 resources.add(res_edit); 283 290 resources.add(res_del); … … 287 294 res_layout.putConstraint(SpringLayout.NORTH, res_add_bitmap,5,SpringLayout.SOUTH, res_tree_sp); 288 295 res_layout.putConstraint(SpringLayout.NORTH, res_add_font,5,SpringLayout.SOUTH, res_tree_sp); 296 res_layout.putConstraint(SpringLayout.NORTH, res_duplicate,5,SpringLayout.SOUTH, res_tree_sp); 289 297 res_layout.putConstraint(SpringLayout.NORTH, res_edit,5,SpringLayout.SOUTH, res_tree_sp); 290 298 res_layout.putConstraint(SpringLayout.NORTH, res_del,5,SpringLayout.SOUTH, res_tree_sp); … … 295 303 res_layout.putConstraint(SpringLayout.WEST, res_add_bitmap,5,SpringLayout.WEST, resources.getContentPane()); 296 304 res_layout.putConstraint(SpringLayout.WEST, res_add_font,5,SpringLayout.EAST, res_add_bitmap); 297 res_layout.putConstraint(SpringLayout.WEST, res_edit,5,SpringLayout.EAST, res_add_font); 305 res_layout.putConstraint(SpringLayout.WEST, res_duplicate,5,SpringLayout.EAST, res_add_font); 306 res_layout.putConstraint(SpringLayout.WEST, res_edit,5,SpringLayout.EAST, res_duplicate); 298 307 res_layout.putConstraint(SpringLayout.WEST, res_del,5,SpringLayout.EAST, res_edit); 299 308 res_layout.putConstraint(SpringLayout.SOUTH, resources.getContentPane(),24+5+5,SpringLayout.SOUTH, res_tree_sp); … … 971 980 Resource r = s.getResource(selected_resource); 972 981 if(r!=null) { 973 if(r.type.equals("Bitmap")) { 974 vlcskineditor.resources.Bitmap b = (vlcskineditor.resources.Bitmap)r; 982 if(r.getClass()==Bitmap.class) { 983 Bitmap b = (Bitmap)r; 984 b.SubBitmaps.add(new vlcskineditor.resources.SubBitmap(s,b)); 985 } 986 else if(r.getClass()==SubBitmap.class) { 987 SubBitmap sb = (SubBitmap)r; 988 Bitmap b = sb.getParentBitmap(); 975 989 b.SubBitmaps.add(new vlcskineditor.resources.SubBitmap(s,b)); 976 990 } 977 991 else { 978 JOptionPane.showMessageDialog(this," No parent bitmap selected!","Could not add subbitmap",JOptionPane.INFORMATION_MESSAGE);992 JOptionPane.showMessageDialog(this,"The selected resource is no bitmap!","Could not add subbitmap",JOptionPane.INFORMATION_MESSAGE); 979 993 } 980 994 } 981 995 else { 982 JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add sub bitmap",JOptionPane.INFORMATION_MESSAGE);996 JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add subbitmap",JOptionPane.INFORMATION_MESSAGE); 983 997 } 984 998 } 985 999 else { 986 JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add sub bitmap",JOptionPane.INFORMATION_MESSAGE);1000 JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add subbitmap",JOptionPane.INFORMATION_MESSAGE); 987 1001 } 988 1002 } … … 1006 1020 s.updateResources(); 1007 1021 } 1022 } 1023 // </editor-fold> 1024 // <editor-fold defaultstate="collapsed" desc="Duplicate resource"> 1025 else if(e.getSource().equals(res_duplicate)) { 1026 if(selected_resource==null) return; 1027 Resource r = s.getResource(selected_resource); 1028 if(r==null) return; 1029 if(r.getClass()==Bitmap.class) { 1030 Bitmap b = (Bitmap)r; 1031 Bitmap b2 = new Bitmap(b.returnCode(),s); 1032 b2.renameForCopy(); 1033 s.resources.add(b2); 1034 s.updateResources(); 1035 s.expandResource(b.id); 1036 } 1037 else if(r.getClass()==SubBitmap.class) { 1038 SubBitmap sb = (SubBitmap)r; 1039 SubBitmap sb2 = new SubBitmap(sb.returnCode(),s,sb.getParentBitmap()); 1040 sb2.renameForCopy(); 1041 sb.getParentBitmap().SubBitmaps.add(sb2); 1042 s.updateResources(); 1043 s.expandResource(sb.id); 1044 } 1045 else { 1046 vlcskineditor.resources.Font f = (vlcskineditor.resources.Font)r; 1047 vlcskineditor.resources.Font f2 = new vlcskineditor.resources.Font(f.returnCode(),s); 1048 f2.renameForCopy(); 1049 s.resources.add(f2); 1050 s.updateResources(); 1051 s.expandResource(f.id); 1052 } 1008 1053 } 1009 1054 // </editor-fold> trunk/src/vlcskineditor/Resource.java
r71 r91 50 50 return null; 51 51 } 52 /** Renames the Resource after the copy process **/ 53 public void renameForCopy() { 54 if(id.indexOf("_copy")!=-1) { 55 id = id.substring(0,id.indexOf("_copy")); 56 } 57 String newid_base = id+="_copy"; 58 String newid = newid_base; 59 int i = 1; 60 while(s.idExists(newid)) { 61 i++; 62 newid = newid_base+"_"+String.valueOf(i); 63 } 64 id = newid; 65 } 52 66 } trunk/src/vlcskineditor/Skin.java
r89 r91 372 372 /** Checks whether an id exists already **/ 373 373 public boolean idExists(String id) { 374 for (int i=0;i<resources.size();i++) { 375 if(resources.get(i).id.equals(id)) return true; 376 } 377 for (int i=0;i<windows.size();i++) { 378 if(windows.get(i).id.equals(id)) return true; 379 for (int l=0;l<windows.get(i).layouts.size();l++) { 380 if(windows.get(i).layouts.get(l).id.equals(id)) return true; 381 for(int x=0;x<windows.get(i).layouts.get(l).items.size();x++) { 382 if(windows.get(i).layouts.get(l).items.get(x).id.equals(id)) return true; 374 if(getResource(id)!=null) return true; 375 for(Window w:windows) { 376 if(w.id.equals(id)) return true; 377 for(Layout l:w.layouts) { 378 if(l.id.equals(id)) return true; 379 if(l.getItem(id)!=null) return true; 380 } 381 } 382 return false; 383 } 384 /** Returns the resource represented by the given id **/ 385 public Resource getResource(String id) { 386 for (Resource r:resources) { 387 if(r.id.equals(id)) return r; 388 if(r.getClass()==Bitmap.class) { 389 Bitmap bmp = (Bitmap)r; 390 for(SubBitmap s:bmp.SubBitmaps) { 391 if(s.id.equals(id)) return s; 383 392 } 384 393 } 385 394 } 386 return false; 387 } 388 /** Returns the resource represented by the given id **/ 389 public Resource getResource(String id) { 390 Resource r = null; 391 for (int i=0;i<resources.size();i++) { 392 if(resources.get(i).id.equals(id)) r=resources.get(i); 393 if(resources.get(i).type.equals("Bitmap")) { 394 Bitmap bmp = (Bitmap)resources.get(i); 395 for(int x=0;x<bmp.SubBitmaps.size();x++) { 396 if(bmp.SubBitmaps.get(x).id.equals(id)) r=bmp.SubBitmaps.get(x); 397 } 398 } 399 } 400 return r; 395 return null; 401 396 } 402 397 /** Returns the image object of a bitmap **/ … … 407 402 } 408 403 else { 409 if(r.type.equals("Bitmap")) { 410 try { 411 Bitmap b = (Bitmap)r; 412 return b.image; 413 } 414 catch(Exception e) { 415 try { 416 SubBitmap sb = (SubBitmap)r; 417 return sb.image; 418 } 419 catch(Exception e2) { 420 421 } 422 } 404 if(r.getClass()==Bitmap.class) { 405 Bitmap b = (Bitmap)r; 406 return b.image; 407 } 408 else if(r.getClass()==SubBitmap.class) { 409 SubBitmap sb = (SubBitmap)r; 410 return sb.image; 423 411 } 424 412 else return null; 425 413 } 426 return null;427 414 } 428 415 public java.awt.Font getFont(String id) { … … 433 420 if(r==null) return (new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,12)); 434 421 try { 435 if(r. type.equals("Font")) {422 if(r.getClass()==vlcskineditor.resources.Font.class) { 436 423 vlcskineditor.resources.Font fr = (vlcskineditor.resources.Font)r; 437 424 return fr.f; … … 506 493 DefaultMutableTreeNode bitmaps_node = new DefaultMutableTreeNode("Root: Bitmaps"); 507 494 DefaultMutableTreeNode fonts_node = new DefaultMutableTreeNode("Root: Fonts"); 508 for( int i=0;i<resources.size();i++) {509 if(r esources.get(i).type=="Bitmap") {510 bitmaps_node.add(r esources.get(i).getTreeNode());511 } 512 } 513 for( int i=0;i<resources.size();i++) {514 if(r esources.get(i).type=="Font") {515 DefaultMutableTreeNode node = r esources.get(i).getTreeNode();495 for(Resource r:resources) { 496 if(r.getClass()==Bitmap.class) { 497 bitmaps_node.add(r.getTreeNode()); 498 } 499 } 500 for(Resource r:resources) { 501 if(r.getClass()==vlcskineditor.resources.Font.class) { 502 DefaultMutableTreeNode node = r.getTreeNode(); 516 503 fonts_node.add(node); 517 504 } trunk/src/vlcskineditor/icons/edit-redo.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/edit-undo.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/editor.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/exit.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/help.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/items.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/new.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/open.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/preview.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/resources.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/save.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/sliderbg_btt.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/icons/sliderbg_ltr.png
- Property svn:mime-type changed from application/octet-stream to image/png
trunk/src/vlcskineditor/resources/Bitmap.java
r71 r91 376 376 return null; 377 377 } 378 @Override 379 public void renameForCopy() { 380 super.renameForCopy(); 381 for(SubBitmap sb:SubBitmaps) sb.renameForCopy(); 382 } 378 383 } trunk/src/vlcskineditor/resources/SubBitmap.java
r87 r91 320 320 return top; 321 321 } 322 public Bitmap getParentBitmap() { 323 return parent; 324 } 322 325 } trunk/src/vlcskineditor/resources/SubBitmapEditWindow.java
r90 r91 91 91 public void paint(Graphics g) { 92 92 if(b.image==null) return; 93 if(drawcount>= 40) drawcount = 0;93 if(drawcount>=30) drawcount = 0; 94 94 g.clearRect(0,0,getWidth(),getHeight()); 95 g.drawImage(b.image, 0, 0, p_width*z_fact, p_height*z_fact, frame); 96 //g.drawImage(b.image,0,0,frame); 95 g.drawImage(b.image, 0, 0, p_width*z_fact, p_height*z_fact, frame); 97 96 g.setColor(Color.RED); 98 97 int[] x = new int[4];
