RLPark 1.0.0
Reinforcement Learning Framework in Java
|
00001 package rlpark.plugin.robot.internal.disco.drops; 00002 00003 import java.awt.Color; 00004 00005 import rlpark.plugin.robot.internal.sync.LiteByteBuffer; 00006 00007 00008 00009 public class DropColor extends DropData { 00010 00011 private Color color = Color.YELLOW; 00012 00013 public DropColor(String label) { 00014 this(label, -1); 00015 } 00016 00017 public DropColor(String label, int index) { 00018 super(label, false, index); 00019 } 00020 00021 public void set(Color color) { 00022 this.color = color == null ? Color.YELLOW : color; 00023 } 00024 00025 public Color color(LiteByteBuffer buffer) { 00026 short red = (short) (0xFF & buffer.get(index)); 00027 short green = (short) (0xFF & buffer.get(index + DropData.ByteSize)); 00028 short blue = (short) (0xFF & buffer.get(index + DropData.ByteSize * 2)); 00029 return new Color(red, green, blue); 00030 } 00031 00032 @Override 00033 public DropData clone(String label, int index) { 00034 return new DropColor(label, index); 00035 } 00036 00037 @Override 00038 public void putData(LiteByteBuffer buffer) { 00039 buffer.put((byte) color.getRed()); 00040 buffer.put((byte) color.getGreen()); 00041 buffer.put((byte) color.getBlue()); 00042 } 00043 00044 @Override 00045 public int size() { 00046 return ByteSize * 3; 00047 } 00048 }