1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.viewer.videoinfo;
21
22 import java.awt.GridBagLayout;
23 import java.io.File;
24
25 import javax.swing.JLabel;
26 import javax.swing.JPanel;
27
28 import org.xnap.XNap;
29 import org.xnap.gui.StatusBar;
30 import org.xnap.gui.util.GUIHelper;
31 import org.xnap.gui.util.GridBagHelper;
32 import org.xnap.util.Formatter;
33
34 /***
35 * VideoInfoPanel displays the length and resolution of avi and mpg files.
36 */
37 public class VideoInfoPanel extends JPanel
38 {
39
40
41
42
43
44 private JLabel jlInfo = new JLabel();
45
46
47
48 public VideoInfoPanel()
49 {
50 super(new GridBagLayout());
51 jlInfo.setBorder(GUIHelper.createDefaultBorder(XNap.tr("Video Info")));
52 GridBagHelper.add(this, jlInfo);
53 GridBagHelper.addVerticalSpacer(this);
54 }
55
56
57
58 public void display(File file)
59 {
60 jlInfo.setText("");
61
62 VideoFile vf = new VideoFile(file);
63
64 if (vf.parse()) {
65 StringBuffer sb = new StringBuffer();
66 sb.append("<html><table>");
67 sb.append(GUIHelper.tableRow(XNap.tr("Filename"),
68 file.getName()));
69 sb.append
70 (GUIHelper.tableRow(XNap.tr("Length"),
71 Formatter.formatLength(vf.getLength())));
72 sb.append(GUIHelper.tableRow(XNap.tr("Height"),
73 vf.getHeight() + ""));
74
75 sb.append(GUIHelper.tableRow(XNap.tr("Width"),
76 vf.getWidth() + ""));
77 sb.append("</table></html>");
78 jlInfo.setText(sb.toString());
79 }
80 else {
81 StatusBar.setText(XNap.tr("Not a valid video file"));
82 }
83 }
84 }