public void zoomIn() {
    Dimension asz = this.getSize();
    int maxzf = 3;
    int coef = 1;
    int r;

    cmdline =
        "/bin/sh get.sh "
            + j2kfilename
            + " "
            + iw
            + " "
            + ih
            + " "
            + rect.x
            + " "
            + rect.y
            + " "
            + rect.width
            + " "
            + rect.height;
    Exec.execPrint(cmdline);

    rect.x = rect.y = rect.width = rect.height = 0;

    img = pgm.open("out.pgm");

    iw = img.getWidth(this);
    ih = img.getHeight(this);
    bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
    big = bi.createGraphics();
    selected = 0;
    fullRefresh = true;
    repaint();
  }
Beispiel #2
0
  public void runNext() throws TestFailException, UnsupportedEncodingException {
    // Get first file and remove it from list
    InputOutput current = inputOutput.remove(0);
    // Create List with only first input in
    List<String> inputFiles = new ArrayList<String>();
    inputFiles.add(null != commonInputFile ? commonInputFile : current.getName() + ".input");
    // Excute Main on that input
    List<String> cmdLine = new ArrayList<String>();
    cmdLine.add("--encoding");
    cmdLine.add(inputFileEncoding);
    classExecResult =
        Exec.execClass(
            className,
            testPath.toString(),
            cmdLine,
            inputFiles,
            Main.jflexTestVersion,
            outputFileEncoding);
    if (Main.verbose) {
      System.out.println("Running scanner on [" + current.getName() + "]");
    }

    // check for output conformance
    File expected = new File(current.getName() + ".output");

    if (expected.exists()) {
      DiffStream check = new DiffStream();
      String diff;
      try {
        diff =
            check.diff(
                jflexDiff,
                new StringReader(classExecResult.getOutput()),
                new InputStreamReader(new FileInputStream(expected), outputFileEncoding));
      } catch (FileNotFoundException e) {
        System.out.println("Error opening file " + expected);
        throw new TestFailException();
      } catch (UnsupportedEncodingException e) {
        System.out.println("Unsupported encoding '" + outputFileEncoding + "'");
        throw new TestFailException();
      }
      if (diff != null) {
        System.out.println("Test failed, unexpected output: " + diff);
        System.out.println("Test output: " + classExecResult.getOutput());
        throw new TestFailException();
      }
    } else {
      System.out.println("Warning: no file for expected output [" + expected + "]");
    }

    // System.out.println(classExecResult);
  }
  public void init() {
    String str;
    int port;

    imgId = 4;
    if (isApplet && (((hostname = this.getParameter("hostname")) == null) || hostname.equals("")))
      hostname = "localhost";
    if (!isApplet || ((str = this.getParameter("cmdPort")) == null)) {
      port = 3000;
    } else {
      port = new Integer(str).intValue();
    }

    this.setSize(512, 512);
    Dimension asz = this.getSize();
    zl.x2 = asz.width;
    zl.y2 = asz.height;

    cmdline =
        "/bin/sh get.sh "
            + j2kfilename
            + " "
            + asz.width
            + " "
            + asz.height
            + " "
            + zl.x1
            + " "
            + zl.y1
            + " "
            + zl.x2
            + " "
            + zl.y2;
    Exec.execPrint(cmdline);
    img = pgm.open("out.pgm");

    iw = img.getWidth(this);
    ih = img.getHeight(this);

    setBackground(Color.black);
    bi = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
    big = bi.createGraphics();
    myMML = new MML(this);
    addMouseListener(myMML);
    addMouseMotionListener(myMML);
  }
Beispiel #4
0
  public void createScanner() throws TestFailException {
    jflexFiles.add((new File(testPath, testName + ".flex")).getPath());
    // invoke JFlex
    jflexResult = Exec.execJFlex(jflexCmdln, jflexFiles);
    // System.out.println(jflexResult);

    if (jflexResult.getSuccess()) {
      // Scanner generation successful
      if (Main.verbose) {
        System.out.println("Scanner generation successful");
      }

      if (expectJFlexFail) {
        System.out.println("JFlex failure expected!");
        throw new TestFailException();
      }

      // check JFlex output conformance
      File expected = new File(testPath, testName + "-flex.output");

      if (expected.exists()) {
        DiffStream check = new DiffStream();
        String diff;
        try {
          diff =
              check.diff(
                  jflexDiff, new StringReader(jflexResult.getOutput()), new FileReader(expected));
        } catch (FileNotFoundException e) {
          System.out.println("Error opening file " + expected);
          throw new TestFailException();
        }
        if (diff != null) {
          System.out.println("Test failed, unexpected jflex output: " + diff);
          System.out.println("JFlex output: " + jflexResult.getOutput());
          throw new TestFailException();
        }
      } else {
        System.out.println("Warning: no file for expected output [" + expected + "]");
      }

      // Compile Scanner
      String toCompile = new File(testPath, className + ".java").getPath();
      if (Main.verbose) {
        System.out.println("File to Compile: " + toCompile);
      }
      javacFiles.add(toCompile);
      javacResult = Exec.execJavac(testPath, Main.jflexTestVersion);

      // System.out.println(javacResult);
      if (Main.verbose) {
        System.out.println(
            "Compilation successful: "
                + javacResult.getSuccess()
                + " [expected: "
                + !expectJavacFail
                + "]");
      }
      if (javacResult.getSuccess() == expectJavacFail) {
        System.out.println("Compilation failed, messages:");
        System.out.println(javacResult.getOutput());
        throw new TestFailException();
      }
    } else {
      if (!expectJFlexFail) {
        System.out.println("Scanner generation failed!");
        System.out.println("JFlex output was:\n" + jflexResult.getOutput());
        throw new TestFailException();
      } else {
        // check JFlex output conformance
        File expected = new File(testPath, testName + "-flex.output");

        if (expected.exists()) {
          DiffStream check = new DiffStream();
          String diff;
          try {
            diff =
                check.diff(
                    jflexDiff, new StringReader(jflexResult.getOutput()), new FileReader(expected));
          } catch (FileNotFoundException e) {
            System.out.println("Error opening file " + expected);
            throw new TestFailException();
          }
          if (diff != null) {
            System.out.println("Test failed, unexpected jflex output: " + diff);
            System.out.println("JFlex output: " + jflexResult.getOutput());
            throw new TestFailException();
          }
        }
      }
    }
  }