/** * {@inheritDoc} */ public boolean isCursorDefined( final int aCursorIdx ) { Cursor[] cursors = this.dataSet.getCursors(); if ( ( aCursorIdx < 0 ) || ( aCursorIdx > cursors.length ) ) { throw new IllegalArgumentException( "Invalid cursor index!" ); } return cursors[aCursorIdx].isDefined(); }
/** * Returns whether or not a cursor with the given index is set. * * @param aCursorIdx * the index of the cursor test. * @return <code>true</code> if the cursor with the given index is set, * <code>false</code> otherwise. */ protected boolean isCursorSet( final int aCursorIdx ) { final Cursor cursor = getCursor( aCursorIdx ); if ( cursor == null ) { return false; } return cursor.isDefined(); }
/** * Returns whether or not the cursor with the given index is set. * * @param aCursorIdx * the index of the cursor to check, should be >= 0 and < 10. * @return <code>true</code> if the cursor with the given index is set, * <code>false</code> otherwise. */ public boolean isCursorPositionSet( final int aCursorIdx ) { if ( ( aCursorIdx < 0 ) || ( aCursorIdx > ( Ols.MAX_CURSORS - 1 ) ) ) { throw new IllegalArgumentException( "Invalid cursor index: " + aCursorIdx + "! Should be between 0 and " + Ols.MAX_CURSORS ); } final Cursor[] cursorPositions = getCursors(); if ( cursorPositions == null ) { return false; } return ( cursorPositions[aCursorIdx] != null ) && ( cursorPositions[aCursorIdx].isDefined() ); }
/** * {@inheritDoc} */ @Override protected String[] getMenuItemNames() { final Cursor[] cursors = this.controller.getCurrentDataSet().getCursors(); final List<String> result = new ArrayList<String>(); for ( Cursor cursor : cursors ) { if ( cursor.isDefined() ) { result.add( Integer.toString( cursor.getIndex() ) ); } } return result.toArray( new String[result.size()] ); }
/** * Returns all defined cursors. * * @return an array of defined cursors, never <code>null</code>. */ public Cursor[] getDefinedCursors() { List<Cursor> result = new ArrayList<Cursor>(); if ( hasData() ) { for ( Cursor c : this.dataSet.getCursors() ) { if ( c.isDefined() ) { result.add( c ); } } } return result.toArray( new Cursor[result.size()] ); }
/** * Asserts the cursor with the given index does NOT occur in the captured * data. * * @param aCursorIdx * the index of the cursor that should be unset. */ public void assertCursorUnset( final int aCursorIdx ) { assertNotNull( this.cursors ); assertTrue( this.cursors.length > aCursorIdx ); assertFalse( this.cursors[aCursorIdx].isDefined() ); }
if ( cursors[i].isDefined() )
if ( cursors[i].isDefined() )
/** * @param aOldCursor * @param aCursor */ private void fireCursorChangeEvent( final String aPropertyName, final Cursor aOldCursor, final Cursor aCursor ) { ICursorChangeListener[] listeners = this.eventListeners.getListeners( ICursorChangeListener.class ); for ( ICursorChangeListener listener : listeners ) { if ( !aOldCursor.isDefined() ) { listener.cursorAdded( aCursor ); } else { listener.cursorChanged( aPropertyName, aOldCursor, aCursor ); } } }
/** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed( final ActionEvent aEvent ) { final Cursor[] definedCursors = this.controller.getDefinedCursors(); for ( Cursor cursor : definedCursors ) { if ( ( this.index == cursor.getIndex() ) && cursor.isDefined() ) { this.controller.scrollToTimestamp( cursor.getTimestamp() ); } } }
/** * Creates a new Cursor instance a copy of a given cursor. * * @param aCursor * the cursor to copy, cannot be <code>null</code>. * @param aAbsLen * the absolute length of the data, >= 0L. * @throws IllegalArgumentException * in case the given index was invalid. */ public CursorImpl( final Cursor aCursor, final long aAbsLen ) { this( aCursor.getIndex() ); this.color = aCursor.getColor(); this.label = aCursor.getLabel(); this.timestamp = aCursor.isDefined() && ( aCursor.getTimestamp() <= aAbsLen ) // ? Long.valueOf( aCursor.getTimestamp() ) : null; }
/** * Returns the X-position of the cursor with the given index, for displaying * purposes on screen. * * @param aCursorIdx * the index of the cursor to retrieve the X-position for, >= 0. * @return the screen X-position of the cursor with the given index, or -1 if * the cursor is not defined. */ public int getCursorScreenCoordinate( final int aCursorIndex ) { Cursor cursorTimestamp = getSignalDiagramModel().getCursor( aCursorIndex ); if ( !cursorTimestamp.isDefined() ) { return -1; } return timestampToCoordinate( cursorTimestamp.getTimestamp() ); }
/** * @param aCursorIdx */ public void removeCursor( final int aCursorIdx ) { Cursor[] cursors = this.dataSet.getCursors(); if ( ( aCursorIdx < 0 ) || ( aCursorIdx > cursors.length ) ) { throw new IllegalArgumentException( "Invalid cursor index!" ); } final Cursor cursor = cursors[aCursorIdx]; if ( !cursor.isDefined() ) { // Nothing to do; the cursor is not defined... return; } final Cursor oldCursor = cursor.clone(); cursor.clear(); ICursorChangeListener[] listeners = this.eventListeners.getListeners( ICursorChangeListener.class ); for ( ICursorChangeListener listener : listeners ) { listener.cursorRemoved( oldCursor ); } }
/** * Asserts the cursor with the given index occur in the captured data. * * @param aCursorIdx * the index of the cursor to assert; * @param aCursorValue * the expected value of the cursor to assert. */ public void assertCursorSet( final int aCursorIdx, final long aCursorValue ) { assertNotNull( this.cursors ); assertTrue( this.cursors.length > aCursorIdx ); assertTrue( this.cursors[aCursorIdx].isDefined() ); assertEquals( aCursorValue, this.cursors[aCursorIdx].getTimestamp() ); }
if ( !aCursor.isDefined() )