From: Egon W. <eg...@us...> - 2002-10-24 13:47:39
|
Update of /cvsroot/jmol/Jmol/src/org/openscience/jmol In directory usw-pr-cvs1:/tmp/cvs-serv31245/src/org/openscience/jmol Modified Files: PropertyGraph.java Log Message: Fixed problem with PropertyGraph. Index: PropertyGraph.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/openscience/jmol/PropertyGraph.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** PropertyGraph.java 11 Oct 2002 15:59:08 -0000 1.18 --- PropertyGraph.java 24 Oct 2002 13:47:35 -0000 1.19 *************** *** 57,63 **** --- 57,73 ---- super(f, "Property Graph", false); + makeNewGraph(); + } + + /** + * Instantiates a new content JPanel for this JDialog. + * Called when loading a new file. + */ + private void makeNewGraph() { gl = new GridLayout(1, 0); panel = new JPanel(gl); + dataFound = false; // see findData() + setContentPane(panel); setSize(500, 500); *************** *** 105,108 **** --- 115,120 ---- if (hasGraphableProperties) { graphAction.setEnabled(true); + dataFound = false; // data must be redisplayed. see findData() + makeNewGraph(); // generate new (empty) JPanel. } else { graphAction.setEnabled(false); *************** *** 112,147 **** public void findData() { ! if (hasGraphableProperties) { ! int nGraphs = GPs.size(); ! int nPoints = inputFile.getNumberOfFrames(); ! gl.setRows(nGraphs); ! double[][] data = new double[nGraphs][nPoints]; ! String[] titles = new String[nGraphs]; ! JASHist[] graphs = new JASHist[nGraphs]; ! for (int j = 0; j < nGraphs; j++) { ! String desc = (String) GPs.elementAt(j); ! titles[j] = new String(desc); ! graphs[j] = new JASHist(); ! for (int i = 0; i < nPoints; i++) { ! Vector fp = inputFile.getFrame(i).getFrameProperties(); ! Enumeration ef = fp.elements(); ! while (ef.hasMoreElements()) { ! PhysicalProperty pf = (PhysicalProperty) ef.nextElement(); ! if (pf.getDescriptor().equals(desc)) { ! data[j][i] = ((Double) pf.getProperty()).doubleValue(); } } } ! } ! for (int j = 0; j < nGraphs; j++) { ! graphs[j].addData(new ArrayDataSource(data[j], titles[j])).show(true); ! panel.add(graphs[j]); } } --- 124,163 ---- public void findData() { ! if (!dataFound) { ! if (hasGraphableProperties) { ! int nGraphs = GPs.size(); ! int nPoints = inputFile.getNumberOfFrames(); ! gl.setRows(nGraphs); ! double[][] data = new double[nGraphs][nPoints]; ! String[] titles = new String[nGraphs]; ! JASHist[] graphs = new JASHist[nGraphs]; ! for (int j = 0; j < nGraphs; j++) { ! String desc = (String) GPs.elementAt(j); ! titles[j] = new String(desc); ! graphs[j] = new JASHist(); ! for (int i = 0; i < nPoints; i++) { ! Vector fp = inputFile.getFrame(i).getFrameProperties(); ! Enumeration ef = fp.elements(); ! while (ef.hasMoreElements()) { ! ! PhysicalProperty pf = (PhysicalProperty) ef.nextElement(); ! if (pf.getDescriptor().equals(desc)) { ! data[j][i] = ((Double) pf.getProperty()).doubleValue(); ! } } } } ! for (int j = 0; j < nGraphs; j++) { ! graphs[j].addData(new ArrayDataSource(data[j], titles[j])).show(true); ! panel.add(graphs[j]); ! } ! dataFound = true; } } *************** *** 303,306 **** --- 319,327 ---- */ private boolean hasGraphableProperties; + + /** + * Have the properties been added to the JPanel yet? + */ + private boolean dataFound; /* |