Example #1
0
  // createericlist with a String signature is used to process a String
  // containing a sequence of GAIGS structures
  // createericlist creates the list of graphics primitives for these snapshot(s).
  // After creating these lists, that are then appended to l, the list of snapshots,
  // Also must return the number of snapshots loaded from the string
  public /*synchronized*/ int createericlist(String structString) {
    int numsnaps = 0;
    if (debug) System.out.println("In create eric " + structString);
    StringTokenizer st = new StringTokenizer(structString, "\r\n");
    while (st.hasMoreTokens()) {
      numsnaps++; // ??
      String tempString;
      LinkedList tempList = new LinkedList();
      StructureType strct;
      tempString = st.nextToken();
      try {
        boolean headers = true;
        while (headers) {
          headers = false;
          if (tempString.toUpperCase().startsWith("VIEW")) {
            tempString = HandleViewParams(tempString, tempList, st);
            headers = true;
          }
          if (tempString.toUpperCase().startsWith("FIBQUESTION ")
              || tempString.toUpperCase().startsWith("MCQUESTION ")
              || tempString.toUpperCase().startsWith("MSQUESTION ")
              || tempString.toUpperCase().startsWith("TFQUESTION ")) {
            tempString = add_a_question(tempString, st);
            headers = true;
          }
        }

        if (tempString.toUpperCase().equals("STARTQUESTIONS")) {
          numsnaps--; // questions don't count as snapshots
          readQuestions(st);
          break;
        }
        // After returning from HandleViewParams, tempString should now contain
        // the line with the structure type and possible additional text height info
        StringTokenizer structLine = new StringTokenizer(tempString, " \t");
        String structType = structLine.nextToken();
        if (debug) System.out.println("About to assign structure" + structType);
        strct = assignStructureType(structType);
        strct.loadTextHeights(structLine, tempList, this);
        strct.loadLinesPerNodeInfo(st, tempList, this);

        strct.loadTitle(st, tempList, this);
        strct.loadStructure(st, tempList, this);
        strct.calcDimsAndStartPts(tempList, this);
        strct.drawTitle(tempList, this);
        strct.drawStructure(tempList, this);
      } catch (VisualizerLoadException e) {
        System.out.println(e.toString());
      }
      //             // You've just created a snapshot.  Need to insure that "**" is appended
      //             // to the URLList for this snapshot IF no VIEW ALGO line was parsed in the
      //             // string for the snapshot.  This could probably best be done in the
      //             // HandleViewParams method
      list_of_snapshots.append(tempList);
      Snaps++;
    }
    return (numsnaps);
  } // createericlist(string)
Example #2
0
  public int createericlist(Element snap) {
    int numsnaps = 0;

    StructureCollection structs = new StructureCollection();
    LinkedList tempList = new LinkedList();

    try {
      load_snap_from_xml(snap, structs, tempList);

      structs.calcDimsAndStartPts(tempList, this);
      structs.drawTitle(tempList, this);
      structs.drawStructure(tempList, this);

    } catch (VisualizerLoadException e) {
      System.out.println(e.toString());
    }

    list_of_snapshots.append(tempList);
    Snaps++;

    return numsnaps; // this.. isnt used, and isnt what it says it is.
  } // createericlist(element)
Example #3
0
 public void next() {
   hasNext = it.next();
   oneItRanges.clear();
   oneItRanges.addAll(it.ranges);
   oneItY = it.y;
 }
Example #4
0
  // Although it presently returns a boolean, that was only needed
  // during my aborted attempted at animated graphics primitives.
  // Until those become a reality the boolean value returned by this
  // routine is unnecessary
  public boolean animate(int sAt, boolean forward) {

    int x;
    LinkedList lt = null;
    animation_done =
        true; // May be re-set in paintComponent via indirect paintImmediately call at end

    // Was used in aborted attempted to
    // introduce animated primitives.  Now
    // it's probably excess baggage that
    // remains because I still have hopes
    // of eventually having animated
    // primitives

    if (getSize().width != 0 && getSize().height != 0) {
      my_width = getSize().width; // set dimensions
      my_height = getSize().height;
    } else {
      my_width = GaigsAV.preferred_width; // set dimensions
      my_height = GaigsAV.preferred_height;
    }

    // First capture the new image in a buffer called image2
    SnapAt = sAt;
    BufferedImage image2 = new BufferedImage(my_width, my_height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = (Graphics2D) image2.getGraphics(); // need a separate object each time?
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(Color.WHITE);
    g2.fillRect(0, 0, my_width, my_height);
    // Set horizoff and vertoff to properly center the visualization in the
    // viewing window. This is not quite perfect because visualizations
    // that are not properly centered within their [0,1] localized
    // coordinates will not be perfectly centered, but it is much better
    // than it was previously.

    if (no_mouse_drag) {
      horizoff = (my_width - GaigsAV.preferred_width) / 2;
      vertoff = (my_height - GaigsAV.preferred_height) / 2;
    }

    list_of_snapshots.reset();
    x = 0;
    lt = new LinkedList();
    while (x < SnapAt && list_of_snapshots.hasMoreElements()) {
      lt = (LinkedList) list_of_snapshots.nextElement();
      x++;
    }
    lt.reset();
    animation_done = true;
    //        System.out.println("before loop " + horizoff);
    while (lt.hasMoreElements()) {
      obj tempObj = (obj) lt.nextElement();
      animation_done =
          animation_done && (tempObj.execute(g2 /*offscreen*/, zoom, vertoff, horizoff));
      //  System.out.println("in loop");
    }

    // Next capture the image we are coming from in a buffer called image1
    SnapAt = (forward ? sAt - 1 : sAt + 1);
    BufferedImage image1 = new BufferedImage(my_width, my_height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g1 = (Graphics2D) image1.getGraphics(); // need a separate object each time?
    g1.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g1.setColor(Color.WHITE);
    g1.fillRect(0, 0, my_width, my_height);
    // Set horizoff and vertoff to properly center the visualization in the
    // viewing window. This is not quite perfect because visualizations
    // that are not properly centered within their [0,1] localized
    // coordinates will not be perfectly centered, but it is much better
    // than it was previously.

    if (no_mouse_drag) {
      horizoff = (my_width - GaigsAV.preferred_width) / 2;
      vertoff = (my_height - GaigsAV.preferred_height) / 2;
    }

    list_of_snapshots.reset();
    x = 0;
    lt = new LinkedList();
    while (x < SnapAt && list_of_snapshots.hasMoreElements()) {
      lt = (LinkedList) list_of_snapshots.nextElement();
      x++;
    }
    lt.reset();
    animation_done = true;
    //        System.out.println("before loop " + horizoff);
    while (lt.hasMoreElements()) {
      obj tempObj = (obj) lt.nextElement();
      animation_done =
          animation_done && (tempObj.execute(g1 /*offscreen*/, zoom, vertoff, horizoff));
      //  System.out.println("in loop");
    }

    // Now slide from image1 to image2

    // From the gaff Visualizer by Chris Gaffney
    //        double step = 4;	// Adjust this for more/less granularity between images
    double step = 40; // Adjust this for more/less granularity between images

    Image buffer = getGraphicsConfiguration().createCompatibleVolatileImage(my_width, my_height);
    Graphics2D g2d = (Graphics2D) buffer.getGraphics();

    AffineTransform trans = AffineTransform.getTranslateInstance(step * (forward ? -1 : 1), 0);
    //        AffineTransform orig = g2d.getTransform();

    Shape mask = createMask(my_width, my_height);

    for (double i = 0; i < my_width; i += step) {
      if (i + step > my_width) // last time through loop, so adjust transform
      trans =
            AffineTransform.getTranslateInstance(((double) (my_width - i)) * (forward ? -1 : 1), 0);
      g2d.transform(trans);
      g2d.drawImage(image1, 0, 0, this);
      g2d.setColor(Color.BLACK);
      g2d.fill(mask);

      AffineTransform last = g2d.getTransform();
      g2d.transform(AffineTransform.getTranslateInstance(my_width * (-1 * (forward ? -1 : 1)), 0));
      g2d.drawImage(image2, 0, 0, this);
      g2d.setColor(Color.BLACK);
      g2d.fill(mask);

      g2d.setTransform(last);

      this.my_image = buffer;
      repaint();

      try {
        Thread.sleep(10);
      } catch (InterruptedException e) {

      }
    }
    Image b = getGraphicsConfiguration().createCompatibleImage(my_width, my_height);
    b.getGraphics().drawImage(buffer, 0, 0, null);
    this.my_image = b;

    return animation_done;
  }
Example #5
0
  // Although it presently returns a boolean, that was only needed
  // during my aborted attempted at animated graphics primitives.
  // Until those become a reality the boolean value returned by this
  // routine is unnecessary
  public /*synchronized*/ boolean execute(int sAt) {

    // The commented-out variables below are remnants from legacy
    // code -- they appear to be no longer needed.

    //         String urlTemp="";
    //         int z=0;
    //         int idx;
    //         int urlid;
    //         boolean showURL=false;
    animation_done =
        true; // May be re-set in paintComponent via indirect paintImmediately call at end

    // Was used in abored attempted to
    // introduce animated primitives.  Now
    // it's probably excess baggage that
    // remains because I still have hopes
    // of eventually having animated
    // primitives
    SnapAt = sAt;

    if (getSize().width != 0 && getSize().height != 0) {
      my_width = getSize().width; // set dimensions
      my_height = getSize().height;
    } else {
      my_width = GaigsAV.preferred_width; // set dimensions
      my_height = GaigsAV.preferred_height;
    }
    BufferedImage buff = new BufferedImage(my_width, my_height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = (Graphics2D) buff.getGraphics(); // need a separate object each time?
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(Color.WHITE);
    g2.fillRect(0, 0, my_width, my_height);
    // Set horizoff and vertoff to properly center the visualization in the
    // viewing window. This is not quite perfect because visualizations
    // that are not properly centered within their [0,1] localized
    // coordinates will not be perfectly centered, but it is much better
    // than it was previously.

    // 	if(no_mouse_drag){
    // 	    if(first_paint_call){
    // // 		horizoff = (my_width - (int)(0.25 * my_width) -
    // // 			    GaigsAV.preferred_width) / 2;
    // 		horizoff = (my_width - GaigsAV.preferred_width) / 2;
    // 		first_paint_call = false;
    // 	    }else{
    // 		horizoff = (my_width - GaigsAV.preferred_width) / 2;
    // 		no_mouse_drag = false;
    // 	    }
    // 	}

    if (no_mouse_drag) {
      horizoff = (my_width - GaigsAV.preferred_width) / 2;
      vertoff = (my_height - GaigsAV.preferred_height) / 2;
    }

    int x;

    list_of_snapshots.reset();
    x = 0;
    LinkedList lt = new LinkedList();
    while (x < SnapAt && list_of_snapshots.hasMoreElements()) {
      lt = (LinkedList) list_of_snapshots.nextElement();
      x++;
    }
    lt.reset();
    animation_done = true;
    //        System.out.println("before loop " + horizoff);
    while (lt.hasMoreElements()) {
      obj tempObj = (obj) lt.nextElement();
      animation_done =
          animation_done && (tempObj.execute(g2 /*offscreen*/, zoom, vertoff, horizoff));
      //  System.out.println("in loop");
    }

    Shape mask = createMask(buff.getWidth(), buff.getHeight());

    g2.setColor(Color.BLACK);
    g2.fill(mask);

    my_image = buff;
    repaint();

    return animation_done;
  }