/** * 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; }
/** * {@inheritDoc} */ @Override public Cursor clone() { try { final Cursor result = ( Cursor )super.clone(); if ( isDefined() ) { result.setTimestamp( this.timestamp.longValue() ); } if ( hasLabel() ) { result.setLabel( new String( this.label ) ); } result.setColor( this.color ); return result; } catch ( CloneNotSupportedException exception ) { throw new RuntimeException( "Internal error: Object#clone() not supported?!" ); } }
/** * @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 ); } }
/** * @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 EditCursorLabelAction.EditCursorDialog instance. */ public EditCursorDialog( final Window aParent, final Cursor aCursor ) { super( aParent, ModalityType.APPLICATION_MODAL ); setResizable( false ); this.defaultLabel = aCursor.getLabel(); this.defaultColor = aCursor.getColor(); initDialog( aCursor ); }
if ( !aCursor.isDefined() ) final double timestamp = this.model.getTimestamp( aCursor.getTimestamp() ); Integer index = Integer.valueOf( aCursor.getIndex() + 1 ); String label = aCursor.getLabel(); if ( !aCursor.hasLabel() )
/** * 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() ); }
@Override public int compare( final Cursor aCursor1, final Cursor aCursor2 ) { return ( int )( aCursor1.getTimestamp() - aCursor2.getTimestamp() ); } }
/** * {@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(); }
/** * {@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()] ); }
/** * Sets a cursor position. * * @param aCursorIdx * the index of the cursor to set, should be >= 0 and < 10; * @param aCursorPosition * the actual cursor position to set. * @throws IllegalArgumentException * in case an invalid cursor index was given. */ public void setCursorPosition( final int aCursorIdx, final Long aCursorPosition ) throws IllegalArgumentException { if ( ( aCursorIdx < 0 ) || ( aCursorIdx > ( Ols.MAX_CURSORS - 1 ) ) ) { throw new IllegalArgumentException( "Invalid cursor index! Should be between 0 and " + Ols.MAX_CURSORS ); } final Cursor[] cursorPositions = getCursors(); if ( cursorPositions != null ) { if ( ( aCursorPosition == null ) || ( aCursorPosition.longValue() == Long.MIN_VALUE ) ) { cursorPositions[aCursorIdx].clear(); } else { cursorPositions[aCursorIdx].setTimestamp( aCursorPosition.longValue() ); } } }
/** * {@inheritDoc} */ public void setCursor( final int aCursorIdx, final long aTimestamp ) { Cursor[] cursors = this.dataSet.getCursors(); if ( ( aCursorIdx < 0 ) || ( aCursorIdx > cursors.length ) ) { throw new IllegalArgumentException( "Invalid cursor index!" ); } final Cursor cursor = cursors[aCursorIdx]; final Cursor oldCursor = cursor.clone(); // Update the time stamp of the cursor... cursor.setTimestamp( aTimestamp ); fireCursorChangeEvent( ICursorChangeListener.PROPERTY_TIMESTAMP, oldCursor, cursor ); }
if ( value > Long.MIN_VALUE ) tempDataSet.getCursor( 0 ).setTimestamp( value ); if ( value > Long.MIN_VALUE ) tempDataSet.getCursor( 1 ).setTimestamp( value ); if ( pos > Long.MIN_VALUE ) tempDataSet.getCursor( idx ).setTimestamp( pos );
/** * Returns the color for a cursor with the given index. * * @param aCursorIdx * the index of the cursor to retrieve the color for; * @param aColor * the color to set, cannot be <code>null</code>. * @return a cursor color, never <code>null</code>. */ public void setCursorColor( final int aCursorIdx, final Color aColor ) { Cursor[] cursors = this.dataSet.getCursors(); if ( ( aCursorIdx < 0 ) || ( aCursorIdx > cursors.length ) ) { throw new IllegalArgumentException( "Invalid cursor index!" ); } final Cursor cursor = cursors[aCursorIdx]; final Cursor oldCursor = cursor.clone(); // Update the color of the cursor... cursor.setColor( aColor ); fireCursorChangeEvent( ICursorChangeListener.PROPERTY_COLOR, oldCursor, cursor ); }
/** * Returns the color for a cursor with the given index. * * @param aCursorIdx * the index of the cursor to retrieve the color for; * @param aLabel * the label to set, cannot be <code>null</code>. * @return a cursor color, never <code>null</code>. */ public void setCursorLabel( final int aCursorIdx, final String aLabel ) { Cursor[] cursors = this.dataSet.getCursors(); if ( ( aCursorIdx < 0 ) || ( aCursorIdx > cursors.length ) ) { throw new IllegalArgumentException( "Invalid cursor index!" ); } final Cursor cursor = cursors[aCursorIdx]; final Cursor oldCursor = cursor.clone(); // Update the label of the cursor... cursor.setLabel( aLabel ); fireCursorChangeEvent( ICursorChangeListener.PROPERTY_LABEL, oldCursor, cursor ); }
/** * Creates a new DeleteCursorAction instance. */ public DeleteCursorAction( final SignalDiagramController aController, final Cursor aCursor ) { super( "Delete cursor " + ( aCursor.getIndex() + 1 ) ); this.controller = aController; this.cursorIdx = aCursor.getIndex(); putValue( ACCELERATOR_KEY, SwingComponentUtils.createKeyMask( KeyEvent.VK_DELETE ) ); }
/** * Returns the color for a cursor with the given index. * * @param aCursorIndex * the index of the cursor to retrieve the color for. * @return a cursor color, never <code>null</code>. */ public Color getCursorColor( final int aCursorIndex ) { final Cursor cursor = getSignalDiagramModel().getCursor( aCursorIndex ); return cursor.getColor(); }
String label = "" + ( cursor.getIndex() + 1 ); if ( cursor.hasLabel() ) label = label.concat( ", " ).concat( cursor.getLabel() ); ClickableLink link = new ClickableLink( linkText, Long.valueOf( cursor.getTimestamp() ) ); link.setLinkListener( CursorDetailsView.this ); link.setEnabled( cursorsEnabled );
/** * 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() ); }
/** * Creates a new {@link SignalMeasurerWorker} instance. * * @param aChannel * the channel to measure; * @param aCursorA * the cursor denoting the start of measurement; * @param aCursorB * the cursor denoting the end of measurement. */ public SignalMeasurerWorker( final Channel aChannel, final Cursor aCursorA, final Cursor aCursorB ) { this.index = aChannel.getIndex(); this.startTimestamp = aCursorA != null ? aCursorA.getTimestamp() : -1L; this.endTimestamp = aCursorB != null ? aCursorB.getTimestamp() : -1L; }