📄 jmappscfg.java
字号:
} else { vectorValues = new Vector (); hashProperties.put ( KEY_JMSTUDIO_FRAME_POS, vectorValues ); } nCount = vectorValues.size (); if ( nFrameIndex < nCount ) vectorValues.setElementAt ( pointValue, nFrameIndex ); else vectorValues.addElement ( pointValue ); } public boolean getAutoPlay () { Object objValue; boolean boolValue = true; objValue = hashProperties.get ( KEY_AUTO_PLAY ); if ( objValue != null && objValue instanceof Boolean ) boolValue = ((Boolean)objValue).booleanValue (); return ( boolValue ); } public void setAutoPlay ( boolean boolValue ) { Boolean objValue; objValue = new Boolean ( boolValue ); hashProperties.put ( KEY_AUTO_PLAY, objValue ); } public boolean getAutoLoop () { Object objValue; boolean boolValue = true; objValue = hashProperties.get ( KEY_AUTO_LOOP ); if ( objValue != null && objValue instanceof Boolean ) boolValue = ((Boolean)objValue).booleanValue (); return ( boolValue ); } public void setAutoLoop ( boolean boolValue ) { Boolean objValue; objValue = new Boolean ( boolValue ); hashProperties.put ( KEY_AUTO_LOOP, objValue ); } public boolean getKeepAspectRatio () { Object objValue; boolean boolValue = false; objValue = hashProperties.get ( KEY_KEEP_ASPECT ); if ( objValue != null && objValue instanceof Boolean ) boolValue = ((Boolean)objValue).booleanValue (); return ( boolValue ); } public void setKeepAspectRatio ( boolean boolValue ) { Boolean objValue; objValue = new Boolean ( boolValue ); hashProperties.put ( KEY_KEEP_ASPECT, objValue ); } protected void init () throws Exception { readFile (); } private void readFile () { FileInputStream streamFile = null; ObjectInputStream streamObject = null; String strSignatue; String strVersion; Object objValue; String strPath; try { strPath = System.getProperty ( "user.home" ); if ( strPath != null ) nameFileCfg = strPath + File.separator + nameFileCfg; streamFile = new FileInputStream ( nameFileCfg ); } catch ( Exception exception ) { // so we will start from scratch return; } try { streamObject = new ObjectInputStream ( streamFile ); strSignatue = streamObject.readUTF (); strVersion = streamObject.readUTF (); objValue = streamObject.readObject (); if ( objValue.toString().equals(signatureHashtable) ) hashProperties = readHashtable ( streamObject ); } catch ( Exception exception ) { MessageDialog.createErrorDialog ( null, JMFI18N.getResource("jmstudio.error.cfgfile.read"), exception ); } try { if ( streamObject != null ) streamObject.close (); if ( streamFile != null ) streamFile.close (); } catch ( Exception exception ) { MessageDialog.createErrorDialog ( null, JMFI18N.getResource("jmstudio.error.cfgfile.close"), exception ); } } private Hashtable readHashtable ( ObjectInputStream streamObject ) throws Exception { int i; int nSize; String strKey; Object objValue; Hashtable hashRead; hashRead = new Hashtable (); nSize = streamObject.readInt (); for ( i = 0; i < nSize; i++ ) { strKey = streamObject.readUTF (); objValue = streamObject.readObject (); if ( objValue != null && objValue.toString().equals(signatureHashtable) ) { objValue = readHashtable ( streamObject ); } hashRead.put ( strKey, objValue ); } return ( hashRead ); } private void saveFile () { FileOutputStream streamFile = null; ObjectOutputStream streamObject = null; String strVersion; int nSize; Enumeration enumKeys; String strKey; Object objValue; try { streamFile = new FileOutputStream ( nameFileCfg ); streamObject = new ObjectOutputStream ( streamFile ); } catch ( Exception exception ) {// MessageDialog.createErrorDialog ( null,// JMFI18N.getResource("jmstudio.error.cfgfile.create"),// exception ); System.out.println ( JMFI18N.getResource("jmstudio.error.cfgfile.create") + " " + exception.getMessage() ); return; } try { streamObject.writeUTF ( signatureFileCfg ); strVersion = Manager.getVersion (); streamObject.writeUTF ( strVersion ); writeHashtable ( streamObject, hashProperties ); } catch ( Exception exception ) { MessageDialog.createErrorDialog ( null, JMFI18N.getResource("jmstudio.error.cfgfile.write"), exception ); } try { if ( streamObject != null ) streamObject.close (); if ( streamFile != null ) streamFile.close (); } catch ( Exception exception ) { MessageDialog.createErrorDialog ( null, JMFI18N.getResource("jmstudio.error.cfgfile.close"), exception ); } } private void writeHashtable ( ObjectOutputStream streamObject, Hashtable hashWrite ) throws Exception { int nSize; Enumeration enumKeys; String strKey; Object objValue; streamObject.writeObject ( signatureHashtable ); nSize = hashWrite.size (); streamObject.writeInt ( nSize ); enumKeys = hashWrite.keys (); while ( enumKeys.hasMoreElements() ) { strKey = (String) enumKeys.nextElement(); objValue = hashWrite.get ( strKey );//System.out.println ( "AAAAA Writing object: " + objValue.getClass().getName() ); if ( objValue instanceof Hashtable ) { streamObject.writeUTF ( strKey ); writeHashtable ( streamObject, (Hashtable)objValue ); } else if ( !(objValue instanceof Serializable) ) {/*CHANGE*/ System.out.println ( "Error. Not Serializable object" ); } else { streamObject.writeUTF ( strKey ); streamObject.writeObject ( objValue ); } streamObject.flush (); } } public RtpData createRtpDataObject () { RtpData dataRtp; dataRtp = new RtpData (); return ( dataRtp ); } public class RtpData implements Serializable { public String strAddress0 = "0"; public String strAddress1 = "0"; public String strAddress2 = "0"; public String strAddress3 = "0"; public String strPort = "0"; public String strTtl = "1"; private void writeObject ( ObjectOutputStream streamOut ) throws IOException { streamOut.writeUTF ( strAddress0 ); streamOut.writeUTF ( strAddress1 ); streamOut.writeUTF ( strAddress2 ); streamOut.writeUTF ( strAddress3 ); streamOut.writeUTF ( strPort ); streamOut.writeUTF ( strTtl ); } private void readObject ( ObjectInputStream streamIn ) throws IOException, ClassNotFoundException { strAddress0 = streamIn.readUTF (); strAddress1 = streamIn.readUTF (); strAddress2 = streamIn.readUTF (); strAddress3 = streamIn.readUTF (); strPort = streamIn.readUTF (); strTtl = streamIn.readUTF (); } public String toString () { return ( "RtpData address " + strAddress0 + "." + strAddress1 + "." + strAddress2 + "." + strAddress3 + "; port " + strPort + "; TTL " + strTtl ); } } public CaptureDeviceData createCaptureDeviceDataObject () { CaptureDeviceData dataCaptureDevice; dataCaptureDevice = new CaptureDeviceData (); return ( dataCaptureDevice ); } public class CaptureDeviceData implements Serializable { public boolean boolUse = false; public String strDeviceName = null; public Format format = null; private void writeObject ( ObjectOutputStream streamOut ) throws IOException { streamOut.writeBoolean ( boolUse ); if ( strDeviceName == null ) { streamOut.writeBoolean ( false ); } else { streamOut.writeBoolean ( true ); streamOut.writeUTF ( strDeviceName ); } if ( format == null ) { streamOut.writeBoolean ( false ); } else { streamOut.writeBoolean ( true ); streamOut.writeObject ( format ); } } private void readObject ( ObjectInputStream streamIn ) throws IOException, ClassNotFoundException { Object objValue; boolean boolRead; boolUse = streamIn.readBoolean (); boolRead = streamIn.readBoolean (); if ( boolRead == true ) strDeviceName = streamIn.readUTF (); else strDeviceName = null; boolRead = streamIn.readBoolean (); if ( boolRead == true ) objValue = streamIn.readObject (); else objValue = null; if ( objValue != null && objValue instanceof Format ) format = (Format) objValue; else format = null; } } public TrackData createTrackDataObject () { TrackData dataTrack; dataTrack = new TrackData (); return ( dataTrack ); } public class TrackData implements Serializable { public boolean boolEnable = false; public Format format = null; private void writeObject ( ObjectOutputStream streamOut ) throws IOException { streamOut.writeBoolean ( boolEnable ); if ( format == null ) { streamOut.writeBoolean ( false ); } else { streamOut.writeBoolean ( true ); streamOut.writeObject ( format ); } } private void readObject ( ObjectInputStream streamIn ) throws IOException, ClassNotFoundException { Object objValue; boolean boolRead; boolEnable = streamIn.readBoolean (); boolRead = streamIn.readBoolean (); if ( boolRead == true ) objValue = streamIn.readObject (); else objValue = null; if ( objValue != null && objValue instanceof Format ) format = (Format) objValue; else format = null; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -