parent
1e19e5aed8
commit
878a44b78d
@ -1,12 +0,0 @@
|
||||
<dispatcherinfo>
|
||||
|
||||
|
||||
|
||||
<managedpackage name="de.games.nanoleaf.lightsswitch"/>
|
||||
|
||||
<managedpackage name="de.games.nanoleaf.panelconfig"/>
|
||||
|
||||
<managedpackage name="de.games.nanoleaf.tictactoe"/>
|
||||
|
||||
</dispatcherinfo>
|
||||
|
||||
@ -0,0 +1,119 @@
|
||||
package de.nanoleaf.games.tictactoe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CheckTicTacToe {
|
||||
|
||||
private class Fields {
|
||||
|
||||
List<Integer> fieldsList = null;
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Integer> getFieldsList() {
|
||||
return fieldsList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Fields(int field1, int field2, int field3) {
|
||||
fieldsList = new ArrayList<Integer>();
|
||||
fieldsList.add(field1);
|
||||
fieldsList.add(field2);
|
||||
fieldsList.add(field3);
|
||||
}
|
||||
}
|
||||
|
||||
List<Fields> m_checkList = null;
|
||||
public List<Fields> getCheckList() {
|
||||
if (m_checkList == null) {
|
||||
m_checkList = new ArrayList<Fields>();
|
||||
}
|
||||
return m_checkList;
|
||||
}
|
||||
|
||||
|
||||
public CheckTicTacToe() {
|
||||
initCheckList();
|
||||
}
|
||||
|
||||
|
||||
private void initCheckList() {
|
||||
|
||||
/**
|
||||
* ###
|
||||
* ###
|
||||
* ###
|
||||
*
|
||||
*/
|
||||
|
||||
getCheckList().add(new Fields(1, 2, 3));
|
||||
getCheckList().add(new Fields(4, 5, 6));
|
||||
getCheckList().add(new Fields(7, 8, 9));
|
||||
|
||||
getCheckList().add(new Fields(1, 4, 7));
|
||||
getCheckList().add(new Fields(2, 5, 6));
|
||||
getCheckList().add(new Fields(3, 6, 9));
|
||||
|
||||
getCheckList().add(new Fields(1, 5, 9));
|
||||
getCheckList().add(new Fields(3, 5, 7));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean checkFinal(int[] playerArray) {
|
||||
|
||||
boolean finish = false;
|
||||
Integer playerlast = 0;
|
||||
boolean next = false;
|
||||
//System.out.println("Start Check...");
|
||||
List<Integer> playerList = new ArrayList<Integer>();
|
||||
for (Fields fields: getCheckList()) {
|
||||
next = false;
|
||||
finish = false;
|
||||
playerList = new ArrayList<Integer>();
|
||||
//System.out.println("List: " + fields.getFieldsList().toString());
|
||||
for (int f = 0; f < fields.getFieldsList().size(); f++) {
|
||||
int field = fields.getFieldsList().get(f).intValue();
|
||||
|
||||
int player = playerArray[field];
|
||||
//System.out.println("Find Player: " + player);
|
||||
if (player == 0) {
|
||||
next = true;
|
||||
finish = false;
|
||||
//System.out.println("NEXT");
|
||||
} else {
|
||||
if (f == 0) {
|
||||
playerlast = player;
|
||||
playerList.add(playerlast);
|
||||
} else {
|
||||
if (playerlast == player) {
|
||||
playerList.add(playerlast);
|
||||
} else {
|
||||
next = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (next) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (next == false) {
|
||||
//System.out.println("FINISH");
|
||||
finish = true;
|
||||
//System.out.println("List: " + fields.getFieldsList().toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return finish;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,325 @@
|
||||
package de.nanoleaf.games.tictactoe;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.eclnt.editor.annotations.CCGenClass;
|
||||
import org.eclnt.jsfserver.base.faces.event.ActionEvent;
|
||||
import org.eclnt.jsfserver.pagebean.PageBean;
|
||||
|
||||
import de.tools.ReflectClass;
|
||||
|
||||
@CCGenClass (expressionBase="#{d.TicTacToeBean}")
|
||||
|
||||
public class TicTacToeBean extends PageBean implements Serializable {
|
||||
|
||||
int[] playerArray = new int[10];
|
||||
|
||||
String m_colorButton1;
|
||||
public String getColorButton1() { return m_colorButton1; }
|
||||
public void setColorButton1(String value) { this.m_colorButton1 = value; }
|
||||
|
||||
String m_colorButton2;
|
||||
public String getColorButton2() { return m_colorButton2; }
|
||||
public void setColorButton2(String value) { this.m_colorButton2 = value; }
|
||||
|
||||
String m_colorButton3;
|
||||
public String getColorButton3() { return m_colorButton3; }
|
||||
public void setColorButton3(String value) { this.m_colorButton3 = value; }
|
||||
|
||||
String m_colorButton4;
|
||||
public String getColorButton4() { return m_colorButton4; }
|
||||
public void setColorButton4(String value) { this.m_colorButton4 = value; }
|
||||
|
||||
String m_colorButton5;
|
||||
public String getColorButton5() { return m_colorButton5; }
|
||||
public void setColorButton5(String value) { this.m_colorButton5 = value; }
|
||||
|
||||
String m_colorButton6;
|
||||
public String getColorButton6() { return m_colorButton6; }
|
||||
public void setColorButton6(String value) { this.m_colorButton6 = value; }
|
||||
|
||||
String m_colorButton7;
|
||||
public String getColorButton7() { return m_colorButton7; }
|
||||
public void setColorButton7(String value) { this.m_colorButton7 = value; }
|
||||
|
||||
String m_colorButton8;
|
||||
public String getColorButton8() { return m_colorButton8; }
|
||||
public void setColorButton8(String value) { this.m_colorButton8 = value; }
|
||||
|
||||
String m_colorButton9;
|
||||
public String getColorButton9() { return m_colorButton9; }
|
||||
public void setColorButton9(String value) { this.m_colorButton9 = value; }
|
||||
|
||||
boolean m_enabledButton1;
|
||||
public boolean getEnabledButton1() { return m_enabledButton1; }
|
||||
public void setEnabledButton1(boolean value) { this.m_enabledButton1 = value; }
|
||||
|
||||
boolean m_enabledButton2;
|
||||
public boolean getEnabledButton2() { return m_enabledButton2; }
|
||||
public void setEnabledButton2(boolean value) { this.m_enabledButton2 = value; }
|
||||
|
||||
boolean m_enabledButton3;
|
||||
public boolean getEnabledButton3() { return m_enabledButton3; }
|
||||
public void setEnabledButton3(boolean value) { this.m_enabledButton3 = value; }
|
||||
|
||||
boolean m_enabledButton4;
|
||||
public boolean getEnabledButton4() { return m_enabledButton4; }
|
||||
public void setEnabledButton4(boolean value) { this.m_enabledButton4 = value; }
|
||||
|
||||
boolean m_enabledButton5;
|
||||
public boolean getEnabledButton5() { return m_enabledButton5; }
|
||||
public void setEnabledButton5(boolean value) { this.m_enabledButton5 = value; }
|
||||
|
||||
boolean m_enabledButton6;
|
||||
public boolean getEnabledButton6() { return m_enabledButton6; }
|
||||
public void setEnabledButton6(boolean value) { this.m_enabledButton6 = value; }
|
||||
|
||||
boolean m_enabledButton7;
|
||||
public boolean getEnabledButton7() { return m_enabledButton7; }
|
||||
public void setEnabledButton7(boolean value) { this.m_enabledButton7 = value; }
|
||||
|
||||
boolean m_enabledButton8;
|
||||
public boolean getEnabledButton8() { return m_enabledButton8; }
|
||||
public void setEnabledButton8(boolean value) { this.m_enabledButton8 = value; }
|
||||
|
||||
boolean m_enabledButton9;
|
||||
public boolean getEnabledButton9() { return m_enabledButton9; }
|
||||
public void setEnabledButton9(boolean value) { this.m_enabledButton9 = value; }
|
||||
|
||||
private void changeColor() {
|
||||
|
||||
if (getLightPlayerNext().equals(getLightPlayer1())) {
|
||||
setLightPlayerNext(getLightPlayer2());
|
||||
setNextPlayer(2);
|
||||
} else {
|
||||
setLightPlayerNext(getLightPlayer1());
|
||||
setNextPlayer(1);
|
||||
}
|
||||
}
|
||||
|
||||
public void onButton1(ActionEvent event) {
|
||||
if (getEnabledButton1() == true) {
|
||||
setColorButton1(getLightPlayerNext());
|
||||
setEnabledButton1(false);
|
||||
playerArray[1] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
|
||||
public void onButton2(ActionEvent event) {
|
||||
if (getEnabledButton2() == true) {
|
||||
setColorButton2(getLightPlayerNext());
|
||||
setEnabledButton2(false);
|
||||
playerArray[2] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
public void onButton3(ActionEvent event) {
|
||||
if (getEnabledButton3() == true) {
|
||||
setColorButton3(getLightPlayerNext());
|
||||
setEnabledButton3(false);
|
||||
playerArray[3] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
public void onButton4(ActionEvent event) {
|
||||
if (getEnabledButton4() == true) {
|
||||
setColorButton4(getLightPlayerNext());
|
||||
setEnabledButton4(false);
|
||||
playerArray[4] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
public void onButton5(ActionEvent event) {
|
||||
if (getEnabledButton5() == true) {
|
||||
setColorButton5(getLightPlayerNext());
|
||||
setEnabledButton5(false);
|
||||
playerArray[5] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
public void onButton6(ActionEvent event) {
|
||||
if (getEnabledButton6() == true) {
|
||||
setColorButton6(getLightPlayerNext());
|
||||
setEnabledButton6(false);
|
||||
playerArray[6] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
public void onButton7(ActionEvent event) {
|
||||
if (getEnabledButton7() == true) {
|
||||
setColorButton7(getLightPlayerNext());
|
||||
setEnabledButton7(false);
|
||||
playerArray[7] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
public void onButton8(ActionEvent event) {
|
||||
if (getEnabledButton8() == true) {
|
||||
setColorButton8(getLightPlayerNext());
|
||||
setEnabledButton8(false);
|
||||
playerArray[8] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
public void onButton9(ActionEvent event) {
|
||||
if (getEnabledButton9() == true) {
|
||||
setColorButton9(getLightPlayerNext());
|
||||
setEnabledButton9(false);
|
||||
playerArray[9] = getNextPlayer();
|
||||
changeColor();
|
||||
}
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
public String m_lightPlayer1 = "#66FF00";
|
||||
public String getLightPlayer1() { return m_lightPlayer1; }
|
||||
|
||||
public String m_lightPlayer2 = "#FF0000";
|
||||
public String getLightPlayer2() { return m_lightPlayer2; }
|
||||
|
||||
public String m_lightPlayerNext = "#66FF00";
|
||||
public void setLightPlayerNext(String lightPlayerNext) { m_lightPlayerNext = lightPlayerNext; }
|
||||
public String getLightPlayerNext() { return m_lightPlayerNext; }
|
||||
|
||||
public int m_nextPlayer = 1;
|
||||
public int getNextPlayer() { return m_nextPlayer; }
|
||||
public void setNextPlayer(int nextPlayer) { m_nextPlayer = nextPlayer; }
|
||||
|
||||
String m_resultText;
|
||||
public String getResultText() { return m_resultText; }
|
||||
public void setResultText(String value) { this.m_resultText = value; }
|
||||
|
||||
public void onReset(ActionEvent event) {
|
||||
|
||||
enabledAllButtons(true);
|
||||
|
||||
playerArray = new int[10];
|
||||
for (int i = 0; i < 10; i++) {
|
||||
playerArray[i] = 0;
|
||||
}
|
||||
|
||||
m_colorButton1 = null;
|
||||
m_colorButton2 = null;
|
||||
m_colorButton3 = null;
|
||||
m_colorButton4 = null;
|
||||
m_colorButton5 = null;
|
||||
m_colorButton6 = null;
|
||||
m_colorButton7 = null;
|
||||
m_colorButton8 = null;
|
||||
m_colorButton9 = null;
|
||||
|
||||
setNextPlayer(1);
|
||||
setLightPlayerNext(getLightPlayer1());
|
||||
|
||||
resultTextSetter();
|
||||
}
|
||||
|
||||
private void enabledAllButtons(boolean enabled) {
|
||||
for (int i = 1; i <= 9; i++) {
|
||||
getReflectClass().setMethod("setEnabledButton" + i, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
CheckTicTacToe m_checkTicTacToe = new CheckTicTacToe();
|
||||
|
||||
public CheckTicTacToe getCheckTicTacToe() {
|
||||
return m_checkTicTacToe;
|
||||
}
|
||||
private boolean checkFinish() {
|
||||
boolean finish = false;
|
||||
|
||||
finish = getCheckTicTacToe().checkFinal(playerArray);
|
||||
|
||||
return finish;
|
||||
}
|
||||
|
||||
ReflectClass m_reflectClass;
|
||||
public ReflectClass getReflectClass() { return m_reflectClass; }
|
||||
|
||||
private void resultTextSetter() {
|
||||
|
||||
if (checkFinish()) {
|
||||
m_resultText = " GEWONNEN. :-)";
|
||||
enabledAllButtons(false);
|
||||
|
||||
} else {
|
||||
m_resultText = "Player "+ getNextPlayer();
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
// inner classes
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/* Listener to the user of the page bean. */
|
||||
public interface IListener extends Serializable
|
||||
{
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// members
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
private IListener m_listener;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// constructors & initialization
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
public TicTacToeBean() {
|
||||
m_reflectClass = new ReflectClass(this);
|
||||
onReset(null);
|
||||
}
|
||||
|
||||
public TicTacToeBean(String lightPlayer1, String lightPlayer2) {
|
||||
this.m_lightPlayer1 = lightPlayer1;
|
||||
this.m_lightPlayer2 = lightPlayer2;
|
||||
|
||||
m_reflectClass = new ReflectClass(this);
|
||||
onReset(null);
|
||||
}
|
||||
|
||||
|
||||
public String getPageName() { return "/nanoleaf/games/tictactoe/tictactoe.xml"; }
|
||||
public String getRootExpressionUsedInPage() { return "#{d.TicTacToeBean}"; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// public usage
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/* Initialization of the bean. Add any parameter that is required within your scenario. */
|
||||
public void prepare(IListener listener)
|
||||
{
|
||||
m_listener = listener;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// private usage
|
||||
// ------------------------------------------------------------------------
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<dispatcherinfo>
|
||||
|
||||
<managedpackage name="de.nanoleaf.games.lightswitch"/>
|
||||
|
||||
<managedpackage name="de.nanoleaf.tools.panelconfig"/>
|
||||
|
||||
<managedpackage name="de.nanoleaf.games.tictactoe"/>
|
||||
|
||||
</dispatcherinfo>
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
package de.nanoleaf.server;
|
||||
|
||||
public class ChangeColorMod {
|
||||
|
||||
public ChangeColorMod() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package de.nanoleaf.server;
|
||||
|
||||
import io.github.rowak.nanoleafapi.Color;
|
||||
|
||||
public enum ColorEnum {
|
||||
|
||||
BLACK(Color.BLACK),
|
||||
|
||||
WHITE(Color.WHITE),
|
||||
|
||||
RED(Color.RED),
|
||||
|
||||
GREEN(Color.GREEN),
|
||||
|
||||
BLUE(Color.BLUE),
|
||||
|
||||
MAGENTA(Color.MAGENTA),
|
||||
|
||||
YELLOW(Color.YELLOW),
|
||||
|
||||
CYAN(Color.CYAN),
|
||||
|
||||
GRAY(Color.GRAY),
|
||||
|
||||
LIGHT_GRAY(Color.LIGHT_GRAY),
|
||||
|
||||
DARK_GRAY(Color.DARK_GRAY),
|
||||
|
||||
PINK(Color.PINK),
|
||||
|
||||
ORANGE(Color.ORANGE),
|
||||
|
||||
;
|
||||
|
||||
private Color m_color;
|
||||
public Color getColor() { return m_color; }
|
||||
|
||||
ColorEnum(Color color) {
|
||||
this.m_color = color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package de.nanoleaf.server;
|
||||
|
||||
public enum ColorModEnum {
|
||||
|
||||
NANOLEAF_LIGHT_SWITCH_PANEL_9_GAME,
|
||||
|
||||
NANOLEAF_TIC_TAC_TOE_PANEL_9_GAME,
|
||||
|
||||
NANOLEAF_ON_OFF_TEST,
|
||||
|
||||
|
||||
|
||||
;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
Funktionen Nanoleaf Server
|
||||
|
||||
-
|
||||
@ -0,0 +1,209 @@
|
||||
package de.nanoleaf.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.rowak.nanoleafapi.Color;
|
||||
import io.github.rowak.nanoleafapi.NanoleafDevice;
|
||||
import io.github.rowak.nanoleafapi.NanoleafException;
|
||||
import io.github.rowak.nanoleafapi.Panel;
|
||||
import io.github.rowak.nanoleafapi.event.DetailedTouchEvent;
|
||||
import io.github.rowak.nanoleafapi.event.NanoleafTouchEventListener;
|
||||
import io.github.rowak.nanoleafapi.event.TouchEvent;
|
||||
|
||||
public class NanoleafDeviceServer {
|
||||
|
||||
private String m_nanoleafHostname = "Canvas-72FA.fritz.box";
|
||||
public String getNanoleafHostname() { return m_nanoleafHostname; }
|
||||
|
||||
private String m_nanoleafHostIP = "";
|
||||
public String getNanoleafHostIP() { return m_nanoleafHostIP; }
|
||||
|
||||
private int m_nanoleafPort = 16021;
|
||||
public int getNanoleafPort() { return m_nanoleafPort; }
|
||||
|
||||
private String m_nanoleafApiLevel = "v1";
|
||||
public String getNanoleafApiLevel() { return m_nanoleafApiLevel; }
|
||||
|
||||
private String m_nanoleafAccessToken = "LAG28BQWrXK2p79NbHMQsvcYYCN1TcD4";
|
||||
public String getNanoleafAccessToken() { return m_nanoleafAccessToken; }
|
||||
|
||||
private NanoleafDevice m_nanoleafDevice = null;
|
||||
public NanoleafDevice getNanoleafDevice() { return m_nanoleafDevice; }
|
||||
|
||||
private int m_nanoleafTouchTimer = 50;
|
||||
public int getNanoleafTouchTimer() { return m_nanoleafTouchTimer; }
|
||||
public void setNanoleafTouchTimer(int nanoleafTouchTimer) { m_nanoleafTouchTimer = nanoleafTouchTimer; }
|
||||
|
||||
private Integer m_nanoleafLastID = null;
|
||||
public Integer getNanoleafLastID() { return m_nanoleafLastID; }
|
||||
public void setNanoleafLastID(Integer nanoleafLastID) { m_nanoleafLastID = nanoleafLastID; }
|
||||
|
||||
private List<Panel> m_nanoLeafPanels = null;
|
||||
public List<Panel> getNanoLeafPanels() { return m_nanoLeafPanels; }
|
||||
|
||||
|
||||
public NanoleafDeviceServer() {
|
||||
|
||||
}
|
||||
|
||||
public NanoleafDeviceServer(String nanoleafHostname, String nanoleafHostIP, int nanoleafPort, String nanoleafAccessToken) {
|
||||
this.m_nanoleafHostname = nanoleafHostname;
|
||||
this.m_nanoleafHostIP = nanoleafHostIP;
|
||||
this.m_nanoleafPort = nanoleafPort;
|
||||
this.m_nanoleafAccessToken = nanoleafAccessToken;
|
||||
}
|
||||
|
||||
public boolean deConnectNanoLeaf() throws NanoleafException, IOException {
|
||||
boolean finish = false;
|
||||
try {
|
||||
getNanoleafDevice().closeEventListeners();
|
||||
getNanoleafDevice().closeTouchEventListeners();
|
||||
getNanoleafDevice().closeAsync();
|
||||
m_nanoleafDevice = null;
|
||||
getNanoLeafPanels().clear();
|
||||
|
||||
finish = true;
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
return finish;
|
||||
}
|
||||
|
||||
public boolean connectNanoLeaf() throws NanoleafException, IOException {
|
||||
boolean connected = false;
|
||||
|
||||
try {
|
||||
m_nanoleafDevice = NanoleafDevice.createDevice(getNanoleafHostname(), getNanoleafPort(), getNanoleafAccessToken());
|
||||
|
||||
if (m_nanoleafDevice != null) {
|
||||
connected = true;
|
||||
refreshPanels();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
return connected;
|
||||
}
|
||||
|
||||
private void refreshPanels() throws NanoleafException, IOException {
|
||||
|
||||
if (getNanoleafDevice() != null) {
|
||||
m_nanoLeafPanels = getNanoleafDevice().getPanels();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkLastIdActiv(Integer lastID) {
|
||||
|
||||
if (getNanoleafLastID() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getNanoleafLastID().equals(lastID);
|
||||
}
|
||||
|
||||
public void startNanoLeafEvent() {
|
||||
|
||||
|
||||
|
||||
try {
|
||||
getNanoleafDevice().setColor(Color.BLACK);
|
||||
|
||||
getNanoleafDevice().enableExternalStreaming();
|
||||
|
||||
getNanoleafDevice().enableTouchEventStreaming(getNanoleafPort()); // You need to specify a port to listen on
|
||||
getNanoleafDevice().registerTouchEventStreamingListener(new NanoleafTouchEventListener() {
|
||||
@Override
|
||||
public void onOpen() {
|
||||
// Called when the listener is created
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed() {
|
||||
// Called when the listener is closed
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(DetailedTouchEvent[] events) {
|
||||
// Called when a touch event occurs
|
||||
//System.out.println("Events: " + events.length);
|
||||
|
||||
DetailedTouchEvent event = events[0];
|
||||
|
||||
Integer lastID = event.getPanelId();
|
||||
|
||||
|
||||
|
||||
|
||||
//TouchEvent touch = event.getTouchType();
|
||||
|
||||
switch (event.getTouchType()) {
|
||||
case TouchEvent.DOUBLE_TAP:
|
||||
//System.out.println("DOUBLE_TAP");
|
||||
break;
|
||||
|
||||
case TouchEvent.SINGLE_TAP:
|
||||
//System.out.println("SINGLE_TAP");
|
||||
if (checkLastIdActiv(lastID)) {
|
||||
return;
|
||||
} else {
|
||||
setNanoleafLastID(lastID);
|
||||
|
||||
try {
|
||||
|
||||
getNanoleafDevice().setPanelExternalStreaming(lastID, Color.RED, 1);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
System.out.println("ID: " + event.getPanelId());
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case TouchEvent.HOLD:
|
||||
//System.out.println("HOLD");
|
||||
break;
|
||||
|
||||
case TouchEvent.UNKNOWN_ATTRIBUTE:
|
||||
//System.out.println("UNKNOWN_ATTRIBUTE");
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
System.out.println("Unexpected value: " + event.getTouchType());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
NanoleafDeviceServer nanoleafDeviceServer = new NanoleafDeviceServer();
|
||||
try {
|
||||
boolean nanoLeafActiv = nanoleafDeviceServer.connectNanoLeaf();
|
||||
|
||||
if (nanoLeafActiv) {
|
||||
nanoleafDeviceServer.startNanoLeafEvent();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package de.games.nanoleaf.server;
|
||||
package de.nanoleaf.server.test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@ -1,4 +1,4 @@
|
||||
package de.games.nanoleaf.server;
|
||||
package de.nanoleaf.server.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package de.games.nanoleaf.server;
|
||||
package de.nanoleaf.server.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package de.games.nanoleaf.server;
|
||||
package de.nanoleaf.server.test;
|
||||
|
||||
import io.github.rowak.nanoleafapi.Aurora;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package de.games.nanoleaf.panelconfig;
|
||||
package de.nanoleaf.tools.panelconfig;
|
||||
|
||||
public class MatrixInfo {
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
package de.nanoleaf.tools.panelconfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.tools.ReflectClass;
|
||||
import io.github.rowak.nanoleafapi.Color;
|
||||
|
||||
public class TestClass {
|
||||
|
||||
public TestClass() {
|
||||
|
||||
Color color = new Color();
|
||||
|
||||
ReflectClass reflectClass = new ReflectClass(color);
|
||||
|
||||
List<String> fieldsList = reflectClass.getAllFields();
|
||||
|
||||
for (String field: fieldsList) {
|
||||
|
||||
System.out.println(field);
|
||||
|
||||
}
|
||||
|
||||
Color farbe = Color.BLUE;
|
||||
|
||||
System.out.println(farbe);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new TestClass();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package de.geis.portal.workplace.layout;
|
||||
package de.tvo.workplace.layout;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package de.geis.portal.workplace.layout;
|
||||
package de.tvo.workplace.layout;
|
||||
|
||||
public interface LayoutInterface {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package de.geis.portal.workplace.layout;
|
||||
package de.tvo.workplace.layout;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<t:layoutdefinition xmlns:t="http://www.CaptainCasa.com/controllibrary/t" >
|
||||
|
||||
<t:beanprocessing id="g_1" beanbinding="#{d.DragDropPaneBean}" />
|
||||
<t:rowtitlebar id="g_2" />
|
||||
<t:rowheader id="g_3" />
|
||||
<t:rowbodypane id="g_4" >
|
||||
<t:row id="g_6" >
|
||||
<t:coldistance id="g_11" />
|
||||
<t:pane id="g_8" actionListener="#{d.DragDropPaneBean.onPaneSource}" border="left:1;right:1;top:1;bottom:1;color:#a5a5a5" dragsend="NANO" height="60" invokeevent="click" width="60" >
|
||||
<t:rowdistance id="g_9" />
|
||||
<t:row id="g_17" >
|
||||
<t:coldistance id="g_7" />
|
||||
<t:label id="g_15" reference="584565" text="584565" />
|
||||
</t:row>
|
||||
</t:pane>
|
||||
<t:coldistance id="g_13" />
|
||||
<t:pane id="g_19" actionListener="#{d.DragDropPaneBean.onPaneSource}" border="left:1;right:1;top:1;bottom:1;color:#a5a5a5" height="60" invokeevent="click" width="60" >
|
||||
<t:rowdistance id="g_20" />
|
||||
<t:row id="g_21" >
|
||||
<t:coldistance id="g_22" />
|
||||
<t:label id="g_23" reference="484565" text="584565" />
|
||||
</t:row>
|
||||
</t:pane>
|
||||
</t:row>
|
||||
<t:rowdistance id="g_10" height="40" />
|
||||
<t:row id="g_25" >
|
||||
<t:coldistance id="g_12" />
|
||||
<t:pane id="g_27" >
|
||||
<t:row id="g_14" />
|
||||
</t:pane>
|
||||
</t:row>
|
||||
</t:rowbodypane>
|
||||
|
||||
</t:layoutdefinition>
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<t:layoutdefinition xmlns:t="http://www.CaptainCasa.com/controllibrary/t" >
|
||||
|
||||
<t:beanprocessing id="g_1" beanbinding="#{d.TicTacToeBean}" />
|
||||
<t:rowbodypane id="g_4" />
|
||||
|
||||
</t:layoutdefinition>
|
||||
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<t:layoutdefinition xmlns:t="http://www.CaptainCasa.com/controllibrary/t" >
|
||||
|
||||
<t:beanprocessing id="g_1" beanbinding="#{d.TicTacToeBean}" />
|
||||
<t:rowbodypane id="g_35" >
|
||||
<t:rowdistance id="g_3" height="20%" />
|
||||
<t:row id="g_4" >
|
||||
<t:coldistance id="g_5" width="50%" />
|
||||
<t:label id="g_6" font="size:24" text="TIC TAC TOE" />
|
||||
<t:coldistance id="g_7" width="50%" />
|
||||
</t:row>
|
||||
<t:rowdistance id="g_8" height="10%" />
|
||||
<t:row id="g_9" >
|
||||
<t:coldistance id="g_10" width="20%" />
|
||||
<t:button id="g_11" actionListener="#{d.TicTacToeBean.onButton1}" background="#{d.TicTacToeBean.colorButton1}" height="20%" reference="1" width="20%" />
|
||||
<t:button id="g_12" actionListener="#{d.TicTacToeBean.onButton2}" background="#{d.TicTacToeBean.colorButton2}" height="20%" reference="2" width="20%" />
|
||||
<t:button id="g_13" actionListener="#{d.TicTacToeBean.onButton3}" background="#{d.TicTacToeBean.colorButton3}" height="20%" reference="3" width="20%" />
|
||||
</t:row>
|
||||
<t:row id="g_14" >
|
||||
<t:coldistance id="g_15" width="20%" />
|
||||
<t:button id="g_16" actionListener="#{d.TicTacToeBean.onButton4}" background="#{d.TicTacToeBean.colorButton4}" height="20%" reference="4" width="20%" />
|
||||
<t:button id="g_17" actionListener="#{d.TicTacToeBean.onButton5}" background="#{d.TicTacToeBean.colorButton5}" height="20%" reference="5" width="20%" />
|
||||
<t:button id="g_18" actionListener="#{d.TicTacToeBean.onButton6}" background="#{d.TicTacToeBean.colorButton6}" height="20%" reference="6" width="20%" />
|
||||
</t:row>
|
||||
<t:row id="g_19" >
|
||||
<t:coldistance id="g_20" width="20%" />
|
||||
<t:button id="g_21" actionListener="#{d.TicTacToeBean.onButton7}" background="#{d.TicTacToeBean.colorButton7}" height="20%" reference="7" width="20%" />
|
||||
<t:button id="g_22" actionListener="#{d.TicTacToeBean.onButton8}" background="#{d.TicTacToeBean.colorButton8}" height="20%" reference="8" width="20%" />
|
||||
<t:button id="g_23" actionListener="#{d.TicTacToeBean.onButton9}" background="#{d.TicTacToeBean.colorButton9}" height="20%" reference="9" width="20%" />
|
||||
</t:row>
|
||||
<t:rowdistance id="g_24" height="20" />
|
||||
<t:row id="g_25" >
|
||||
<t:coldistance id="g_26" width="50%" />
|
||||
<t:label id="g_27" font="size:18" text="#{d.TicTacToeBean.resultText}" />
|
||||
<t:coldistance id="g_28" width="50%" />
|
||||
</t:row>
|
||||
<t:rowdistance id="g_29" height="10" />
|
||||
<t:row id="g_30" >
|
||||
<t:coldistance id="g_31" width="50%" />
|
||||
<t:button id="g_32" actionListener="#{d.TicTacToeBean.onReset}" font="size:18" text="Neu beginnen" />
|
||||
</t:row>
|
||||
<t:rowdistance id="g_33" height="20%" />
|
||||
</t:rowbodypane>
|
||||
|
||||
</t:layoutdefinition>
|
||||
Loading…
Reference in new issue