Changeset 94

Show
Ignore:
Timestamp:
02/02/08 17:51:20 (10 months ago)
Author:
altglass
Message:

Slider BG Generator finished (atm only horizontal sliders w/o overlay image option)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vlcskineditor/ProgressWindow.java

    r68 r94  
    4848    pbar.setIndeterminate(true); 
    4949  }   
     50  public void setProgress(int i) { 
     51      pbar.setIndeterminate(false); 
     52      pbar.setMaximum(1000); 
     53      pbar.setMinimum(0); 
     54      pbar.setValue(i); 
     55  } 
    5056  /** Sets the text displayed on the progress bar */ 
    5157  public void setText(String s) { 
  • trunk/src/vlcskineditor/SliderBGGen.java

    r93 r94  
    2525import java.awt.*; 
    2626import java.awt.event.*; 
     27import java.io.File; 
    2728import javax.swing.*; 
     29import javax.swing.border.EtchedBorder; 
    2830import vlcskineditor.items.SliderBackground; 
     31import vlcskineditor.resources.Bitmap; 
    2932 
    3033/** 
     
    7073  JButton bg_btn, e1_btn, md_btn, e2_btn; 
    7174  JFileChooser bg_fc, e1_fc, md_fc, e2_fc; 
     75   
     76  JLabel bg_l, e1_l, md_l, e2_l; 
     77  JPanel bg_p, e1_p, md_p, e2_p; 
     78   
    7279  JButton step2_prev_btn, step2_finish_btn, step2_cancel_btn;   
    7380   
     
    8188  ImageIcon margin_t_i = createIcon("icons/sbg_margin_t.png"); 
    8289  ImageIcon margin_b_i = createIcon("icons/sbg_margin_b.png"); 
     90  ImageIcon bg_h = createIcon("icons/sbg_bg_h.png"); 
     91  ImageIcon bg_v = createIcon("icons/sbg_bg_v.png"); 
     92  ImageIcon left = createIcon("icons/sbg_left.png"); 
     93  ImageIcon right = createIcon("icons/sbg_right.png"); 
     94  ImageIcon top = createIcon("icons/sbg_top.png"); 
     95  ImageIcon bottom = createIcon("icons/sbg_bottom.png"); 
     96  ImageIcon middle_h = createIcon("icons/sbg_middle_h.png"); 
     97  ImageIcon middle_v = createIcon("icons/sbg_middle_v.png"); 
     98  ImageIcon tile = createIcon("icons/sbg_tile.png"); 
     99  ImageIcon stretch = createIcon("icons/sbg_stretch.png"); 
    83100   
    84101  /** 
     
    111128    card_step1.add(header1_l);  
    112129     
    113     JLabel welcome_l = new JLabel("<html><div style=\"width:400px;margin-top:2px\">Welcome to the slider background generator.<br>" + 
     130    JLabel welcome_l = new JLabel("<html><div style=\"width:400px;margin-top:2px\">Welcome to the slider background generator. It will help you to create a neat slider from your images, in just a few steps.<br>" + 
    114131                                  "As a first step, please choose whether the slider is going from left to right or from the bottom to the top and what size the background should have.</div></html>");     
    115132    card_step1.add(welcome_l);     
    116     welcome_l.setBounds(5,25,630,100); 
     133    welcome_l.setBounds(5,30,630,100); 
    117134    ltr_rb = new JRadioButton("");     
    118135    card_step1.add(ltr_rb); 
    119     ltr_rb.setBounds(5,105,20,100); 
     136    ltr_rb.setBounds(5,125,20,60); 
    120137    ltr_rb.setSelected(true); 
    121138    JLabel ltr_l = new JLabel(ltr_icon); 
    122139    ltr_l.setLabelFor(ltr_rb); 
    123140    card_step1.add(ltr_l); 
    124     ltr_l.setBounds(30,105,100,100); 
     141    ltr_l.setBounds(30,125,100,60); 
    125142     
    126143    btt_rb = new JRadioButton(""); 
    127144    card_step1.add(btt_rb); 
    128     btt_rb.setBounds(255,105,20,100); 
     145    btt_rb.setBounds(255,125,20,60); 
    129146    JLabel btt_l = new JLabel(btt_icon); 
    130147    btt_l.setLabelFor(btt_rb); 
     
    132149    btt_l.setBounds(280,105,100,100); 
    133150     
     151    btt_rb.setEnabled(false); 
     152    btt_l.setEnabled(false); 
     153     
    134154    ButtonGroup dir_bg = new ButtonGroup(); 
    135155    dir_bg.add(ltr_rb); 
     156    ltr_rb.addActionListener(this); 
    136157    dir_bg.add(btt_rb); 
     158    btt_rb.addActionListener(this); 
    137159     
    138160    JSeparator horz2_s = new JSeparator(JSeparator.HORIZONTAL); 
     
    140162    horz2_s.setBounds(5,215,525,215);     
    141163     
    142     JLabel width_l = new JLabel("Width:",width_i,JLabel.RIGHT); 
     164    JLabel width_l = new JLabel("Width:",width_i,JLabel.TRAILING); 
     165    width_l.setHorizontalAlignment(JLabel.LEFT); 
    143166    width_tf = new JTextField();     
    144167    width_tf.setDocument(new NumbersOnlyDocument(false)); 
     
    150173    width_tf.setBounds(90,230,50,25);     
    151174     
    152     JLabel height_l = new JLabel("Height:",height_i,JLabel.RIGHT); 
     175    JLabel height_l = new JLabel("Height:",height_i,JLabel.TRAILING); 
     176    height_l.setHorizontalAlignment(JLabel.LEFT); 
    153177    height_tf = new JTextField(); 
    154178    height_tf.setDocument(new NumbersOnlyDocument(false)); 
     
    160184    height_tf.setBounds(90,265,50,25); 
    161185     
    162     JLabel margin_l_l = new JLabel("Left margin:", margin_l_i, JLabel.RIGHT); 
     186    JLabel margin_l_l = new JLabel("Left margin:", margin_l_i, JLabel.TRAILING); 
     187    margin_l_l.setHorizontalAlignment(JLabel.LEFT); 
    163188    margin_l_tf = new JTextField(); 
    164189    margin_l_tf.setDocument(new NumbersOnlyDocument(false)); 
    165190    margin_l_l.setLabelFor(margin_l_tf); 
    166     JLabel margin_r_l = new JLabel("Right margin:", margin_r_i, JLabel.RIGHT); 
     191    JLabel margin_r_l = new JLabel("Right margin:", margin_r_i, JLabel.TRAILING); 
     192    margin_r_l.setHorizontalAlignment(JLabel.LEFT); 
    167193    margin_r_tf = new JTextField(); 
    168194    margin_r_tf.setDocument(new NumbersOnlyDocument(false)); 
    169195    margin_r_l.setLabelFor(margin_r_tf); 
    170     JLabel margin_t_l = new JLabel("Top margin:", margin_t_i, JLabel.RIGHT); 
     196    JLabel margin_t_l = new JLabel("Top margin:", margin_t_i, JLabel.TRAILING); 
     197    margin_t_l.setHorizontalAlignment(JLabel.LEFT); 
    171198    margin_t_tf = new JTextField(); 
    172199    margin_t_tf.setDocument(new NumbersOnlyDocument(false)); 
    173200    margin_t_l.setLabelFor(margin_t_tf); 
    174     JLabel margin_b_l = new JLabel("Bottom margin:", margin_b_i, JLabel.RIGHT); 
     201    JLabel margin_b_l = new JLabel("Bottom margin:", margin_b_i, JLabel.TRAILING); 
     202    margin_b_l.setHorizontalAlignment(JLabel.LEFT); 
    175203    margin_b_tf = new JTextField(); 
    176204    margin_b_tf.setDocument(new NumbersOnlyDocument(false)); 
     
    194222    margin_b_tf.setBounds(445,265,50,25); 
    195223     
     224    JSeparator separator2 = new JSeparator(JSeparator.HORIZONTAL); 
     225    JLabel info_l = new JLabel("<html>In the following step you have to choose the correct image files associated" + 
     226            " to the different parts of your slider.<br>Note that the icons are just examples to illustrate" + 
     227            " what the different parts represent. They are not a preview of the images that will be used in" + 
     228            " the background generation.</html>"); 
     229     
     230    card_step1.add(separator2); 
     231    card_step1.add(info_l); 
     232     
     233    separator2.setBounds(5,300,525,5); 
     234    info_l.setBounds(5,310,525,80); 
     235     
    196236    step1_horz_s = new JSeparator(JSeparator.HORIZONTAL);    
    197237    step1_next_btn = new JButton("Next >"); 
     
    204244    card_step1.add(step1_cancel_btn); 
    205245     
    206     step1_horz_s.setBounds(5,345,525,5);     
    207     step1_next_btn.setBounds(370,350,75,20); 
    208     step1_cancel_btn.setBounds(450,350,75,20);     
     246    step1_horz_s.setBounds(5,395,525,5);     
     247    step1_next_btn.setBounds(370, 400,75,20); 
     248    step1_cancel_btn.setBounds(450,400,75,20);     
    209249     
    210250    card_step1.setSize(540,400);    
     
    217257    card_step2.add(header2_l);  
    218258     
    219     JPanel bg_p = new JPanel(null); 
    220     JLabel bg_l = new JLabel("Image file:"); 
     259   bg_p = new JPanel(null); 
     260    bg_l = new JLabel("Image file:",bg_h,JLabel.TRAILING); 
    221261    bg_tf = new JTextField(""); 
    222262    bg_btn = new JButton("Open..."); 
    223      
     263    bg_btn.addActionListener(this); 
     264    JLabel bg_rs_l = new JLabel("Resize behaviour:"); 
     265    ButtonGroup bg_rs_g = new ButtonGroup(); 
     266    bgt_rb = new JRadioButton("",true); 
     267    JLabel bgt_l = new JLabel("Tile",tile,JLabel.TRAILING); 
     268    bgt_l.setHorizontalAlignment(JLabel.LEFT); 
     269    bg_rs_g.add(bgt_rb); 
     270    bgs_rb = new JRadioButton("",false); 
     271    JLabel bgs_l = new JLabel("Stretch",stretch,JLabel.TRAILING); 
     272    bgs_l.setHorizontalAlignment(JLabel.LEFT); 
     273    bg_rs_g.add(bgs_rb); 
     274    bg_p.add(bg_l); 
     275    bg_p.add(bg_tf); 
     276    bg_p.add(bg_btn);     
     277    bg_p.add(bg_rs_l); 
     278    bg_p.add(bgt_rb); 
     279    bg_p.add(bgt_l); 
     280    bg_p.add(bgs_rb); 
     281    bg_p.add(bgs_l);     
     282    bg_l.setBounds(10,20,100,25); 
     283    bg_tf.setBounds(115,20,300,25); 
     284    bg_btn.setBounds(420,20,100,25); 
     285    bg_rs_l.setBounds(10,60,100,25); 
     286    bgt_rb.setBounds(115,60,25,25); 
     287    bgt_l.setBounds(140,60,100,25); 
     288    bgs_rb.setBounds(220,60,25,25); 
     289    bgs_l.setBounds(250,60,100,25);     
     290    bg_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Background"));     
     291    card_step2.add(bg_p); 
     292    bg_p.setBounds(5,60,530,95);     
     293     
     294    e1_p = new JPanel(null); 
     295    e1_l = new JLabel("Image file:",left,JLabel.TRAILING); 
     296    e1_tf = new JTextField(); 
     297    e1_btn = new JButton("Open..."); 
     298    e1_btn.addActionListener(this); 
     299    e1_p.add(e1_l); 
     300    e1_p.add(e1_tf); 
     301    e1_p.add(e1_btn); 
     302    e1_l.setBounds(10,20,100,25); 
     303    e1_tf.setBounds(115,20,300,25); 
     304    e1_btn.setBounds(420,20,100,25); 
     305    e1_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Left edge"));     
     306    card_step2.add(e1_p); 
     307    e1_p.setBounds(5,160,530,55); 
     308     
     309    md_p = new JPanel(null); 
     310    md_l = new JLabel("Image file:",middle_h,JLabel.TRAILING); 
     311    md_tf = new JTextField(""); 
     312    md_btn = new JButton("Open..."); 
     313    md_btn.addActionListener(this); 
     314    JLabel md_rs_l = new JLabel("Resize behaviour:"); 
     315    ButtonGroup md_rs_g = new ButtonGroup(); 
     316    mdt_rb = new JRadioButton("",true); 
     317    JLabel mdt_l = new JLabel("Tile",tile,JLabel.TRAILING); 
     318    mdt_l.setHorizontalAlignment(JLabel.LEFT); 
     319    md_rs_g.add(mdt_rb); 
     320    mds_rb = new JRadioButton("",false); 
     321    JLabel mds_l = new JLabel("Stretch",stretch,JLabel.TRAILING); 
     322    mds_l.setHorizontalAlignment(JLabel.LEFT); 
     323    md_rs_g.add(mds_rb); 
     324    md_p.add(md_l); 
     325    md_p.add(md_tf); 
     326    md_p.add(md_btn);     
     327    md_p.add(md_rs_l); 
     328    md_p.add(mdt_rb); 
     329    md_p.add(mdt_l); 
     330    md_p.add(mds_rb); 
     331    md_p.add(mds_l);     
     332    md_l.setBounds(10,20,100,25); 
     333    md_tf.setBounds(115,20,300,25); 
     334    md_btn.setBounds(420,20,100,25); 
     335    md_rs_l.setBounds(10,60,100,25); 
     336    mdt_rb.setBounds(115,60,25,25); 
     337    mdt_l.setBounds(140,60,100,25); 
     338    mds_rb.setBounds(220,60,25,25); 
     339    mds_l.setBounds(250,60,100,25);     
     340    md_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Middle part"));     
     341    card_step2.add(md_p); 
     342    md_p.setBounds(5,220,530,95);     
     343     
     344    e2_p = new JPanel(null); 
     345    e2_l = new JLabel("Image file:",right,JLabel.TRAILING); 
     346    e2_tf = new JTextField(); 
     347    e2_btn = new JButton("Open..."); 
     348    e2_btn.addActionListener(this); 
     349    e2_p.add(e2_l); 
     350    e2_p.add(e2_tf); 
     351    e2_p.add(e2_btn); 
     352    e2_l.setBounds(10,20,100,25); 
     353    e2_tf.setBounds(115,20,300,25); 
     354    e2_btn.setBounds(420,20,100,25); 
     355    e2_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Right edge"));     
     356    card_step2.add(e2_p); 
     357    e2_p.setBounds(5,320,530,55); 
    224358     
    225359    JSeparator step2_horz_s = new JSeparator(JSeparator.HORIZONTAL); 
     
    236370    card_step2.add(step2_cancel_btn); 
    237371     
    238     step2_horz_s.setBounds(5,345,525,5);     
    239     step2_prev_btn.setBounds(275,350,90,20); 
    240     step2_finish_btn.setBounds(370,350,75,20); 
    241     step2_cancel_btn.setBounds(450,350,75,20);     
     372    step2_horz_s.setBounds(5,395,525,5);     
     373    step2_prev_btn.setBounds(275,400,90,20); 
     374    step2_finish_btn.setBounds(370,400,75,20); 
     375    step2_cancel_btn.setBounds(450,400,75,20);     
    242376   
    243377    add(card_step2,STEP2);     
    244378     
    245     setSize(540,400); 
     379    setSize(540,450); 
    246380    setResizable(false); 
    247381  } 
    248382  public void actionPerformed(ActionEvent e) { 
    249383    if(e.getActionCommand().equals("Cancel")) { 
    250       System.exit(1); 
     384      setVisible(false); 
     385      dispose(); 
    251386    } 
    252387    else if (e.getSource().equals(step1_next_btn)) { 
     
    257392    } 
    258393    else if (e.getSource().equals(step2_finish_btn)) { 
    259       //Do something 
     394      File f = new File(s.skinfolder+sbg.id+".png"); 
     395      int i = 1; 
     396      while(f.exists()) { 
     397          f = new File(s.skinfolder+sbg.id+"_"+String.valueOf(i)+".png"); 
     398          i++; 
     399      } 
     400      SliderBGBuilder sbgb = new SliderBGBuilder(this); 
     401      if(sbgb.cancontinue) { 
     402          sbgb.build(); 
     403          sbgb.save(f); 
     404          Bitmap b = new Bitmap(s, f); 
     405          s.resources.add(b); 
     406          sbg.image_tf.setText(b.id); 
     407          sbg.nbvert_tf.setText(String.valueOf(sbgb.nbframes)); 
     408          sbg.nbhoriz_tf.setText("1"); 
     409          sbg.padhoriz_tf.setText("0"); 
     410          sbg.padvert_tf.setText("0");           
     411          setVisible(false); 
     412          dispose(); 
     413      }       
     414    } 
     415    else if(e.getSource().equals(ltr_rb)) { 
     416        bg_l.setIcon(bg_h); 
     417        e1_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Left edge")); 
     418        e1_l.setIcon(left); 
     419        md_l.setIcon(middle_h); 
     420        e2_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Right edge")); 
     421        e2_l.setIcon(right); 
     422    } 
     423    else if(e.getSource().equals(btt_rb)) { 
     424        bg_l.setIcon(bg_v); 
     425        e1_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Top edge")); 
     426        e1_l.setIcon(top); 
     427        md_l.setIcon(middle_v); 
     428        e2_p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Bottom edge")); 
     429        e2_l.setIcon(bottom); 
     430    } 
     431    else if(e.getSource().equals(bg_btn)) { 
     432        JFileChooser fc = new JFileChooser(new File(s.skinfolder)); 
     433        int i = fc.showOpenDialog(this); 
     434        if(i==JFileChooser.APPROVE_OPTION && fc.getSelectedFile().exists()) { 
     435            bg_tf.setText(fc.getSelectedFile().getPath()); 
     436        }         
     437    } 
     438    else if(e.getSource().equals(e1_btn)) { 
     439        JFileChooser fc = new JFileChooser(new File(s.skinfolder)); 
     440        int i = fc.showOpenDialog(this); 
     441        if(i==JFileChooser.APPROVE_OPTION && fc.getSelectedFile().exists()) { 
     442            e1_tf.setText(fc.getSelectedFile().getPath()); 
     443        }         
     444    } 
     445    else if(e.getSource().equals(md_btn)) { 
     446        JFileChooser fc = new JFileChooser(new File(s.skinfolder)); 
     447        int i = fc.showOpenDialog(this); 
     448        if(i==JFileChooser.APPROVE_OPTION && fc.getSelectedFile().exists()) { 
     449            md_tf.setText(fc.getSelectedFile().getPath()); 
     450        }         
     451    } 
     452    else if(e.getSource().equals(e2_btn)) { 
     453        JFileChooser fc = new JFileChooser(new File(s.skinfolder)); 
     454        int i = fc.showOpenDialog(this); 
     455        if(i==JFileChooser.APPROVE_OPTION && fc.getSelectedFile().exists()) { 
     456            e2_tf.setText(fc.getSelectedFile().getPath()); 
     457        }         
    260458    } 
    261459  } 
     
    271469        //img = ImageIO.read(file); 
    272470        return new ImageIcon(img);   
    273       } catch (Exception e) { 
     471      } catch (Exception e) {         
    274472        System.out.println(e); 
    275473        return null; 
  • trunk/src/vlcskineditor/icons/sbg_height.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/sbg_margin_b.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/sbg_margin_l.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/sbg_margin_r.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/sbg_margin_t.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/sbg_width.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/windows.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/items/SliderBackground.java

    r92 r94  
    5050   
    5151  JFrame frame; 
    52   JTextField id_tf, image_tf, nbhoriz_tf, nbvert_tf, padhoriz_tf, padvert_tf; 
     52  public JTextField id_tf, image_tf, nbhoriz_tf, nbvert_tf, padhoriz_tf, padvert_tf; 
    5353  JButton gen_btn, ok_btn, cancel_btn, help_btn; 
    5454  BufferedImage bi = null; 
     
    8686      padhoriz = Integer.parseInt(padhoriz_tf.getText()); 
    8787      padvert = Integer.parseInt(padvert_tf.getText()); 
    88       frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); 
     88      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
    8989      created = true; 
    9090       
     
    219219      } 
    220220      update(); 
     221      s.updateItems(); 
     222      s.expandItem(id); 
    221223      frame.setVisible(false); 
    222224      frame.dispose(); 
     
    239241    } 
    240242    else if(e.getSource().equals(gen_btn)) { 
    241       //TODO 
     243      SliderBGGen sbgg = new SliderBGGen(this, s); 
     244      sbgg.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
     245      sbgg.setVisible(true);       
    242246    } 
    243247    else if(e.getSource().equals(cancel_btn)) { 
     
    246250      frame = null; 
    247251      if(!created) sl.removeBG();       
    248     } 
    249   } 
     252    }     
     253  }   
    250254  public String returnCode() { 
    251255    String code = "<SliderBackground";