From eb04ad3f338916f0a69ca6108e9f8c4b46484070 Mon Sep 17 00:00:00 2001 From: Marc Froehlich Date: Tue, 27 Feb 2024 01:53:24 +0100 Subject: [PATCH] implemented all filters to the chatmemberlist, activity-displays in chatmember table and userinfopanel, linked selected messages to the userinfopanel for better UI feeling, begin of AS-Showpath-function (not yet ready) --- .../kst4contest/ApplicationConstants.java | 2 +- .../controller/ChatController.java | 50 +- .../MessageBusManagementThread.java | 23 +- .../kst4contest/controller/Utils4KST.java | 15 + .../locatorUtils/DirectionUtils.java | 50 ++ .../java/kst4contest/model/ChatMember.java | 12 +- .../kst4contest/model/ChatPreferences.java | 49 +- .../view/Kst4ContestApplication.java | 739 +++++++++++++++--- src/main/resources/praktiKSTpreferences.xml | 3 + 9 files changed, 810 insertions(+), 133 deletions(-) create mode 100644 src/main/java/kst4contest/locatorUtils/DirectionUtils.java diff --git a/src/main/java/kst4contest/ApplicationConstants.java b/src/main/java/kst4contest/ApplicationConstants.java index 25b02a7..89a18a4 100644 --- a/src/main/java/kst4contest/ApplicationConstants.java +++ b/src/main/java/kst4contest/ApplicationConstants.java @@ -9,7 +9,7 @@ public class ApplicationConstants { /** * Name of file to store preferences in. */ - public static final double APPLICATION_CURRENTVERSIONNUMBER = 0.9; + public static final double APPLICATION_CURRENTVERSIONNUMBER = 1.0; public static final String VERSIONINFOURLFORUPDATES_KST4CONTEST = "https://do5amf.funkerportal.de/kst4ContestVersionInfo.xml"; public static final String VERSIONINFDOWNLOADEDLOCALFILE = "kst4ContestVersionInfo.xml"; diff --git a/src/main/java/kst4contest/controller/ChatController.java b/src/main/java/kst4contest/controller/ChatController.java index 40be8bb..02bb5de 100644 --- a/src/main/java/kst4contest/controller/ChatController.java +++ b/src/main/java/kst4contest/controller/ChatController.java @@ -99,6 +99,54 @@ public class ChatController { this.disconnected = disconnected; } + public void airScout_SendAsShowPathPacket(ChatMember remoteChatMember) { + + DatagramSocket dsocket; + + String prefix_asSetpath ="ASSHOWPATH: \"KST\" \"AS\" "; + String bandString = "1440000"; + String myCallAndMyLocString = chatPreferences.getLoginCallSign() + "," + chatPreferences.getLoginLocator(); + String remoteCallAndLocString = remoteChatMember.getCallSign() +"," + remoteChatMember.getQra(); + + String host = "255.255.255.255"; +// int port = 9872; + int port = chatPreferences.getAirScout_asCommunicationPort(); +// System.out.println("<<<<<<<<<<<<<<<<<<<
@@ -290,7 +338,7 @@ public class ChatController { private String chatState; private String hostname = "109.90.0.130"; - private String praktiKSTVersion = "praktiKST 0.9b"; + private String praktiKSTVersion = "praktiKST 1.0"; private String praktiKSTVersionInfo = "2022-10 - 2022-12\ndeveloped by DO5AMF, Marc\nContact: praktimarc@gmail.com\nDonations via paypal are welcome"; private int port = 23001; // kst4contest.test 4 23001 diff --git a/src/main/java/kst4contest/controller/MessageBusManagementThread.java b/src/main/java/kst4contest/controller/MessageBusManagementThread.java index c04c7a3..006c467 100644 --- a/src/main/java/kst4contest/controller/MessageBusManagementThread.java +++ b/src/main/java/kst4contest/controller/MessageBusManagementThread.java @@ -366,7 +366,8 @@ public class MessageBusManagementThread extends Thread { // newMember.setQTFdirection(LocatorUtils); newMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getLoginLocator(), newMember.getQra())); newMember.setQTFdirection(new Location(client.getChatPreferences().getLoginLocator()).getBearing(new Location(newMember.getQra()))); - newMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat()); + newMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat());//TODO evt obsolete! + newMember.setActivityTimeLastInEpoch(new Utils4KST().time_generateCurrentEpochTime()); // this.client.getChatMemberTable().put(splittedMessageLine[2], newMember); //TODO: map -> List @@ -406,6 +407,7 @@ public class MessageBusManagementThread extends Thread { newMember.setQra(splittedMessageLine[4]); newMember.setState(Integer.parseInt(splittedMessageLine[5])); newMember.setLastActivity(new Utils4KST().time_generateActualTimeInDateFormat()); + newMember.setActivityTimeLastInEpoch(new Utils4KST().time_generateCurrentEpochTime()); newMember.setQrb(new Location().getDistanceKmByTwoLocatorStrings(client.getChatPreferences().getLoginLocator(), newMember.getQra())); newMember.setQTFdirection(new Location(client.getChatPreferences().getLoginLocator()).getBearing(new Location(newMember.getQra()))); @@ -488,10 +490,12 @@ public class MessageBusManagementThread extends Thread { int index = checkListForChatMemberIndexByCallSign(this.client.getLst_chatMemberList(), sender); + //if the user had been found in the active users list if (index != -1) { //user found in the chatmember list try { newMessage.setSender(this.client.getLst_chatMemberList().get(index)); // set sender to member of + this.client.getLst_chatMemberList().get(index).setActivityTimeLastInEpoch(new Utils4KST().time_generateCurrentEpochTime()); } catch (Exception exc) { ChatMember aSenderDummy = new ChatMember(); aSenderDummy.setCallSign(splittedMessageLine[3] + "[n/a]"); @@ -502,7 +506,7 @@ public class MessageBusManagementThread extends Thread { } // b4 init list } else { - //user not found in chatmember list + //user not found in chatmember list, mark it, sender can not be set if (!sender.getCallSign().equals(this.client.getChatPreferences().getLoginCallSign().toUpperCase())) { sender.setCallSign("[n/a]" + sender.getCallSign()); // if someone sent a message without being in the userlist (cause @@ -909,7 +913,7 @@ public class MessageBusManagementThread extends Thread { System.out.println("Passwort falsch!"); if (splittedMessageLine[2].contains("password")) { - splittedMessageLine[2] += "pse disc- and reconnect"; + splittedMessageLine[2] += " pse disc- and reconnect"; } ChatMember server = new ChatMember(); @@ -921,10 +925,19 @@ public class MessageBusManagementThread extends Thread { pwErrorMsg.setMessageGeneratedTime(client.getCurrentEpochTime()+""); pwErrorMsg.setSender(server); pwErrorMsg.setMessageText(splittedMessageLine[2]); + + ChatMember receiverDummy = new ChatMember(); + receiverDummy.setCallSign(client.getChatPreferences().getLoginCallSign()); + receiverDummy.setQrb(0.); + receiverDummy.setQTFdirection(0.); + pwErrorMsg.setReceiver(receiverDummy); + + for (int i = 0; i < 10; i++) { - client.getLst_toMeMessageList().add(pwErrorMsg); - client.getLst_toAllMessageList().add(pwErrorMsg); + client.getLst_globalChatMessageList().add(pwErrorMsg); +// client.getLst_toMeMessageList().add(pwErrorMsg); +// client.getLst_toAllMessageList().add(pwErrorMsg); } // Kst4ContestApplication.alertWindowEvent("Password was wrong. Pse check!"); diff --git a/src/main/java/kst4contest/controller/Utils4KST.java b/src/main/java/kst4contest/controller/Utils4KST.java index 65d5eeb..af06ddd 100644 --- a/src/main/java/kst4contest/controller/Utils4KST.java +++ b/src/main/java/kst4contest/controller/Utils4KST.java @@ -49,6 +49,21 @@ public class Utils4KST { return formatted; } + + public static long time_getSecondsBetweenEpochAndNow(String epoch1) { + + long epoch1Long = Long.parseLong(epoch1); + long epoch2Long = new Utils4KST().time_generateCurrentEpochTime(); +// Instant instant = Instant.ofEpochSecond(epoch); + + Date date = new Date(epoch1Long * 1000L); + Date date2 = new Date(epoch2Long * 1000L); + + long seconds = Math.abs(date.getTime()-date2.getTime())/1000; + + return seconds; + + } public Date time_generateActualTimeInDateFormat() { Date date = new Date(time_generateCurrentEpochTime() * 1000L); diff --git a/src/main/java/kst4contest/locatorUtils/DirectionUtils.java b/src/main/java/kst4contest/locatorUtils/DirectionUtils.java new file mode 100644 index 0000000..93eab91 --- /dev/null +++ b/src/main/java/kst4contest/locatorUtils/DirectionUtils.java @@ -0,0 +1,50 @@ +package kst4contest.locatorUtils; + +public class DirectionUtils { + + /** + * Tests, if the angle (from me to) other station is in the range of the + * angle (qtf) in degrees where my antenna points to. + * + * @param toForeignAngle [degrees] + * @param mySelectedQTFAngle [degrees] + * @param antennaBeamwidth [degrees] + * @return + */ + public static boolean isAngleInRange(double toForeignAngle, + double mySelectedQTFAngle, double antennaBeamwidth) { + + double beamwidth = antennaBeamwidth / 2; // half left, half right + + double startAngle = mySelectedQTFAngle - beamwidth; + double endAngle = mySelectedQTFAngle + beamwidth; + + // Normalize angles to be between 0 and 360 degrees + toForeignAngle = normalizeAngle(toForeignAngle); + startAngle = normalizeAngle(startAngle); + endAngle = normalizeAngle(endAngle); + + // Check if the range wraps around 360 degrees + if (startAngle <= endAngle) { + return toForeignAngle >= startAngle && toForeignAngle <= endAngle; + } else { + // Range wraps around 360 degrees, so check if angle is within the + // range or outside the range + return toForeignAngle >= startAngle || toForeignAngle <= endAngle; + } + } + + private static double normalizeAngle(double angle) { + if (angle < 0) { + angle += 360; + } + if (angle >= 360) { + angle -= 360; + } + return angle; + } + + + + +} diff --git a/src/main/java/kst4contest/model/ChatMember.java b/src/main/java/kst4contest/model/ChatMember.java index 849fcc7..fd83a6e 100644 --- a/src/main/java/kst4contest/model/ChatMember.java +++ b/src/main/java/kst4contest/model/ChatMember.java @@ -19,7 +19,7 @@ public class ChatMember { ChatCategory chatCategory; // only used by own instance of the chatmember instance to login to the chat // ChatCategory chatCategory;//only used by own instance of the chatmember instance to login to the chat - long activityCounter; // time of last activity in epochtimesec + long activityTimeLastInEpoch; // time of last activity in epochtimesec Date lastActivity; // time of last activity in epochtimesec Date lastActualizationTimeOfThisMember; // time of last state change if that member Double qrb; @@ -125,8 +125,8 @@ public class ChatMember { this.workedCategories = workedCategories; } - public void setActivityCounter(long activityCounter) { - this.activityCounter = activityCounter; + public void setActivityTimeLastInEpoch(long activityTimeLastInEpoch) { + this.activityTimeLastInEpoch = activityTimeLastInEpoch; } public int getState() { @@ -210,12 +210,12 @@ public class ChatMember { this.frequency = frequency; } - public long getActivityCounter() { - return activityCounter; + public long getActivityTimeLastInEpoch() { + return activityTimeLastInEpoch; } public void setActivityCounter(int activityCounter) { - this.activityCounter = activityCounter; + this.activityTimeLastInEpoch = activityCounter; } public boolean isWorked() { diff --git a/src/main/java/kst4contest/model/ChatPreferences.java b/src/main/java/kst4contest/model/ChatPreferences.java index a08b031..d18a734 100644 --- a/src/main/java/kst4contest/model/ChatPreferences.java +++ b/src/main/java/kst4contest/model/ChatPreferences.java @@ -138,6 +138,10 @@ public class ChatPreferences { String loginName = "Marc"; String loginLocator = "jn49fk"; + double stn_antennaBeamWidthDeg = 50; + double stn_maxQRBDefault = 900; + double stn_qtfDefault = 135; + ChatCategory loginChatCategory = new ChatCategory(2); IntegerProperty actualQTF = new SimpleIntegerProperty(360); // will be updated by user at runtime! @@ -211,7 +215,29 @@ public class ChatPreferences { // } + public double getStn_antennaBeamWidthDeg() { + return stn_antennaBeamWidthDeg; + } + public void setStn_antennaBeamWidthDeg(double stn_antennaBeamWidthDeg) { + this.stn_antennaBeamWidthDeg = stn_antennaBeamWidthDeg; + } + + public double getStn_maxQRBDefault() { + return stn_maxQRBDefault; + } + + public void setStn_maxQRBDefault(double stn_maxQRBDefault) { + this.stn_maxQRBDefault = stn_maxQRBDefault; + } + + public double getStn_qtfDefault() { + return stn_qtfDefault; + } + + public void setStn_qtfDefault(double stn_qtfDefault) { + this.stn_qtfDefault = stn_qtfDefault; + } public boolean isLoginAFKState() { return loginAFKState; @@ -560,6 +586,18 @@ public class ChatPreferences { ChatCategory.setTextContent(this.getLoginChatCategory().getCategoryNumber()+""); station.appendChild(ChatCategory); + Element stn_antennaBeamWidthDeg = doc.createElement("stn_antennaBeamWidthDeg"); + stn_antennaBeamWidthDeg.setTextContent(this.stn_antennaBeamWidthDeg+""); + station.appendChild(stn_antennaBeamWidthDeg); + + Element stn_maxQRBDefault = doc.createElement("stn_maxQRBDefault"); + stn_maxQRBDefault.setTextContent(this.stn_maxQRBDefault+""); + station.appendChild(stn_maxQRBDefault); + + Element stn_qtfDefault = doc.createElement("stn_qtfDefault"); + stn_qtfDefault.setTextContent(this.stn_qtfDefault+""); + station.appendChild(stn_qtfDefault); + // Element salary = doc.createElement("salary"); // salary.setAttribute("currency", "USD"); // salary.setTextContent("5000"); @@ -851,9 +889,18 @@ public class ChatPreferences { loginChatCategory = new ChatCategory(2); // TODO: Set this default at another place } + double antennaBeamWidthDeg = Double.parseDouble(element.getElementsByTagName("stn_antennaBeamWidthDeg").item(0).getTextContent()); + stn_antennaBeamWidthDeg = antennaBeamWidthDeg; + double maxQRBDefault = Double.parseDouble(element.getElementsByTagName("stn_maxQRBDefault").item(0).getTextContent()); + stn_maxQRBDefault = maxQRBDefault; + double qtfDefault = Double.parseDouble(element.getElementsByTagName("stn_qtfDefault").item(0).getTextContent()); + stn_qtfDefault = qtfDefault; + + + System.out.println("[ChatPreferences, info]: Current Element: " + node.getNodeName() + " --> call: " + call + " / " + password + " / " + loginDisplayedName + " / " + qra - + " / " + category); + + " / " + category + " / " + antennaBeamWidthDeg + " / " + maxQRBDefault + " / " + qtfDefault); } } diff --git a/src/main/java/kst4contest/view/Kst4ContestApplication.java b/src/main/java/kst4contest/view/Kst4ContestApplication.java index 89eca3e..0159042 100644 --- a/src/main/java/kst4contest/view/Kst4ContestApplication.java +++ b/src/main/java/kst4contest/view/Kst4ContestApplication.java @@ -8,6 +8,7 @@ import java.util.function.Predicate; import javafx.beans.binding.Bindings; import javafx.scene.control.*; +import javafx.scene.input.*; import javafx.scene.layout.*; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer; @@ -35,15 +36,12 @@ import javafx.scene.control.TableColumn.CellDataFeatures; import javafx.scene.control.TableColumn.CellEditEvent; import javafx.scene.control.TableView.TableViewSelectionModel; import javafx.scene.control.cell.TextFieldTableCell; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.input.MouseButton; -import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.stage.FileChooser; import javafx.stage.Stage; import javafx.stage.WindowEvent; import javafx.util.Callback; +import kst4contest.locatorUtils.DirectionUtils; import kst4contest.model.ChatCategory; import kst4contest.model.ChatMember; import kst4contest.model.ChatMessage; @@ -99,12 +97,24 @@ public class Kst4ContestApplication extends Application { selectedCallSignDownerSiteGridPane.setVgap(2); selectedCallSignDownerSiteGridPane.add(selectedCallSignInfoLblQTFInfo, 0,0,1,1); selectedCallSignDownerSiteGridPane.add(selectedCallSignInfoLblQRBInfo, 0,1,1,1); - selectedCallSignDownerSiteGridPane.add(new Label("last activity dateTime"), 0,2,1,1); - selectedCallSignDownerSiteGridPane.add(new Label("last activity duration"), 0,3,1,1); - selectedCallSignDownerSiteGridPane.add(new Button("show path in AS"), 1,0,1,3); - selectedCallSignDownerSiteGridPane.add(new Label("publicmsgCount"), 3,0,1,1); - selectedCallSignDownerSiteGridPane.add(new Label("toMeMsgCount"), 3,1,1,1); - selectedCallSignDownerSiteGridPane.add(new Label("fromMeMSGCount"), 3,2,1,1); + selectedCallSignDownerSiteGridPane.add(new Label("Last activity: " + new Utils4KST().time_convertEpochToReadable(selectedCallSignInfoStageChatMember.getActivityTimeLastInEpoch()+"")), 0,2,1,1); + selectedCallSignDownerSiteGridPane.add(new Label(("(" + Utils4KST.time_getSecondsBetweenEpochAndNow(selectedCallSignInfoStageChatMember.getActivityTimeLastInEpoch()+"") /60%60) +" min ago)"), 0,3,1,1); + + Button selectedCallSignShowAsPathBtn = new Button("Show path in AS"); + selectedCallSignShowAsPathBtn.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent actionEvent) { + chatcontroller.airScout_SendAsShowPathPacket(selectedCallSignInfoStageChatMember); + } + }); + + selectedCallSignDownerSiteGridPane.add(selectedCallSignShowAsPathBtn, 1,0,1,3); + + + +// selectedCallSignDownerSiteGridPane.add(new Label("publicmsgCount"), 3,0,1,1); +// selectedCallSignDownerSiteGridPane.add(new Label("toMeMsgCount"), 3,1,1,1); +// selectedCallSignDownerSiteGridPane.add(new Label("fromMeMSGCount"), 3,2,1,1); // HBox selectedCallSignDownerSiteHBox = new HBox(); // selectedCallSignDownerSiteHBox.getChildren().add(selectedCallSignInfoLblQRBInfo); // selectedCallSignDownerSiteHBox.getChildren().add(selectedCallSignInfoLblQTFInfo); @@ -121,6 +131,7 @@ public class Kst4ContestApplication extends Application { ToggleGroup selectedCallSignInfoFilterMessagesRadioGrp = new ToggleGroup(); RadioButton selectedCallSignFilterToMeMsgRB = new RadioButton("pm to me "); + selectedCallSignFilterToMeMsgRB.setSelected(true); //TODO: that behavior as default selection could be made preferencable selectedCallSignFilterToMeMsgRB.setToggleGroup(selectedCallSignInfoFilterMessagesRadioGrp); RadioButton selectedCallSignFilterMsgToOtherRB = new RadioButton("pm to other"); selectedCallSignFilterMsgToOtherRB.setToggleGroup(selectedCallSignInfoFilterMessagesRadioGrp); @@ -128,24 +139,32 @@ public class Kst4ContestApplication extends Application { selectedCallSignFilterMsgpublic.setToggleGroup(selectedCallSignInfoFilterMessagesRadioGrp); RadioButton selectedCallSignNoFilterRB = new RadioButton("nothing"); selectedCallSignNoFilterRB.setToggleGroup(selectedCallSignInfoFilterMessagesRadioGrp); - selectedCallSignNoFilterRB.setSelected(true); //TODO: that behavior as default selection could be made preferencable + selectedCallSignInfoFilterMessagesRadioGrp.selectedToggleProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observableValue, Toggle toggle, Toggle t1) { RadioButton radioButton = (RadioButton) selectedCallSignInfoFilterMessagesRadioGrp.getSelectedToggle(); + if (radioButton.equals(selectedCallSignFilterToMeMsgRB)) { chatcontroller.getLst_selectedCallSignInfofilteredMessageList().setPredicate(new Predicate() { @Override public boolean test(ChatMessage chatMessage) { - if (((chatMessage.getReceiver().getCallSign().equals(chatcontroller.getChatPreferences().getLoginCallSign())) || (chatMessage.getSender().getCallSign().equals(chatcontroller.getChatPreferences().getLoginCallSign())) - ) && ((chatMessage.getReceiver().getCallSign().equals(selectedCallSignInfoStageChatMember.getCallSign())) || (chatMessage.getSender().getCallSign().equals(selectedCallSignInfoStageChatMember.getCallSign())))) { - return true; + try { + + if (((chatMessage.getReceiver().getCallSign().equals(chatcontroller.getChatPreferences().getLoginCallSign())) || (chatMessage.getSender().getCallSign().equals(chatcontroller.getChatPreferences().getLoginCallSign())) + ) && ((chatMessage.getReceiver().getCallSign().equals(selectedCallSignInfoStageChatMember.getCallSign())) || (chatMessage.getSender().getCallSign().equals(selectedCallSignInfoStageChatMember.getCallSign())))) { + return true; + } + + else return false; + } catch (Exception exception) { + System.out.println("KST4ContestApp <<>> " + exception.getMessage()); } - else return false; + return true; } }); @@ -228,7 +247,7 @@ public class Kst4ContestApplication extends Application { } else return false; } catch (Exception exception) { - System.out.println("KST4ContestApplication <<>>>: cant get sender infos due to sender is not known yet"); + System.out.println("KST4ContestApplication <<>>>: cant get sender infos due to sender is not known yet" + exception.getMessage()); return false; } } @@ -240,8 +259,22 @@ public class Kst4ContestApplication extends Application { private TableView initChatMemberTable() { TableView tbl_chatMemberTable = new TableView(); + tbl_chatMemberTable.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler() { + @Override + public void handle(KeyEvent event) { + + //we need to overdrive the Enter pressed as it should (in the whole scene) send the text! + if (event.getCode() == KeyCode.ENTER) { + + event.consume(); + sendButton.fire(); + } + + } + }); + tbl_chatMemberTable.setTooltip(new Tooltip( - "Stations available \n\n Use right click to a station to select predefined texts \n\n Texts can be changed in the config-file")); + "Stations available \n\nUse right click to a station to select predefined texts\nor hit + <1> ... <9> to write textsnippet to selected station\n\nHit to send")); TableColumn callSignCol = new TableColumn("Callsign"); callSignCol.setCellValueFactory(new Callback, ObservableValue>() { @@ -284,6 +317,19 @@ public class Kst4ContestApplication extends Application { } }); + TableColumn qtfCol = new TableColumn("QTF"); + qtfCol.setCellValueFactory(new Callback, ObservableValue>() { + + @Override + public ObservableValue call(CellDataFeatures cellDataFeatures) { + SimpleStringProperty qra = new SimpleStringProperty(); + + qra.setValue(cellDataFeatures.getValue().getQTFdirection()+"°"); + + return qra; + } + }); + TableColumn qrgCol = new TableColumn("QRG"); qrgCol.setCellValueFactory(new Callback, ObservableValue>() { @@ -371,6 +417,23 @@ public class Kst4ContestApplication extends Application { * END HIGH EXPERIMENTAL:::::::: */ + + TableColumn lastActCol = new TableColumn("Act"); + lastActCol.setCellValueFactory(new Callback, ObservableValue>() { + + @Override + public ObservableValue call(CellDataFeatures cellDataFeatures) { + SimpleStringProperty lastActEpoch = new SimpleStringProperty(); + +// lastActEpoch.setValue(cellDataFeatures.getValue().getActivityTimeLastInEpoch()+""); + + lastActEpoch.setValue((Utils4KST.time_getSecondsBetweenEpochAndNow(cellDataFeatures.getValue().getActivityTimeLastInEpoch()+"") /60%60) +""); + + return lastActEpoch; + } + }); + + TableColumn workedCol = new TableColumn("worked"); workedCol.setCellValueFactory(new Callback, ObservableValue>() { @@ -546,7 +609,7 @@ public class Kst4ContestApplication extends Application { workedCol.getColumns().addAll(wkdAny_subcol, vhfCol_subcol, uhfCol_subcol, shf23_subcol, shf13_subcol, shf9_subcol, shf6_subcol, shf3_subcol); // TODO: automatize enabling to users bandChoice - tbl_chatMemberTable.getColumns().addAll(callSignCol, nameCol, qraCol, qrgCol, airScoutCol, workedCol); + tbl_chatMemberTable.getColumns().addAll(callSignCol, nameCol, qraCol, qtfCol, qrgCol, lastActCol, airScoutCol, workedCol); // tbl_chatMemberTable.setItems(chatcontroller.getLst_chatMemberListFiltered()); @@ -580,11 +643,13 @@ public class Kst4ContestApplication extends Application { tbl_chatMemberTable.getSortOrder().add(callSignCol); +// initializeCommunicationOverMyHeadVizalizationStage(new ChatMember()); + /** * timer_chatMemberTableSortTimer --> * This part fixes a javafx bug. The update of the Chatmember fields is (for any - * reason) not visible in the ui. Its neccessarry to sort the table in intervals - * to keep the table up to date. + * reason) not visible in the ui. Its neccessarry to (now no more sort!) but refresh + * the table in intervals to keep the table up to date. */ timer_chatMemberTableSortTimer = new Timer(); @@ -607,7 +672,7 @@ public class Kst4ContestApplication extends Application { try { - tbl_chatMemberTable.sort(); +// tbl_chatMemberTable.sort(); } catch (Exception e) { System.out.println("[Main.java, Warning:] Table sorting (actualizing) failed this time."); @@ -617,7 +682,7 @@ public class Kst4ContestApplication extends Application { }); } - }, new Date(), 10000); + }, new Date(), 5000); tbl_chatMemberTable.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY); tbl_chatMemberTable.autosize(); @@ -676,74 +741,32 @@ public class Kst4ContestApplication extends Application { // // } - private Stage initializeFurtherInfoOnSelectedChatMemberStage(ChatMember selectedChatMember) { - try { - - -// stage_selectedCallSignInfoStage = new Stage(); -// stage_selectedCallSignInfoStage.close(); - - stage_selectedCallSignInfoStage.setTitle("Further info on "+ selectedChatMember.getCallSign()); - Label selectedCallSignInfoLblQTFInfo = new Label("QTF: " + selectedChatMember.getQTFdirection() + " deg"); - Label selectedCallSignInfoLblQRBInfo = new Label("QRB: " + selectedChatMember.getQrb() + " km"); - - - AnchorPane selectedCallSignInfoPane = new AnchorPane(); - BorderPane selectedCallSignInfoBorderPane = new BorderPane(); - selectedCallSignInfoPane.getChildren().add(selectedCallSignInfoBorderPane); - - SplitPane selectedCallSignSplitPane = new SplitPane(); - selectedCallSignSplitPane.setOrientation(Orientation.VERTICAL); - - TableView initFurtherInfoAbtCallsignMSGTable = initFurtherInfoAbtCallsignMSGTable(); - - - GridPane selectedCallSignDownerSiteGridPane = new GridPane(); - selectedCallSignDownerSiteGridPane.setHgap(10); - selectedCallSignDownerSiteGridPane.setVgap(2); - selectedCallSignDownerSiteGridPane.add(selectedCallSignInfoLblQTFInfo, 0,0,1,1); - selectedCallSignDownerSiteGridPane.add(selectedCallSignInfoLblQRBInfo, 0,1,1,1); - selectedCallSignDownerSiteGridPane.add(new Label("last activity dateTime"), 0,2,1,1); - selectedCallSignDownerSiteGridPane.add(new Label("last activity duration"), 0,3,1,1); - selectedCallSignDownerSiteGridPane.add(new Button("show path in AS"), 1,0,1,3); - selectedCallSignDownerSiteGridPane.add(new Label("publicmsgCount"), 3,0,1,1); - selectedCallSignDownerSiteGridPane.add(new Label("toMeMsgCount"), 3,1,1,1); - selectedCallSignDownerSiteGridPane.add(new Label("fromMeMSGCount"), 3,2,1,1); -// HBox selectedCallSignDownerSiteHBox = new HBox(); -// selectedCallSignDownerSiteHBox.getChildren().add(selectedCallSignInfoLblQRBInfo); -// selectedCallSignDownerSiteHBox.getChildren().add(selectedCallSignInfoLblQTFInfo); - - selectedCallSignSplitPane.getItems().add(initFurtherInfoAbtCallsignMSGTable); - selectedCallSignSplitPane.getItems().add(selectedCallSignDownerSiteGridPane); - - - selectedCallSignInfoBorderPane.setCenter(selectedCallSignSplitPane); - - HBox selectedCallSignInfoBottomControlsBox = new HBox(); - selectedCallSignInfoBottomControlsBox.getChildren().add(new CheckBox("Always on top")); - selectedCallSignInfoBottomControlsBox.getChildren().add(new CheckBox("Filter messages to me")); - selectedCallSignInfoBottomControlsBox.getChildren().add(new CheckBox("Filter messages to Other")); - selectedCallSignInfoBorderPane.setBottom(selectedCallSignInfoBottomControlsBox); - - - stage_selectedCallSignInfoStage.setScene(new Scene(selectedCallSignInfoPane, 500, 400)); - stage_selectedCallSignInfoStage.setAlwaysOnTop(false); - - if (!stage_selectedCallSignInfoStage.isShowing()) { - - stage_selectedCallSignInfoStage.show(); - } - - stage_selectedCallSignInfoStage.show(); - return stage_selectedCallSignInfoStage; - } - - catch (Exception e) { - e.printStackTrace(); - System.out.println("There occured an error due to the selected callsign had been deleted!"); - return stage_selectedCallSignInfoStage; - } - } +// private Stage initializeCommunicationOverMyHeadVizalizationStage(ChatMember selectedChatMember) { +// Stage stage_CommunicationOverMyHeadVizalizationStage = new Stage(); +// stage_CommunicationOverMyHeadVizalizationStage.setAlwaysOnTop(true); +// +// MaidenheadLocatorMapPane locatorMapPane = new MaidenheadLocatorMapPane(); +// locatorMapPane.addLocator("JO51IJ", Color.RED); +// locatorMapPane.addLocator("JN39OC", Color.BLUE); +// locatorMapPane.addLocator("JN49GL", Color.GREEN); +// locatorMapPane.connectLocators("JO51IJ", "JN49GL"); +// +// try { +// +// +// BorderPane bp_CommunicationOverMyHeadVizalizationStage = new BorderPane(); +// +// stage_CommunicationOverMyHeadVizalizationStage.setTitle("Further info on "+ selectedChatMember.getCallSign()); +// +// stage_CommunicationOverMyHeadVizalizationStage.setScene(new Scene(locatorMapPane)); +// stage_CommunicationOverMyHeadVizalizationStage.show(); +// +// return stage_CommunicationOverMyHeadVizalizationStage; +// } catch (Exception exception){ +// +// } +// return stage_CommunicationOverMyHeadVizalizationStage; +// } /** * Initializes the right click contextmenu for the chatmember-table, sets the @@ -1056,6 +1079,9 @@ public class Kst4ContestApplication extends Application { } }); + + + TableColumn msgCol = new TableColumn("Message"); msgCol.setCellValueFactory(new Callback, ObservableValue>() { @@ -1318,6 +1344,7 @@ public class Kst4ContestApplication extends Application { * END HIGH EXPERIMENTAL:::::::: */ + tbl_privateMSGTable.getColumns().addAll(timeCol, callSignCol, nameCol, qraCol, msgCol, qrgCol, airScoutCol); ObservableList privateMSGList = chatcontroller.getLst_toMeMessageList(); @@ -2142,12 +2169,13 @@ public class Kst4ContestApplication extends Application { Menu helpMenu = new Menu("Info"); MenuItem help1 = new MenuItem("No help here."); - MenuItem help2 = new MenuItem("Support the chatclient development via PayPal"); + MenuItem help2 = new MenuItem("Donate for kst4Contest development via PayPal"); MenuItem help3 = new MenuItem("_______________________"); help3.setDisable(true); MenuItem help4 = new MenuItem("Visit DARC X08-Homepage"); - MenuItem help5 = new MenuItem("_______________________"); - help5.setDisable(true); + MenuItem menuItmDonateON4KST = new MenuItem("Donate for ON4KST Chatservers with PayPal to on4kst@skynet.be"); + MenuItem menuItmDonateOV3T = new MenuItem("Donate for OV3T´s plane feed service"); +// help5.setDisable(true); MenuItem help6 = new MenuItem("Contact the author using default mail app"); MenuItem help8 = new MenuItem("Join kst4Contest newsgroup"); // MenuItem help9 = new MenuItem("Download the changelog / roadmap"); @@ -2188,6 +2216,24 @@ public class Kst4ContestApplication extends Application { } }); +// menuItmDonateON4KST.setOnAction(new EventHandler() { +// public void handle(ActionEvent event) { +// +// getHostServices().showDocument("https://www.paypal.com"); +// +// +// } +// }); + + menuItmDonateOV3T.setOnAction(new EventHandler() { + public void handle(ActionEvent event) { + + getHostServices().showDocument("https://www.paypal.me/ov3t"); + + + } + }); + // help9.setOnAction(new EventHandler() { // public void handle(ActionEvent event) { // @@ -2211,7 +2257,7 @@ public class Kst4ContestApplication extends Application { }); // helpMenu.getItems().add(help1); - helpMenu.getItems().addAll(help2, help4, help5, help6, help8, help10); + helpMenu.getItems().addAll(help2, help3, help4, menuItmDonateOV3T, menuItmDonateON4KST, help6, help8, help10); // helpMenu.getItems().add(help2); // helpMenu.getItems().add(help4); @@ -2231,6 +2277,7 @@ public class Kst4ContestApplication extends Application { MenuItem menuItemOptionsSetFrequencyAsName; TextField txt_chatMessageUserInput = new TextField(); + Button sendButton; TextField txt_ownqrg = new TextField(); TextField txt_myQTF = new TextField(); Button btnOptionspnlConnect; @@ -2712,9 +2759,14 @@ public class Kst4ContestApplication extends Application { // System.out.println("Textfield on focus"); // Do nothing until field loses focus, user will enter his frequency } else { + try { System.out.println( "[Main.java, Info]: Set the MYQTF property by hand to: " + txt_myQTF.getText()); - chatcontroller.getChatPreferences().getActualQTF().set(Integer.parseInt(txt_myQTF.getText())); + chatcontroller.getChatPreferences().getActualQTF().set(Integer.parseInt(txt_myQTF.getText()));} + catch (Exception exception) { + System.out.println("bullshit entered in myqtf"); + txt_myQTF.setText("0"); + } } } }); @@ -2731,6 +2783,79 @@ public class Kst4ContestApplication extends Application { Scene scene = new Scene(bPaneChatWindow, 1024, 768); + scene.setOnKeyPressed(new EventHandler() { + KeyCombination keyComboSTRGplus1 = new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus2 = new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus3 = new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus4 = new KeyCodeCombination(KeyCode.DIGIT4, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus5 = new KeyCodeCombination(KeyCode.DIGIT5, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus6 = new KeyCodeCombination(KeyCode.DIGIT6, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus7 = new KeyCodeCombination(KeyCode.DIGIT7, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus8 = new KeyCodeCombination(KeyCode.DIGIT8, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus9 = new KeyCodeCombination(KeyCode.DIGIT9, KeyCombination.CONTROL_DOWN); + KeyCombination keyComboSTRGplus0 = new KeyCodeCombination(KeyCode.DIGIT0, KeyCombination.CONTROL_DOWN); + + + @Override + public void handle(KeyEvent keyEvent) { + try { + +// System.out.println(keyEvent.getCode()); + + /** + * if a macro is set by hitting strg+Nr, it should be possible to send the message by hit the enter key + */ + if (keyEvent.getCode() == KeyCode.ENTER) { + + sendButton.fire(); + + } else if (keyEvent.getCode() == KeyCode.ESCAPE) { + txt_chatMessageUserInput.clear(); + } else + + if (selectedCallSignInfoStageChatMember.getCallSign() != null) { + + if (keyComboSTRGplus1.match(keyEvent)) { + + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(0)); + + } else if (keyComboSTRGplus2.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(1)); + + } else if (keyComboSTRGplus3.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(2)); + + } else if (keyComboSTRGplus4.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(3)); + + } else if (keyComboSTRGplus5.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(4)); + + } else if (keyComboSTRGplus6.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(5)); + + } else if (keyComboSTRGplus7.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(6)); + + } else if (keyComboSTRGplus8.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(7)); + + } else if (keyComboSTRGplus9.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(8)); + + } else if (keyComboSTRGplus0.match(keyEvent)) { + txt_chatMessageUserInput.setText("/cq " + selectedCallSignInfoStageChatMember.getCallSign() + " " + chatcontroller.getChatPreferences().getLst_txtSnipList().get(9)); + + } + + } + } catch (Exception nullPointerExc) { + System.out.println("There are no predifined textsnippets for this keycombo! -> " + nullPointerExc.getMessage()); + } + } + }); + + // primaryStage.setTitle(this.chatcontroller.getChatPreferences().getChatState()); // scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); @@ -2749,7 +2874,7 @@ public class Kst4ContestApplication extends Application { // FlowPane textInputFlowPane = new FlowPane(); - Button sendButton = new Button("send"); + sendButton = new Button("send"); sendButton.setMinSize(60, 0); sendButton.setOnAction(new EventHandler() { @Override @@ -2944,6 +3069,15 @@ public class Kst4ContestApplication extends Application { txt_chatMessageUserInput.clear(); txt_chatMessageUserInput.setText("/cq " + selectedChatMemberPrivateChat.getList().get(0).getSender().getCallSign() + " "); + + try { + selectedCallSignFurtherInfoPane.getChildren().clear(); + selectedCallSignInfoStageChatMember = selectedChatMemberPrivateChat.getList().get(0).getSender(); + selectedCallSignFurtherInfoPane.getChildren().add(generateFurtherInfoAbtSelectedCallsignBP(selectedCallSignInfoStageChatMember)); + } catch (Exception exception) { + System.out.println("KST4CApp, <<>>>: message sender is not in the userlist any more!"); + } + System.out.println("privChat selected ChatMember: " + selectedChatMemberPrivateChat.getList().get(0).getSender()); // selectedChatMemberList.clear(); @@ -2999,6 +3133,14 @@ public class Kst4ContestApplication extends Application { + selectedChatMemberGeneralChat.getList().get(0).getSender().getCallSign() + " "); System.out.println("privChat selected ChatMember: " + selectedChatMemberGeneralChat.getList().get(0).getSender()); + + try { + selectedCallSignFurtherInfoPane.getChildren().clear(); + selectedCallSignInfoStageChatMember = selectedChatMemberGeneralChat.getList().get(0).getSender(); + selectedCallSignFurtherInfoPane.getChildren().add(generateFurtherInfoAbtSelectedCallsignBP(selectedCallSignInfoStageChatMember)); + } catch (Exception exception) { + System.out.println("KST4CApp, <<>>>: message sender is not in the userlist any more!"); + } // selectedChatMemberList.clear(); // selectionModelChatMember.clearSelection(0); } @@ -3009,6 +3151,7 @@ public class Kst4ContestApplication extends Application { messageSectionSplitpane.getItems().addAll(privateMessageTable, flwPane_textSnippets, textInputFlowPane, tbl_generalMessageTable); + messageSectionSplitpane.setDividerPositions(0.9); //Changed to add contextmenu to cq message table // messageSectionSplitpane.getItems().addAll(privateMessageTable, flwPane_textSnippets, textInputFlowPane, // initChatGeneralMSGTable()); @@ -3044,8 +3187,8 @@ public class Kst4ContestApplication extends Application { txt_chatMessageUserInput.clear(); txt_chatMessageUserInput .setText("/cq " + selectedChatMember.getList().get(0).getCallSign() + " "); - System.out.println( - "##################selected ChatMember: " + selectedChatMember.getList().get(0)); +// System.out.println( +// "##################selected ChatMember: " + selectedChatMember.getList().get(0)); // selectedChatMemberList.clear(); // selectionModelChatMember.clearSelection(0); } @@ -3104,7 +3247,7 @@ public class Kst4ContestApplication extends Application { HBox chatMemberTableFilterQRBHBox = new HBox(); chatMemberTableFilterQRBHBox.setAlignment(Pos.CENTER_LEFT); - TextField chatMemberTableFilterMaxQrbTF = new TextField("1000"); + TextField chatMemberTableFilterMaxQrbTF = new TextField(chatcontroller.getChatPreferences().getStn_maxQRBDefault() + ""); ToggleButton tglBtnQRBEnable = new ToggleButton("Show only QRB [km] <= "); tglBtnQRBEnable.selectedProperty().addListener(new ChangeListener() { Predicate maxQrbPredicate = new Predicate() { @@ -3150,14 +3293,19 @@ public class Kst4ContestApplication extends Application { HBox chatMemberTableFilterQTFHBox = new HBox(); chatMemberTableFilterQTFHBox.setAlignment(Pos.CENTER_LEFT); - CheckBox chatMemberTableFilterQtfEnableChkbx = new CheckBox("Show only QTF +/-25 degrees"); - TextField chatMemberTableFilterQtfTF = new TextField("0"); + CheckBox chatMemberTableFilterQtfEnableChkbx = new CheckBox("Show only QTF:"); + TextField chatMemberTableFilterQtfTF = new TextField(chatcontroller.getChatPreferences().getStn_qtfDefault()+""); chatMemberTableFilterQtfTF.textProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observableValue, String oldValue, String newValue) { + if (newValue.equals("")) { + chatMemberTableFilterQtfTF.setText("0"); + } if (!newValue.matches("\\d*")) { chatMemberTableFilterQtfTF.setText(newValue.replaceAll("[^\\d]", "")); } + chatMemberTableFilterQtfEnableChkbx.setSelected(false); + chatMemberTableFilterQtfEnableChkbx.setSelected(true); } }); chatMemberTableFilterQtfEnableChkbx.selectedProperty().addListener(new ChangeListener() { @@ -3168,21 +3316,10 @@ public class Kst4ContestApplication extends Application { System.out.println(chatMemberTableFilterQtfTF.getText() + " stn have " + chatMember.getQTFdirection()); - double myQTF = Double.parseDouble(chatMemberTableFilterQtfTF.getText()); +// double myQTF = ); - Double diff360 = 0.; + return DirectionUtils.isAngleInRange(chatMember.getQTFdirection(),Double.parseDouble(chatMemberTableFilterQtfTF.getText()), chatcontroller.getChatPreferences().getStn_antennaBeamWidthDeg()); - if (myQTF-25 < 0) { - diff360 = myQTF-25+360; - System.out.println("diff- " + diff360); - } else if (myQTF+25 >360) { - diff360 = myQTF+25-360; - System.out.println("diff+ " + diff360); - } - - if ((chatMember.getQTFdirection() >= myQTF-diff360 ) && (chatMember.getQTFdirection() <= myQTF+diff360)){ - return true; - } else return false; } }; @Override @@ -3268,7 +3405,7 @@ public class Kst4ContestApplication extends Application { }); chatMemberTableFilterQTFHBox.setSpacing(5); - chatMemberTableFilterQTFHBox.getChildren().addAll(qtfNorth, qtfNorthEast, qtfEast, qtfSouthEast, chatMemberTableFilterQtfTF, qtfSouth, qtfSouthWest, qtfWest, qtfNorthWest); + chatMemberTableFilterQTFHBox.getChildren().addAll(chatMemberTableFilterQtfTF, new Label("deg, " + chatcontroller.getChatPreferences().getStn_antennaBeamWidthDeg() + " beamwidth"), qtfNorth, qtfNorthEast, qtfEast, qtfSouthEast, qtfSouth, qtfSouthWest, qtfWest, qtfNorthWest); chatMemberTableFilterQTFAndQRBHbox.getChildren().add(chatMemberTableFilterQTFHBox); chatMemberTableFilterVBoxForAllFilters.getChildren().add(chatMemberTableFilterQTFAndQRBHbox); @@ -3359,15 +3496,205 @@ public class Kst4ContestApplication extends Application { } } }); + ToggleButton btnTglwkd144 = new ToggleButton("144"); + + Predicate wkd144Predicate = new Predicate() { + @Override + public boolean test(ChatMember chatMember) { + + if (chatMember.isWorked144()) { + return false; + } + else return true; + } + }; + btnTglwkd144.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent actionEvent) { + if (btnTglwkd144.isSelected()) { + chatcontroller.getLst_chatMemberListFilterPredicates().add(wkd144Predicate); + } else { + chatcontroller.getLst_chatMemberListFilterPredicates().remove(wkd144Predicate); + } + } + }); + ToggleButton btnTglwkd432 = new ToggleButton("432"); + + Predicate wkd432Predicate = new Predicate() { + @Override + public boolean test(ChatMember chatMember) { + + if (chatMember.isWorked432()) { + return false; + } + else return true; + } + }; + btnTglwkd432.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent actionEvent) { + if (btnTglwkd432.isSelected()) { + chatcontroller.getLst_chatMemberListFilterPredicates().add(wkd432Predicate); + } else { + chatcontroller.getLst_chatMemberListFilterPredicates().remove(wkd432Predicate); + } + } + }); + + ToggleButton btnTglwkd23 = new ToggleButton("23"); + + Predicate wkd23Predicate = new Predicate() { + @Override + public boolean test(ChatMember chatMember) { + + if (chatMember.isWorked1240()) { + return false; + } + else return true; + } + }; + btnTglwkd23.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent actionEvent) { + if (btnTglwkd23.isSelected()) { + chatcontroller.getLst_chatMemberListFilterPredicates().add(wkd23Predicate); + } else { + chatcontroller.getLst_chatMemberListFilterPredicates().remove(wkd23Predicate); + } + } + }); + ToggleButton btnTglwkd13 = new ToggleButton("13"); + + Predicate wkd13Predicate = new Predicate() { + @Override + public boolean test(ChatMember chatMember) { + + if (chatMember.isWorked2300()) { + return false; + } + else return true; + } + }; + btnTglwkd13.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent actionEvent) { + if (btnTglwkd13.isSelected()) { + chatcontroller.getLst_chatMemberListFilterPredicates().add(wkd13Predicate); + } else { + chatcontroller.getLst_chatMemberListFilterPredicates().remove(wkd13Predicate); + } + } + }); + ToggleButton btnTglwkd9 = new ToggleButton("9"); + + Predicate wkd9Predicate = new Predicate() { + @Override + public boolean test(ChatMember chatMember) { + + if (chatMember.isWorked3400()) { + return false; + } + else return true; + } + }; + btnTglwkd9.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent actionEvent) { + if (btnTglwkd9.isSelected()) { + chatcontroller.getLst_chatMemberListFilterPredicates().add(wkd9Predicate); + } else { + chatcontroller.getLst_chatMemberListFilterPredicates().remove(wkd9Predicate); + } + } + }); + + ToggleButton btnTglwkd6 = new ToggleButton("6"); + + Predicate wkd6Predicate = new Predicate() { + @Override + public boolean test(ChatMember chatMember) { + + if (chatMember.isWorked5600()) { + return false; + } + else return true; + } + }; + btnTglwkd6.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent actionEvent) { + if (btnTglwkd6.isSelected()) { + chatcontroller.getLst_chatMemberListFilterPredicates().add(wkd6Predicate); + } else { + chatcontroller.getLst_chatMemberListFilterPredicates().remove(wkd6Predicate); + } + } + }); + + ToggleButton btnTglwkd3 = new ToggleButton("3"); + + Predicate wkd3Predicate = new Predicate() { + @Override + public boolean test(ChatMember chatMember) { + + if (chatMember.isWorked10G()) { + return false; + } + else return true; + } + }; + btnTglwkd3.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent actionEvent) { + if (btnTglwkd3.isSelected()) { + chatcontroller.getLst_chatMemberListFilterPredicates().add(wkd3Predicate); + } else { + chatcontroller.getLst_chatMemberListFilterPredicates().remove(wkd3Predicate); + } + } + }); + ToggleButton btnTglInactive = new ToggleButton("Inactive stations"); + Predicate inactivePredicate = new Predicate() { + @Override + public boolean test(ChatMember chatMember) { + + + if ((Utils4KST.time_getSecondsBetweenEpochAndNow(chatMember.getActivityTimeLastInEpoch()+"") /60%60) > 20) { + return false; + } + else return true; + } + }; + btnTglInactive.setOnAction(new EventHandler() { + + @Override + public void handle(ActionEvent actionEvent) { + if (btnTglInactive.isSelected()) { + chatcontroller.getLst_chatMemberListFilterPredicates().add(inactivePredicate); + } else { + chatcontroller.getLst_chatMemberListFilterPredicates().remove(inactivePredicate); + } + } + }); + + btnTglInactive.setTooltip(new Tooltip("not implemented yet!")); + chatMemberTableFilterWorkedBandFiltersHbx.getChildren().add(new Label("Hide: ")); chatMemberTableFilterWorkedBandFiltersHbx.getChildren().add(btnTglwkd); chatMemberTableFilterWorkedBandFiltersHbx.getChildren().add(btnTglwkd144); @@ -3398,6 +3725,12 @@ public class Kst4ContestApplication extends Application { chatMemberTableFilterVBoxForAllFilters.getChildren().add(chatMemberTableFilterTextFieldAndWorkedBandsHbx); +// Tooltip filterPanelTooltip = new Tooltip("Set the station-visible-filters here"); +// Tooltip.install(chatMemberTableFilterVBoxForAllFilters,filterPanelTooltip); + + Tooltip filterTextBoxTooltip = new Tooltip("Free text search"); + Tooltip.install(chatMemberTableFilterTextField,filterTextBoxTooltip); + chatMemberTableBorderPane.setTop(chatMemberTableFilterVBoxForAllFilters); @@ -3405,6 +3738,7 @@ public class Kst4ContestApplication extends Application { mainWindowLeftSplitPane.getItems().addAll(messageSectionSplitpane, mainWindowRightSplitPane); + mainWindowLeftSplitPane.setDividerPositions(0.8); /** * initializing the furter infos of a callsign part of the right splitpane @@ -3622,9 +3956,9 @@ public class Kst4ContestApplication extends Application { @Override public void changed(ObservableValue observed, String oldString, String newString) { - - System.out.println("[Main.java, Info]: Setted the Login Callsign: " + txtFldCallSign.getText()); - chatcontroller.getChatPreferences().setLoginCallSign(txtFldCallSign.getText()); + txtFldCallSign.setText(txtFldCallSign.getText().toUpperCase()); + System.out.println("[Main.java, Info]: Setted the Login Callsign: " + txtFldCallSign.getText().toUpperCase()); + chatcontroller.getChatPreferences().setLoginCallSign(txtFldCallSign.getText().toUpperCase()); } }); @@ -3705,6 +4039,70 @@ public class Kst4ContestApplication extends Application { // labeledSeparator.getChildren().add(rightSeparator); // labeledSeparator.setAlignment(Pos.CENTER); + TextField txtFldstn_antennaBeamWidthDeg = new TextField(this.chatcontroller.getChatPreferences().getStn_antennaBeamWidthDeg() + ""); + + txtFldstn_antennaBeamWidthDeg.textProperty().addListener(new ChangeListener() { + + @Override + public void changed(ObservableValue observed, String oldString, String newString) { + + if (newString.equals("")) { + txtFldstn_antennaBeamWidthDeg.setText("0"); + } + + if (!newString.matches("\\d*")) { + txtFldstn_antennaBeamWidthDeg.setText(newString.replaceAll("[^\\d]", "")); + } + + System.out.println("[Main.java, Info]: Setted the beam: " + txtFldstn_antennaBeamWidthDeg.getText()); + chatcontroller.getChatPreferences().setStn_antennaBeamWidthDeg(Double.parseDouble(txtFldstn_antennaBeamWidthDeg.getText())); + } + }); + + TextField txtFldstn_maxQRBDefault = new TextField(this.chatcontroller.getChatPreferences().getStn_maxQRBDefault() + ""); + + txtFldstn_maxQRBDefault.textProperty().addListener(new ChangeListener() { + + @Override + public void changed(ObservableValue observed, String oldString, String newString) { + + if (newString.equals("")) { + txtFldstn_maxQRBDefault.setText("0"); + } + + if (!newString.matches("\\d*")) { + txtFldstn_maxQRBDefault.setText(newString.replaceAll("[^\\d]", "")); + } + + System.out.println("[Main.java, Info]: Setted the QRB: " + txtFldstn_maxQRBDefault.getText()); + chatcontroller.getChatPreferences().setStn_antennaBeamWidthDeg(Double.parseDouble(txtFldstn_maxQRBDefault.getText())); + } + }); + + TextField txtFldstn_qtfDefault = new TextField(this.chatcontroller.getChatPreferences().getStn_qtfDefault() + ""); + + txtFldstn_qtfDefault.textProperty().addListener(new ChangeListener() { + + @Override + public void changed(ObservableValue observed, String oldString, String newString) { + + if (newString.equals("")) { + txtFldstn_qtfDefault.setText("0"); + } + + if (!newString.matches("\\d*")) { + txtFldstn_qtfDefault.setText(newString.replaceAll("[^\\d]", "")); + } + + System.out.println("[Main.java, Info]: Setted the QRB: " + txtFldstn_qtfDefault.getText()); + chatcontroller.getChatPreferences().setStn_antennaBeamWidthDeg(Double.parseDouble(txtFldstn_qtfDefault.getText())); +// chatMemberTableFilterQTFHBox.getChildren().addAll(chatMemberTableFilterQtfTF, new Label("deg, " + chatcontroller.getChatPreferences().getStn_antennaBeamWidthDeg() + " beamwidth"), qtfNorth, qtfNorthEast, qtfEast, qtfSouthEast, qtfSouth, qtfSouthWest, qtfWest, qtfNorthWest); +// chatMemberTableFilterQTFHBox.getChildren().addAll(chatMemberTableFilterQtfTF, new Label("deg, " + chatcontroller.getChatPreferences().getStn_antennaBeamWidthDeg() + " beamwidth"), qtfNorth, qtfNorthEast, qtfEast, qtfSouthEast, qtfSouth, qtfSouthWest, qtfWest, qtfNorthWest); + } + + }); + + grdPnlStation.add(lblCallSign, 0, 0); grdPnlStation.add(txtFldCallSign, 1, 0); grdPnlStation.add(lblPassword, 0, 1); @@ -3715,6 +4113,12 @@ public class Kst4ContestApplication extends Application { grdPnlStation.add(txtFldLocator, 1, 3); grdPnlStation.add(lblChatCategory, 0, 4); grdPnlStation.add(choiceBxChatChategory, 1, 4); + grdPnlStation.add(new Label("Antenna beamwidth:"), 0, 5); + grdPnlStation.add(txtFldstn_antennaBeamWidthDeg, 1, 5); + grdPnlStation.add(new Label("Default maximum QRB:"), 0, 6); + grdPnlStation.add(txtFldstn_maxQRBDefault, 1, 6); + grdPnlStation.add(new Label("Default filter QTF:"), 0, 7); + grdPnlStation.add(txtFldstn_qtfDefault, 1, 7); VBox vbxStation = new VBox(); vbxStation.setPadding(new Insets(10, 10, 10, 10)); @@ -4216,7 +4620,7 @@ public class Kst4ContestApplication extends Application { // grdPnlShorts.add(lblEnableTRXMsgbyUCX, 0, 1); // grdPnlShorts.add(chkBxEnableTRXMsgbyUCX, 1, 1); - grdPnlShorts.add(generateLabeledSeparator(100, "Set the Text-snippets (userlist right-click textsnippets)"), 0, + grdPnlShorts.add(generateLabeledSeparator(100, "Set the Text-snippets (First 10 are accessible by pressing + !)"), 0, 3, 2, 1); VBox vbxShorts = new VBox(); @@ -4550,6 +4954,9 @@ public class Kst4ContestApplication extends Application { txtFldName.setDisable(true); txtFldLocator.setDisable(true); choiceBxChatChategory.setDisable(true); + txtFldstn_antennaBeamWidthDeg.setDisable(true); + txtFldstn_qtfDefault.setDisable(true); + txtFldstn_maxQRBDefault.setDisable(true); btnOptionspnlConnect.setDisable(true); btnOptionspnlDisconnect.setDisable(false); chatcontroller.setConnectedAndLoggedIn(true); @@ -4679,4 +5086,98 @@ public class Kst4ContestApplication extends Application { launch(args); } +// public class MaidenheadLocatorMapPane extends Pane { +// +// private static final double MAP_WIDTH = 800; +// private static final double MAP_HEIGHT = 600; +// private static final double CIRCLE_RADIUS = 5; +// private static final double TEXT_OFFSET_X = 10; +// private static final double TEXT_OFFSET_Y = -10; +// +// public MaidenheadLocatorMapPane() { +// setPrefSize(MAP_WIDTH, MAP_HEIGHT); +// } +// +// public void addLocator(String locator, Color color) { +// double[] coords = locatorToCoordinates(locator); +// Circle circle = new Circle(coords[0], coords[1], CIRCLE_RADIUS, color); +// Text text = new Text(coords[0] + TEXT_OFFSET_X, coords[1] + TEXT_OFFSET_Y, locator); +// getChildren().addAll(circle, text); +// } +// +// public void connectLocators(String locator1, String locator2) { +// double[] coords1 = locatorToCoordinates(locator1); +// double[] coords2 = locatorToCoordinates(locator2); +// Line line = new Line(coords1[0], coords1[1], coords2[0], coords2[1]); +// getChildren().add(line); +// +// // Calculate distance between locators +// double distance = calculateDistance(coords1, coords2); +// +// // Calculate direction in degrees from locator1 to locator2 +// double direction = calculateDirection(coords1, coords2); +// +// // Format distance to display only two decimal places +// DecimalFormat df = new DecimalFormat("#.##"); +// +// // Create text for displaying distance and direction +// Text distanceText = new Text((coords1[0] + coords2[0]) / 2, (coords1[1] + coords2[1]) / 2, "Distance: " + df.format(distance) + " km"); +// Text directionText = new Text((coords1[0] + coords2[0]) / 2, (coords1[1] + coords2[1]) / 2 + 20, "Direction: " + df.format(direction) + "°"); +// getChildren().addAll(distanceText, directionText); +// } +// +// // Helper method to convert Maidenhead locator string to coordinates +// private double[] locatorToCoordinates(String locator) { +// double lon = (locator.charAt(0) - 'A') * 20 - 180; +// double lat = (locator.charAt(1) - 'A') * 10 - 90; +// lon += (locator.charAt(2) - '0') * 2; +// lat += (locator.charAt(3) - '0'); +// lon += (locator.charAt(4) - 'A') * 5.0 / 60; +// lat += (locator.charAt(5) - 'A') * 2.5 / 60; +// +// // Convert coordinates to map coordinates +// double x = (lon + 180) / 360 * MAP_WIDTH; +// double y = MAP_HEIGHT - (lat + 90) / 180 * MAP_HEIGHT; +// return new double[]{x, y}; +// } +// +// // Helper method to calculate distance between two coordinates (in km) +// private double calculateDistance(double[] coords1, double[] coords2) { +// double lon1 = Math.toRadians(coords1[0]); +// double lat1 = Math.toRadians(coords1[1]); +// double lon2 = Math.toRadians(coords2[0]); +// double lat2 = Math.toRadians(coords2[1]); +// +// double dlon = lon2 - lon1; +// double dlat = lat2 - lat1; +// +// double a = Math.pow(Math.sin(dlat / 2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(dlon / 2), 2); +// double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); +// +// // Earth radius in km +// double radius = 6371; +// +// return radius * c; +// } +// +// // Helper method to calculate direction in degrees from coords1 to coords2 +// private double calculateDirection(double[] coords1, double[] coords2) { +// double lon1 = Math.toRadians(coords1[0]); +// double lat1 = Math.toRadians(coords1[1]); +// double lon2 = Math.toRadians(coords2[0]); +// double lat2 = Math.toRadians(coords2[1]); +// +// double dLon = lon2 - lon1; +// +// double y = Math.sin(dLon) * Math.cos(lat2); +// double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon); +// +// double direction = Math.atan2(y, x); +// direction = Math.toDegrees(direction); +// direction = (direction + 360) % 360; +// +// return direction; +// } +// } + } diff --git a/src/main/resources/praktiKSTpreferences.xml b/src/main/resources/praktiKSTpreferences.xml index 8604755..3619536 100644 --- a/src/main/resources/praktiKSTpreferences.xml +++ b/src/main/resources/praktiKSTpreferences.xml @@ -6,6 +6,9 @@ Paule JO51DI 2 + 50 + 900 + 135 SimpleLogFile.txt