Advertisement
Guest User

Untitled

a guest
Nov 18th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. String thisinput = //The original slider input given (before k split it up)
  2.  
  3. public Slider( String input, int numPoints, double sliderX, double beatSpace )
  4.     {
  5.         super( input );
  6.         type = k[on++];
  7.         int oddX, oddY;
  8.  
  9.         //This is where things get confusing.
  10.         //In format 10, merely splitting via : will return bogus numbers.
  11.         //Use thisinput to split numerous times
  12.  
  13.         String[] split = thisinput.split("[|]");
  14.  
  15.         //With these splits pull out the needed information
  16.         //Substring to take the first part out of the slider text since k took care of it
  17.  
  18.         String aftertype = thisinput.substring(split[0].length());
  19.         split = aftertype.split("[|]");
  20.  
  21.         //Now we need to find the first comma, that's the proper split we need.
  22.         for(int i=0;i<split.length;i++)
  23.         {
  24.             //Find first split with a comma in it, that's what is needed.
  25.             if (split[i].indexOf(',')!=-1)
  26.             {
  27.                 aftertype = split[i];
  28.                 break;
  29.             }
  30.         }    
  31.     //Now get the ending x time (I called it oddX since it's only used when repeats are odd)
  32.         split = aftertype.split("[:]");    
  33.         oddX = Integer.parseInt(split[0]);  
  34.         aftertype = split[1];
  35.     //Split it up with commas now. This either has 3 or 4 parts to it (the 4th we can ignore)
  36.         split = aftertype.split("[,]");
  37.         oddY = Integer.parseInt(split[0]);
  38.         repeats = Integer.parseInt(split[1]);
  39.         sliderLength = Double.parseDouble(split[2]);  
  40.         allTimes = new int[repeats + 1];
  41.     //And that's it for the special parsing. Hope this helps!
  42.     //Oh yeah, and the odd repeats check is changed, go look at it. vvvvv
  43.  
  44.         // For now, takes a rounded time, instead of proper calibration
  45.         double timeInterval = ( sliderLength * beatSpace ) / ( 100 * sliderX );
  46.         for ( int i = 0; i < repeats + 1; i++ )
  47.         {
  48.             allTimes[i] = (int)( time + i * timeInterval );
  49.         }
  50.         endTime = allTimes[allTimes.length - 1];
  51.  
  52.         // For now, uses the last node for endX and endY
  53.         if ( repeats % 2 == 0 )
  54.         {
  55.             endX = x;
  56.             endY = y;
  57.         }
  58.         else
  59.         {
  60.         //Using the parsed odd values if repeat count is odd
  61.             endX = oddX;
  62.             endY = oddY;
  63.         }
  64.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement