Ejemplo n.º 1
0
 /**
  * Returns the light value at the given coordinate.
  *
  * @param x
  * @param y
  * @return int An integer between 0 and 1023 representing the light value.
  * @throws IllegalArgumentException When the x or y coordinates are not valid |
  *     !sensors.isValid(x,y)
  */
 public int getLightValue(int x, int y) {
   int correctedY = sensors.getMaxY() - y;
   if (sensors.isValid(x, correctedY)) {
     int clr = img.getRGB(x, correctedY);
     int lightValue = calculateLightValue(clr);
     //		  System.out.println("Lightsensor white-value: "+lightValue);
     return lightValue;
   } else {
     throw new IllegalArgumentException("X or Y out of bounds");
   }
 }
Ejemplo n.º 2
0
 /**
  * Basic constructor where only a Sensors object is needed.
  *
  * <p>Tiles will be found from the Sensors object
  *
  * @param sensors
  */
 public VirtualLightSensor(Sensors sensors) {
   this.sensors = sensors;
   img =
       new BufferedImage(sensors.getMaxX() + 1, sensors.getMaxY() + 1, BufferedImage.TYPE_INT_RGB);
   setWhiteLineColor(STANDARD_WHITE_LINE_COLOR);
   setEmptySpaceColor(STANDARD_EMPTY_SPACE_COLOR);
   generateMap();
   //		try {
   //			ImageIO.write(img, fileType, new File(destinationPath));
   //		} catch (IOException e) {
   //			e.printStackTrace();
   //		}
 }