/** * Override the init method for when this data source is unpersisted. We simply check the * imageList to see if this object came from a legacy bundle. */ public void initAfterUnpersistence() { super.initAfterUnpersistence(); List tmp = getTmpPaths(); if (tmp != null) { List obs = getRDS().getSoundingObs(); AddeSoundingAdapter asa = (AddeSoundingAdapter) getRDS().getSoundingAdapter(); for (int i = 0; i < tmp.size(); i += 2) { SoundingOb ob = (SoundingOb) obs.get(i / 2); ob.setMandatoryFile(tmp.get(i).toString()); ob.setMandatoryFile(tmp.get(i + 1).toString()); } } }
/** Initialize after we have been unpersisted */ public void initAfterUnpersistence() { super.initAfterUnpersistence(); // Check if we were created with the background layers. If so then use the new list if (wmsSelections != null) { List backgroundImages = getDataContext().getIdv().getBackgroundImages(); for (Object o : wmsSelections) { if (backgroundImages.contains(o)) { wmsSelections = backgroundImages; break; } } } initWmsDataSource(); }
/** * A utility method that will wait until all displays are finished being created. This looks at * the DisplayControls, data sources, global wait cursor count, the visad thread pool and looks at * any active java3d threads * * @param uiManager The ui manager. We use this to access the wait cursor count * @param timeToWait (milliseconds) elapsed time to wait for nothing to be active */ public static void waitUntilDisplaysAreDone(IdvUIManager uiManager, long timeToWait) { Trace.call1("Waiting on displays"); int successiveTimesWithNoActive = 0; int sleepTime = 10; long firstTime = System.currentTimeMillis(); int cnt = 0; while (true) { boolean cursorCount = (uiManager.getWaitCursorCount() > 0); boolean actionCount = ActionImpl.getTaskCount() > 0; boolean dataActive = DataSourceImpl.getOutstandingGetDataCalls() > 0; boolean anyJ3dActive = anyJava3dThreadsActive(); boolean allDisplaysInitialized = uiManager.getIdv().getAllDisplaysIntialized(); // System.err.println ("\tAll displays init:" + allDisplaysInitialized +" cursor // cnt:" + uiManager.getWaitCursorCount() + " action cnt:" +actionCount + " data active: " + // dataActive); // if ((cnt++) % 30 == 0) { // System.err.println ("\tcnt:" + uiManager.getWaitCursorCount() + " " // +actionCount + " " + dataActive); // } boolean anyActive = actionCount || cursorCount || dataActive || !allDisplaysInitialized || anyJ3dActive; if (dataActive) { firstTime = System.currentTimeMillis(); } if (anyActive) { successiveTimesWithNoActive = 0; } else { successiveTimesWithNoActive++; } if ((timeToWait == 0) && !anyActive) { break; } if (successiveTimesWithNoActive * sleepTime > timeToWait) { break; } Misc.sleep(sleepTime); // At most wait 120 seconds if (System.currentTimeMillis() - firstTime > 120000) { System.err.println("Error waiting for to be done:" + LogUtil.getStackDump(false)); return; } } Trace.call2("Waiting on displays"); }
public Element saveParameterSet() { if (imageDefaults == null) { imageDefaults = getImageDefaults(); } if (newCompName.length() == 0) { newComponentError("parameter set"); return null; } Element newChild = imageDefaultsDocument.createElement(TAG_DEFAULT); newChild.setAttribute(ATTR_NAME, newCompName); if (datachoice == null) { datachoice = getDataChoice(); } dataSource = getDataSource(); if (!(dataSource.getClass().isInstance(new AddeImageParameterDataSource()))) { return newChild; } AddeImageParameterDataSource testDataSource = (AddeImageParameterDataSource) dataSource; List imageList = testDataSource.getDescriptors(datachoice, this.dataSelection); int numImages = imageList.size(); List dateTimes = new ArrayList(); DateTime thisDT = null; if (!(imageList == null)) { AddeImageDescriptor aid = null; for (int imageNo = 0; imageNo < numImages; imageNo++) { aid = (AddeImageDescriptor) (imageList.get(imageNo)); thisDT = aid.getImageTime(); if (!(dateTimes.contains(thisDT))) { if (thisDT != null) { dateTimes.add(thisDT); } } } String dateS = ""; String timeS = ""; if (!(dateTimes.isEmpty())) { thisDT = (DateTime) dateTimes.get(0); dateS = thisDT.dateString(); timeS = thisDT.timeString(); if (dateTimes.size() > 1) { for (int img = 1; img < dateTimes.size(); img++) { thisDT = (DateTime) dateTimes.get(img); String str = ',' + thisDT.dateString(); String newString = new String(dateS + str); dateS = newString; str = ',' + thisDT.timeString(); newString = new String(timeS + str); timeS = newString; } } } if (aid != null) { String displayUrl = testDataSource.getDisplaySource(); ImageParameters ip = new ImageParameters(displayUrl); List props = ip.getProperties(); List vals = ip.getValues(); String server = ip.getServer(); newChild.setAttribute(ATTR_SERVER, server); int num = props.size(); if (num > 0) { String attr = ""; String val = ""; for (int i = 0; i < num; i++) { attr = (String) (props.get(i)); if (attr.equals(ATTR_POS)) { val = new Integer(numImages - 1).toString(); } else if (attr.equals(ATTR_DAY)) { val = dateS; } else if (attr.equals(ATTR_TIME)) { val = timeS; } else { val = (String) (vals.get(i)); } newChild.setAttribute(attr, val); } } } } Element parent = xmlTree.getSelectedElement(); if (parent == null) { parent = (Element) lastCat; } if (parent != null) { Element exists = XmlUtil.findElement(parent, "default", ATTR_NAME, newCompName); if (!(exists == null)) { JLabel label = new JLabel("Replace \"" + newCompName + "\"?"); JPanel contents = GuiUtils.top(GuiUtils.inset(label, newCompName.length() + 12)); if (!GuiUtils.showOkCancelDialog(null, "Parameter Set Exists", contents, null)) { return newChild; } parent.removeChild(exists); } parent.appendChild(newChild); makeXmlTree(); } try { imageDefaults.writeWritable(); } catch (Exception e) { logger.error("write error!", e); } imageDefaults.setWritableDocument(imageDefaultsDocument, imageDefaultsRoot); return newChild; }
private Hashtable makeParameterValues() { Hashtable parameterValues = new Hashtable(); // Document doc = XmlUtil.makeDocument(); // Element newChild = doc.createElement(TAG_DEFAULT); if (datachoice == null) { datachoice = getDataChoice(); } dataSource = getDataSource(); if (!(dataSource.getClass().isInstance(new AddeImageParameterDataSource()))) { logger.trace( "dataSource not a AddeImageParameterDataSource; it is: {}", dataSource.getClass().toString()); return parameterValues; } AddeImageParameterDataSource testDataSource = (AddeImageParameterDataSource) dataSource; List imageList = testDataSource.getDescriptors(datachoice, this.dataSelection); int numImages = imageList.size(); List dateTimes = new ArrayList(); DateTime thisDT = null; if (!(imageList == null)) { AddeImageDescriptor aid = null; for (int imageNo = 0; imageNo < numImages; imageNo++) { aid = (AddeImageDescriptor) (imageList.get(imageNo)); thisDT = aid.getImageTime(); if (!(dateTimes.contains(thisDT))) { if (thisDT != null) { dateTimes.add(thisDT); } } } // Set the date and time for later reference String dateS = ""; String timeS = ""; if (!(dateTimes.isEmpty())) { thisDT = (DateTime) dateTimes.get(0); dateS = thisDT.dateString(); timeS = thisDT.timeString(); if (dateTimes.size() > 1) { for (int img = 1; img < dateTimes.size(); img++) { thisDT = (DateTime) dateTimes.get(img); String str = "," + thisDT.dateString(); String newString = new String(dateS + str); dateS = newString; str = "," + thisDT.timeString(); newString = new String(timeS + str); timeS = newString; } } } // Set the unit for later reference String unitS = ""; if (!(datachoice.getId() instanceof BandInfo)) { logger.trace( "dataChoice ID not a BandInfo; it is: {}", datachoice.getId().getClass().toString()); return parameterValues; } BandInfo bi = (BandInfo) datachoice.getId(); unitS = bi.getPreferredUnit(); if (aid != null) { String displayUrl = testDataSource.getDisplaySource(); ImageParameters ip = new ImageParameters(displayUrl); List props = ip.getProperties(); List vals = ip.getValues(); String server = ip.getServer(); parameterValues.put(ATTR_SERVER, server); // newChild.setAttribute(ATTR_SERVER, server); int num = props.size(); if (num > 0) { String attr = ""; String val = ""; for (int i = 0; i < num; i++) { attr = (String) (props.get(i)); if (attr.equals(ATTR_POS)) { val = new Integer(numImages - 1).toString(); } else if (attr.equals(ATTR_DAY)) { val = dateS; } else if (attr.equals(ATTR_TIME)) { val = timeS; } else if (attr.equals(ATTR_UNIT)) { val = unitS; } else { val = (String) (vals.get(i)); } parameterValues.put(attr, val); } } } } return parameterValues; }
protected JComponent getHistogramTabComponent() { List choices = new ArrayList(); if (datachoice == null) { datachoice = getDataChoice(); } choices.add(datachoice); histoWrapper = new McIDASVHistogramWrapper("histo", choices, (DisplayControlImpl) this); dataSource = getDataSource(); if (dataSource == null) { try { image = (FlatField) ((ComboDataChoice) datachoice).getData(); histoWrapper.loadData(image); } catch (Exception e) { } } else { Hashtable props = dataSource.getProperties(); try { DataSelection testSelection = datachoice.getDataSelection(); DataSelection realSelection = getDataSelection(); if (testSelection == null) { datachoice.setDataSelection(realSelection); } ImageSequenceImpl seq = null; if (dataSelection == null) dataSelection = dataSource.getDataSelection(); if (dataSelection == null) { image = (FlatField) dataSource.getData(datachoice, null, props); if (image == null) { image = (FlatField) datachoice.getData(null); } } else { Data data = dataSource.getData(datachoice, null, dataSelection, props); if (data instanceof ImageSequenceImpl) { seq = (ImageSequenceImpl) data; } else if (data instanceof FlatField) { image = (FlatField) data; } else if (data instanceof FieldImpl) { image = (FlatField) ((FieldImpl) data).getSample(0, false); } else { throw new Exception("Histogram must be made from a FlatField"); } } if (seq != null) { if (seq.getImageCount() > 0) image = (FlatField) seq.getImage(0); } histoWrapper.loadData(image); } catch (Exception e) { logger.error("attempting to set up histogram", e); } } JComponent histoComp = histoWrapper.doMakeContents(); JButton resetButton = new JButton("Reset"); resetButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { resetColorTable(); } }); JPanel resetPanel = GuiUtils.center(GuiUtils.inset(GuiUtils.wrap(resetButton), 4)); return GuiUtils.centerBottom(histoComp, resetPanel); }
/** * _more_ * * @param comps _more_ */ public void getPropertiesComponents(List comps) { super.getPropertiesComponents(comps); maintainRatioCbx = new JCheckBox("Match Ration", maintainRatio); comps.add(GuiUtils.filler()); comps.add(GuiUtils.left(maintainRatioCbx)); }