From: yeom Date: Fri, 16 Sep 2011 01:15:03 +0000 (+0000) Subject: more changes. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=429c71f9189c045b06be392cedaaca1522856c6e more changes. --- diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java b/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java index 6a42734f..067a86d1 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/Classifier.java @@ -150,6 +150,7 @@ public class Classifier { int avgItems = 0; for (int i = 0; i < this.scanAreas.length; ++i) { ScanArea scanArea = this.scanAreas[i]; + // System.out.println("scanarea="+scanArea); values[i] = 0l; values[i] += @@ -169,6 +170,7 @@ public class Classifier { values[i] = (long) (values[i] / ((float) scanArea.getSize(scaleFactor))); avg = ((avgItems * avg) + values[i]) / (++avgItems); } +// System.out.println("avg=" + avg); // int amountYesNo = this.possibilityFaceNo + this.possibilityFaceYes; @@ -186,6 +188,7 @@ public class Classifier { isFaceYes *= (bright ? this.possibilities_FaceYes[i] : 1 - this.possibilities_FaceYes[i]); isFaceNo *= (bright ? this.possibilities_FaceNo[i] : 1 - this.possibilities_FaceNo[i]); } +// System.out.println("avg=" + avg + " yes=" + isFaceYes + " no=" + isFaceNo); return (isFaceYes >= isFaceNo && (isFaceYes / (isFaceYes + isFaceNo)) > borderline); } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/ClassifierTree.java b/Robust/src/Benchmarks/SSJava/EyeTracking/ClassifierTree.java index c2e3e2d0..8c3dfffe 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/ClassifierTree.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/ClassifierTree.java @@ -191,6 +191,7 @@ public class ClassifierTree { new Rectangle2D((smallImage.getWidth() - smallImageMaxDimension) / 2.0, (smallImage.getHeight() - smallImageMaxDimension) / 2.0, smallImageMaxDimension, smallImageMaxDimension); +// System.out.println("lastCoordinates=" + lastCoordinates); } else { // first we have to scale the last coodinates back relative to the resized // image @@ -226,6 +227,7 @@ public class ClassifierTree { ) { float factor = startFactor + factorDiff; +// System.out.println("factor=" + factor); if (factor > maxScaleFactor || factor < minScaleFactor) continue; @@ -257,14 +259,15 @@ public class ClassifierTree { Classifier classifier = (Classifier) classifiers.get(iterations); float borderline = 0.8f + (iterations / (classifiers.size() - 1)) * (maxBorder - 0.8f); - if (!classifier.classifyFace(imageData, factor, xPos, yPos, borderline)) { +// System.out.println("continue yLines; "); backToYLines = true; break; - // continue yLines; + // continue yLines; } } + // if we reach here we have a face recognized because our image went // through all // classifiers @@ -272,7 +275,6 @@ public class ClassifierTree { if (backToYLines) { continue; } - Rectangle2D faceRect = new Rectangle2D(xPos * originalImageFactor, yPos * originalImageFactor, actualDimmension * originalImageFactor, actualDimmension * originalImageFactor); diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/Deviation.java b/Robust/src/Benchmarks/SSJava/EyeTracking/Deviation.java index 8f152e9b..ff10c62c 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/Deviation.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/Deviation.java @@ -28,7 +28,6 @@ public class Deviation { int directionX, directionY; String direction; - public Deviation(String direction, int directionX, int directionY) { this.directionX = directionX; @@ -36,6 +35,10 @@ public class Deviation { this.direction = direction; } + public boolean concurs(int directionX, int directionY) { + return (directionX == this.directionX && directionY == this.directionY); + } + public boolean equals(Object o) { if (!(o instanceof Deviation)) { return false; diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java b/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java index 2f9cd843..456e3d12 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java @@ -26,10 +26,25 @@ public class DeviationScanner { private EyePosition eyePositions[]; + // LEFT_UP(+1, -1), UP(0, -1), RIGHT_UP(-1, -1), LEFT(+1, 0), NONE(0, 0), + // RIGHT(-1, 0), LEFT_DOWN( + // +1, +1), DOWN(0, +1), RIGHT_DOWN(-1, +1); + + private static final Deviation LEFT_UP = new Deviation("NONE", +1, -1); + private static final Deviation UP = new Deviation("UP", 0, -1); + private static final Deviation RIGHT_UP = new Deviation("RIGHT_UP", -1, -1); + private static final Deviation LEFT = new Deviation("LEFT", +1, 0); private static final Deviation NONE = new Deviation("NONE", 0, 0); + private static final Deviation RIGHT = new Deviation("NONE", -1, 0); + private static final Deviation LEFT_DOWN = new Deviation("NONE", +1, +1); + private static final Deviation DOWN = new Deviation("NONE", 0, +1); + private static final Deviation RIGHT_DOWN = new Deviation("NONE", -1, +1); + + private int size; public DeviationScanner() { eyePositions = new EyePosition[3]; + size = 0; } public void addEyePosition(EyePosition eyePosition) { @@ -38,17 +53,26 @@ public class DeviationScanner { eyePositions[i + 1] = eyePositions[i]; } eyePositions[0] = eyePosition; + + if (size < eyePositions.length) { + size++; + } + } + + public int getEyePositionsSize() { + return size; } public Deviation scanForDeviation(Rectangle2D faceRect) { Deviation deviation = NONE; - if (eyePositions.length >= 3) { + if (getEyePositionsSize() >= 3) { double deviationX = 0; double deviationY = 0; EyePosition lastEyePosition = null; for (int i = 0; i < 3; ++i) { EyePosition eyePosition = this.eyePositions[i]; + System.out.println("lastEyePosition=" + lastEyePosition); if (lastEyePosition != null) { deviationX += (eyePosition.getX() - lastEyePosition.getX()); deviationY += (eyePosition.getY() - lastEyePosition.getY()); @@ -76,6 +100,7 @@ public class DeviationScanner { deviation = getDirectionFor(deviationAbsoluteX, deviationAbsoluteY); if (deviation != NONE) { eyePositions = new EyePosition[3]; + size = 0; } // System.out.println(String.format("%.2f%% | %.2f%% => %d and %d >>> %s", // deviationX*100, deviationY*100, deviationAbsoluteX, deviationAbsoluteY, @@ -88,22 +113,32 @@ public class DeviationScanner { public static Deviation getDirectionFor(int directionX, int directionY) { - // for (Deviation direction : Deviation.values()) { - // if (direction.concurs(directionX, directionY)) { - // return direction; - // } - // } + if (LEFT_UP.concurs(directionX, directionY)) { + return LEFT_UP; + } else if (UP.concurs(directionX, directionY)) { + return UP; + } else if (RIGHT_UP.concurs(directionX, directionY)) { + return RIGHT_UP; + } else if (LEFT.concurs(directionX, directionY)) { + return LEFT; + } else if (NONE.concurs(directionX, directionY)) { + return NONE; + } else if (RIGHT.concurs(directionX, directionY)) { + return RIGHT; + } else if (LEFT_DOWN.concurs(directionX, directionY)) { + return LEFT_DOWN; + } else if (DOWN.concurs(directionX, directionY)) { + return DOWN; + } else if (RIGHT_DOWN.concurs(directionX, directionY)) { + return RIGHT_DOWN; + } return null; } public void clear() { System.out.println("CLEAR"); - // this.eyePositions.clear(); + eyePositions = new EyePosition[3]; + size = 0; } - // LEFT_UP(+1, -1), UP(0, -1), RIGHT_UP(-1, -1), LEFT(+1, 0), NONE(0, 0), - // RIGHT(-1, 0), LEFT_DOWN( - // +1, +1), DOWN(0, +1), RIGHT_DOWN(-1, +1); - // - } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/EyeDetector.java b/Robust/src/Benchmarks/SSJava/EyeTracking/EyeDetector.java index 92a77041..922961bb 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/EyeDetector.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/EyeDetector.java @@ -41,9 +41,19 @@ class EyeDetector { height = (int) faceRect.getHeight() / 2; pixelBuffer = new int[width * height]; - for (int y = (int) faceRect.getY(); y < faceRect.getY() + height; y++) { - for (int x = (int) faceRect.getX(); x < faceRect.getX() + width; x++) { - pixelBuffer[(y * width) + x] = (int) image.getPixel(x, y); + // System.out.println("eye w=" + width + " h=" + height); + // System.out + // .println("faceRect.getX()=" + faceRect.getX() + " faceRect.getY()=" + + // faceRect.getY()); + // System.out.println("image w=" + image.getWidth() + " h=" + + // image.getHeight()); + + int startX = (int) faceRect.getX(); + int startY = (int) faceRect.getY(); + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + pixelBuffer[(y * width) + x] = (int) image.getPixel(x + startX, y + startY); } } @@ -52,7 +62,7 @@ class EyeDetector { public Point detectEye() { Point eyePosition = null; float brightness = 255f; - + System.out.println("detectEye=" + percent); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { final int position = y * width + x; @@ -60,6 +70,7 @@ class EyeDetector { new int[] { (pixelBuffer[position] & 0xFF0000) >> 16, (pixelBuffer[position] & 0x00FF00) >> 8, pixelBuffer[position] & 0x0000FF }; final float acBrightness = getBrightness(color); + System.out.println("p=" + pixelBuffer[position] + " acBrightness=" + acBrightness); if (acBrightness < brightness) { eyePosition = new Point(x + (int) percent, y + (int) percent); @@ -68,6 +79,9 @@ class EyeDetector { } } + System.out.println("eyePosition=" + eyePosition); + System.exit(0); + return eyePosition; } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/EyePosition.java b/Robust/src/Benchmarks/SSJava/EyeTracking/EyePosition.java index 72676d27..a4bf4670 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/EyePosition.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/EyePosition.java @@ -46,6 +46,10 @@ public class EyePosition { return this.y; } + public String toString(){ + return "("+x+","+y+")"; + } + // public Deviation getDeviation(EyePosition oldEyePosition) { // if (oldEyePosition == null) return Deviation.NONE; // diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/ImageReader.java b/Robust/src/Benchmarks/SSJava/EyeTracking/ImageReader.java index eb0a37ce..3428e7b3 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/ImageReader.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/ImageReader.java @@ -26,11 +26,11 @@ public class ImageReader { int nwidth = (((int) bi[7] & 0xff) << 24) | (((int) bi[6] & 0xff) << 16) | (((int) bi[5] & 0xff) << 8) | (int) bi[4] & 0xff; -// System.out.println("Width is :" + nwidth); + // System.out.println("Width is :" + nwidth); int nheight = (((int) bi[11] & 0xff) << 24) | (((int) bi[10] & 0xff) << 16) | (((int) bi[9] & 0xff) << 8) | (int) bi[8] & 0xff; -// System.out.println("Height is :" + nheight); + // System.out.println("Height is :" + nheight); int nplanes = (((int) bi[13] & 0xff) << 8) | (int) bi[12] & 0xff; // System.out.println("Planes is :" + nplanes); int nbitcount = (((int) bi[15] & 0xff) << 8) | (int) bi[14] & 0xff; @@ -38,11 +38,11 @@ public class ImageReader { // Look for non-zero values to indicate compression int ncompression = (((int) bi[19]) << 24) | (((int) bi[18]) << 16) | (((int) bi[17]) << 8) | (int) bi[16]; -// System.out.println("Compression is :" + ncompression); + // System.out.println("Compression is :" + ncompression); int nsizeimage = (((int) bi[23] & 0xff) << 24) | (((int) bi[22] & 0xff) << 16) | (((int) bi[21] & 0xff) << 8) | (int) bi[20] & 0xff; -// System.out.println("SizeImage is :" + nsizeimage); + // System.out.println("SizeImage is :" + nsizeimage); int nxpm = (((int) bi[27] & 0xff) << 24) | (((int) bi[26] & 0xff) << 16) @@ -61,35 +61,37 @@ public class ImageReader { | (((int) bi[37] & 0xff) << 8) | (int) bi[36] & 0xff; // System.out.println("Colors important are :" + nclrimp); - int ndata[]; - Image image = new Image(nwidth, nheight); if (nbitcount == 24) { // No Palatte data for 24-bit format but scan lines are // padded out to even 4-byte boundaries. int npad = (nsizeimage / nheight) - nwidth * 3; - ndata = new int[(nheight * nwidth) + 4]; + // ndata = new int[(nheight * nwidth) + 4]; byte brgb[] = new byte[(nwidth + npad) * 3 * nheight]; // fs.read (brgb, 0, (nwidth + npad) * 3 * nheight); fs.read(brgb); int nindex = 0; + int yPos = 0; for (int j = 0; j < nheight; j++) { for (int i = 0; i < nwidth; i++) { // ndata[nwidth * (nheight - j - 1) + i] = // (255 & 0xff) << 24 | (((int) brgb[nindex + 2] & 0xff) << 16) // | (((int) brgb[nindex + 1] & 0xff) << 8) | (int) brgb[nindex] & // 0xff; - // System.out.println("Encoded Color at (" + i + "," + j + ")is:" + - // brgb + " (R,G,B)= (" - // + ((int) (brgb[nindex + 2]) & 0xff) + "," + ((int) brgb[nindex + 1] - // & 0xff) + "," - // + ((int) brgb[nindex] & 0xff) + ")"); +// System.out.println("Encoded Color at (" + i + "," + j + ")is:" + +// brgb + " (R,G,B)= (" +// + ((int) (brgb[nindex + 2]) & 0xff) + "," + ((int) brgb[nindex + 1] +// & 0xff) + "," +// + ((int) brgb[nindex] & 0xff) + ")"); int ta = ((3 * ((int) (brgb[nindex + 2]) & 0xff) + 6 * ((int) brgb[nindex + 1] & 0xff) + ((int) brgb[nindex] & 0xff))) / 10; - ndata[nwidth * (nheight - j - 1) + i + 4] = ta; + // ndata[nwidth * (nheight - j - 1) + i + 4] = ta; nindex += 3; - image.setPixel(i, j, ta); + // image.setPixel(i, j, ta); + yPos = nheight - j - 1; +// System.out.println("yPos=" + yPos + " nheight=" + nheight + " j=" + j); + image.setPixel(i, yPos, ta); } nindex += npad; } @@ -139,14 +141,15 @@ public class ImageReader { int npad8 = (nsizeimage / nheight) - nwidth; // System.out.println("nPad is:" + npad8); // int ndata8[] = new int[nwidth * nheight]; - ndata = new int[(nwidth * nheight) + 4]; + // ndata = new int[(nwidth * nheight) + 4]; byte bdata[] = new byte[(nwidth + npad8) * nheight]; // fs.read (bdata, 0, (nwidth+npad8)*nheight); fs.read(bdata); nindex8 = 0; for (int j8 = 0; j8 < nheight; j8++) { for (int i8 = 0; i8 < nwidth; i8++) { - ndata[nwidth * (nheight - j8 - 1) + i8 + 4] = npalette[((int) bdata[nindex8] & 0xff)]; + // ndata[nwidth * (nheight - j8 - 1) + i8 + 4] = npalette[((int) + // bdata[nindex8] & 0xff)]; image.setPixel(i8, j8, npalette[((int) bdata[nindex8] & 0xff)]); // System.out.println("Encoded Color at (" + i8 + "," + j8 + ")is: " // + ndata[nwidth * (nheight - j8 - 1) + i8 + 4]); diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/IntegralImageData.java b/Robust/src/Benchmarks/SSJava/EyeTracking/IntegralImageData.java index 0ef7c518..71125598 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/IntegralImageData.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/IntegralImageData.java @@ -48,6 +48,13 @@ public class IntegralImageData { // pg.grabPixels(); // } catch (InterruptedException ie) { // } + + // for (int y = 0; y < bufferedImage.getHeight(); ++y) { + // for (int x = 0; x < bufferedImage.getWidth(); ++x) { + // System.out.println(bufferedImage.getPixel(x, y) & 0xff); + // } + // } + // System.exit(0); long[][] s = new long[bufferedImage.getWidth()][bufferedImage.getHeight()]; for (int y = 0; y < bufferedImage.getHeight(); ++y) { diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/JMFCaptureDevice.java b/Robust/src/Benchmarks/SSJava/EyeTracking/JMFCaptureDevice.java deleted file mode 100644 index 5199a853..00000000 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/JMFCaptureDevice.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2009 (c) Florian Frankenberger (darkblue.de) - * - * This file is part of LEA. - * - * LEA is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) any - * later version. - * - * LEA is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with LEA. If not, see . - */ - - -import java.awt.Dimension; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.util.Vector; - -import javax.media.Buffer; -import javax.media.CannotRealizeException; -import javax.media.CaptureDeviceInfo; -import javax.media.CaptureDeviceManager; -import javax.media.Format; -import javax.media.Manager; -import javax.media.MediaLocator; -import javax.media.NoDataSourceException; -import javax.media.NoPlayerException; -import javax.media.Player; -import javax.media.control.FormatControl; -import javax.media.control.FrameGrabbingControl; -import javax.media.format.RGBFormat; -import javax.media.format.VideoFormat; -import javax.media.format.YUVFormat; -import javax.media.protocol.CaptureDevice; -import javax.media.protocol.DataSource; -import javax.media.util.BufferToImage; - -import de.darkblue.lea.ifaces.ICaptureDevice; - -/** - * This class is a proxy to the Java Media Framework. You can use - * this class to make use of a JMF compatible webcam or - * other image source. - *

- * To receive a list of all available image sources just call the static - * method getImageSources. - * - * @author Florian Frankenberger - */ -public class JMFCaptureDevice implements ICaptureDevice { - - private Player player; - private FrameGrabbingControl fgc; - - /** - * Initializes the JMF with the first available (YUV compatible) image source. The image - * source is then tested if it matches certain criteria - if not an IllegalStateException - * is thrown. - *

- * Criteria are: - *

  • provides YUV or RGB images - *
  • can provide images with 640x480 pixels - * - * @throws NoDataSourceException - * @throws NoPlayerException - * @throws CannotRealizeException - * @throws IOException - * @throws IllegalStateException if the data source does not match the criteria - */ - public JMFCaptureDevice() throws NoDataSourceException, NoPlayerException, CannotRealizeException, IOException { - CaptureDeviceInfo imageSource = null; - - // get all image sources on the system that can supply us with at least YUV-images - CaptureDeviceInfo[] devices = getImageSourcesAvailable(); - - if (devices.length == 0) { - throw new IllegalStateException("No Webcams found on this system."); - } - - // we use the first best (most of the time this is the webcam the user wants) - imageSource = devices[0]; - - initImageSource(imageSource); - } - - /** - * Initializes the JMF with the given image source. An IllegalStateException is thrown - * if the image source does not the following criteria: - *

    - * Criteria are: - *

  • provides YUV or RGB images - *
  • can provide images with 640x480 pixels - * - * @param imageSource the image source to use - * @throws NoDataSourceException - * @throws NoPlayerException - * @throws CannotRealizeException - * @throws IOException - * @throws IllegalStateException if the data source does not match the criteria - */ - public JMFCaptureDevice(CaptureDeviceInfo imageSource) throws NoDataSourceException, NoPlayerException, CannotRealizeException, IOException { - initImageSource(imageSource); - } - - private void initImageSource(CaptureDeviceInfo imageSource) throws NoDataSourceException, IOException, NoPlayerException, CannotRealizeException { - if (imageSource == null) throw new IllegalStateException("Image source cannot be null"); - - // search the right format - VideoFormat matchingFormat = null; - VideoFormat alternateMatchingFormat = null; - for (Format format: imageSource.getFormats()) { - if (format instanceof VideoFormat) { - VideoFormat videoFormat = (VideoFormat) format; - - if (videoFormat instanceof RGBFormat) { - RGBFormat rgbFormat = (RGBFormat)videoFormat; - Dimension size = rgbFormat.getSize(); - - if (size.width == 640 && size.height == 480 && - rgbFormat.getBitsPerPixel() == 24) { - matchingFormat = videoFormat; - break; - } - } - - if (videoFormat instanceof YUVFormat) { - YUVFormat rgbFormat = (YUVFormat)videoFormat; - Dimension size = rgbFormat.getSize(); - - if (size.width == 640 && size.height == 480) { - alternateMatchingFormat = videoFormat; - } - } - } - } - - if (matchingFormat == null && alternateMatchingFormat != null) - matchingFormat = alternateMatchingFormat; - - if (matchingFormat == null) { - throw new IllegalStateException ("Your image source does not support the 640x480 RGB/YUV format. This testenvironment relies on the fact, that your cam provides this resolution in this colorspace."); - } - - MediaLocator mediaLocator = imageSource.getLocator(); - - DataSource dataSource = Manager.createDataSource(mediaLocator); - for (FormatControl formatControl: ((CaptureDevice) dataSource).getFormatControls()) { - if (formatControl == null) continue; - formatControl.setFormat(matchingFormat); - } - - player = Manager.createRealizedPlayer(dataSource); - - player.setRate(15); - player.start(); - - fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl"); - } - - /** - * Returns a vector of all image sources available on this system - * @return a vector of image sources - */ - @SuppressWarnings("unchecked") - public static CaptureDeviceInfo[] getImageSourcesAvailable() { - // get all image sources on the system that can supply us with at least YUV-images - Vector devices = CaptureDeviceManager.getDeviceList(new VideoFormat(VideoFormat.YUV)); - return devices.toArray(new CaptureDeviceInfo[0]); - } - - - /* (non-Javadoc) - * @see de.darkblue.lea.ICaptureDevice#getFrameRate() - */ - @Override - public int getFrameRate() { - return 15; - } - - /* (non-Javadoc) - * @see de.darkblue.lea.ICaptureDevice#getImage() - */ - @Override - public BufferedImage getImage() { - Buffer buffer = fgc.grabFrame(); - - // Convert it to an image - BufferToImage btoi = new BufferToImage((VideoFormat)buffer.getFormat()); - return (BufferedImage)btoi.createImage(buffer); - } - - /* (non-Javadoc) - * @see de.darkblue.lea.ICaptureDevice#close() - */ - @Override - public void close() { - if (player != null) { - player.close(); - player.deallocate(); - } - } - - - - -} diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/LEA.java b/Robust/src/Benchmarks/SSJava/EyeTracking/LEA.java index 0439b2d1..fed080cf 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/LEA.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/LEA.java @@ -197,9 +197,10 @@ public class LEA { if (positions.getEyePosition() != null) { deviationScanner.addEyePosition(positions.getEyePosition()); Deviation deviation = deviationScanner.scanForDeviation(positions.getFacePosition());// positions.getEyePosition().getDeviation(lastPositions.getEyePosition()); - // if (deviation != Deviation.NONE) { - // notifyEyeMovementListenerEyeMoved(deviation); - // } + if (deviation != DeviationScanner.NONE) { + System.out.println("DEVICATION=" + deviation); + // notifyEyeMovementListenerEyeMoved(deviation); + } } // else { // if (statusWindow != null) diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java b/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java index ce997210..50e6d016 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java @@ -47,7 +47,8 @@ public class LEAImplementation { eyePosition = new EyePosition(point, faceRect); } } - + System.out.println("eyePosition="+eyePosition); + return new FaceAndEyePosition(faceRect, eyePosition); } @@ -98,10 +99,12 @@ public class LEAImplementation { classifier.setPossibilitiesFaceYes(array); // parsing possibilities face no + array = new float[numArea]; for (int idx = 0; idx < numArea; idx++) { array[idx] = Float.parseFloat(inputFile.readLine()); } classifier.setPossibilitiesFaceNo(array); + classifier.setPossibilityFaceYes(Integer.parseInt(inputFile.readLine())); classifier.setPossibilityFaceNo(Integer.parseInt(inputFile.readLine())); diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/Point.java b/Robust/src/Benchmarks/SSJava/EyeTracking/Point.java index cfc3eafa..2feea59d 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/Point.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/Point.java @@ -10,5 +10,9 @@ public class Point { public Point() { } + + public String toString(){ + return "("+x+","+y+")"; + } } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/ScanArea.java b/Robust/src/Benchmarks/SSJava/EyeTracking/ScanArea.java index df3c8425..a7955960 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/ScanArea.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/ScanArea.java @@ -107,9 +107,8 @@ public class ScanArea { public String toString() { String str = ""; str += "fromPoint=(" + fromPoint.x + "," + fromPoint.y + ")"; - str += "\n"; str += "toPoint=(" + toPoint.x + "," + toPoint.y + ")"; - str += "\n"; + str += "size=" + size; return str; } } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/facedata.dat b/Robust/src/Benchmarks/SSJava/EyeTracking/facedata.dat index a38e0e8d..96564538 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/facedata.dat +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/facedata.dat @@ -1,2090 +1,2090 @@ 8 6 -54 -54 -91 -62 -296.0 -25 47 -39 -66 -266.0 -12 -29 -45 -38 -297.0 -49 -65 -62 -86 -273.0 +59 58 +65 +66.0 +47 +35 +73 38 +78.0 +26 +48 +43 +52 +68.0 +10 +43 +17 +51 +56.0 +74 +75 +85 +81 +66.0 +45 +22 +59 +26 +56.0 +0.999 +0.999 +0.001 +0.001 +0.001 +0.999 +0.6108889 +0.87702256 +0.31148863 +0.31148872 +0.64415544 +0.75504464 +3 90 -47 -288.0 -49 -5 -61 -28 -276.0 -0.78447694 -0.51399076 -0.019654196 -0.038308397 -0.7471684 -0.89640224 -0.43222174 -0.5485019 -0.56839997 -0.44714534 -0.44154882 -0.5034207 -107 -3210 7 -43 -65 -57 -71 -84.0 +51 +52 +80 +59 +203.0 +5 42 +23 +53 +198.0 +40 55 -81 -58 -117.0 -76 -21 -79 -49 -84.0 +45 +93 +190.0 +22 +56 +28 +88 +192.0 54 -27 +31 69 -33 -90.0 +44 +195.0 +34 +20 +72 +25 +190.0 +35 +32 +53 43 +198.0 +0.999 +0.001 +0.001 +0.001 +0.999 +0.001 +0.999 +0.74395585 +0.3225777 +0.37802225 +0.11188894 +0.89920026 +0.8326669 +0.66633344 +3 +90 +9 40 -58 -46 -90.0 +32 +63 +35 +69.0 +39 +80 +64 +83 +75.0 +67 +20 +80 25 -73 -57 -76 -96.0 -36 +65.0 +17 21 -60 +32 25 -96.0 -0.57928056 -0.9243835 -0.5139905 -0.29946703 -0.30879453 -0.17821494 -0.6632244 -0.4956475 -0.49564773 -0.4794796 -0.49347022 -0.5314026 -0.54974556 -0.561873 -107 -3210 +60.0 +29 9 35 -74 -54 -79 -95.0 -12 -61 -23 -70 -99.0 -60 -45 -69 -56 -99.0 -58 -26 -87 -30 -116.0 -27 -60 -49 +18 +54.0 +71 +36 +73 +63 +54.0 65 -110.0 -53 -45 -59 -61 -96.0 -44 -38 +52 +68 70 -42 -104.0 +54.0 +44 48 -18 -75 -22 -108.0 -29 -31 -62 -34 -99.0 -0.112925306 -0.5979346 -0.93371063 -0.07561684 -0.41139242 -0.45802805 -0.73784137 -0.4953364 -0.532645 -0.50652957 -0.5596948 -0.4552287 -0.46455583 -0.54508185 -0.45616162 -0.48165566 -0.4869416 -0.5376199 -107 -3210 -13 -32 -32 -60 -36 -112.0 -28 -18 +64 +51 +60.0 +25 +58 46 -24 -108.0 -36 +61 +63.0 +0.999 +0.001 +0.001 +0.001 +0.001 +0.999 +0.999 +0.999 +0.001 +0.6441556 +0.37802222 +0.9435559 +0.35584423 +0.4556444 +0.77722245 +0.67742234 +0.6219778 +0.22277781 +3 +90 +13 52 -71 -55 -105.0 -22 -45 -55 -48 -99.0 -59 -37 -92 -40 -99.0 -30 -60 +80 +69 +84 +68.0 +38 59 -64 -116.0 -73 -67 -92 +68 +62 +90.0 +41 +69 +65 72 -95.0 -67 -11 -73 -27 -96.0 -55 -82 -75 -87 -100.0 +72.0 +30 32 +45 37 -56 -41 -96.0 -6 -27 +75.0 14 +32 +25 39 -96.0 -58 -44 -82 -48 -96.0 -41 -72 -45 -96 -96.0 -0.3927383 -0.17821503 -0.69120574 -0.6165889 -0.8590937 -0.28081292 -0.79380393 -0.08494394 -0.70985985 -0.37408417 -0.14090677 -0.93371063 -0.280813 -0.5202099 -0.5513008 -0.48352194 -0.5264276 -0.4269359 -0.51119345 -0.43066725 -0.45709372 -0.4431036 -0.51896566 -0.5761743 -0.43595245 -0.4853875 -107 -3210 -21 +77.0 +10 70 -43 -89 -46 -57.0 +34 +73 +72.0 +45 39 -37 +61 +44 +80.0 +69 +24 +72 +47 +69.0 +26 +55 54 -40 -45.0 -33 +58 +84.0 +10 +24 +22 +30 +72.0 60 -53 -63 -60.0 -52 -67 -59 +85 74 -49.0 -51 -14 -55 -25 -44.0 -13 -73 +90 +70.0 +11 +40 26 -77 -52.0 -71 -69 -84 +45 +75.0 +61 73 -52.0 -59 -35 -66 +88 +76 +81.0 +0.001 +0.999 +0.001 +0.6663334 +0.999 +0.001 +0.999 +0.999 +0.33366668 +0.001 +0.001 +0.001 +0.999 +0.6663334 +0.72177804 +0.6441556 +0.54435563 +0.4223777 +0.22277781 +0.77722234 +0.91028917 +0.36693332 +0.43346664 +0.73286694 +0.4223777 +0.6885114 +3 +90 +21 +88 42 -49.0 -13 +98 +45 +30.0 +69 +63 +74 +68 +25.0 +43 +43 +47 +49 +24.0 +69 +41 +77 +44 +24.0 +55 +31 +62 35 -17 +28.0 +48 +66 +55 +70 +28.0 +80 +28 +87 +32 +28.0 +40 +51 46 -44.0 -35 +55 +24.0 +18 +50 +19 +73 +23.0 +40 +61 +47 +65 +28.0 23 +26 +25 38 -38 -45.0 -47 -51 -63 -54 -48.0 -58 -56 -77 -59 -57.0 -33 -72 -40 -79 -49.0 -39 +24.0 +18 +44 +24 +48 +24.0 +85 +37 +91 41 -54 +24.0 +53 44 -45.0 -8 57 -14 -65 -48.0 -58 -10 -66 +50 +24.0 +56 +56 +59 +64 +24.0 +52 +19 +61 +22 +27.0 +35 16 -48.0 +36 +39 +23.0 +29 +8 +36 +12 +28.0 +47 +37 +56 +40 +27.0 +26 +38 +29 +46 +24.0 43 -83 -62 -86 -57.0 -20 -25 +85 +48 +90 +25.0 +0.999 +0.999 +0.6663334 +0.999 +0.999 +0.001 +0.999 +0.001 +0.001 +0.001 +0.001 +0.001 +0.999 +0.999 +0.999 +0.001 +0.001 +0.001 +0.999 +0.999 +0.001 +0.8437558 +0.67742234 +0.43346658 +0.83266693 +0.82157797 +0.4667334 +0.932467 +0.43346667 +0.15624456 +0.3447555 +0.37802207 +0.31148878 +0.87702256 +0.6663335 +0.6219778 +0.7217779 +0.4445555 +0.49999982 +0.67742234 +0.3447554 +0.2893111 +3 +90 +37 +33 +60 +42 +63 +27.0 +77 +48 +78 +74 +26.0 28 +25 31 -48.0 +34 +27.0 +27 35 -47 -50 -50 -45.0 -70 -47 -81 -51 -44.0 -10 +34 +39 +28.0 +53 52 -24 -56 -56.0 -0.9243835 -0.17821491 -0.13157943 -0.5419719 -0.94303775 -0.16888793 -0.80313104 -0.6538973 -0.2528317 -0.2714859 -0.5979345 -0.9803462 -0.03830837 -0.1222525 -0.07561681 -0.9243835 -0.50466365 -0.001 -0.21552329 -0.9803462 -0.5233179 -0.41791958 -0.49968916 -0.50497437 -0.44185993 -0.48569784 -0.5497462 -0.42507058 -0.44652277 -0.5702664 -0.5276726 -0.45025402 -0.4306672 -0.500933 -0.49657974 -0.550678 -0.46766484 -0.4685978 -0.5634273 -0.5105703 -0.42569247 -0.5606273 -107 -3210 -37 -35 -20 -45 -24 -40.0 -28 +57 +59 +28.0 58 +85 +60 +98 +26.0 +82 +40 +89 44 -61 -48.0 +28.0 29 -43 +19 +38 +22 +27.0 45 -46 -48.0 -50 +21 +47 +34 +26.0 +6 53 +14 +57 +32.0 +39 53 -65 -36.0 -73 +47 +57 +32.0 +51 +46 +59 +50 +32.0 64 -75 -82 -36.0 -22 +69 +67 +78 +27.0 +12 +26 +14 +39 +26.0 +48 70 +54 +75 +30.0 37 -73 -45.0 -56 -51 +5 +39 +18 +26.0 62 +42 +66 +49 +28.0 +92 +50 +96 57 -36.0 -19 -22 -23 -31 -36.0 -16 -63 -18 -81 -36.0 -79 -58 -81 -76 -36.0 -13 -52 -29 -55 -48.0 -46 -8 -61 -11 -45.0 -53 -38 -68 -41 -45.0 -84 -37 -86 -55 -36.0 -38 -25 -51 -28 -39.0 -69 -28 -70 -63 -35.0 -32 -62 -45 -65 -39.0 -64 -14 -80 -17 -48.0 -39 -70 -49 -74 -40.0 -15 -33 -19 -42 -36.0 -49 -46 +28.0 59 -50 -40.0 +6 +64 +12 +30.0 41 -13 -51 -17 -40.0 -38 -86 -46 -91 -40.0 -79 -22 -82 -34 -36.0 -66 -88 -74 -93 -40.0 -54 -73 -56 -91 -36.0 -2 +43 47 -7 -54 -35.0 -57 -81 -65 -86 -40.0 -36 -29 -44 -34 -40.0 -3 -60 -15 -63 -36.0 -27 +48 +30.0 35 +45 +38 +54 +27.0 +51 34 +56 40 -35.0 -57 -59 -59 -77 -36.0 -64 -64 -69 +30.0 +82 71 -35.0 -26 -14 -28 -32 -36.0 85 -58 -94 -62 -36.0 -51 -30 -57 -36 -36.0 -42 80 -49 -85 -35.0 -0.24350454 -0.44870088 -0.36475706 -0.7285142 -0.9057293 -0.29946718 -0.32744858 -0.028981311 -0.3834112 -0.961692 -0.87774795 -0.9057293 -0.6445702 -0.88707507 -0.54197204 -0.99900043 -0.1315795 -0.45802796 -0.48600936 -0.16888788 -0.6725514 -0.93371063 -0.45802793 -0.18754214 -0.60726196 -0.4020654 -0.010327146 -0.52331775 -0.31812155 -0.07561681 -0.8590937 -0.3181214 -0.70053285 -0.001 -0.52331793 -0.5419721 -0.38341117 -0.5376197 -0.5286042 -0.52269644 -0.46206897 -0.4185414 -0.5307805 -0.44310337 -0.5584525 -0.53886336 -0.41698694 -0.546638 -0.5080832 -0.44963196 -0.42444828 -0.51274693 -0.42382675 -0.51492363 -0.45243058 -0.48103434 -0.5528546 -0.46984145 -0.5180326 -0.49067295 -0.44590148 -0.43968338 -0.44154894 -0.56404704 -0.44869992 -0.5335793 -0.5453939 -0.5528552 -0.42071792 -0.42942348 -0.5472579 -0.42413813 -0.47077382 -0.4866306 -107 -3210 -69 -29 -33 -31 -44 -22.0 -75 -35 -83 -38 -24.0 -33 -36 -34 -57 -21.0 -32 -71 -36 -77 -24.0 -70 -34 -74 -40 -24.0 -51 -84 -56 -89 -25.0 -35 -26 -39 -32 -24.0 -25 -60 -34 -63 27.0 -41 -51 -46 -56 -25.0 49 -23 -55 -27 -24.0 +81 +53 +88 +28.0 +28 43 -23 -44 -44 -21.0 +31 +52 +27.0 +10 +45 +19 +48 +27.0 +71 +38 72 -57 -75 -64 -21.0 -26 -50 -32 -54 -24.0 -17 -55 -24 -58 -21.0 -5 -42 -11 -46 -24.0 64 -19 -70 -23 -24.0 -51 -47 -57 -51 -24.0 -20 -86 -28 -89 -24.0 -30 -10 -33 +26.0 17 -21.0 -71 -25 +59 +27 +62 +30.0 +74 +9 78 -28 -21.0 -42 -10 -49 -13 -21.0 -64 -58 -68 -64 -24.0 -24 -71 -29 -76 -25.0 16 -34 +28.0 +40 +91 +45 +97 +30.0 +16 +81 +26 +84 +30.0 +76 +33 +87 +36 +33.0 +53 21 -39 -25.0 +58 +27 +30.0 +33 +79 35 -51 -39 -57 -24.0 -57 -67 +92 +26.0 +63 +52 +68 58 -88 -21.0 -75 -18 -83 -21 -24.0 -64 -6 -67 -13 -21.0 +30.0 +15 71 -81 +27 74 -88 -21.0 -37 -4 -40 -11 -21.0 +36.0 +15 +22 +25 +25 +30.0 +0.001 +0.999 +0.33366668 +0.999 +0.33366668 +0.001 +0.999 +0.001 +0.999 +0.33366668 +0.001 +0.999 +0.999 +0.001 +0.001 +0.001 +0.999 +0.999 +0.999 +0.999 +0.001 +0.999 +0.999 +0.001 +0.999 +0.001 +0.999 +0.001 +0.999 +0.001 +0.001 +0.999 +0.999 +0.001 +0.999 +0.001 +0.001 +0.33366668 +0.71068907 +0.47782215 +0.4445555 +0.6996001 +0.5776223 +0.8548447 +0.49999982 +0.58871126 +0.28931105 +0.47782227 +0.6774224 +0.6330667 +0.43346658 +0.58871114 +0.56653345 +0.78831136 +0.821578 +0.86593366 +0.5332667 +0.42237762 +0.7661334 +0.67742246 +0.5000002 +0.38911098 +0.38911104 +0.78831124 +0.26713338 +0.9546448 +0.3558445 +0.20060001 +0.89920026 +0.75504464 +0.33366677 +0.7328668 +0.24495552 +0.44455555 +3 90 -51 -98 -54 -24.0 -35 -58 -42 -61 +69 +66 +84 +68 +94 +20.0 +74 +59 +77 +66 21.0 -80 -53 -85 -58 -25.0 -25 -14 +51 +7 +55 +12 +20.0 +50 29 +57 +32 +21.0 +84 20 -24.0 +88 +25 +20.0 +68 +44 +73 +48 +20.0 +58 43 -80 -51 -83 +60 +53 +20.0 +46 +41 +49 +48 +21.0 +38 +81 +46 +84 24.0 -36 -86 +72 +18 +73 +38 +20.0 42 -90 -24.0 -7 -60 -16 -63 -27.0 -21 -27 -30 -30 -27.0 53 -31 +51 56 -38 -21.0 -49 -66 -54 -71 -25.0 -52 -4 -61 -7 27.0 -58 -22 +57 +63 62 +67 +20.0 +44 +24 +50 28 24.0 -39 +26 +63 +28 73 -44 -78 -25.0 -27 -64 -32 -69 -25.0 -76 +20.0 +37 +34 +45 +37 +24.0 +37 +48 +38 68 -78 -79 -22.0 -54 -61 -62 -64 +20.0 +35 +40 +43 +43 24.0 -54 -53 -59 58 -25.0 -61 -70 -64 -77 -21.0 -43 -45 -48 -50 -25.0 -62 -83 70 -86 +66 +73 24.0 16 -74 -18 -85 -22.0 -22 -42 -24 -53 -22.0 -15 -18 -21 -22 -24.0 -6 +44 +19 51 -14 -54 -24.0 -81 -61 -82 -82 21.0 -41 -92 -50 -95 -27.0 -75 -41 -81 -45 -24.0 -58 -46 -67 -49 -27.0 -52 -13 -59 +38 16 -21.0 -87 -42 -89 +47 +19 +27.0 +76 53 -22.0 -27 -78 -35 81 -24.0 +57 +20.0 +20 +78 +23 +85 +21.0 +38 +73 +41 +80 +21.0 +88 +43 +96 46 -61 +24.0 +70 +7 +75 +11 +20.0 +76 +33 +81 +37 +20.0 52 +50 +57 +54 +20.0 +12 +56 +14 +66 +20.0 +31 65 +35 +70 +20.0 +31 +30 +32 +50 +20.0 +24 +26 +32 +29 24.0 -56 -42 -64 -45 +78 +17 +83 +21 +20.0 +84 +62 +86 +72 +20.0 +60 +7 +68 +10 24.0 -35 -42 -42 -45 -21.0 -61 -33 -66 -38 -25.0 -69 -49 -76 -52 -21.0 +24 +55 +25 +75 +20.0 +26 56 -94 -61 -99 -25.0 30 -86 -34 -92 +61 +20.0 +62 +21 +70 +24 24.0 -84 -32 -92 -35 +64 +38 +70 +42 24.0 -0.89640224 -0.44870088 -0.803131 -0.178215 -0.72851413 -0.5606263 -0.25283164 -0.8964022 -0.20619617 -0.95236486 -0.094271086 -0.99900043 -0.9803462 -0.83111244 -0.1595608 -0.13157965 -0.58860755 -0.1968692 -0.4673551 -0.11292524 -0.9243835 -0.8124582 -0.28081292 -0.13157965 -0.1968692 -0.29014012 -0.1409067 -0.89640224 -0.7005328 -0.87774795 -0.29014015 -0.12225243 -0.9150564 -0.001 -0.280813 -0.3367756 -0.1409067 -0.001 -0.4487009 -0.7378413 -0.89640224 -0.37408397 -0.09427106 -0.5419721 -0.7844768 -0.31812128 -0.3274484 -0.3367757 -0.4020654 -0.5886074 -0.16888782 -0.94303775 -0.08494392 -0.18754199 -0.81245816 -0.7844769 -0.95236486 -0.66322434 -0.9243835 -0.7844769 -0.09427106 -0.5233177 -0.4673551 -0.19686913 -0.6165888 -0.9896733 -0.75649554 -0.26215878 -0.280813 -0.54601437 -0.42662486 -0.5239404 -0.51741076 -0.44030485 -0.46548912 -0.53233284 -0.53264564 -0.5055968 -0.49471414 -0.50404143 -0.42320526 -0.5413512 -0.5450827 -0.55627555 -0.44776708 -0.46393427 -0.54010737 -0.56498075 -0.4434139 -0.5242502 -0.43066725 -0.5410397 -0.54912555 -0.52922535 -0.4328436 -0.44869947 -0.47139576 -0.42475927 -0.54850155 -0.42040655 -0.5174102 -0.42507055 -0.5609385 -0.48880714 -0.497513 -0.5450818 -0.5584515 -0.46144667 -0.4505651 -0.4962689 -0.45087564 -0.49782407 -0.5220751 -0.42724708 -0.4353308 -0.4555398 -0.43657473 -0.5043537 -0.43875065 -0.53824323 -0.530781 -0.56187207 -0.5584515 -0.41667587 -0.48663133 -0.43035597 -0.44403616 -0.4869417 -0.42040643 -0.52922606 -0.47605973 -0.45585036 -0.52735937 -0.44683382 -0.43284342 -0.45989278 -0.5198991 -0.4384393 -107 -3210 -133 -29 -21 -30 -41 +37 +23 +39 +33 20.0 +53 +20 +58 24 -73 -26 -83 20.0 +48 +60 +56 +63 +24.0 +49 +76 +57 +79 +24.0 +16 +22 +24 25 -20 -27 -30 -20.0 +24.0 +9 +48 15 -50 -20 -54 -20.0 -86 -28 -89 -35 +52 +24.0 +73 +79 +80 +82 21.0 -37 -37 -43 -41 +40 +93 +48 +96 24.0 -49 -54 +68 +12 +73 +16 +20.0 53 +35 59 -20.0 -33 -56 39 -60 24.0 -83 -28 -84 -48 +10 +27 +15 +31 20.0 -58 -44 +64 +62 +73 65 -47 +27.0 +89 +67 +96 +70 21.0 -77 -73 -85 +43 +63 +46 +70 +21.0 +69 +84 +78 +87 +27.0 +81 76 +89 +79 24.0 -49 -18 -58 -21 -27.0 -51 -92 -56 -96 +28 +88 +35 +91 +21.0 +60 +81 +62 +91 20.0 -41 -45 -49 -48 -24.0 -12 +16 63 20 -66 -24.0 -67 -9 -76 +68 +20.0 +81 +64 +83 +74 +20.0 +62 12 -27.0 -69 -26 +65 +19 +21.0 +18 +14 +25 +17 +21.0 76 -29 +25 +83 +28 21.0 -29 -62 +41 +88 +49 +91 +24.0 +34 +17 36 -65 +27 +20.0 +39 +62 +42 +69 21.0 -41 -9 -50 -12 -27.0 -67 -46 +54 +14 +60 +18 +24.0 +61 +30 69 -56 +33 +24.0 +40 +10 +49 +13 +27.0 +19 +52 +23 +57 +20.0 +92 +47 +95 +54 +21.0 +0.001 +0.999 +0.999 +0.999 +0.999 +0.999 +0.999 +0.999 +0.001 +0.999 +0.001 +0.999 +0.999 +0.001 +0.001 +0.001 +0.001 +0.001 +0.001 +0.001 +0.999 +0.001 +0.001 +0.999 +0.999 +0.999 +0.6663334 +0.001 +0.001 +0.999 +0.001 +0.999 +0.999 +0.999 +0.001 +0.001 +0.001 +0.999 +0.33366668 +0.999 +0.999 +0.001 +0.001 +0.001 +0.001 +0.001 +0.6663334 +0.999 +0.001 +0.999 +0.999 +0.001 +0.001 +0.33366668 +0.001 +0.001 +0.001 +0.999 +0.33366668 +0.001 +0.999 +0.001 +0.001 +0.001 +0.001 +0.999 +0.999 +0.001 +0.999 +0.59980005 +0.6552445 +0.7106891 +0.68851125 +0.9546448 +0.84375584 +0.6441556 +0.5443555 +0.3225779 +0.87702245 +0.48891115 +0.6219776 +0.5554444 +0.24495552 +0.48891088 +0.27822217 +0.43346658 +0.588711 +0.3447554 +0.54435563 +0.6885114 +0.17842232 +0.26713333 +0.8437558 +0.91028917 +0.88811135 +0.59980005 +0.26713324 +0.2560444 +0.38911104 +0.4223777 +0.9435559 +0.68851125 +0.83266693 +0.22277775 +0.27822217 +0.91028917 +0.8437558 +0.51108897 +0.68851125 +0.5110889 +0.4889112 +0.44455555 +0.33366656 +0.6441556 +0.34475565 +0.91028917 +0.7328668 +0.45564443 +0.69960016 +0.75504464 +0.35584447 +0.6663334 +0.6774223 +0.2560444 +0.58871114 +0.24495548 +0.6552446 +0.8437558 +0.45564443 +0.91028917 +0.3225779 +0.51108897 +0.36693335 +0.75504464 +0.84375584 +0.67742234 +0.3336665 +0.821578 +3 +90 +133 +30 +15 +34 +20 20.0 +18 +51 +27 +54 +27.0 +52 +6 +58 +10 +24.0 53 -48 +43 57 -53 +48 20.0 -29 -74 -38 -77 +60 +76 +69 +79 27.0 -53 +29 +66 +33 71 -56 -78 -21.0 -10 -46 -18 -49 -24.0 -42 -63 -44 -73 20.0 +35 +52 39 -20 +57 +20.0 +45 +35 48 -23 -27.0 -24 42 -31 -45 21.0 -63 -6 -64 -26 -20.0 -24 -46 -26 -56 -20.0 -50 -43 -55 -47 -20.0 -25 -10 -31 -14 -24.0 -64 -86 +62 +53 70 -90 +56 24.0 +28 +32 +29 +52 +20.0 +15 75 -39 -78 -46 +18 +82 21.0 +51 +60 +55 65 -73 +20.0 +11 +33 +20 +36 +27.0 +62 72 -76 -21.0 -26 -68 -35 71 +75 27.0 -44 -36 -48 -41 -20.0 -68 -61 -76 -64 -24.0 -21 -57 -25 +42 +42 +43 62 20.0 -56 -54 -63 -57 -21.0 +46 +3 47 -74 -50 -81 -21.0 -37 -28 -43 -32 -24.0 -81 -50 -82 +23 +20.0 +53 +51 +58 +55 +20.0 +42 +66 +48 70 +24.0 +88 +33 +92 +38 20.0 -54 -29 +62 63 -32 +71 +66 27.0 -70 +74 +50 79 -75 -83 -20.0 -55 -12 -61 -16 -24.0 -46 -87 54 -90 -24.0 -33 -29 -35 -39 20.0 -31 +41 +27 46 -40 -49 -27.0 -20 +31 +20.0 +76 +74 +84 77 -23 +24.0 84 -21.0 -93 -37 -97 -42 -20.0 -83 -61 -91 +57 +87 64 -24.0 -53 -3 -60 -6 -21.0 -65 -37 -72 -40 -21.0 -54 -38 -60 -42 -24.0 -14 -73 -17 -80 21.0 -7 +88 +43 +97 +46 +27.0 55 -12 +26 +62 +29 +21.0 +24 59 +26 +69 20.0 -46 -25 -48 +78 35 +83 +39 20.0 -35 -3 +27 +56 +34 +59 +21.0 37 -13 -20.0 -19 -32 -26 -35 +15 +44 +18 21.0 -80 -22 -84 -27 -20.0 -80 +19 +75 +28 78 -86 -82 -24.0 -64 -27 +27.0 +73 +11 +75 +21 +20.0 +12 +58 +14 68 +20.0 32 +22 +36 +27 20.0 -74 -55 -80 -59 -24.0 -57 -63 +30 +72 +39 +75 +27.0 +36 59 -73 -20.0 -89 -53 -96 -56 +39 +66 21.0 -80 -37 -82 47 +52 +52 +56 20.0 -45 -65 -49 -70 -20.0 -45 -91 -49 -96 +73 +42 +77 +47 20.0 -22 +27 +23 +30 +30 +21.0 +56 +18 +65 +21 +27.0 +60 +83 +69 86 -31 -89 27.0 +66 +10 +68 +20 +20.0 +3 +59 +11 +62 +24.0 +69 57 -74 +77 60 -81 -21.0 -66 -19 -73 -22 -21.0 +24.0 +32 +39 +41 +42 +27.0 +67 +39 +71 +44 +20.0 +55 +33 +63 +36 +24.0 37 -83 +85 42 -87 +89 20.0 -29 +17 +44 +23 +48 +24.0 +38 +21 +44 +25 +24.0 +65 +30 +66 50 -33 -55 20.0 -10 +14 +21 +16 31 -13 -38 -21.0 -13 -57 -18 +20.0 +16 61 +21 +65 20.0 -86 +49 +37 +53 +42 +20.0 +43 +83 46 -91 -50 +90 +21.0 +57 +57 +66 +60 +27.0 +83 +69 +89 +73 +24.0 +84 +38 +86 +48 20.0 +32 +31 +39 +34 +21.0 +7 40 -74 -45 +10 +47 +21.0 +55 78 +59 +83 20.0 -86 -70 -90 -75 +78 +13 +80 +23 20.0 -12 -26 -19 -29 +36 +4 +39 +11 21.0 -28 -17 -35 -20 +90 +61 +97 +64 21.0 -39 -50 -45 -54 +25 +11 +26 +31 +20.0 +72 +30 +81 +33 +27.0 +78 +62 +82 +67 +20.0 +51 +73 +59 +76 24.0 -2 +72 +68 +75 +75 +21.0 +35 +44 +41 48 -8 -52 24.0 -14 -39 -20 43 -24.0 -39 +3 +45 13 -46 -16 -21.0 -73 -49 -77 -54 +20.0 +82 +18 +86 +23 20.0 30 -91 +35 39 -94 +38 27.0 -69 -31 -73 -36 -20.0 -66 -77 -69 -84 -21.0 +57 +39 64 +42 +21.0 53 -66 -63 +90 +62 +93 +27.0 +41 +71 +47 +75 +24.0 +10 +72 +13 +79 +21.0 +48 +15 +53 +19 20.0 -18 +15 +68 21 -24 -25 +72 24.0 -29 -78 -34 -82 +50 +21 +55 +25 20.0 -76 +70 +24 77 -79 -84 +27 21.0 -1 -40 -9 +60 43 -24.0 -51 -79 -56 -83 +64 +48 20.0 +51 +69 59 -33 -66 -36 -21.0 -50 -24 -56 -28 +72 +24.0 +72 +85 +81 +88 +27.0 +6 +54 +14 +57 +24.0 +18 +40 +27 +43 +27.0 +87 +48 +93 +52 24.0 +44 46 -60 -51 -64 +46 +56 20.0 -38 -63 -41 -70 -21.0 -66 -41 -74 -44 +15 +56 +23 +59 24.0 -62 -92 -66 -97 +15 +15 +19 +20 20.0 -4 -67 -12 -70 +87 +26 +93 +30 24.0 -81 -14 -86 -18 -20.0 -75 +88 +39 +95 +42 +21.0 +19 85 -82 +26 88 21.0 -8 -74 -13 -78 +33 +76 +35 +86 20.0 -31 -21 +42 +76 +48 +80 +24.0 +72 36 -25 +77 +40 20.0 -14 -16 -19 -20 +4 +49 +9 +53 20.0 -92 +45 60 -96 +49 65 20.0 +80 +80 +87 +83 +21.0 +47 +29 +52 +33 +20.0 +40 +49 +41 +69 +20.0 +48 +88 +51 +95 +21.0 +54 +12 +58 +17 +20.0 +85 53 -63 +92 56 -70 21.0 -13 -68 -20 -71 +28 +7 +31 +14 21.0 -9 -21 -15 -25 +49 +80 +52 +87 +21.0 +64 +89 +72 +92 24.0 -50 +30 +48 33 -53 -40 -21.0 -43 55 -48 -59 -20.0 -71 -84 -74 -91 21.0 -62 -66 -68 +63 +67 70 -24.0 70 -67 -74 +21.0 72 -20.0 78 +76 +83 +20.0 +37 +92 +46 +95 +27.0 +63 +24 +68 28 -82 -33 20.0 -54 -59 -62 -62 -24.0 -21 -64 -23 -74 +78 +57 +83 +61 20.0 -5 -60 -11 -64 -24.0 -86 -36 -89 -43 +10 +49 +17 +52 21.0 -91 -28 -94 +30 +89 35 -21.0 -75 -15 +93 +20.0 +28 79 -20 +32 +84 20.0 -59 48 -65 -52 -24.0 +2 +51 +9 +21.0 +72 +62 +77 +66 +20.0 +63 3 -33 -8 -37 +65 +13 20.0 +18 +26 +24 +30 +24.0 +6 27 -56 -31 -61 -20.0 -86 -66 +13 +30 +21.0 94 -69 -24.0 -57 -86 -62 -90 +47 +98 +52 +20.0 +12 +39 +16 +44 +20.0 +5 +32 +9 +37 +20.0 +67 +30 +71 +35 20.0 +79 +40 +83 45 -4 -50 -8 20.0 -52 -7 -61 -10 -27.0 -70 +19 +80 +24 +84 +20.0 +3 +40 +6 47 -72 +21.0 +88 57 +96 +60 +24.0 +4 +65 +9 +69 20.0 -92 -44 -98 -48 +80 +25 +86 +29 24.0 +56 61 -73 -63 -83 +61 +65 20.0 21 -36 -26 -40 +12 +23 +22 20.0 -0.12225246 -0.37408406 -0.06628969 -0.64457035 -0.23417756 -0.26215884 -0.7658226 -0.374084 -0.47668225 -0.5792806 -0.76582265 -0.961692 -0.8124583 -0.2994673 -0.47668222 -0.8870751 -0.084943935 -0.53264505 -0.93371063 -0.99900043 -0.47668222 -0.22485054 -0.3087944 -0.5606262 -0.24350454 -0.5979348 -0.93371063 -0.8031311 -0.99900043 -0.6165891 -0.6259161 -0.70986 -0.961692 -0.6259158 -0.29946718 -0.23417749 -0.99900043 -0.9803462 -0.374084 -0.08494389 -0.29946724 -0.95236486 -0.48600927 -0.7098599 -0.9150564 -0.47668222 -0.5886074 -0.42071956 -0.38341117 -0.34610268 -0.65389746 -0.89640224 -0.877748 -0.34610277 -0.15956078 -0.14090666 -0.54197186 -0.87774795 -0.12225238 -0.1968692 -0.5606262 -0.3367757 -0.99900043 -0.4113925 -0.40206534 -0.9243835 -0.7005328 -0.8217853 -0.2528317 -0.09427108 -0.15956095 -0.29946703 -0.93371063 -0.16888794 -0.45802802 -0.77514976 -0.112925306 -0.41139245 -0.028981315 -0.010327125 -0.11292531 -0.028981313 -0.5046636 -0.9150564 -0.99900043 -0.36475682 -0.4673551 -0.3367756 -0.81245816 -0.2155235 -0.12225255 -0.7285141 -0.03830839 -0.34610268 -0.6445701 -0.90572935 -0.46735507 -0.08494399 -0.9803462 -0.7005328 -0.028981308 -0.1502338 -0.55129915 -0.056962583 -0.26215878 -0.001 -0.21552338 -0.6818787 -0.38341117 -0.038308375 -0.6818787 -0.5046638 -0.7005328 -0.60726166 -0.81245816 -0.23417744 -0.3461027 -0.65389735 -0.06628969 -0.7098598 -0.32744846 -0.18754216 -0.6352431 -0.10359822 -0.94303775 -0.3367755 -0.7564956 -0.9150564 -0.89640224 -0.99900043 -0.2528317 -0.09427107 -0.635243 -0.5369992 -0.52984786 -0.54756886 -0.5422835 -0.43719596 -0.52363014 -0.47108513 -0.5279833 -0.4213391 -0.45305237 -0.41823047 -0.49129438 -0.4642455 -0.50652903 -0.53482056 -0.4664212 -0.4449682 -0.52300787 -0.5289151 -0.4384398 -0.45864865 -0.52207553 -0.4490107 -0.55969524 -0.48445427 -0.5267381 -0.5404183 -0.44869956 -0.5320225 -0.4654884 -0.566225 -0.45087644 -0.43128857 -0.42880148 -0.52425164 -0.5087055 -0.4176089 -0.54197407 -0.44652355 -0.46704352 -0.52798176 -0.4107687 -0.4654884 -0.42849013 -0.48010147 -0.47543806 -0.538551 -0.5115033 -0.53357875 -0.4390612 -0.41885254 -0.5000005 -0.45149782 -0.4567832 -0.5382421 -0.5540993 -0.5031086 -0.5453929 -0.55005723 -0.44590163 -0.43097773 -0.4483886 -0.42569262 -0.43470928 -0.41854125 -0.42165032 -0.46984157 -0.47699314 -0.5382414 -0.44901082 -0.44621223 -0.48974022 -0.5304696 -0.56062824 -0.5485018 -0.41854134 -0.49409282 -0.42786875 -0.5615612 -0.5506783 -0.50777215 -0.56124943 -0.5540982 -0.5357551 -0.43035617 -0.5099492 -0.4319103 -0.43159947 -0.42600358 -0.562494 -0.5174119 -0.43128875 -0.5609393 -0.45927057 -0.4493212 -0.49720109 -0.48134533 -0.4947147 -0.44963247 -0.45522898 -0.5397966 -0.4605139 -0.43097767 -0.53699964 -0.5435267 -0.5659129 -0.41885272 -0.44683474 -0.5335799 -0.55845106 -0.48258862 -0.4978235 -0.4340867 -0.4350199 -0.42817983 -0.4418594 -0.43999457 -0.52300787 -0.5500567 -0.43284288 -0.44621256 -0.45429567 -0.45243043 -0.55876267 -0.52829295 -0.41636503 -0.4542963 -0.5292259 -0.49720162 -0.4284908 -0.41667572 -0.4390618 -0.5429041 -107 -3210 +0.33366668 +0.001 +0.999 +0.999 +0.6663334 +0.001 +0.001 +0.999 +0.999 +0.999 +0.001 +0.999 +0.001 +0.999 +0.001 +0.999 +0.001 +0.001 +0.999 +0.999 +0.999 +0.33366668 +0.6663334 +0.999 +0.999 +0.999 +0.001 +0.999 +0.001 +0.001 +0.001 +0.999 +0.001 +0.001 +0.001 +0.001 +0.001 +0.999 +0.001 +0.33366668 +0.001 +0.6663334 +0.999 +0.999 +0.001 +0.999 +0.999 +0.001 +0.001 +0.001 +0.999 +0.001 +0.001 +0.999 +0.001 +0.999 +0.999 +0.999 +0.001 +0.001 +0.001 +0.999 +0.001 +0.999 +0.001 +0.999 +0.999 +0.33366668 +0.999 +0.001 +0.999 +0.999 +0.001 +0.999 +0.001 +0.001 +0.001 +0.6663334 +0.001 +0.999 +0.001 +0.999 +0.001 +0.001 +0.33366668 +0.999 +0.999 +0.001 +0.001 +0.001 +0.6663334 +0.999 +0.001 +0.001 +0.001 +0.999 +0.999 +0.999 +0.001 +0.999 +0.001 +0.001 +0.001 +0.999 +0.001 +0.001 +0.001 +0.6663334 +0.999 +0.001 +0.001 +0.6663334 +0.999 +0.001 +0.001 +0.001 +0.999 +0.999 +0.999 +0.001 +0.001 +0.999 +0.001 +0.001 +0.999 +0.999 +0.001 +0.999 +0.999 +0.999 +0.999 +0.999 +0.001 +0.5332665 +0.3558443 +0.75504464 +0.6663334 +0.6663334 +0.30040005 +0.37802207 +0.56653345 +0.74395573 +0.36693314 +0.18951117 +0.5221777 +0.44455558 +0.6441556 +0.4223777 +0.6774222 +0.6330667 +0.4002 +0.89920026 +0.6552446 +0.79940015 +0.49999982 +0.67742234 +0.74395585 +0.8437558 +0.8104891 +0.25604448 +0.86593366 +0.31148884 +0.5776221 +0.18951117 +0.97682256 +0.27822217 +0.5332666 +0.27822217 +0.30039993 +0.57762235 +0.86593354 +0.44455555 +0.8437558 +0.62197787 +0.91028917 +0.26713336 +0.72177804 +0.41128874 +0.82157797 +0.82157797 +0.3669333 +0.38911098 +0.5332665 +0.84375584 +0.43346664 +0.25604448 +0.64415574 +0.34475562 +0.710689 +0.71068895 +0.86593354 +0.52217793 +0.34475535 +0.5998002 +0.97682256 +0.5554445 +0.77722245 +0.45564443 +0.8992004 +0.6663336 +0.54435563 +0.6663335 +0.4001999 +0.61088896 +0.9435559 +0.4556444 +0.82157797 +0.50000006 +0.35584447 +0.18951117 +0.69960016 +0.22277781 +0.74395585 +0.9213781 +0.76613355 +0.5554445 +0.67742234 +0.30039993 +0.37802207 +0.821578 +0.48891115 +0.3004 +0.4445555 +0.97682256 +0.8437558 +0.22277768 +0.31148896 +0.36693335 +0.87702245 +0.3225776 +0.4889113 +0.6552446 +0.6219779 +0.34475544 +0.4667334 +0.8104891 +0.78831124 +0.5443554 +0.5 +0.6663336 +0.37802207 +0.6663334 +0.6330667 +0.3558445 +0.91028917 +0.7328668 +0.3447555 +0.25604454 +0.27822214 +0.67742234 +0.69960016 +0.8437558 +0.4223777 +0.4223777 +0.821578 +0.4112888 +0.43346664 +0.87702256 +0.86593354 +0.21168894 +0.36693314 +0.78831124 +0.23386659 +0.96573365 +0.63306683 +0.47782215 +3 +90 diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/makefile b/Robust/src/Benchmarks/SSJava/EyeTracking/makefile index b04e9c4d..dbdb3236 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/makefile +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/makefile @@ -3,7 +3,7 @@ BUILDSCRIPT=../../../buildscript PROGRAM=LEA SOURCE_FILES=LEA.java -BSFLAGS= -32bit -ssjava -mainclass $(PROGRAM) -heapsize-mb 1000 -debug -garbagestats -ssjavadebug -printlinenum -joptimize #-nooptimize +BSFLAGS= -32bit -ssjava -mainclass $(PROGRAM) -heapsize-mb 1000 -debug -garbagestats -ssjavadebug -printlinenum -joptimize -optimize default: $(PROGRAM)s.bin diff --git a/Robust/src/ClassLibrary/SSJava/ArrayList.java b/Robust/src/ClassLibrary/SSJava/ArrayList.java new file mode 100644 index 00000000..08bb4c64 --- /dev/null +++ b/Robust/src/ClassLibrary/SSJava/ArrayList.java @@ -0,0 +1,621 @@ +/* ArrayList.java -- JDK1.2's answer to Vector; this is an array-backed + implementation of the List interface + Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +//package java.util; + +/*import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.reflect.Array; +*/ +/** + * An array-backed implementation of the List interface. This implements + * all optional list operations, and permits null elements, so that it is + * better than Vector, which it replaces. Random access is roughly constant + * time, and iteration is roughly linear time, so it is nice and fast, with + * less overhead than a LinkedList. + *

    + * + * Each list has a capacity, and as the array reaches that capacity it + * is automatically transferred to a larger array. You also have access to + * ensureCapacity and trimToSize to control the backing array's size, avoiding + * reallocation or wasted memory. + *

    + * + * ArrayList is not synchronized, so if you need multi-threaded access, + * consider using:
    + * List l = Collections.synchronizedList(new ArrayList(...)); + *

    + * + * The iterators are fail-fast, meaning that any structural + * modification, except for remove() called on the iterator + * itself, cause the iterator to throw a + * {@link ConcurrentModificationException} rather than exhibit + * non-deterministic behavior. + * + * @author Jon A. Zeppieri + * @author Bryce McKinlay + * @author Eric Blake (ebb9@email.byu.edu) + * @see Collection + * @see List + * @see LinkedList + * @see Vector + * @see Collections#synchronizedList(List) + * @see AbstractList + * @status updated to 1.4 + */ +//public class ArrayList extends AbstractList +// implements List, RandomAccess, Cloneable, Serializable +public class ArrayList +{ + protected transient int modCount; + /** + * Compatible with JDK 1.2 + */ + private static final long serialVersionUID = 8683452581122892189L; + + /** + * The default capacity for new ArrayLists. + */ + private static final int DEFAULT_CAPACITY = 10; + + /** + * The number of elements in this list. + * @serial the list size + */ + private int size; + + /** + * Where the data is stored. + */ + //private transient E[] data; + private transient Object[] data; + + /** + * Construct a new ArrayList with the supplied initial capacity. + * + * @param capacity initial capacity of this ArrayList + * @throws IllegalArgumentException if capacity is negative + */ + public ArrayList(int capacity) + { + // Must explicitly check, to get correct exception. + if (capacity < 0) + throw new Error("Illegal Argument Exception")/*IllegalArgumentException()*/; + data = (Object/*E*/[]) new Object[capacity]; + } + + /** + * Construct a new ArrayList with the default capacity (16). + */ + public ArrayList() + { + this(DEFAULT_CAPACITY); + } + + /** + * Construct a new ArrayList, and initialize it with the elements + * in the supplied Collection. The initial capacity is 110% of the + * Collection's size. + * + * @param c the collection whose elements will initialize this list + * @throws NullPointerException if c is null + */ + /*public ArrayList(Collection c) + { + this((int) (c.size() * 1.1f)); + addAll(c); + }*/ + + /** + * Trims the capacity of this List to be equal to its size; + * a memory saver. + */ + public void trimToSize() + { + // Not a structural change from the perspective of iterators on this list, + // so don't update modCount. + if (size != data.length) + { + Object/*E*/[] newData = /*(ObjectE[])*/ new Object[size]; + System.arraycopy(data, 0, newData, 0, size); + data = newData; + } + } + + /** + * Guarantees that this list will have at least enough capacity to + * hold minCapacity elements. This implementation will grow the list to + * max(current * 2, minCapacity) if (minCapacity > current). The JCL says + * explictly that "this method increases its capacity to minCap", while + * the JDK 1.3 online docs specify that the list will grow to at least the + * size specified. + * + * @param minCapacity the minimum guaranteed capacity + */ + public void ensureCapacity(int minCapacity) + { + int current = data.length; + + if (minCapacity > current) + { + Object/*E*/[] newData = /*(E[])*/ new Object[Math.max(current * 2, minCapacity)]; + System.arraycopy(data, 0, newData, 0, size); + data = newData; + } + } + + /** + * Returns the number of elements in this list. + * + * @return the list size + */ + public int size() + { + return size; + } + + /** + * Checks if the list is empty. + * + * @return true if there are no elements + */ + public boolean isEmpty() + { + return size == 0; + } + + /** + * Returns true iff element is in this ArrayList. + * + * @param e the element whose inclusion in the List is being tested + * @return true if the list contains e + */ + public boolean contains(Object e) + { + return indexOf(e) != -1; + } + + /** + * Returns the lowest index at which element appears in this List, or + * -1 if it does not appear. + * + * @param e the element whose inclusion in the List is being tested + * @return the index where e was found + */ + public int indexOf(Object e) + { + for (int i = 0; i < size; i++) + if (equals(e, data[i])) + return i; + return -1; + } + + /** + * Returns the highest index at which element appears in this List, or + * -1 if it does not appear. + * + * @param e the element whose inclusion in the List is being tested + * @return the index where e was found + */ + public int lastIndexOf(Object e) + { + for (int i = size - 1; i >= 0; i--) + if (equals(e, data[i])) + return i; + return -1; + } + + boolean equals(Object o1, Object o2) + { + return o1 == null ? o2 == null : o1.equals(o2); + } + + /** + * Creates a shallow copy of this ArrayList (elements are not cloned). + * + * @return the cloned object + */ + /*public Object clone() + { + ArrayList clone = null; + try + { + clone = (ArrayList) super.clone(); + //clone = new ArrayList(); + clone.data = (E[]) data.clone(); + } + catch (CloneNotSupportedException e) + { + // Impossible to get here. + } + return clone; + }*/ + + /** + * Returns an Object array containing all of the elements in this ArrayList. + * The array is independent of this list. + * + * @return an array representation of this list + */ + public Object[] toArray() + { + Object/*E*/[] array = /*(E[])*/ new Object[size]; + System.arraycopy(data, 0, array, 0, size); + return array; + } + + /** + * Returns an Array whose component type is the runtime component type of + * the passed-in Array. The returned Array is populated with all of the + * elements in this ArrayList. If the passed-in Array is not large enough + * to store all of the elements in this List, a new Array will be created + * and returned; if the passed-in Array is larger than the size + * of this List, then size() index will be set to null. + * + * @param a the passed-in Array + * @return an array representation of this list + * @throws ArrayStoreException if the runtime type of a does not allow + * an element in this list + * @throws NullPointerException if a is null + */ + /*public T[] toArray(T[] a) + { + if (a.length < size) + a = (T[]) Array.newInstance(a.getClass().getComponentType(), size); + else if (a.length > size) + a[size] = null; + System.arraycopy(data, 0, a, 0, size); + return a; + }*/ + + /** + * Retrieves the element at the user-supplied index. + * + * @param index the index of the element we are fetching + * @throws IndexOutOfBoundsException if index < 0 || index >= size() + */ + public Object/*E*/ get(int index) + { + checkBoundExclusive(index); + return data[index]; + } + + /** + * Sets the element at the specified index. The new element, e, + * can be an object of any type or null. + * + * @param index the index at which the element is being set + * @param e the element to be set + * @return the element previously at the specified index + * @throws IndexOutOfBoundsException if index < 0 || index >= 0 + */ + public Object/*E*/ set(int index, Object/*E*/ e) + { + checkBoundExclusive(index); + Object/*E*/ result = data[index]; + data[index] = e; + return result; + } + + /** + * Appends the supplied element to the end of this list. + * The element, e, can be an object of any type or null. + * + * @param e the element to be appended to this list + * @return true, the add will always succeed + */ + public boolean add(Object/*E*/ e) + { + modCount++; + if (size == data.length) + ensureCapacity(size + 1); + data[size++] = e; + return true; + } + + /** + * Adds the supplied element at the specified index, shifting all + * elements currently at that index or higher one to the right. + * The element, e, can be an object of any type or null. + * + * @param index the index at which the element is being added + * @param e the item being added + * @throws IndexOutOfBoundsException if index < 0 || index > size() + */ + public void add(int index, Object/*E*/ e) + { + checkBoundInclusive(index); + modCount++; + if (size == data.length) + ensureCapacity(size + 1); + if (index != size) + System.arraycopy(data, index, data, index + 1, size - index); + data[index] = e; + size++; + } + + /** + * Removes the element at the user-supplied index. + * + * @param index the index of the element to be removed + * @return the removed Object + * @throws IndexOutOfBoundsException if index < 0 || index >= size() + */ + public Object/*E*/ remove(int index) + { + checkBoundExclusive(index); + Object/*E*/ r = data[index]; + modCount++; + if (index != --size) + System.arraycopy(data, index + 1, data, index, size - index); + // Aid for garbage collection by releasing this pointer. + data[size] = null; + return r; + } + + /** + * Removes all elements from this List + */ + public void clear() + { + if (size > 0) + { + modCount++; + // Allow for garbage collection. + //Arrays.fill(data, 0, size, null); + for(int i = 0; i < size; i++) { + this.data[i] = null; + } + size = 0; + } + } + + /** + * Add each element in the supplied Collection to this List. It is undefined + * what happens if you modify the list while this is taking place; for + * example, if the collection contains this list. c can contain objects + * of any type, as well as null values. + * + * @param c a Collection containing elements to be added to this List + * @return true if the list was modified, in other words c is not empty + * @throws NullPointerException if c is null + */ + /*public boolean addAll(Collection c) + { + return addAll(size, c); + }*/ + + /** + * Add all elements in the supplied collection, inserting them beginning + * at the specified index. c can contain objects of any type, as well + * as null values. + * + * @param index the index at which the elements will be inserted + * @param c the Collection containing the elements to be inserted + * @throws IndexOutOfBoundsException if index < 0 || index > 0 + * @throws NullPointerException if c is null + */ + /*public boolean addAll(int index, Collection c) + { + checkBoundInclusive(index); + Iterator itr = c.iterator(); + int csize = c.size(); + + modCount++; + if (csize + size > data.length) + ensureCapacity(size + csize); + int end = index + csize; + if (size > 0 && index != size) + System.arraycopy(data, index, data, end, size - index); + size += csize; + for ( ; index < end; index++) + data[index] = itr.next(); + return csize > 0; + }*/ + + /** + * Removes all elements in the half-open interval [fromIndex, toIndex). + * Does nothing when toIndex is equal to fromIndex. + * + * @param fromIndex the first index which will be removed + * @param toIndex one greater than the last index which will be removed + * @throws IndexOutOfBoundsException if fromIndex > toIndex + */ + protected void removeRange(int fromIndex, int toIndex) + { + int change = toIndex - fromIndex; + if (change > 0) + { + modCount++; + System.arraycopy(data, toIndex, data, fromIndex, size - toIndex); + size -= change; + } + else if (change < 0) + throw new Error("Index Out Of Bounds Exception")/*IndexOutOfBoundsException()*/; + } + + /** + * Checks that the index is in the range of possible elements (inclusive). + * + * @param index the index to check + * @throws IndexOutOfBoundsException if index > size + */ + private void checkBoundInclusive(int index) + { + // Implementation note: we do not check for negative ranges here, since + // use of a negative index will cause an ArrayIndexOutOfBoundsException, + // a subclass of the required exception, with no effort on our part. + if (index > size) + raiseBoundsError(index); + } + + /** + * Checks that the index is in the range of existing elements (exclusive). + * + * @param index the index to check + * @throws IndexOutOfBoundsException if index >= size + */ + private void checkBoundExclusive(int index) + { + // Implementation note: we do not check for negative ranges here, since + // use of a negative index will cause an ArrayIndexOutOfBoundsException, + // a subclass of the required exception, with no effort on our part. + if (index >= size) + raiseBoundsError(index); + } + + /** + * Raise the ArrayIndexOfOutBoundsException. + * + * @param index the index of the access + * @throws IndexOutOfBoundsException unconditionally + */ + private void raiseBoundsError(int index) + { + // Implementaion note: put in a separate method to make the JITs job easier + // (separate common from uncommon code at method boundaries when trivial to + // do so). + throw new Error/*IndexOutOfBoundsException*/("IndexOutOfBoundsException Index: " + index + ", Size: " + size); + } + + + /** + * Remove from this list all elements contained in the given collection. + * This is not public, due to Sun's API, but this performs in linear + * time while the default behavior of AbstractList would be quadratic. + * + * @param c the collection to filter out + * @return true if this list changed + * @throws NullPointerException if c is null + */ + /*boolean removeAllInternal(Collection c) + { + int i; + int j; + for (i = 0; i < size; i++) + if (c.contains(data[i])) + break; + if (i == size) + return false; + + modCount++; + for (j = i++; i < size; i++) + if (! c.contains(data[i])) + data[j++] = data[i]; + size -= i - j; + return true; + }*/ + + /** + * Retain in this vector only the elements contained in the given collection. + * This is not public, due to Sun's API, but this performs in linear + * time while the default behavior of AbstractList would be quadratic. + * + * @param c the collection to filter by + * @return true if this vector changed + * @throws NullPointerException if c is null + * @since 1.2 + */ + /*boolean retainAllInternal(Collection c) + { + int i; + int j; + for (i = 0; i < size; i++) + if (! c.contains(data[i])) + break; + if (i == size) + return false; + + modCount++; + for (j = i++; i < size; i++) + if (c.contains(data[i])) + data[j++] = data[i]; + size -= i - j; + return true; + }*/ + + /** + * Serializes this object to the given stream. + * + * @param s the stream to write to + * @throws IOException if the underlying stream fails + * @serialData the size field (int), the length of the backing array + * (int), followed by its elements (Objects) in proper order. + */ + /*private void writeObject(ObjectOutputStream s) throws IOException + { + // The 'size' field. + s.defaultWriteObject(); + // We serialize unused list entries to preserve capacity. + int len = data.length; + s.writeInt(len); + // it would be more efficient to just write "size" items, + // this need readObject read "size" items too. + for (int i = 0; i < size; i++) + s.writeObject(data[i]); + }*/ + + /** + * Deserializes this object from the given stream. + * + * @param s the stream to read from + * @throws ClassNotFoundException if the underlying stream fails + * @throws IOException if the underlying stream fails + * @serialData the size field (int), the length of the backing array + * (int), followed by its elements (Objects) in proper order. + */ + /*private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + // the `size' field. + s.defaultReadObject(); + int capacity = s.readInt(); + data = (E[]) new Object[capacity]; + for (int i = 0; i < size; i++) + data[i] = (E) s.readObject(); + }*/ + + public ArrayListIterator iterator() + { + // Bah, Sun's implementation forbids using listIterator(0). + return new ArrayListIterator(this); + } +} diff --git a/Robust/src/ClassLibrary/SSJava/ArrayListIterator.java b/Robust/src/ClassLibrary/SSJava/ArrayListIterator.java new file mode 100644 index 00000000..cb3b226d --- /dev/null +++ b/Robust/src/ClassLibrary/SSJava/ArrayListIterator.java @@ -0,0 +1,64 @@ +public class ArrayListIterator extends Iterator { + private int pos; + private int size; + private int last; + private ArrayList list; + + public ArrayListIterator(ArrayList list) { + this.list = list; + this.pos = 0; + this.size = this.list.size(); + this.last = -1; + } + + /** + * Tests to see if there are any more objects to + * return. + * + * @return True if the end of the list has not yet been + * reached. + */ + public boolean hasNext() + { + return pos < size; + } + + /** + * Retrieves the next object from the list. + * + * @return The next object. + * @throws NoSuchElementException if there are + * no more objects to retrieve. + * @throws ConcurrentModificationException if the + * list has been modified elsewhere. + */ + public Object next() + { + if (pos == size) + throw new /*NoSuchElement*/Exception("NoSuchElementException"); + last = pos; + return this.list.get(pos++); + } + + /** + * Removes the last object retrieved by next() + * from the list, if the list supports object removal. + * + * @throws ConcurrentModificationException if the list + * has been modified elsewhere. + * @throws IllegalStateException if the iterator is positioned + * before the start of the list or the last object has already + * been removed. + * @throws UnsupportedOperationException if the list does + * not support removing elements. + */ + public void remove() + { + if (last < 0) + throw new /*IllegalState*/Exception("IllegalStateException"); + this.list.remove(last); + pos--; + size--; + last = -1; + } +} \ No newline at end of file diff --git a/Robust/src/ClassLibrary/SSJava/Double.java b/Robust/src/ClassLibrary/SSJava/Double.java new file mode 100644 index 00000000..8af978ab --- /dev/null +++ b/Robust/src/ClassLibrary/SSJava/Double.java @@ -0,0 +1,556 @@ +/* Double.java -- object wrapper for double + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Free Software Foundation, Inc. + + This file is part of GNU Classpath. + + GNU Classpath is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GNU Classpath is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Classpath; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. + + Linking this library statically or dynamically with other modules is + making a combined work based on this library. Thus, the terms and + conditions of the GNU General Public License cover the whole + combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent + modules, and to copy and distribute the resulting executable under + terms of your choice, provided that you also meet, for each linked + independent module, the terms and conditions of the license of that + module. An independent module is a module which is not derived from + or based on this library. If you modify this library, you may extend + this exception to your version of the library, but you are not + obligated to do so. If you do not wish to do so, delete this + exception statement from your version. */ + +//package java.lang; + + +/** + * Instances of class Double represent primitive + * double values. + * + * Additionally, this class provides various helper functions and variables + * related to doubles. + * + * @author Paul Fisher + * @author Andrew Haley (aph@cygnus.com) + * @author Eric Blake (ebb9@email.byu.edu) + * @author Tom Tromey (tromey@redhat.com) + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.0 + * @status partly updated to 1.5 + */ +public final class Double extends Number //implements Comparable +{ + /** + * Compatible with JDK 1.0+. + */ + /** + * The immutable value of this Double. + * + * @serial the wrapped double + */ + private final double value; + + /** + * Create a Double from the primitive double + * specified. + * + * @param value the double argument + */ + public Double(double value) { + this.value = value; + } + + /** + * Create a Double from the specified String. + * This method calls Double.parseDouble(). + * + * @param s the String to convert + * @throws NumberFormatException if s cannot be parsed as a + * double + * @throws NullPointerException if s is null + * @see #parseDouble(String) + */ + public Double(String s) { + value = parseDouble(s); + } + + /** + * Convert the double to a String. + * Floating-point string representation is fairly complex: here is a + * rundown of the possible values. "[-]" indicates that a + * negative sign will be printed if the value (or exponent) is negative. + * "<number>" means a string of digits ('0' to '9'). + * "<digit>" means a single digit ('0' to '9').
    + * + * + * + * + * + * + * + * + * + * + *
    Value of DoubleString Representation
    [+-] 0 [-]0.0
    Between [+-] 10-3 and 107, exclusive[-]number.number
    Other numeric value[-]<digit>.<number> + * E[-]<number>
    [+-] infinity [-]Infinity
    NaN NaN
    + * + * Yes, negative zero is a possible value. Note that there is + * always a . and at least one digit printed after + * it: even if the number is 3, it will be printed as 3.0. + * After the ".", all digits will be printed except trailing zeros. The + * result is rounded to the shortest decimal number which will parse back + * to the same double. + * + *

    To create other output formats, use {@link java.text.NumberFormat}. + * + * @XXX specify where we are not in accord with the spec. + * + * @param d the double to convert + * @return the String representing the double + */ + public static String toString(double d) { + return String.valueOf(d); + } + + /** + * Convert a double value to a hexadecimal string. This converts as + * follows: + *

      + *
    • A NaN value is converted to the string "NaN". + *
    • Positive infinity is converted to the string "Infinity". + *
    • Negative infinity is converted to the string "-Infinity". + *
    • For all other values, the first character of the result is '-' + * if the value is negative. This is followed by '0x1.' if the + * value is normal, and '0x0.' if the value is denormal. This is + * then followed by a (lower-case) hexadecimal representation of the + * mantissa, with leading zeros as required for denormal values. + * The next character is a 'p', and this is followed by a decimal + * representation of the unbiased exponent. + *
    + * @param d the double value + * @return the hexadecimal string representation + * @since 1.5 + */ + public static String toHexString(double d) { + /* + if (isNaN(d)) + return "NaN"; + if (isInfinite(d)) + return d < 0 ? "-Infinity" : "Infinity"; + + long bits = doubleToLongBits(d); + StringBuilder result = new StringBuilder(); + + if (bits < 0) + result.append('-'); + result.append("0x"); + + final int mantissaBits = 52; + final int exponentBits = 11; + long mantMask = (1L << mantissaBits) - 1; + long mantissa = bits & mantMask; + long expMask = (1L << exponentBits) - 1; + long exponent = (bits >>> mantissaBits) & expMask; + + result.append(exponent == 0 ? '0' : '1'); + result.append('.'); + result.append(Long.toHexString(mantissa)); + if (exponent == 0 && mantissa != 0) + { + // Treat denormal specially by inserting '0's to make + // the length come out right. The constants here are + // to account for things like the '0x'. + int offset = 4 + ((bits < 0) ? 1 : 0); + // The silly +3 is here to keep the code the same between + // the Float and Double cases. In Float the value is + // not a multiple of 4. + int desiredLength = offset + (mantissaBits + 3) / 4; + while (result.length() < desiredLength) + result.insert(offset, '0'); + } + result.append('p'); + if (exponent == 0 && mantissa == 0) + { + // Zero, so do nothing special. + } + else + { + // Apply bias. + boolean denormal = exponent == 0; + exponent -= (1 << (exponentBits - 1)) - 1; + // Handle denormal. + if (denormal) + ++exponent; + } + + result.append(Long.toString(exponent)); + return result.toString(); + */ + return "0x0"; + } + + /** + * Returns a Double object wrapping the value. + * In contrast to the Double constructor, this method + * may cache some values. It is used by boxing conversion. + * + * @param val the value to wrap + * @return the Double + * @since 1.5 + */ + public static Double valueOf(double val) { + // We don't actually cache, but we could. + return new Double(val); + } + + /** + * Create a new Double object using the String. + * + * @param s the String to convert + * @return the new Double + * @throws NumberFormatException if s cannot be parsed as a + * double + * @throws NullPointerException if s is null. + * @see #parseDouble(String) + */ + public static Double valueOf(String s) { + return new Double(parseDouble(s)); + } + + /** + * Parse the specified String as a double. The + * extended BNF grammar is as follows:
    + *
    +   * DecodableString:
    +   *      ( [ - | + ] NaN )
    +   *    | ( [ - | + ] Infinity )
    +   *    | ( [ - | + ] FloatingPoint
    +   *              [ f | F | d
    +   *                | D] )
    +   * FloatingPoint:
    +   *      ( { Digit }+ [ . { Digit } ]
    +   *              [ Exponent ] )
    +   *    | ( . { Digit }+ [ Exponent ] )
    +   * Exponent:
    +   *      ( ( e | E )
    +   *              [ - | + ] { Digit }+ )
    +   * Digit: '0' through '9'
    +   * 
    + * + *

    NaN and infinity are special cases, to allow parsing of the output + * of toString. Otherwise, the result is determined by calculating + * n * 10exponent to infinite precision, then rounding + * to the nearest double. Remember that many numbers cannot be precisely + * represented in floating point. In case of overflow, infinity is used, + * and in case of underflow, signed zero is used. Unlike Integer.parseInt, + * this does not accept Unicode digits outside the ASCII range. + * + *

    If an unexpected character is found in the String, a + * NumberFormatException will be thrown. Leading and trailing + * 'whitespace' is ignored via String.trim(), but spaces + * internal to the actual number are not allowed. + * + *

    To parse numbers according to another format, consider using + * {@link java.text.NumberFormat}. + * + * @XXX specify where/how we are not in accord with the spec. + * + * @param str the String to convert + * @return the double value of s + * @throws NumberFormatException if s cannot be parsed as a + * double + * @throws NullPointerException if s is null + * @see #MIN_VALUE + * @see #MAX_VALUE + * @see #POSITIVE_INFINITY + * @see #NEGATIVE_INFINITY + * @since 1.2 + */ + public static double parseDouble(String str) { + return nativeparsedouble(str); + } + + public static native double nativeparsedouble(String str); + public static native double nativeparsedouble(int start, int length, byte[] str); + + /** + * Return true if the double has the same + * value as NaN, otherwise return false. + * + * @param v the double to compare + * @return whether the argument is NaN. + */ + public static boolean isNaN(double v) { + // This works since NaN != NaN is the only reflexive inequality + // comparison which returns true. + return v != v; + } + + /** + * Return true if the double has a value + * equal to either NEGATIVE_INFINITY or + * POSITIVE_INFINITY, otherwise return false. + * + * @param v the double to compare + * @return whether the argument is (-/+) infinity. + */ + public static boolean isInfinite(double v) { + return false; + } + + /** + * Return true if the value of this Double + * is the same as NaN, otherwise return false. + * + * @return whether this Double is NaN + */ + public boolean isNaN() { + return isNaN(value); + } + + /** + * Return true if the value of this Double + * is the same as NEGATIVE_INFINITY or + * POSITIVE_INFINITY, otherwise return false. + * + * @return whether this Double is (-/+) infinity + */ + public boolean isInfinite() { + return isInfinite(value); + } + + /** + * Convert the double value of this Double + * to a String. This method calls + * Double.toString(double) to do its dirty work. + * + * @return the String representation + * @see #toString(double) + */ + public String toString() { + return toString(value); + } + + /** + * Return the value of this Double as a byte. + * + * @return the byte value + * @since 1.1 + */ + public byte byteValue() { + return (byte) value; + } + + /** + * Return the value of this Double as a short. + * + * @return the short value + * @since 1.1 + */ + public short shortValue() { + return (short) value; + } + + /** + * Return the value of this Double as an int. + * + * @return the int value + */ + public int intValue() { + return (int) value; + } + + /** + * Return the value of this Double as a long. + * + * @return the long value + */ + public long longValue() { + return (long) value; + } + + /** + * Return the value of this Double as a float. + * + * @return the float value + */ + public float floatValue() { + return (float) value; + } + + /** + * Return the value of this Double. + * + * @return the double value + */ + public double doubleValue() { + return value; + } + + /** + * Return a hashcode representing this Object. Double's hash + * code is calculated by:
    + * long v = Double.doubleToLongBits(doubleValue());
    + * int hash = (int)(v^(v>>32))
    . + * + * @return this Object's hash code + * @see #doubleToLongBits(double) + */ + public int hashCode() { + long v = doubleToLongBits(value); + return (int) (v ^ (v >>> 32)); + } + + /** + * Returns true if obj is an instance of + * Double and represents the same double value. Unlike comparing + * two doubles with ==, this treats two instances of + * Double.NaN as equal, but treats 0.0 and + * -0.0 as unequal. + * + *

    Note that d1.equals(d2) is identical to + * doubleToLongBits(d1.doubleValue()) == + * doubleToLongBits(d2.doubleValue()). + * + * @param obj the object to compare + * @return whether the objects are semantically equal + */ + public boolean equals(Object obj) { + if (!(obj instanceof Double)) + return false; + + double d = ((Double) obj).value; + + // Avoid call to native method. However, some implementations, like gcj, + // are better off using floatToIntBits(value) == floatToIntBits(f). + // Check common case first, then check NaN and 0. + if (value == d) + return (value != 0) || (1 / value == 1 / d); + return isNaN(value) && isNaN(d); + } + + /** + * Convert the double to the IEEE 754 floating-point "double format" bit + * layout. Bit 63 (the most significant) is the sign bit, bits 62-52 + * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0 + * (masked by 0x000fffffffffffffL) are the mantissa. This function + * collapses all versions of NaN to 0x7ff8000000000000L. The result of this + * function can be used as the argument to + * Double.longBitsToDouble(long) to obtain the original + * double value. + * + * @param value the double to convert + * @return the bits of the double + * @see #longBitsToDouble(long) + */ + public static long doubleToLongBits(double value) { + if (isNaN(value)) + return 0x7ff8000000000000L; + else + return /*VMDouble.*/ doubleToRawLongBits(value); + } + + /** + * Convert the double to the IEEE 754 floating-point "double format" bit + * layout. Bit 63 (the most significant) is the sign bit, bits 62-52 + * (masked by 0x7ff0000000000000L) represent the exponent, and bits 51-0 + * (masked by 0x000fffffffffffffL) are the mantissa. This function + * leaves NaN alone, rather than collapsing to a canonical value. The + * result of this function can be used as the argument to + * Double.longBitsToDouble(long) to obtain the original + * double value. + * + * @param value the double to convert + * @return the bits of the double + * @see #longBitsToDouble(long) + */ + /*public static long doubleToRawLongBits(double value) + { + return VMDouble.doubleToRawLongBits(value); + }*/ + public static native long doubleToRawLongBits(double value); + + /** + * Convert the argument in IEEE 754 floating-point "double format" bit + * layout to the corresponding float. Bit 63 (the most significant) is the + * sign bit, bits 62-52 (masked by 0x7ff0000000000000L) represent the + * exponent, and bits 51-0 (masked by 0x000fffffffffffffL) are the mantissa. + * This function leaves NaN alone, so that you can recover the bit pattern + * with Double.doubleToRawLongBits(double). + * + * @param bits the bits to convert + * @return the double represented by the bits + * @see #doubleToLongBits(double) + * @see #doubleToRawLongBits(double) + */ + /*public static double longBitsToDouble(long bits) + { + return VMDouble.longBitsToDouble(bits); + }*/ + public static native double longBitsToDouble(long bits); + + /** + * Compare two Doubles numerically by comparing their double + * values. The result is positive if the first is greater, negative if the + * second is greater, and 0 if the two are equal. However, this special + * cases NaN and signed zero as follows: NaN is considered greater than + * all other doubles, including POSITIVE_INFINITY, and positive + * zero is considered greater than negative zero. + * + * @param d the Double to compare + * @return the comparison + * @since 1.2 + */ + public int compareTo(Double d) { + return compare(value, d.value); + } + + /** + * Behaves like new Double(x).compareTo(new Double(y)); in + * other words this compares two doubles, special casing NaN and zero, + * without the overhead of objects. + * + * @param x the first double to compare + * @param y the second double to compare + * @return the comparison + * @since 1.4 + */ + public static int compare(double x, double y) { + // handle the easy cases: + if (x < y) + return -1; + if (x > y) + return 1; + + // handle equality respecting that 0.0 != -0.0 (hence not using x == y): + long lx = doubleToRawLongBits(x); + long ly = doubleToRawLongBits(y); + if (lx == ly) + return 0; + + // handle NaNs: + if (x != x) + return (y != y)?0:1; + else if (y != y) + return -1; + + // handle +/- 0.0 + return (lx < ly)?-1:1; + } +} diff --git a/Robust/src/ClassLibrary/SSJava/Float.java b/Robust/src/ClassLibrary/SSJava/Float.java index 360145af..a7353d71 100644 --- a/Robust/src/ClassLibrary/SSJava/Float.java +++ b/Robust/src/ClassLibrary/SSJava/Float.java @@ -355,7 +355,7 @@ public final class Float public static float parseFloat(String str) { //return VMFloat.parseFloat(str); - return (float)(Long.parseLong(str)); + return (float)(Double.parseDouble(str)); } /** diff --git a/Robust/src/ClassLibrary/SSJava/Iterator.java b/Robust/src/ClassLibrary/SSJava/Iterator.java new file mode 100644 index 00000000..f80ed50d --- /dev/null +++ b/Robust/src/ClassLibrary/SSJava/Iterator.java @@ -0,0 +1,16 @@ +public class Iterator { + boolean hasNext() { + System.out.println("Iterator is an abstract class."); + System.exit(-1); + } + + Object next() { + System.out.println("Iterator is an abstract class."); + System.exit(-1); + } + + void remove() { + System.out.println("Iterator is an abstract class."); + System.exit(-1); + } +} diff --git a/Robust/src/ClassLibrary/SSJava/Math.java b/Robust/src/ClassLibrary/SSJava/Math.java index dd89a554..b6f4a130 100644 --- a/Robust/src/ClassLibrary/SSJava/Math.java +++ b/Robust/src/ClassLibrary/SSJava/Math.java @@ -1,7 +1,8 @@ @LATTICE("Bb)?a:b; + return (a > b) ? a : b; } public static float max(float a, float b) { - return (a>b)?a:b; + return (a > b) ? a : b; } public static int max(int a, int b) { - return (a>b)?a:b; + return (a > b) ? a : b; } public static long max(long a, long b) { - return (a>b)?a:b; + return (a > b) ? a : b; } - + @RETURNLOC("IN") public static double min(@LOC("IN") double a, @LOC("IN") double b) { - return (a abs(b)) { - r = b/a; - r = abs(a)*sqrt(1+r*r); + r = b / a; + r = abs(a) * sqrt(1 + r * r); } else if (b != 0) { - r = a/b; - r = abs(b)*sqrt(1+r*r); + r = a / b; + r = abs(b) * sqrt(1 + r * r); } else { r = 0.0; } return r; } + public static int round(float a) { + // this check for NaN, from JLS 15.21.1, saves a method call + return (int) floor(a + 0.5f); + } + public static double rint(double x) { double y = ceil(x); double d = y - x; - if( d == 0.5 ) { - if( ((int)y)%2 == 0 ) { + if (d == 0.5) { + if (((int) y) % 2 == 0) { return y; } else { return y - 1.0; } - } else if( d < 0.5 ) { + } else if (d < 0.5) { return y; } return y - 1.0; } public static native double sin(double a); + public static native double cos(double a); + public static native double asin(double a); + public static native double acos(double a); + public static native double tan(double a); + public static native double atan(double a); + public static native double atan2(double a, double b); + public static native double exp(double a); + public static native double sqrt(double a); + public static native double log(double a); - + @RETURNLOC("OUT") - public static native double pow(@LOC("IN") double a, @LOC("IN") double b); + public static native double pow(@LOC("IN") double a, @LOC("IN") double b); public static native double ceil(double a); + public static native double floor(double a); public static native float sinf(float a); + public static native float cosf(float a); + public static native float expf(float a); + public static native float sqrtf(float a); + public static native float logf(float a); + public static native float powf(float a, float b); + public static native float ceilf(float a); + public static native float IEEEremainder(float f1, float f2); } diff --git a/Robust/src/ClassLibrary/SSJava/Number.java b/Robust/src/ClassLibrary/SSJava/Number.java new file mode 100644 index 00000000..93013893 --- /dev/null +++ b/Robust/src/ClassLibrary/SSJava/Number.java @@ -0,0 +1,164 @@ +/* Number.java =- abstract superclass of numeric objects + Copyright (C) 1998, 2001, 2002, 2005 Free Software Foundation, Inc. + + This file is part of GNU Classpath. + + GNU Classpath is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GNU Classpath is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Classpath; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. + + Linking this library statically or dynamically with other modules is + making a combined work based on this library. Thus, the terms and + conditions of the GNU General Public License cover the whole + combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent + modules, and to copy and distribute the resulting executable under + terms of your choice, provided that you also meet, for each linked + independent module, the terms and conditions of the license of that + module. An independent module is a module which is not derived from + or based on this library. If you modify this library, you may extend + this exception to your version of the library, but you are not + obligated to do so. If you do not wish to do so, delete this + exception statement from your version. */ + + +//package java.lang; + +//import java.io.Serializable; + +/** + * Number is a generic superclass of all the numeric classes, including + * the wrapper classes {@link Byte}, {@link Short}, {@link Integer}, + * {@link Long}, {@link Float}, and {@link Double}. Also worth mentioning + * are the classes in {@link java.math}. + * + * It provides ways to convert numeric objects to any primitive. + * + * @author Paul Fisher + * @author John Keiser + * @author Warren Levy + * @author Eric Blake (ebb9@email.byu.edu) + * @since 1.0 + * @status updated to 1.4 + */ +public /*abstract*/ class Number //implements Serializable +{ + /** + * Compatible with JDK 1.1+. + */ + //private static final long serialVersionUID = -8742448824652078965L; + + /** + * Table for calculating digits, used in Character, Long, and Integer. + */ + /*static*/ final char[] digits; + + /** + * The basic constructor (often called implicitly). + */ + public Number() { + digits = new char[36]; + digits[0] = '0'; + digits[1] = '1'; + digits[2] = '2'; + digits[3] = '3'; + digits[4] = '4'; + digits[5] = '5'; + digits[6] = '6'; + digits[7] = '7'; + digits[8] = '8'; + digits[9] = '9'; + digits[10] = 'a'; + digits[11] = 'b'; + digits[12] = 'c'; + digits[13] = 'd'; + digits[14] = 'e'; + digits[15] = 'f'; + digits[16] = 'g'; + digits[17] = 'h'; + digits[18] = 'i'; + digits[19] = 'j'; + digits[20] = 'k'; + digits[21] = 'l'; + digits[22] = 'm'; + digits[23] = 'n'; + digits[24] = 'o'; + digits[25] = 'p'; + digits[26] = 'q'; + digits[27] = 'r'; + digits[28] = 's'; + digits[29] = 't'; + digits[30] = 'u'; + digits[31] = 'v'; + digits[32] = 'w'; + digits[33] = 'x'; + digits[34] = 'y'; + digits[35] = 'z'; + } + + /** + * Return the value of this Number as an int. + * + * @return the int value + */ + public /*abstract*/ int intValue() { + } + + /** + * Return the value of this Number as a long. + * + * @return the long value + */ + public /*abstract*/ long longValue() { + } + + /** + * Return the value of this Number as a float. + * + * @return the float value + */ + public /*abstract*/ float floatValue() { + } + + /** + * Return the value of this Number as a float. + * + * @return the double value + */ + public /*abstract*/ double doubleValue() { + } + + /** + * Return the value of this Number as a byte. + * + * @return the byte value + * @since 1.1 + */ + public byte byteValue() { + return (byte) intValue(); + } + + /** + * Return the value of this Number as a short. + * + * @return the short value + * @since 1.1 + */ + public short shortValue() { + return (short) intValue(); + } +}