Esempio n. 1
0
  /**
   * fileReader builds a scene from a file
   *
   * @return sceneOfInput
   * @throws IOException
   */
  public static Scene fileReader() throws IOException {
    long startTime = System.currentTimeMillis();

    //		FileReader fr = new FileReader("file/LogManager-short.dat");
    FileReader fr = new FileReader("file/LogManager-live-tool-2.dat");
    //		FileReader fr = new FileReader("file/LogManager-example.dat");
    //		FileReader fr = new FileReader("file/LogManager-long.dat");
    BufferedReader br = new BufferedReader(fr);

    String line = "";
    List<Tick> tmpTickList = new ArrayList<Tick>();

    /*
     * Read file, split lines into Type and Timestamp, generate Ticks
     */
    while ((line = br.readLine()) != null) {

      String[] parts = line.split(";", -1);
      int tmpTimestamp = Integer.parseInt(parts[0]);
      Tick tmpTick = new Tick(tmpTimestamp, parts[1], parts[2]);
      tmpTickList.add(tmpTick);
    }
    br.close();
    /*
     * filtering out special hashmarks and adding their content to mark before
     */
    int lastHashMark = 0;
    for (int i = 0; i < tmpTickList.size(); i++) {
      Tick currentTick = tmpTickList.get(i);

      if (currentTick.getType().compareTo("########") == 0) {

        lastHashMark = i;

      } else if (currentTick.getType().compareTo("#+#+#+#+") == 0) {

        if (lastHashMark == 0) { // if first mark is special hash

          tmpTickList.remove(i); // remove it

        } else {

          tmpTickList.remove(lastHashMark); // otherwise remove last normal hash
          currentTick.setType("########"); // and convert special to normal hash
          // thus adding special object to normal
          lastHashMark = i - 1; // set new hashmark
        }
      }
    }
    List<Sequence> sequenceList = structureCreator(tmpTickList);

    Sequence[] sequenceArray = new Sequence[sequenceList.size()];
    sequenceArray = sequenceList.toArray(sequenceArray);

    Scene sceneFromInput = new Scene(sequenceArray);

    System.out.println((System.currentTimeMillis() - startTime) + " milliseconds to read log");
    return sceneFromInput;
  }
Esempio n. 2
0
    public int compareTo(Object otherTick) {
      if (!(otherTick instanceof Tick)) {
        throw new ClassCastException("Not a valid Tick object!");
      }

      Tick tempTick = (Tick) otherTick;

      if (this.getTimeStamp() > tempTick.getTimeStamp()) {
        return 1;
      } else if (this.getTimeStamp() < tempTick.getTimeStamp()) {
        return -1;
      } else {
        return 0;
      }
    }
Esempio n. 3
0
      // displays the timeline box and the ticks.
      public void display() {
        noStroke();
        fill(204);
        // timeline
        rect(xpos, ypos, swidth, sheight);
        if (over || locked) {
          fill(0, 0, 0);
        } else {
          fill(102, 102, 102);
        }
        // scrubber
        // println(spos);
        rect(spos - sheight / 2, ypos, sheight, sheight);

        for (int i = 0; i < tickArr.size(); i++) {
          tickArr.get(i).displayTick();
        }

        prevTick = null;
        nextTick = null;

        for (int i = 0; i < tickArr.size(); i++) {
          if (tickArr.get(i).getXPos() < spos) {
            prevTick = tickArr.get(i);
          } else {
            break;
          }
        }

        for (int i = 0; i < tickArr.size(); i++) {
          if (tickArr.get(i).getXPos() > spos) {
            nextTick = tickArr.get(i);
            break;
          }
        }

        if (prevTick != null) {
          prevTick.changeCamColorPrev();
        }
        if (nextTick != null) {
          nextTick.changeCamColorNext();
        }
      }
Esempio n. 4
0
  /** @param tmpTickList */
  private static List<Sequence> structureCreator(List<Tick> tmpTickList) {

    /*
     * transform List of Ticks to Frames
     */
    List<Tick> tickList = new ArrayList<Tick>();
    List<Frame> frameList = new ArrayList<Frame>();
    List<Sequence> sequenceList = new ArrayList<Sequence>();

    for (int i = 0; i < tmpTickList.size(); i++) {
      Tick currentTick = tmpTickList.get(i);

      if (currentTick.getType().compareTo("########") == 0) { // currentTick equal to ########
        /*
         * add Frames to frameList
         */
        Tick[] tickArray = new Tick[tickList.size()];
        tickArray = tickList.toArray(tickArray);
        tickList.clear();
        Frame tmpFrame = new Frame(tickArray);
        frameList.add(tmpFrame);

      } else {

        tickList.add(currentTick);
      }
    }

    /*
     * Arrange Frames into Sequences and create a Scene with them
     */
    List<Frame> listOfFrames = new ArrayList<Frame>();

    Frame stopFrame = new Frame();
    listOfFrames.add(frameList.get(0)); // always start the listOfFrames with first frame
    for (int i = 0; i < frameList.size(); i++) {

      Frame frameA = frameList.get(i);
      Frame frameB;
      if (frameList.size() - 1 == i) {
        frameB = stopFrame;
      } else {
        frameB = frameList.get(i + 1);
      }

      if (frameA.equalTo(frameB)) {
        listOfFrames.add(frameB); // add duplicate frames to listOfFrames

      } else {

        int frameSize = frameA.getArrayLength();
        int sequenceLength = listOfFrames.size();
        int[][] timestampArray = new int[sequenceLength][frameSize];

        String[] typeArray = frameA.getConcatenatedTypes();

        for (int j = 0; j < sequenceLength; j++) { // for every Frame on the listOfFrames

          Frame tmpFrame = listOfFrames.get(j); // get the Frame
          timestampArray[j] = tmpFrame.getTimestamps(); // add every Timestamp in this Frame
        }

        Sequence prevSequence;
        if (sequenceList.isEmpty()) {
          prevSequence = new Sequence();
        } else {
          prevSequence = sequenceList.get(sequenceList.size() - 1);
        }
        Sequence tmpSequence =
            new Sequence(
                typeArray, timestampArray, prevSequence); // create Sequence out of Types and Times

        sequenceList.add(tmpSequence); // add Sequence to List

        listOfFrames.clear(); // rinse and repeat
        listOfFrames.add(frameB); // but add FrameB as a startingpoint for the next iteration
      }
    }

    return sequenceList;
  }