diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-03-27 14:40:42 +0200 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-03-27 14:40:42 +0200 |
| commit | 5d8eafe9e8c36c86f9b4c33f32305866dd898f3e (patch) | |
| tree | 495158ddee0c0eb2ce33111e37ae2a449c24305d /src/device/Keyboard.java | |
| parent | 25b636c0afd61245765b521dd03255f0ecd4ef8f (diff) | |
Add state class
Diffstat (limited to 'src/device/Keyboard.java')
| -rw-r--r-- | src/device/Keyboard.java | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/device/Keyboard.java b/src/device/Keyboard.java index 4acf4a1..cc7d8f9 100644 --- a/src/device/Keyboard.java +++ b/src/device/Keyboard.java @@ -10,27 +10,20 @@ public class Keyboard{ * Device driver */ private Driver device; - + /** - * Define Keyboard color state + * Keyboard State */ - private HashMap<Region, Color> KeyboardColor=new HashMap<>(); + private KeyboardState state; /** - * Define Keyboard mode state - */ - private Mode mode=Mode.NORMAL; - - /** * Build a keyboard access + * + * @throws InstantiationException Throw if failed to instanciate driver */ - public Keyboard(){ - try { - this.device=new Driver(); - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + public Keyboard() throws InstantiationException{ + this.device=new Driver(); + this.state=new KeyboardState(); } @@ -42,10 +35,8 @@ public class Keyboard{ * @param intensity Intensity wanted */ public void setColor(Color color, Intensity intensity){ - // Save state - this.KeyboardColor.put(Region.LEFT, color); - this.KeyboardColor.put(Region.MIDDLE, color); - this.KeyboardColor.put(Region.RIGHT, color); + //Save state + this.state.setColor(color, intensity); // Set color this.device.setColor(Region.LEFT, color, intensity); @@ -53,7 +44,7 @@ public class Keyboard{ this.device.setColor(Region.RIGHT, color, intensity); // Apply color - this.device.commit(this.mode); + this.device.commit(this.state.getMode()); } @@ -67,13 +58,13 @@ public class Keyboard{ */ public void setRegionColor(Region region, Color color, Intensity intensity){ // Save state - this.KeyboardColor.put(region, color); + this.state.setRegionColor(region, color, intensity); // Set color this.device.setColor(region, color, intensity); // Apply color - this.device.commit(this.mode); + this.device.commit(this.state.getMode()); } |
