Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mine.test;
- public class DataTask implements Runnable{
- private int sleepTime = 300; //In milliseconds
- private int division;
- private int end;
- private int start;
- private Test test;
- //Am drawing a parabola here... so I need the x-values.
- public DataTask( int start, int end, int division, Test test ) {
- this.start = start;
- this.end = end;
- this.division = division;
- this.test = test;
- }
- @Override
- public void run() {
- try {
- int count = ( end - start ) / division; //am interested only on the integer part
- for( int i = 0; i < count; i++ )
- {
- int xValue = start + division * i;
- int yValue = ( int )Math.pow( xValue , 2 );
- test.dataset.add( xValue , start + 0.0, end + 0.0, yValue);
- Thread.sleep( sleepTime );
- }
- }catch( InterruptedException ex ) {
- ex.printStackTrace();
- }
- }
- public void setSleepTime( int sleepTime )
- {
- this.sleepTime = sleepTime;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement