public void changeLAF(int iLAFIndex) { try { // Change LAF if (iLAFIndex >= marrLaf.length) iLAFIndex = marrLaf.length - 1; UIManager.setLookAndFeel( (LookAndFeel) Class.forName(marrLaf[iLAFIndex].getClassName()).newInstance()); // Update UI ((JMenuItem) mvtLAFItem.elementAt(iLAFIndex)).setSelected(true); SwingUtilities.updateComponentTreeUI(this); SwingUtilities.updateComponentTreeUI(mnuMain); WindowManager.updateLookAndField(); // Store config try { Hashtable prt = Global.loadHashtable(Global.FILE_CONFIG); prt.put("LAF", String.valueOf(iLAFIndex)); Global.storeHashtable(prt, Global.FILE_CONFIG); } catch (Exception e) { } } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } }
public void removeUser(String strChannel) { Vector vtData = tblUser.getFilteredData(); for (int iIndex = 0; iIndex < vtData.size(); iIndex++) { Vector vtRow = (Vector) vtData.elementAt(iIndex); if (vtRow.elementAt(0).equals(strChannel)) tblUser.deleteRow(iIndex); } }
private void updateTabBar(Vector vtThread) { pnlThread.removeAll(); for (int iThreadIndex = 0; iThreadIndex < vtThread.size(); iThreadIndex++) { try { Vector vtThreadInfo = (Vector) vtThread.elementAt(iThreadIndex); PanelThreadMonitor mntTemp = new PanelThreadMonitor(channel); String strThreadID = (String) vtThreadInfo.elementAt(0); String strThreadName = (String) vtThreadInfo.elementAt(1); int iThreadStatus = Integer.parseInt((String) vtThreadInfo.elementAt(2)); mntTemp.setThreadID(strThreadID); mntTemp.setThreadName(strThreadName); mntTemp.setThreadStatus(iThreadStatus); showResult(mntTemp.txtMonitor, (String) vtThreadInfo.elementAt(3)); mntTemp.addPropertyChangeListener(this); pnlThread.add(strThreadName, mntTemp); mntTemp.updateStatus(); } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } } Skin.applySkin(this); }
public Object clone() { FigForkState figClone = (FigForkState) super.clone(); Vector v = figClone.getFigs(); figClone._bigPort = (FigRect) v.elementAt(0); figClone._head = (FigRect) v.elementAt(1); return figClone; }
public Object clone() { FigShallowHistoryState figClone = (FigShallowHistoryState) super.clone(); Vector v = figClone.getFigs(); figClone._bigPort = (FigCircle) v.elementAt(0); figClone._head = (FigCircle) v.elementAt(1); figClone._name = (FigText) v.elementAt(2); return figClone; }
public Object clone() { FigUseCase figClone = (FigUseCase) super.clone(); Vector v = figClone.getFigs(); figClone._bigPort = (FigCircle) v.elementAt(0); figClone._cover = (FigCircle) v.elementAt(1); figClone._name = (FigText) v.elementAt(2); return figClone; }
public Object clone() { FigComponentInstance figClone = (FigComponentInstance) super.clone(); Vector v = figClone.getFigs(); figClone._bigPort = (FigRect) v.elementAt(0); figClone._cover = (FigRect) v.elementAt(1); figClone._stereo = (FigText) v.elementAt(2); figClone._name = (FigText) v.elementAt(3); figClone._upperRect = (FigRect) v.elementAt(4); figClone._lowerRect = (FigRect) v.elementAt(5); return figClone; }
/** * Get the specified bookmark. * * @param item the row number of the bookmark to retrieve. * @return the specified bookmark. */ public Bookmark getBookmark(final int item) { final Vector activeVector = getActiveVector(); synchronized (activeVector) { return (Bookmark) ((item < activeVector.size()) ? activeVector.elementAt(item) : null); } }
public void changeDictionary(String strLanguage) { // Change dictionary MonitorDictionary.setCurrentLanguage(strLanguage); DefaultDictionary.setCurrentLanguage(strLanguage); ErrorDictionary.setCurrentLanguage(strLanguage); // Update UI updateLanguage(); WindowManager.updateLanguage(); int iIndex = mvtLanguage.indexOf(strLanguage); if (iIndex >= 0) { JRadioButtonMenuItem mnu = (JRadioButtonMenuItem) mvtLanguageItem.elementAt(iIndex); mnu.setSelected(true); } // Store config Hashtable prt = null; try { prt = Global.loadHashtable(Global.FILE_CONFIG); } catch (Exception e) { prt = new Hashtable(); } prt.put("Language", strLanguage); try { Global.storeHashtable(prt, Global.FILE_CONFIG); } catch (Exception e) { } }
// ------------------------------------------- public static String toSpaceSeparatedString(Vector v) { StringBuffer sb = new StringBuffer(30); for (int i = 0; i < v.size(); i++) { Object o = v.elementAt(i); sb.append(" " + o); // NOI18N } return new String(sb); }
public Vector rowObjectsFor(Object t) { if (!(t instanceof UMLDeploymentDiagram)) return new Vector(); UMLDeploymentDiagram d = (UMLDeploymentDiagram) t; Vector edges = d.getEdges(); Vector res = new Vector(); int size = edges.size(); for (int i = 0; i < size; i++) { Object edge = edges.elementAt(i); if (edge instanceof MDependencyImpl) res.addElement(edge); } return res; }
public void setNode(Vector figures) { int size = figures.size(); if (figures != null && (size > 0)) { for (int i = 0; i < size; i++) { Object o = figures.elementAt(i); if (o instanceof FigComponentInstance) { FigComponentInstance figcomp = (FigComponentInstance) o; figcomp.setEnclosingFig(this); } } } }
private static void appendHTML(JEditorPane editor, String html) { try { html = StringUtil.replaceAll(html, "\t", " "); html = StringUtil.replaceAll(html, "\r\n", "\n"); html = StringUtil.replaceAll(html, "\r", ""); Vector vt = StringUtil.toStringVector(html, "\n"); HTMLEditorKit kit = (HTMLEditorKit) editor.getEditorKit(); HTMLDocument doc = (HTMLDocument) editor.getDocument(); for (int iIndex = 0; iIndex < vt.size(); iIndex++) kit.insertHTML(doc, doc.getLength(), (String) vt.elementAt(iIndex), 0, 0, null); } catch (Exception e) { e.printStackTrace(); } }
/** * Called to check any bookmarks linked to the specified page number. * * @param pageno specifies page number. */ public void setCheckedPage(final int pageno) { final Vector activeVector = getActiveVector(); synchronized (activeVector) { final Vector pagenoVector = getPagenoVector(); if (pageno < pagenoVector.size()) { final Object bookmark = pagenoVector.elementAt(pageno); if (bookmark != null) { setCheckedBookmark((Bookmark) bookmark, activeVector); } } } }
public Object clone() { FigActor figClone = (FigActor) super.clone(); Vector v = figClone.getFigs(); figClone._bigPort = (FigCircle) v.elementAt(0); figClone._head = (FigCircle) v.elementAt(1); figClone._body = (FigLine) v.elementAt(2); figClone._arms = (FigLine) v.elementAt(3); figClone._leftLeg = (FigLine) v.elementAt(4); figClone._rightLeg = (FigLine) v.elementAt(5); figClone._name = (FigText) v.elementAt(6); return figClone; }
/** * Set the checked value of the specified bookmark. * * @param bookmark to check. * @param activeVector of active bookmarks. * @return the row number of the bookmark. */ protected int setCheckedBookmark(final Bookmark bookmark, final Vector activeVector) { final Bookmark parent = (Bookmark) (getParentMap().get(bookmark)); int item = 0; if (parent != null) { item = setCheckedBookmark(parent, activeVector); } while (item < activeVector.size()) { final Bookmark current = (Bookmark) activeVector.elementAt(item++); if (current == bookmark) { setCheckedItem(item - 1, true, activeVector); break; } } return item; }
/** * This method is called when the focused component (and none of its ancestors) want the key * event. This will look up the keystroke to see if any chidren (or subchildren) of the specified * container want a crack at the event. If one of them wants it, then it will "DO-THE-RIGHT-THING" */ public boolean fireKeyboardAction(KeyEvent e, boolean pressed, Container topAncestor) { if (e.isConsumed()) { System.out.println("Acquired pre-used event!"); Thread.dumpStack(); } // There may be two keystrokes associated with a low-level key event; // in this case a keystroke made of an extended key code has a priority. KeyStroke ks; KeyStroke ksE = null; if (e.getID() == KeyEvent.KEY_TYPED) { ks = KeyStroke.getKeyStroke(e.getKeyChar()); } else { if (e.getKeyCode() != e.getExtendedKeyCode()) { ksE = KeyStroke.getKeyStroke(e.getExtendedKeyCode(), e.getModifiers(), !pressed); } ks = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), !pressed); } Hashtable keyMap = containerMap.get(topAncestor); if (keyMap != null) { // this container isn't registered, so bail Object tmp = null; // extended code has priority if (ksE != null) { tmp = keyMap.get(ksE); if (tmp != null) { ks = ksE; } } if (tmp == null) { tmp = keyMap.get(ks); } if (tmp == null) { // don't do anything } else if (tmp instanceof JComponent) { JComponent c = (JComponent) tmp; if (c.isShowing() && c.isEnabled()) { // only give it out if enabled and visible fireBinding(c, ks, e, pressed); } } else if (tmp instanceof Vector) { // more than one comp registered for this Vector v = (Vector) tmp; // There is no well defined order for WHEN_IN_FOCUSED_WINDOW // bindings, but we give precedence to those bindings just // added. This is done so that JMenus WHEN_IN_FOCUSED_WINDOW // bindings are accessed before those of the JRootPane (they // both have a WHEN_IN_FOCUSED_WINDOW binding for enter). for (int counter = v.size() - 1; counter >= 0; counter--) { JComponent c = (JComponent) v.elementAt(counter); // System.out.println("Trying collision: " + c + " vector = "+ v.size()); if (c.isShowing() && c.isEnabled()) { // don't want to give these out fireBinding(c, ks, e, pressed); if (e.isConsumed()) return true; } } } else { System.out.println("Unexpected condition in fireKeyboardAction " + tmp); // This means that tmp wasn't null, a JComponent, or a Vector. What is it? Thread.dumpStack(); } } if (e.isConsumed()) { return true; } // if no one else handled it, then give the menus a crack // The're handled differently. The key is to let any JMenuBars // process the event if (keyMap != null) { Vector v = (Vector) keyMap.get(JMenuBar.class); if (v != null) { Enumeration iter = v.elements(); while (iter.hasMoreElements()) { JMenuBar mb = (JMenuBar) iter.nextElement(); if (mb.isShowing() && mb.isEnabled()) { // don't want to give these out boolean extended = (ksE != null) && !ksE.equals(ks); if (extended) { fireBinding(mb, ksE, e, pressed); } if (!extended || !e.isConsumed()) { fireBinding(mb, ks, e, pressed); } if (e.isConsumed()) { return true; } } } } } return e.isConsumed(); }
/** * Parse the section file and fill in the Dbase. * * @return Success code */ public void parse() throws Exception { JOAParameter tempProperties[] = new JOAParameter[100]; FileInputStream in = null; DataInputStream inData = null; short inShort = 0; long bytesRead = 0; long bytesInFile = mFile.length(); short[] sarray = new short[1]; int mTotalStns = 0; EPSProgressDialog mProgress = new EPSProgressDialog(new Frame(), mProgressStr, Color.blue); mProgress.setVisible(true); // Get an epic key database specific to JOA EPIC_Key_DB mEpicKeyDB = new EPIC_Key_DB("joa_epic.key"); // Get an epic key database specific to JOA EPIC_Key_DB mOrigEpicKeyDB = new EPIC_Key_DB("epic.key"); // create a vector for temporary storage of the dbases Vector dBases = new Vector(100); try { in = new FileInputStream(mFile); BufferedInputStream bis = new BufferedInputStream(in, 1000000); inData = new DataInputStream(bis); // read version short vers = inData.readShort(); bytesRead += 2; if (vers < 2) { FileImportException fiex = new FileImportException(); String errStr = "Invalid version for a JOA binary file"; fiex.setErrorType(errStr); throw fiex; } // read number of bytes in file description string inShort = inData.readShort(); bytesRead += 2; // read the file description String byte buf[] = new byte[inShort]; inData.read(buf, 0, inShort); String fileDescrip = new String(buf); bytesRead += inShort; // create a new open file object JOADataFile of = new JOADataFile(fileDescrip); // read the number of sections int numSections = inData.readShort(); bytesRead += 2; // read each section JOASection sech; int ord = 0; for (int s = 0; s < numSections; s++) { mProgress.setPercentComplete(100.0 * ((double) bytesRead / (double) bytesInFile)); // read the section header inShort = inData.readShort(); bytesRead += 2; byte buf1[] = new byte[inShort]; inData.read(buf1, 0, inShort); String sectionDescrip = new String(buf1); bytesRead += inShort; // read the ship code byte bufsc[] = new byte[2]; bufsc[0] = inData.readByte(); bufsc[1] = inData.readByte(); String shipCode = new String(bufsc); bytesRead += 2; // read num casts int numCasts = inData.readShort(); bytesRead += 2; // read num parameters int numVars = inData.readShort(); bytesRead += 2; // quality code int qcStd = 1; if (vers == 4) { qcStd = inData.readShort(); bytesRead += 2; } // create a new section of.mNumSections++; sech = new JOASection(of.mNumSections, sectionDescrip, shipCode, numCasts, numVars); if (vers == 2) { // read the properties byte bufv[] = new byte[4]; for (int p = 0; p < numVars; p++) { // parameter name inData.read(bufv, 0, 4); String tempVar = new String(bufv); bytesRead += 4; // units inShort = inData.readShort(); bytesRead += 2; String units = null; if (inShort > 0) { byte buf11[] = new byte[inShort]; inData.read(buf11, 0, inShort); units = new String(buf11); bytesRead += inShort; } // convert varnames to UC tempVar.toUpperCase(); // create new property tempProperties[p] = new JOAParameter(tempVar, units); // add this property to the section property list if (tempProperties[p].mUnits == null) { tempProperties[p].mUnits = EPS_Util.paramNameToJOAUnits(false, tempProperties[0].mVarLabel); } if (tempProperties[p].mUnits == null) { tempProperties[p].mUnits = new String("na"); } tempProperties[p].mCastOrObs = EPSConstants.ALL_OBS; // read the actual scale int actScale = inData.readShort(); bytesRead += 2; if (actScale != 0) tempProperties[p].mActScale = 1.0 / (double) actScale; else tempProperties[p].mActScale = 1.0; // read the actual origin int actOrigin = inData.readShort(); tempProperties[p].mActOrigin = (double) actOrigin * tempProperties[p].mActScale; // read reverse y int reverseY = inData.readShort(); bytesRead += 2; if (reverseY == 0) tempProperties[p].mReverseY = false; else tempProperties[p].mReverseY = true; tempProperties[p].mWasCalculated = false; } } else { // read the properties String tempVar = null; for (int p = 0; p < numVars; p++) { // length of parameter name inShort = inData.readShort(); bytesRead += 2; // parameter name if (inShort > 0) { byte buf13[] = new byte[inShort]; inData.read(buf13, 0, inShort); tempVar = new String(buf13); bytesRead += inShort; } // units inShort = inData.readShort(); bytesRead += 2; String units = null; if (inShort > 0) { byte buf11[] = new byte[inShort]; inData.read(buf11, 0, inShort); units = new String(buf11); bytesRead += inShort; } // convert varnames to UC tempVar = tempVar.toUpperCase(); // create new property tempProperties[p] = new JOAParameter(tempVar, units); // add this property to the section property list if (tempProperties[p].mUnits == null) { tempProperties[p].mUnits = EPS_Util.paramNameToJOAUnits(false, tempProperties[0].mVarLabel); } if (tempProperties[p].mUnits == null) { tempProperties[p].mUnits = new String("na"); } tempProperties[p].mCastOrObs = EPSConstants.ALL_OBS; // read the actual scale int actScale = inData.readShort(); bytesRead += 2; if (actScale != 0) tempProperties[p].mActScale = 1.0 / (double) actScale; else tempProperties[p].mActScale = 1.0; // read the actual origin int actOrigin = inData.readShort(); tempProperties[p].mActOrigin = (double) actOrigin * tempProperties[p].mActScale; // read reverse y int reverseY = inData.readShort(); bytesRead += 2; if (reverseY == 0) tempProperties[p].mReverseY = false; else tempProperties[p].mReverseY = true; tempProperties[p].mWasCalculated = false; } } // read the cast headers for (int c = 0; c < numCasts; c++) { // read station number inShort = inData.readShort(); bytesRead += 2; byte bufx[] = new byte[inShort]; inData.read(bufx, 0, inShort); String stnNum = new String(bufx); bytesRead += inShort; // read cast number int castNum = inData.readShort(); bytesRead += 2; double myLat = 0.0; double myLon = 0.0; if (vers == 2) { // read latitude/lon int lat = inData.readInt(); bytesRead += 4; int lon = inData.readInt(); bytesRead += 4; myLat = lat * 0.001; myLon = lon * 0.001; } else if (vers > 2) { // read latitude/lon myLat = inData.readDouble(); bytesRead += 8; myLon = inData.readDouble(); bytesRead += 4; } // read number of bottles int numBottles = inData.readShort(); bytesRead += 2; // read the date int year = inData.readInt(); bytesRead += 4; int month = inData.readInt(); bytesRead += 4; int day = inData.readInt(); bytesRead += 4; int hour = inData.readInt(); bytesRead += 4; double min = inData.readDouble(); bytesRead += 8; // read bottom int bottomdbar = inData.readInt(); // read station quality int stnQual = inData.readShort(); bytesRead += 2; ord++; JOAStation sh = new JOAStation( ord, shipCode, stnNum, castNum, myLat, myLon, numBottles, year, month, day, hour, min, bottomdbar, stnQual); sech.mStations.addElement(sh); sh.setType("JOA BOTTLE"); // make a DBase object Dbase db = new Dbase(); // add the global attributes db.addEPSAttribute( "CRUISE", EPCHAR, sech.mSectionDescription.length(), sech.mSectionDescription); db.addEPSAttribute("CAST", EPCHAR, sh.mStnNum.length(), sh.mStnNum); sarray[0] = (short) sh.mBottomDepthInDBARS; db.addEPSAttribute("WATER_DEPTH", EPSHORT, 1, sarray); db.addEPSAttribute("DATA_ORIGIN", EPCHAR, sech.mShipCode.length(), sech.mShipCode); String dType = sh.getType(); if (dType == null) dType = "UNKN"; db.addEPSAttribute("DATA_TYPE", EPCHAR, dType.length(), dType); sarray[0] = (short) stnQual; db.addEPSAttribute("STN_QUALITY", EPSHORT, 1, sarray); db.setDataType("JOA BOTTLE"); // add to temporary collection dBases.addElement(db); } int start = mTotalStns; int end = sech.mStations.size() + mTotalStns; for (int sc = start; sc < end; sc++) { mProgress.setPercentComplete(100.0 * ((double) bytesRead / (double) bytesInFile)); // get a dBase Dbase db = (Dbase) dBases.elementAt(sc); // get a station JOAStation sh = (JOAStation) sech.mStations.elementAt(sc - start); // create an array of arrays to store the data double[][] va = new double[sech.mNumVars][sh.mNumBottles]; int[][] qc = new int[sech.mNumVars][sh.mNumBottles]; short[] bqc = new short[sh.mNumBottles]; int presPos = 0; // read the bottles for (int b = 0; b < sh.mNumBottles; b++) { // read the bottle quality code bqc[b] = inData.readShort(); bytesRead += 2; for (int v = 0; v < sech.mNumVars; v++) { // store the position of the PRES variable if (tempProperties[v].mVarLabel.equals("PRES")) presPos = v; // get the measured parameter double dVarVal = EPSConstants.MISSINGVALUE; try { dVarVal = inData.readDouble(); } catch (IOException e) { FileImportException fiex = new FileImportException(); String errStr = "Error reading the parameter data. " + "\n" + "Bottle #" + b + " Parameter #" + v; fiex.setErrorType(errStr); throw fiex; } bytesRead += 8; // store the value in the multidimensional array va[v][b] = dVarVal; // get the quality flag short flag = (short) EPSConstants.MISSINGVALUE; try { flag = inData.readShort(); } catch (IOException e) { FileImportException fiex = new FileImportException(); String errStr = "Error reading the parameter quality code. " + "\n" + "Bottle #" + b + " Parameter #" + v; fiex.setErrorType(errStr); throw fiex; } bytesRead += 2; qc[v][b] = flag; } // for v } // for b // add the bottle quality codes as an attribute db.addEPSAttribute("BOTTLE_QUALITY_CODES", EPSHORT, sh.mNumBottles, bqc); // create the axes time = 0, depth = 1, lat = 2, lon = 3 Axis timeAxis = new Axis(); Axis zAxis = new Axis(); Axis latAxis = new Axis(); Axis lonAxis = new Axis(); // time axis timeAxis.setName("time"); timeAxis.setTime(true); timeAxis.setUnlimited(false); timeAxis.setAxisType(EPTAXIS); timeAxis.setLen(1); int hour = 0; if (sh.mHour != EPSConstants.MISSINGVALUE) hour = sh.mHour; double mins = 0; if (sh.mMinute != EPSConstants.MISSINGVALUE) mins = sh.mMinute; // make the time axis units String date = "days since "; int min = (int) mins; double fmin = mins - min; int secs = (int) (fmin * 60.0); double fsec = (fmin * 60.0) - secs; int msec = (int) (fsec * 1000.0); String fs = String.valueOf(fsec); fs = fs.substring(fs.indexOf(".") + 1, fs.length()).trim(); int f = 0; if (fs != null && fs.length() > 0) f = Integer.valueOf(fs).intValue(); // sprintf(time_string,"%04d-%02d-%02d %02d:%02d:%02d.%03d",yr,mon,day,hr,min,sec,f); String frmt = new String( "{0,number,####}-{1,number,00}-{2,number,00} {3,number,00}:{4,number,00}:{5,number,00}.{6,number,000}"); MessageFormat msgf = new MessageFormat(frmt); Object[] objs = { new Integer(sh.mYear), new Integer(sh.mMonth), new Integer(sh.mDay), new Integer(hour), new Integer(min), new Integer(secs), new Integer(f) }; StringBuffer out = new StringBuffer(); msgf.format(objs, out, null); String time_string = new String(out); date = date + time_string; timeAxis.addAttribute(0, "units", EPCHAR, date.length(), date); timeAxis.setUnits(date); GeoDate gd = null; try { gd = new GeoDate(sh.mMonth, sh.mDay, sh.mYear, hour, min, secs, msec); GeoDate[] ta = {gd}; MultiArray tma = new ArrayMultiArray(ta); timeAxis.setData(tma); db.setAxis(timeAxis); } catch (Exception ex) { GeoDate[] ta = {new GeoDate()}; MultiArray tma = new ArrayMultiArray(ta); timeAxis.setData(tma); db.setAxis(timeAxis); } // add the time axes variable EPSVariable var = new EPSVariable(); var.setOname("time"); var.setDtype(EPDOUBLE); var.setVclass(Double.TYPE); var.addAttribute(0, "units", EPCHAR, date.length(), date); var.setUnits(date); double[] vta = {0.0}; MultiArray vtma = new ArrayMultiArray(vta); try { var.setData(vtma); } catch (Exception ex) { } db.addEPSVariable(var); // z axis zAxis.setName("depth"); zAxis.setTime(false); zAxis.setUnlimited(false); zAxis.setLen(sh.mNumBottles); zAxis.setAxisType(EPZAXIS); zAxis.addAttribute(0, "FORTRAN_format", EPCHAR, 5, "f10.1"); zAxis.addAttribute(1, "units", EPCHAR, 4, "dbar"); zAxis.setUnits("dbar"); zAxis.setFrmt("f10.1"); // zAxis.addAttribute(2, "type", EPCHAR, 0, ""); sarray[0] = 1; zAxis.addAttribute(2, "epic_code", EPSHORT, 1, sarray); double[] za = new double[sh.mNumBottles]; for (int b = 0; b < sh.mNumBottles; b++) { za[b] = va[presPos][b]; } MultiArray zma = new ArrayMultiArray(za); zAxis.setData(zma); db.setAxis(zAxis); // add the z axes variables var = new EPSVariable(); var.setOname("depth"); var.setDtype(EPDOUBLE); var.setVclass(Double.TYPE); var.addAttribute(0, "FORTRAN_format", EPCHAR, 5, "f10.1"); var.addAttribute(1, "units", EPCHAR, 4, "dbar"); var.setUnits("dbar"); var.setFrmt("f10.1"); // var.addAttribute(2, "type", EPCHAR, 0, ""); sarray[0] = 1; var.addAttribute(2, "epic_code", EPSHORT, 1, sarray); MultiArray zvma = new ArrayMultiArray(za); try { var.setData(zvma); } catch (Exception ex) { } db.addEPSVariable(var); // lat axis latAxis.setName("latitude"); latAxis.setTime(false); latAxis.setUnlimited(false); latAxis.setLen(1); latAxis.setAxisType(EPYAXIS); latAxis.addAttribute(0, "FORTRAN_format", EPCHAR, 5, "f10.4"); latAxis.addAttribute(1, "units", EPCHAR, 7, "degrees"); latAxis.setUnits("degrees"); latAxis.setFrmt("f10.4"); // latAxis.addAttribute(2, "type", EPCHAR, 0, ""); sarray[0] = 500; latAxis.addAttribute(2, "epic_code", EPSHORT, 1, sarray); double lat = sh.mLat; double[] la = {lat}; MultiArray lma = new ArrayMultiArray(la); latAxis.setData(lma); db.setAxis(latAxis); // add the y axes variable var = new EPSVariable(); var.setOname("latitude"); var.setDtype(EPDOUBLE); var.setVclass(Double.TYPE); var.addAttribute(0, "FORTRAN_format", EPCHAR, 5, "f10.4"); var.addAttribute(1, "units", EPCHAR, 7, "degrees"); var.setUnits("degrees"); var.setFrmt("f10.4"); // var.addAttribute(2, "type", EPCHAR, 0, ""); sarray[0] = 500; var.addAttribute(2, "epic_code", EPSHORT, 1, sarray); MultiArray yvma = new ArrayMultiArray(la); try { var.setData(yvma); } catch (Exception ex) { } db.addEPSVariable(var); // lon axis lonAxis.setName("longitude"); lonAxis.setTime(false); lonAxis.setUnlimited(false); lonAxis.setLen(1); lonAxis.setAxisType(EPXAXIS); lonAxis.addAttribute(0, "FORTRAN_format", EPCHAR, 5, "f10.4"); lonAxis.addAttribute(1, "units", EPCHAR, 7, "degrees"); lonAxis.setUnits("degrees"); lonAxis.setFrmt("f10.4"); // lonAxis.addAttribute(2, "type", EPCHAR, 0, ""); sarray[0] = 502; lonAxis.addAttribute(2, "epic_code", EPSHORT, 1, sarray); double lon = sh.mLon; double[] lla = {lon}; lma = new ArrayMultiArray(lla); lonAxis.setData(lma); db.setAxis(lonAxis); // add the x axes variable var = new EPSVariable(); var.setOname("longitude"); var.setDtype(EPDOUBLE); var.setVclass(Double.TYPE); var.addAttribute(0, "FORTRAN_format", EPCHAR, 5, "f10.4"); var.addAttribute(1, "units", EPCHAR, 7, "degrees"); var.setUnits("degrees"); var.setFrmt("f10.4"); // var.addAttribute(2, "type", EPCHAR, 0, ""); sarray[0] = 502; var.addAttribute(2, "epic_code", EPSHORT, 1, sarray); MultiArray xvma = new ArrayMultiArray(lla); try { var.setData(xvma); } catch (Exception ex) { } db.addEPSVariable(var); // add the measured variables for (int v = 0; v < sech.mNumVars; v++) { // if (presPos == v) // continue; // create an array of measured EPSVariables for this database EPSVariable epsVar = new EPSVariable(); // initialize the new EPSVariables // look this variable up in JOA EPIC_Key. find matching entry in original EPIC Key String oname = tempProperties[v].mVarLabel; String sname = null; String lname = null; String gname = null; String units = null; String ffrmt = null; int keyID = -99; int type = -99; try { keyID = mEpicKeyDB.findKey(tempProperties[v].mVarLabel); Key key = mOrigEpicKeyDB.findKey(keyID); gname = key.getGname(); sname = key.getSname(); lname = key.getLname(); units = key.getUnits(); ffrmt = key.getFrmt(); type = key.getType(); } catch (Exception e) { lname = tempProperties[v].mVarLabel; gname = tempProperties[v].mVarLabel; sname = tempProperties[v].mVarLabel; units = tempProperties[v].mUnits; } // make a new variable epsVar = new EPSVariable(); epsVar.setOname(oname); epsVar.setSname(sname); epsVar.setLname(lname); epsVar.setGname(gname); epsVar.setDtype(EPDOUBLE); epsVar.setVclass(Double.TYPE); int numAttributes = 0; if (ffrmt != null) { epsVar.addAttribute(numAttributes++, "FORTRAN_format", EPCHAR, ffrmt.length(), ffrmt); epsVar.setFrmt(ffrmt); } if (units != null && units.length() > 0) { epsVar.addAttribute(numAttributes++, "units", EPCHAR, units.length(), units); epsVar.setUnits(units); } if (keyID >= 0) { sarray[0] = (short) type; // epsVar.addAttribute(numAttributes++, "type", EPSHORT, 1, sarray); } if (keyID >= 0) { sarray[0] = (short) keyID; epsVar.addAttribute(numAttributes++, "epic_code", EPSHORT, 1, sarray); } // add the quality code attribute String qcVar = oname + "_QC"; epsVar.addAttribute(numAttributes++, "OBS_QC_VARIABLE", EPCHAR, qcVar.length(), qcVar); // connect variable to axis epsVar.setDimorder(0, 0); epsVar.setDimorder(1, 1); epsVar.setDimorder(2, 2); epsVar.setDimorder(3, 3); epsVar.setT(timeAxis); epsVar.setZ(zAxis); epsVar.setY(latAxis); epsVar.setX(lonAxis); // set the data // create storage for the measured variables double[][][][] vaa = new double[1][sh.mNumBottles][1][1]; for (int b = 0; b < sh.mNumBottles; b++) { vaa[0][b][0][0] = va[v][b]; } MultiArray mdma = new ArrayMultiArray(vaa); try { epsVar.setData(mdma); } catch (Exception ex) { System.out.println("throwing"); } // add the variable to the database db.addEPSVariable(epsVar); // create the quality code variable epsVar = new EPSVariable(); epsVar.setOname(oname + "_QC"); epsVar.setSname(sname + "_QC"); epsVar.setLname(sname + "_QC"); epsVar.setGname(sname + "_QC"); epsVar.setDtype(EPSHORT); epsVar.setVclass(Short.TYPE); // connect variable to axis epsVar.setDimorder(0, 0); epsVar.setDimorder(1, 1); epsVar.setDimorder(2, 2); epsVar.setDimorder(3, 3); epsVar.setT(timeAxis); epsVar.setZ(zAxis); epsVar.setY(latAxis); epsVar.setX(lonAxis); // set the data // create storage for the qc variables short[][][][] qcaa = new short[1][sh.mNumBottles][1][1]; for (int b = 0; b < sh.mNumBottles; b++) { qcaa[0][b][0][0] = (short) qc[v][b]; } MultiArray qcma = new ArrayMultiArray(qcaa); try { epsVar.setData(qcma); } catch (Exception ex) { System.out.println("throwing"); } // add the qc variable to the database db.addEPSVariable(epsVar); } // for v } mTotalStns += numCasts; } // for sc // read the file comments StringBuffer sb = null; while (true) { try { // read continuation line inShort = inData.readShort(); bytesRead += 2; if (inShort == 1) { // read number of bytes in file description string inShort = inData.readShort(); bytesRead += 2; // read the file description String byte buf2[] = new byte[inShort]; inData.read(buf2, 0, inShort); String commentLine = new String(buf2); bytesRead += inShort; if (sb == null) sb = new StringBuffer(commentLine); else sb.append(commentLine); } } catch (IOException e) { break; } } // while true if (sb != null) { // make attributes for the comments mOwnerDBase.setDataComment(new String(sb)); } // make a sub database in the dbase mOwnerDBase.createSubEntries(mTotalStns, mFile.getName()); for (int d = 0; d < mTotalStns; d++) { Dbase db = (Dbase) dBases.elementAt(d); mOwnerDBase.addSubEntry(db); } mProgress.setPercentComplete(100.0); mProgress.setVisible(false); mProgress.dispose(); in.close(); } catch (IOException e) { mProgress.setVisible(false); mProgress.dispose(); throw e; } }
public void setEnclosingFig(Fig encloser) { if (encloser != null && encloser.getOwner() instanceof MNodeInstance && getOwner() != null) { MNodeInstance node = (MNodeInstance) encloser.getOwner(); MComponentInstance comp = (MComponentInstance) getOwner(); if (comp.getNodeInstance() != node) { comp.setNodeInstance(node); } super.setEnclosingFig(encloser); Vector figures = getEnclosedFigs(); if (getLayer() != null) { // elementOrdering(figures); Vector contents = getLayer().getContents(); int contentsSize = contents.size(); for (int j = 0; j < contentsSize; j++) { Object o = contents.elementAt(j); if (o instanceof FigEdgeModelElement) { FigEdgeModelElement figedge = (FigEdgeModelElement) o; figedge.getLayer().bringToFront(figedge); } } } } else if (encloser == null && getEnclosingFig() != null) { if (getEnclosingFig() instanceof FigNodeModelElement) ((FigNodeModelElement) getEnclosingFig()).getEnclosedFigs().removeElement(this); _encloser = null; } /* super.setEnclosingFig(encloser); Vector figures = getEnclosedFigs(); if (getLayer() != null) { // elementOrdering(figures); Vector contents = getLayer().getContents(); int contentsSize = contents.size(); for (int j=0; j<contentsSize; j++) { Object o = contents.elementAt(j); if (o instanceof FigEdgeModelElement) { FigEdgeModelElement figedge = (FigEdgeModelElement) o; figedge.getLayer().bringToFront(figedge); } } } if (!(getOwner() instanceof MModelElement)) return; if (getOwner() instanceof MComponentInstance) { MComponentInstance me = (MComponentInstance) getOwner(); MNodeInstance mnode = null; if (encloser != null && (encloser.getOwner() instanceof MNodeInstance)) { mnode = (MNodeInstance) encloser.getOwner(); } if (encloser != null && (encloser.getOwner() instanceof MComponentInstance)) { MComponentInstance comp = (MComponentInstance) encloser.getOwner(); mnode = (MNodeInstance) comp.getNodeInstance(); } try { if(mnode != null) { me.setNodeInstance(mnode); } else { if (me.getNodeInstance() != null) { me.setNodeInstance(null); } } setNode(figures); } catch (Exception e) { cat.error("could not set package", e); } } */ }