Changeset 352
- Timestamp:
- 10/08/08 13:59:53 (16 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/greenstone/Greenstone3Connection.java
r313 r352 17 17 import java.util.Set; 18 18 19 import org.apache.xerces.parsers.DOMParser;19 //import org.apache.xerces.parsers.DOMParser; 20 20 import org.w3c.dom.Document; 21 21 import org.w3c.dom.NamedNodeMap; … … 425 425 StringReader sr = new StringReader(result); 426 426 InputSource is = new InputSource(sr); 427 DOMParser p = new DOMParser(); 428 429 try { 430 p.parse(is); 431 } catch (SAXException se) { 432 System.err.println(se); 433 } catch (IOException ioe) { 434 System.err.println(ioe); 435 } 436 Document d = p.getDocument(); 437 NodeList metadataList = d.getElementsByTagName("metadata"); 438 for (int i = 0; i < metadataList.getLength(); i++) { 439 Node n = metadataList.item(i); 440 NamedNodeMap nnm = n.getAttributes(); 441 Node att = nnm.getNamedItem("name"); 442 if (att.getNodeValue().compareTo("numDocsMatched") == 0) { 443 queryOutcome.setHowManyDocsMatched(n.getFirstChild() 444 .getNodeValue()); 445 } else if (att.getNodeValue().compareTo("numDocsReturned") == 0) { 446 queryOutcome.setHowManyDocsReturned(n.getFirstChild() 447 .getNodeValue()); 448 } 449 } 450 451 NodeList documentList = d.getElementsByTagName("documentNode"); 452 for (int i = 0; i < documentList.getLength(); i++) { 453 Node n = documentList.item(i); 454 NamedNodeMap nnm = n.getAttributes(); 455 Node nid = nnm.getNamedItem("nodeID"); 456 Node nscore = nnm.getNamedItem("rank"); 457 String docID = nid.getFirstChild().getNodeValue(); 458 queryOutcome.addResult(docID, firstDoc + i, nscore.getFirstChild() 459 .getNodeValue()); 460 } 461 query.addQueryOutcome(queryOutcome); 462 Query q = (Query) query.clone(); 463 queryList.add(q); 464 465 for (int i = 0; i < documentList.getLength(); i++) { 466 Node n = documentList.item(i); 467 NamedNodeMap nnm = n.getAttributes(); 468 Node nid = nnm.getNamedItem("nodeID"); 469 Node nscore = nnm.getNamedItem("rank"); 470 String docID = nid.getFirstChild().getNodeValue(); 471 472 QueryContext queryContext = new QueryContext(firstDoc + i, nscore 473 .getFirstChild().getNodeValue(), q); 474 if (allResults.containsKey(docID)) { 475 ResultDocument resultDocument = (ResultDocument) allResults 476 .get(docID); 477 resultDocument.incrementFrequencyReturned(); 478 resultDocument.addQueryContext(queryContext); 479 allResults.put(docID, resultDocument); 480 } else { 481 ResultDocument resultDocument = new ResultDocument(); 482 resultDocument.addQueryContext(queryContext); 483 allResults.put(docID, resultDocument); 484 } 485 } 486 return queryOutcome; 427 428 429 430 431 432 433 434 435 436 437 return null; 438 439 // DOMParser p = new DOMParser(); 440 // 441 // try { 442 // p.parse(is); 443 // } catch (SAXException se) { 444 // System.err.println(se); 445 // } catch (IOException ioe) { 446 // System.err.println(ioe); 447 // } 448 // Document d = p.getDocument(); 449 // NodeList metadataList = d.getElementsByTagName("metadata"); 450 // for (int i = 0; i < metadataList.getLength(); i++) { 451 // Node n = metadataList.item(i); 452 // NamedNodeMap nnm = n.getAttributes(); 453 // Node att = nnm.getNamedItem("name"); 454 // if (att.getNodeValue().compareTo("numDocsMatched") == 0) { 455 // queryOutcome.setHowManyDocsMatched(n.getFirstChild() 456 // .getNodeValue()); 457 // } else if (att.getNodeValue().compareTo("numDocsReturned") == 0) { 458 // queryOutcome.setHowManyDocsReturned(n.getFirstChild() 459 // .getNodeValue()); 460 // } 461 // } 462 // 463 // NodeList documentList = d.getElementsByTagName("documentNode"); 464 // for (int i = 0; i < documentList.getLength(); i++) { 465 // Node n = documentList.item(i); 466 // NamedNodeMap nnm = n.getAttributes(); 467 // Node nid = nnm.getNamedItem("nodeID"); 468 // Node nscore = nnm.getNamedItem("rank"); 469 // String docID = nid.getFirstChild().getNodeValue(); 470 // queryOutcome.addResult(docID, firstDoc + i, nscore.getFirstChild() 471 // .getNodeValue()); 472 // } 473 // query.addQueryOutcome(queryOutcome); 474 // Query q = (Query) query.clone(); 475 // queryList.add(q); 476 // 477 // for (int i = 0; i < documentList.getLength(); i++) { 478 // Node n = documentList.item(i); 479 // NamedNodeMap nnm = n.getAttributes(); 480 // Node nid = nnm.getNamedItem("nodeID"); 481 // Node nscore = nnm.getNamedItem("rank"); 482 // String docID = nid.getFirstChild().getNodeValue(); 483 // 484 // QueryContext queryContext = new QueryContext(firstDoc + i, nscore 485 // .getFirstChild().getNodeValue(), q); 486 // if (allResults.containsKey(docID)) { 487 // ResultDocument resultDocument = (ResultDocument) allResults 488 // .get(docID); 489 // resultDocument.incrementFrequencyReturned(); 490 // resultDocument.addQueryContext(queryContext); 491 // allResults.put(docID, resultDocument); 492 // } else { 493 // ResultDocument resultDocument = new ResultDocument(); 494 // resultDocument.addQueryContext(queryContext); 495 // allResults.put(docID, resultDocument); 496 // } 497 // } 498 // return queryOutcome; 487 499 } 488 500 … … 554 566 StringReader sr = new StringReader(result); 555 567 InputSource is = new InputSource(sr); 556 DOMParser p = new DOMParser();557 try {558 p.parse(is);568 //DOMParser p = new DOMParser(); 569 /* try { 570 //p.parse(is); 559 571 } catch (SAXException se) { 560 572 System.err.println(se); 561 573 } catch (IOException ioe) { 562 574 System.err.println(ioe); 563 } 564 Document d = p.getDocument(); 575 }*/ 576 //Document d = p.getDocument(); 577 Document d = null; 565 578 NodeList metadataList = d.getElementsByTagName("metadata"); 566 579 String metadataval = null; … … 690 703 StringReader sr = new StringReader(result); 691 704 InputSource is = new InputSource(sr); 692 DOMParser p = new DOMParser();693 try {694 p.parse(is);695 } catch (SAXException se) {696 System.err.println(se);697 } catch (IOException ioe) {698 System.err.println(ioe);699 }705 // DOMParser p = new DOMParser(); 706 // try { 707 // p.parse(is); 708 // } catch (SAXException se) { 709 // System.err.println(se); 710 // } catch (IOException ioe) { 711 // System.err.println(ioe); 712 // } 700 713 701 714 String returnName = null; 702 715 703 Document d = p.getDocument(); 716 //Document d = p.getDocument(); 717 Document d = null; 704 718 NodeList metadataList = d.getElementsByTagName("metadata"); 705 719 for (int i = 0; i < metadataList.getLength(); i++) { … … 736 750 StringReader sr = new StringReader(result); 737 751 InputSource is = new InputSource(sr); 738 DOMParser p = new DOMParser();739 try {740 p.parse(is);741 } catch (SAXException se) {742 System.err.println(se);743 } catch (IOException ioe) {744 System.err.println(ioe);745 }746 Document d = p.getDocument();747 752 // DOMParser p = new DOMParser(); 753 // try { 754 // p.parse(is); 755 // } catch (SAXException se) { 756 // System.err.println(se); 757 // } catch (IOException ioe) { 758 // System.err.println(ioe); 759 // } 760 // Document d = p.getDocument(); 761 Document d = null; 748 762 NodeList childList = d.getElementsByTagName("classifierNode"); 749 763 NodeList documentList = d.getElementsByTagName("documentNode"); -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r348 r352 2543 2543 2544 2544 return remain; 2545 } else if (mergee instanceof WidgetCorner 2546 || mergee instanceof WidgetEdge) { 2545 } else if (mergee instanceof WidgetCorner) { 2547 2546 if (merger.size() == 1 && txt.getLink() != null) { 2548 2547 // If the text item is linked then use that 2549 mergee.setLink(txt.getAbsoluteLink()); 2548 ((WidgetCorner)mergee).setLink(txt.getAbsoluteLink(), txt); 2549 } else { 2550 remain.addAll(merger); 2551 } 2552 return remain; 2553 } else if (mergee instanceof WidgetEdge) { 2554 if (merger.size() == 1 && txt.getLink() != null) { 2555 // If the text item is linked then use that 2556 ((WidgetEdge)mergee).setLink(txt.getAbsoluteLink(), txt); 2550 2557 } else { 2551 2558 remain.addAll(merger); -
trunk/src/org/expeditee/items/widgets/DataFrameWidget.java
r313 r352 108 108 109 109 @Override 110 public void setLink(String link ) {110 public void setLink(String link, Text linker) { 111 111 String newLink = Item.convertToAbsoluteLink(link); 112 112 String oldLink = getSource().getAbsoluteLink(); … … 114 114 || (newLink != null && newLink.equals(oldLink))) 115 115 return; 116 super.setLink(link );116 super.setLink(link, linker); 117 117 clearSubjects(); 118 118 setDataFrame(null); -
trunk/src/org/expeditee/items/widgets/InteractiveWidget.java
r334 r352 899 899 return Math.abs(_d4.getY() - _d1.getY()); 900 900 } 901 902 public Point getPosition() { 903 return new Point(getX(), getY()); 904 } 901 905 902 906 /** … … 1549 1553 * 1550 1554 * @param link 1551 * The new frame link. Can be null (for no link) 1552 * 1553 */ 1554 public void setLink(String link) { 1555 * The new frame link. Can be null (for no link) 1556 * 1557 * @param linker 1558 * The text item creating the link. Null if not created from 1559 * a text item. 1560 */ 1561 public void setLink(String link, Text linker) { 1555 1562 // Make sure the link is redrawn when a link is added 1556 1563 if (link == null) -
trunk/src/org/expeditee/items/widgets/WidgetCorner.java
r320 r352 8 8 import org.expeditee.items.Dot; 9 9 import org.expeditee.items.ItemParentStateChangedEvent; 10 import org.expeditee.items.Text; 10 11 11 12 public class WidgetCorner extends Dot { … … 170 171 @Override 171 172 public void setLink(String link) { 172 _widgetSource.setLink(link); 173 _widgetSource.setLink(link, null); 174 } 175 176 /** 177 * @param link 178 * The new frame link. Can be null (for no link) 179 * 180 * @param linker 181 * The text item creating the link. Null if not created from 182 * a text item. 183 */ 184 public void setLink(String link, Text linker) { 185 _widgetSource.setLink(link, linker); 173 186 } 174 187 -
trunk/src/org/expeditee/items/widgets/WidgetEdge.java
r320 r352 7 7 import org.expeditee.items.Item; 8 8 import org.expeditee.items.Line; 9 import org.expeditee.items.Text; 9 10 10 11 /** … … 136 137 } 137 138 138 139 @Override 139 140 public void setLink(String link) { 140 _widgetSource.setLink(link); 141 _widgetSource.setLink(link, null); 142 } 143 144 /** 145 * @param link 146 * The new frame link. Can be null (for no link) 147 * 148 * @param linker 149 * The text item creating the link. Null if not created from 150 * a text item. 151 */ 152 public void setLink(String link, Text linker) { 153 _widgetSource.setLink(link, linker); 141 154 } 142 155 -
trunk/src_apollo/org/apollo/AudioFrameMouseActions.java
r344 r352 60 60 FrameMouseActions.MouseY = e.getY(); 61 61 62 } else if (e.isShiftDown() && 62 } else if (e.isShiftDown() && !AudioFrameKeyboardActions.isControlDown && 63 63 !FreeItems.getInstance().isEmpty()) { 64 64 … … 143 143 */ 144 144 public static boolean isYAxisRestictionOn() { 145 return AudioFrameKeyboardActions.isControlDown && AudioFrameKeyboardActions.isShiftDown;145 return AudioFrameKeyboardActions.isControlDown && !AudioFrameKeyboardActions.isShiftDown; 146 146 } 147 147 -
trunk/src_apollo/org/apollo/audio/structure/AudioStructureModel.java
r349 r352 1199 1199 if (odframe != null) { // is loaded? 1200 1200 AbstractTrackGraphNode tinf = odframe.getLinkedTrack(virtualFilename); 1201 assert(tinf != null); // due to the assumption that the model is consistent 1202 if (tinf.getName() != newName) { 1201 if (tinf != null && tinf.getName() != newName) { 1203 1202 tinf.setName(newName); 1204 1203 // Note: a fetch might be waiting on this - i.e in progress. Thus must be cancelled. -
trunk/src_apollo/org/apollo/gui/EditableSampledTrackGraphView.java
r342 r352 133 133 case KeyEvent.VK_RIGHT: 134 134 135 float ftmp = (float)COARSE_PAN_PIXEL_LENGTH / (float)getWidth(); 136 int pan = (int)(getTimeScaleLength() * ftmp); 137 if (pan == 0) pan = 1; 138 139 if (e.getKeyCode() == KeyEvent.VK_RIGHT && 140 (getSampledTrackModel().getSelectionStart() + 141 getSampledTrackModel().getSelectionLength()) < getSampledTrackModel().getFrameCount()) { // RIGHT 142 143 getSampledTrackModel().setSelection(getSampledTrackModel().getSelectionStart() + pan, 144 getSampledTrackModel().getSelectionLength()); 145 146 } else if(e.getKeyCode() == KeyEvent.VK_LEFT && 147 getSampledTrackModel().getSelectionStart() > 0) { // LEFT 148 getSampledTrackModel().setSelection(getSampledTrackModel().getSelectionStart() - pan, 149 getSampledTrackModel().getSelectionLength()); 135 // Select to end of track? 136 if (e.isControlDown()) { 137 if (e.getKeyCode() == KeyEvent.VK_LEFT) { 138 139 int oldStart = getSampledTrackModel().getSelectionStart(); 140 int oldLength = getSampledTrackModel().getSelectionLength(); 141 if (oldLength < 1) oldLength = 1; 142 143 getSampledTrackModel().setSelection(0, oldStart + oldLength); 144 145 } else { // Right 146 147 getSampledTrackModel().setSelection( 148 getSampledTrackModel().getSelectionStart(), 149 getSampledTrackModel().getFrameCount() - getSampledTrackModel().getSelectionStart()); 150 151 } 152 } else { 153 float ftmp = (float)COARSE_PAN_PIXEL_LENGTH / (float)getWidth(); 154 int pan = (int)(getTimeScaleLength() * ftmp); 155 if (pan == 0) pan = 1; 156 157 if (e.getKeyCode() == KeyEvent.VK_RIGHT && 158 (getSampledTrackModel().getSelectionStart() + 159 getSampledTrackModel().getSelectionLength()) < getSampledTrackModel().getFrameCount()) { // RIGHT 160 161 getSampledTrackModel().setSelection(getSampledTrackModel().getSelectionStart() + pan, 162 getSampledTrackModel().getSelectionLength()); 163 164 } else if(e.getKeyCode() == KeyEvent.VK_LEFT && 165 getSampledTrackModel().getSelectionStart() > 0) { // LEFT 166 getSampledTrackModel().setSelection(getSampledTrackModel().getSelectionStart() - pan, 167 getSampledTrackModel().getSelectionLength()); 168 } 150 169 } 151 170 break; -
trunk/src_apollo/org/apollo/gui/FrameRenderPasses.java
r344 r352 15 15 import org.apollo.items.RecordOverdubLauncher; 16 16 import org.apollo.widgets.LinkedTrack; 17 import org.apollo.widgets.SampleRecorder;18 17 import org.apollo.widgets.SampledTrack; 19 18 import org.expeditee.gui.Browser; … … 195 194 196 195 if (iw != null && (iw instanceof SampledTrack || 197 iw instanceof LinkedTrack || iw instanceof SampleRecorder)) {196 iw instanceof LinkedTrack)) { 198 197 199 198 if (seen == null) { -
trunk/src_apollo/org/apollo/items/EmulatedTextItem.java
r344 r352 201 201 (e.getKeyChar() == KeyEvent.VK_DELETE && !emulatedSource.isEmpty()) || 202 202 e.getKeyChar() == KeyEvent.VK_SPACE || 203 e.getKeyChar() == KeyEvent.VK_UNDERSCORE)) { 203 e.getKeyChar() == KeyEvent.VK_UNDERSCORE) || 204 e.getKeyChar() == KeyEvent.VK_AMPERSAND || 205 e.getKeyChar() == KeyEvent.VK_OPEN_BRACKET || 206 e.getKeyChar() == KeyEvent.VK_CLOSE_BRACKET || 207 e.getKeyChar() == KeyEvent.VK_MINUS) { 204 208 205 209 -
trunk/src_apollo/org/apollo/util/Mutable.java
r349 r352 10 10 */ 11 11 public class Mutable { 12 13 12 private static Mutable instance = new Mutable(); 14 13 private Mutable() {} … … 21 20 } 22 21 22 public class Long { 23 public Long(long val) { 24 this.value = val; 25 } 26 public long value; 27 } 28 23 29 public static Integer createMutableInteger(int val) { 24 30 return instance.new Integer(val); 25 31 } 26 32 33 public static Long createMutableLong(long val) { 34 return instance.new Long(val); 35 } 27 36 } -
trunk/src_apollo/org/apollo/widgets/LinkedTrack.java
r349 r352 208 208 209 209 public void keyPressed(KeyEvent e) { 210 if ( state != PLAYING && state != STOPPED) return;210 if ((state != PLAYING && state != STOPPED) || e.isControlDown()) return; 211 211 if (nameLabel.onKeyPressed(e, _swingComponent)) { 212 212 e.consume(); … … 216 216 217 217 public void keyReleased(KeyEvent e) { 218 if ( state != PLAYING && state != STOPPED) return;218 if ((state != PLAYING && state != STOPPED) || e.isControlDown()) return; 219 219 if (nameLabel.onKeyReleased(e, _swingComponent)) { 220 220 e.consume(); … … 771 771 */ 772 772 @Override 773 public void setLink(String link ) {773 public void setLink(String link, Text linker) { 774 774 775 775 String oldABSLink = getAbsoluteLink(); 776 776 777 super.setLink(link );777 super.setLink(link, linker); 778 778 779 779 String newABSLink = getAbsoluteLink(); … … 789 789 parentName); 790 790 791 792 791 // And adding a new one (if applicable) 793 792 if (parent != null && newABSLink != null) { … … 798 797 799 798 if (initTime == null) initTime = 0L; 799 800 String newName = (linker != null && linker.getText() != null) ? linker.getText() : getName(); 801 if (newName != getName()) { 802 setName(newName); 803 } 800 804 801 805 AudioStructureModel.getInstance().onLinkedTrackWidgetAnchored( … … 804 808 initTime, // TODO: Revise: actually would be better to get from model .. if possible 805 809 newABSLink, 806 getName(),810 newName, 807 811 getY()); 808 812 -
trunk/src_apollo/org/apollo/widgets/SampledTrack.java
r349 r352 63 63 import org.expeditee.gui.Frame; 64 64 import org.expeditee.gui.FrameGraphics; 65 import org.expeditee.gui.FrameIO; 65 66 import org.expeditee.gui.MouseEventRouter; 66 67 import org.expeditee.gui.PopupManager; … … 393 394 394 395 public void keyPressed(KeyEvent e) { 395 if ( nameLabel != null) {396 if (!e.isControlDown() && nameLabel != null) { 396 397 if (nameLabel.onKeyPressed(e, fulltrackView)) { 397 398 e.consume(); … … 401 402 402 403 public void keyReleased(KeyEvent e) { 403 if ( nameLabel != null) {404 if (!e.isControlDown() && nameLabel != null) { 404 405 if (nameLabel.onKeyReleased(e, fulltrackView)) { 405 406 e.consume(); … … 414 415 415 416 // Delete-and-Split audio command 416 if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_DELETE) {417 else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_DELETE) { 417 418 418 419 // First is selection valid? … … 481 482 482 483 } 484 // Convert to linked track 485 else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_L) { 486 487 Frame current = DisplayIO.getCurrentFrame(); 488 489 if (current != null) { 490 491 String name = getName(); 492 if (name == null) name = "Unamed"; 493 494 long initTime = getInitiationTimeFromMeta(); 495 496 Text linkSource = new Text(current.getNextItemID()); 497 linkSource.addToData(TrackWidgetCommons.META_NAME_TAG + name); 498 linkSource.setPosition(getPosition()); 499 linkSource.setParent(current); 500 LinkedTrack linkedVersion = new LinkedTrack(linkSource, null); 501 502 // Save any changes in the audio - or save for the first time 503 if (trackModel.isAudioModified()) 504 saveWidgetData(); // a little lag is OK .. could make smarter if really need to 505 506 // Create a new frame to hold the track 507 Frame newFrame = FrameIO.CreateNewFrame(SampledTrack.this.getFirstCorner()); 508 509 // Remove track from current frame 510 removeSelf(); 511 512 // Add to new frame 513 newFrame.addAllItems(getItems()); 514 515 // Save changes 516 FrameIO.SaveFrame(newFrame); 517 518 // Link it 519 linkedVersion.setLink(newFrame.getName(), null); 520 521 // Add the new link 522 current.addAllItems(linkedVersion.getItems()); 523 524 // Ensure initiation times are retained to the exact frame... avoiding loss due to resolution 525 linkedVersion.setInitiationTime(initTime); 526 527 528 529 } 530 531 } 483 532 484 533 }
Note:
See TracChangeset
for help on using the changeset viewer.