📄 x.java
字号:
/*
* @(#)X.java - main incl. GUI
*
* Copyright (c) 2001-2005 by dvb.matt, All rights reserved.
*
* This file is part of X, a free Java based demux utility.
* X is intended for educational purposes only, as a non-commercial test project.
* It may not be used otherwise. Most parts are only experimental.
*
*
* This program is free software; you can redistribute it free of charge
* and/or modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* X is completely designed as a test, therefore it mostly implements its
* own code instead of a derivation of an ISO reference source or
* any other code. Considerable effort has been expended to ensure
* an useful implementation, even in cases where the standards
* are ambiguous or misleading.
* Do not expect any useful output, even if that may be possible.
*
* For a program compliant to the international standards ISO 11172
* and ISO 13818 it is inevitable to use methods covered by patents
* in various countries. The authors of this program disclaim any
* liability for patent infringement caused by using, modifying or
* redistributing this program.
*
*/
package net.sourceforge.dvb.projectx.common;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.PushbackInputStream;
import java.io.RandomAccessFile;
import java.io.StringWriter;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JProgressBar;
import javax.swing.JRadioButton;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JViewport;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.net.URL;
import net.sourceforge.dvb.projectx.audio.Audio;
import net.sourceforge.dvb.projectx.audio.AudioFrameConstants;
import net.sourceforge.dvb.projectx.audio.CRC;
import net.sourceforge.dvb.projectx.audio.MPAC;
import net.sourceforge.dvb.projectx.audio.MPAD;
import net.sourceforge.dvb.projectx.audio.RIFFHeader;
import net.sourceforge.dvb.projectx.gui.AboutBox;
import net.sourceforge.dvb.projectx.gui.BRMonitor;
import net.sourceforge.dvb.projectx.gui.HexViewer;
import net.sourceforge.dvb.projectx.gui.Html;
import net.sourceforge.dvb.projectx.gui.LogArea;
import net.sourceforge.dvb.projectx.gui.StartUp;
import net.sourceforge.dvb.projectx.gui.UISwitchListener;
import net.sourceforge.dvb.projectx.gui.Dialogs;
import net.sourceforge.dvb.projectx.io.IDDBufferedOutputStream;
import net.sourceforge.dvb.projectx.io.StandardBuffer;
import net.sourceforge.dvb.projectx.subtitle.BMP;
import net.sourceforge.dvb.projectx.subtitle.Bitmap;
import net.sourceforge.dvb.projectx.subtitle.SubPicture;
import net.sourceforge.dvb.projectx.subtitle.Teletext;
import net.sourceforge.dvb.projectx.subtitle.TeletextPageMatrix;
import net.sourceforge.dvb.projectx.thirdparty.Chapters;
import net.sourceforge.dvb.projectx.thirdparty.D2V;
import net.sourceforge.dvb.projectx.thirdparty.Ifo;
import net.sourceforge.dvb.projectx.thirdparty.TS;
import net.sourceforge.dvb.projectx.video.MPVD;
import net.sourceforge.dvb.projectx.video.PatchPanel;
import net.sourceforge.dvb.projectx.video.Preview;
import net.sourceforge.dvb.projectx.video.PreviewObject;
import net.sourceforge.dvb.projectx.video.Video;
import net.sourceforge.dvb.projectx.parser.VBI;
import net.sourceforge.dvb.projectx.parser.PidBuffer;
import net.sourceforge.dvb.projectx.parser.CommonParsing;
import net.sourceforge.dvb.projectx.parser.Scan;
import net.sourceforge.dvb.projectx.xinput.DirType;
import net.sourceforge.dvb.projectx.xinput.XInputDirectory;
import net.sourceforge.dvb.projectx.xinput.XInputFile;
import net.sourceforge.dvb.projectx.xinput.ftp.FtpChooser;
import net.sourceforge.dvb.projectx.xinput.topfield_raw.RawInterface;
import net.sourceforge.dvb.projectx.gui.X_JFileChooser;
import net.sourceforge.dvb.projectx.gui.ColumnLayout;
import net.sourceforge.dvb.projectx.io.RawFile;
public class X extends JPanel
{
/* main version index */
static String version_name = "ProjectX 0.82.1";
static String version_date = "31.03.2005";
static String standard_ini = "X.ini";
public static boolean CLI_mode = false;
static int loadSizeForward = 2560000;
static BRMonitor brm;
public static SubPicture subpicture = new SubPicture();
MPAC MPAConverter = new MPAC();
MPAD MPADecoder = new MPAD();
static Audio audio = new Audio();
static D2V d2v = new D2V();
static TS tf = new TS();
static String inifile = "";
static String inidir = System.getProperty("user.dir");
static String filesep = System.getProperty("file.separator");
static String frametitle = "";
static java.text.DateFormat base_time = new java.text.SimpleDateFormat("HH:mm:ss.SSS");
PrintStream logging;
static String loggin="", workouts ="", loggin2="";
static boolean comchange=false, outchange=false, singleraw=false, newvideo=true, running=false, qinfo=false, qbreak=false, qpause=false;
static String outalias = "";
static String newOutName = "";
static ArrayList newOutNameList = new ArrayList();
private static long process_time = 0;
public static long[] options = new long[58];
static byte[] headerrescue= new byte[1];
static int[] clv = new int[10];
static long CP[] = new long[2];
static int bs=8192000;
static Object[] inputfiles = new Object[0], collectionlist = new Object[0], collectionwork = new Object[0], lastlist = new Object[0];
static ArrayList[] collfiles = new ArrayList[0];
static ArrayList collout = new ArrayList(), tempfiles = new ArrayList();
static ArrayList workinglist = new ArrayList(), combvideo = new ArrayList();
static ArrayList InfoAtEnd = new ArrayList(), cell = new ArrayList();
static ArrayList cutlist = new ArrayList(), ctemp = new ArrayList(), speciallist = new ArrayList();
static ArrayList TSPidlist = new ArrayList(), PVAPidlist = new ArrayList();
static ArrayList TSdemuxlist = new ArrayList(), PVAdemuxlist = new ArrayList(), VDRdemuxlist = new ArrayList(), PESdemuxlist = new ArrayList();
static JFrame frame = new JFrame();
static int[] framelocation = { 200, 100, 714, 460};
static String[] workfiles = {""}, VBASIC = new String[4];
static String messagelog="";
static JButton doitButton, breakButton, scanButton, pauseButton, extract, exeButton, picButton;
public static JRadioButton[] RButton = new JRadioButton[25];
public static JComboBox[] comBox = new JComboBox[39];
public static JCheckBox[] cBox = new JCheckBox[82];
/**
* radio buttons for look and feels in general menu
*/
private JRadioButtonMenuItem lf_item[] = null;
public static JList list1, list3, list4;
static X_JFileChooser chooser;
static JLabel msoff, audiostatusLabel, splitLabel, cutnum, ttxheaderLabel, ttxvpsLabel, outSize;
static JProgressBar progress;
public static JTextField outfield;
static JTextField[] d2vfield = new JTextField[10], exefield = new JTextField[10];
JTextField ftpcommand = null;
static boolean bool=false, PureVideo=false;
static byte[] dumpfill = new byte[16];
static int ERRORCODE=0;
static int currentcoll=0;
static int origframes=0, cutcount=0, FileNumber=0;
static int activecoll=-1, NoOfAudio=0, NoOfPictures=0, NoOfTTX=0, MPGVideotype=0;
static long CUT_BYTEPOSITION=0;
private static long firstVideoPTS;
private COLLECTION dialog = null;
private PatchPanel vpatch = null;
EXECUTE executePane = null;
Scan scan = null;
TabListener mytabListener = new TabListener();
FileListener my0Listener = new FileListener();
GoListener my2Listener = new GoListener();
DNDListener dnd = new DNDListener();
MenuListener menulistener = new MenuListener();
static AudioFrameConstants afc = new AudioFrameConstants();
static DropTarget dropTarget_1, dropTarget_2, dropTarget_3, dropTarget_4;
public static LogArea TextArea, FileInfoTextArea;
static JViewport viewport, viewport_2;
static JTabbedPane logtab;
static JButton add_files;
JPopupMenu popup;
JMenuBar menuBar;
JFrame autoload;
TeletextPageMatrix tpm = null;
static Chapters chapters = null;
long fakedPTS = -1;
static double videoframerate = 3600.0;
static double videotimecount = 0.0;
/**
* Constructor of X.
*/
public X()
{}
void buildGUI()
{
// don't re-use ATM!
RButton[0] = new JRadioButton();
RButton[1] = new JRadioButton();
RButton[7] = new JRadioButton();
RButton[8] = new JRadioButton();
RButton[11] = new JRadioButton();
RButton[12] = new JRadioButton();
RButton[13] = new JRadioButton();
chooser = new X_JFileChooser(); //DM12122003 081.6 int05
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
buildMenus(); //DM20032004 081.6 int18 add
buildPopupMenu(); //DM26032004 081.6 int18 add
buildAutoloadPanel(); //DM26032004 081.6 int18 add
JPanel files = buildFilePanel();
add(files);
JPanel main = buildMainPanel();
add(main, BorderLayout.CENTER);
JPanel status = buildStatusPanel();
add(status, BorderLayout.SOUTH);
add(Box.createRigidArea(new Dimension(1,5)));
base_time.setTimeZone(java.util.TimeZone.getTimeZone("GMT+0:00"));
java.util.Arrays.fill(dumpfill,(byte)0xFF);
// now we can also build the other GUI elements
tpm = new TeletextPageMatrix();
vpatch = new PatchPanel(frame);
dialog = new COLLECTION();
executePane = new EXECUTE();
scan = new Scan();
chapters = new Chapters();
/**
* static class for little outsourced dialogues
*/
new Dialogs(frame);
outalias = Resource.getString("working.output.std");
brm.surf.repaint();
}
//DM20032004 081.6 int18 moved
protected void buildPopupMenu()
{
popup = new JPopupMenu(Resource.getString("popup.what"));
JMenuItem menuitem_1 = popup.add(Resource.getString("popup.cutspecials"));
menuitem_1.setActionCommand("openCut");
popup.addSeparator();
JMenuItem menuitem_8 = popup.add(Resource.getString("popup.url"));
menuitem_8.setActionCommand("url");
JMenuItem menuitem_2 = popup.add(Resource.getString("popup.add"));
menuitem_2.setActionCommand("add");
JMenuItem menuitem_3 = popup.add(Resource.getString("popup.remove"));
menuitem_3.setActionCommand("remove");
JMenuItem menuitem_9 = popup.add(Resource.getString("popup.newOutName"));
menuitem_9.setActionCommand("newOutName");
popup.addSeparator();
JMenuItem menuitem_4 = popup.add(Resource.getString("popup.rename"));
menuitem_4.setActionCommand("rename");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -