示例#1
0
  /**
   * Creates the tool context denoting the range of samples that should be analysed by a tool.
   *
   * @return a tool context, never <code>null</code>.
   */
  private ToolContext createToolContext() {
    int startOfDecode = -1;
    int endOfDecode = -1;

    final int dataLength = this.dataContainer.getValues().length;
    if (this.dataContainer.isCursorsEnabled()) {
      if (this.dataContainer.isCursorPositionSet(0)) {
        final Long cursor1 = this.dataContainer.getCursorPosition(0);
        startOfDecode = this.dataContainer.getSampleIndex(cursor1.longValue()) - 1;
      }
      if (this.dataContainer.isCursorPositionSet(1)) {
        final Long cursor2 = this.dataContainer.getCursorPosition(1);
        endOfDecode = this.dataContainer.getSampleIndex(cursor2.longValue()) + 1;
      }
    } else {
      startOfDecode = 0;
      endOfDecode = dataLength;
    }

    startOfDecode = Math.max(0, startOfDecode);
    if ((endOfDecode < 0) || (endOfDecode >= dataLength)) {
      endOfDecode = dataLength - 1;
    }

    return new DefaultToolContext(startOfDecode, endOfDecode);
  }
示例#2
0
 /**
  * Goes to the current cursor position of the cursor with the given index.
  *
  * @param aCursorIdx the index of the cursor to go to, >= 0 && < 10.
  */
 public void gotoCursorPosition(final int aCursorIdx) {
   if ((this.mainFrame != null) && this.dataContainer.isCursorsEnabled()) {
     final Long cursorPosition = this.dataContainer.getCursorPosition(aCursorIdx);
     if (cursorPosition != null) {
       this.mainFrame.gotoPosition(cursorPosition.longValue());
     }
   }
 }
示例#3
0
 /** Goes to the current cursor position of the last available cursor. */
 public void gotoLastAvailableCursor() {
   if ((this.mainFrame != null) && this.dataContainer.isCursorsEnabled()) {
     for (int c = CapturedData.MAX_CURSORS - 1; c >= 0; c--) {
       if (this.dataContainer.isCursorPositionSet(c)) {
         final Long cursorPosition = this.dataContainer.getCursorPosition(c);
         if (cursorPosition != null) {
           this.mainFrame.gotoPosition(cursorPosition.longValue());
         }
         break;
       }
     }
   }
 }
示例#4
0
  /**
   * Sets the cursor position of the cursor with the given index.
   *
   * @param aCursorIdx the index of the cursor to set, >= 0 && < 10;
   * @param aLocation the mouse location on screen where the cursor should become, cannot be <code>
   *     null</code>.
   */
  public void setCursorPosition(final int aCursorIdx, final Point aLocation) {
    // Implicitly enable cursor mode, the user already had made its
    // intensions clear that he want to have this by opening up the
    // context menu anyway...
    setCursorMode(true);

    if (this.mainFrame != null) {
      // Convert the mouse-position to a sample index...
      final long sampleIdx = this.mainFrame.convertMousePositionToSampleIndex(aLocation);

      this.dataContainer.setCursorPosition(aCursorIdx, Long.valueOf(sampleIdx));

      fireCursorChangedEvent(aCursorIdx, aLocation.x);
    }

    updateActions();
  }