Commit 087aaa63 authored by Junita Sinambela's avatar Junita Sinambela
Browse files

Merge branch 'master' of...

Merge branch 'master' of http://gitlab.informatika.org/sinambelajunita/IF3230-Tugas-Besar-Sister-2015
parents 2464ac65 1bb1abdc
......@@ -5,15 +5,17 @@
<group>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/TradePanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/grandquest/GrandQuest.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/HelperClasses/ButtonColumn.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/FindPanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/LoginPanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/MixItemPanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/Request/Request.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/MapPanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/MainFrame.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/OfferingPanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/AcceptPanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/InventoryPanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/HelperClasses/ButtonColumn.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/GUI/OfferingPanel.java</file>
<file>file:/E:/OneDrive/Data%20Semester%206/Sistem%20Terdistribusi/GrandQuest/src/client/src/HelperClasses/KeyValuePair.java</file>
</group>
</open-files>
</project-private>
......@@ -29,11 +29,13 @@ dist.jar=${dist.dir}/GrandQuest.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.json-simple-1.1.1.jar=C:\\Users\\Rikysamuel\\Downloads\\json-simple-1.1.1.jar
file.reference.org.json-20120521.jar=..\\server\\lib\\org.json-20120521.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.org.json-20120521.jar}
${file.reference.org.json-20120521.jar}:\
${file.reference.json-simple-1.1.1.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
......
......@@ -33,8 +33,8 @@
<EmptySpace pref="56" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="level2Panel" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="level4Panel" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="level4Panel" min="-2" pref="171" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="backButton" min="-2" max="-2" attributes="0"/>
</Group>
......@@ -222,7 +222,7 @@
<Component class="javax.swing.JLabel" name="herbs">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/honey.png"/>
<Image iconType="3" name="/img/herbs.png"/>
</Property>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
......@@ -230,7 +230,7 @@
<Component class="javax.swing.JLabel" name="clay">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/honey.png"/>
<Image iconType="3" name="/img/clay.png"/>
</Property>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
......@@ -238,7 +238,7 @@
<Component class="javax.swing.JLabel" name="mineral">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/honey.png"/>
<Image iconType="3" name="/img/mineral.png"/>
</Property>
<Property name="text" type="java.lang.String" value="jLabel1"/>
</Properties>
......@@ -365,11 +365,17 @@
</Component>
<Component class="javax.swing.JLabel" name="incense">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/incense.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Incense"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="gems">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/gems.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Gems"/>
</Properties>
</Component>
......@@ -385,17 +391,26 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="level4Label" min="-2" pref="58" max="-2" attributes="0"/>
<EmptySpace pref="137" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="philosopherStoneLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="PilospherCount" min="-2" pref="10" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="level4Label" min="-2" pref="58" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel3" min="-2" pref="123" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="philosopherStoneLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="PilospherCount" min="-2" pref="10" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
......@@ -403,7 +418,9 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="level4Label" min="-2" pref="23" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="130" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" pref="126" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="philosopherStoneLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="PilospherCount" alignment="3" min="-2" max="-2" attributes="0"/>
......@@ -429,6 +446,13 @@
<Property name="text" type="java.lang.String" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/stone.png"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="level3Panel">
......@@ -516,11 +540,17 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/life.png"/>
</Property>
<Property name="text" type="java.lang.String" value="life elixir"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/img/mana.png"/>
</Property>
<Property name="text" type="java.lang.String" value="life elixir"/>
</Properties>
</Component>
......
......@@ -59,6 +59,7 @@ public class InventoryPanel extends javax.swing.JPanel {
level4Label = new javax.swing.JLabel();
philosopherStoneLabel = new javax.swing.JLabel();
PilospherCount = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
level3Panel = new javax.swing.JPanel();
level3Label = new javax.swing.JLabel();
lifeElixirLabel = new javax.swing.JLabel();
......@@ -95,13 +96,13 @@ public class InventoryPanel extends javax.swing.JPanel {
honey.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/honey.png"))); // NOI18N
honey.setText("jLabel1");
herbs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/honey.png"))); // NOI18N
herbs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/herbs.png"))); // NOI18N
herbs.setText("jLabel1");
clay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/honey.png"))); // NOI18N
clay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/clay.png"))); // NOI18N
clay.setText("jLabel1");
mineral.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/honey.png"))); // NOI18N
mineral.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/mineral.png"))); // NOI18N
mineral.setText("jLabel1");
javax.swing.GroupLayout level1PanelLayout = new javax.swing.GroupLayout(level1Panel);
......@@ -192,8 +193,10 @@ public class InventoryPanel extends javax.swing.JPanel {
potion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/potion.png"))); // NOI18N
potion.setText("jLabel1");
incense.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/incense.png"))); // NOI18N
incense.setText("Incense");
gems.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/gems.png"))); // NOI18N
gems.setText("Gems");
javax.swing.GroupLayout level2PanelLayout = new javax.swing.GroupLayout(level2Panel);
......@@ -257,26 +260,35 @@ public class InventoryPanel extends javax.swing.JPanel {
PilospherCount.setText("0");
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/stone.png"))); // NOI18N
javax.swing.GroupLayout level4PanelLayout = new javax.swing.GroupLayout(level4Panel);
level4Panel.setLayout(level4PanelLayout);
level4PanelLayout.setHorizontalGroup(
level4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(level4PanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(level4Label, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(137, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, level4PanelLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(philosopherStoneLabel)
.addGap(18, 18, 18)
.addComponent(PilospherCount, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42))
.addGroup(level4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(level4PanelLayout.createSequentialGroup()
.addComponent(level4Label, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, level4PanelLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(level4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(level4PanelLayout.createSequentialGroup()
.addComponent(philosopherStoneLabel)
.addGap(18, 18, 18)
.addComponent(PilospherCount, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(42, 42, 42))))
);
level4PanelLayout.setVerticalGroup(
level4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(level4PanelLayout.createSequentialGroup()
.addComponent(level4Label, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(130, 130, 130)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(level4PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(philosopherStoneLabel)
.addComponent(PilospherCount))
......@@ -295,8 +307,10 @@ public class InventoryPanel extends javax.swing.JPanel {
ManaCrystalCount.setText("0");
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/life.png"))); // NOI18N
jLabel1.setText("life elixir");
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/mana.png"))); // NOI18N
jLabel2.setText("life elixir");
javax.swing.GroupLayout level3PanelLayout = new javax.swing.GroupLayout(level3Panel);
......@@ -358,8 +372,8 @@ public class InventoryPanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(level2Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(level4Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(level4Panel, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(backButton)))
.addGap(36, 36, 36))
......@@ -384,7 +398,7 @@ public class InventoryPanel extends javax.swing.JPanel {
}// </editor-fold>//GEN-END:initComponents
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed
gq.retHome();
gq.retBack();
}//GEN-LAST:event_backButtonActionPerformed
......@@ -412,6 +426,7 @@ public class InventoryPanel extends javax.swing.JPanel {
private javax.swing.JLabel incense;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel level1Label;
private javax.swing.JPanel level1Panel;
private javax.swing.JLabel level2Label;
......
......@@ -149,6 +149,9 @@
<Properties>
<Property name="text" type="java.lang.String" value="Register"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
......
......@@ -8,7 +8,6 @@ package GUI;
import Request.Request;
import grandquest.GrandQuest;
import java.util.Arrays;
import javax.swing.JOptionPane;
/**
......@@ -17,10 +16,17 @@ import javax.swing.JOptionPane;
*/
public class LoginPanel extends javax.swing.JPanel {
GrandQuest gq;
/**
* Creates new form LoginPanel
*/
public LoginPanel() {
// GrandQuest.host = "192.168.43.249";
// GrandQuest.port = 6789;
// GrandQuest.host = "localhost";
// GrandQuest.port = 8080;
GrandQuest.host = "167.205.32.46";
GrandQuest.port = 8025;
gq = new GrandQuest();
initComponents();
}
......@@ -73,6 +79,11 @@ public class LoginPanel extends javax.swing.JPanel {
});
jButton1.setText("Register");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Not a member?");
......@@ -154,20 +165,46 @@ public class LoginPanel extends javax.swing.JPanel {
}//GEN-LAST:event_usernameFormActionPerformed
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButtonActionPerformed
if(Request.connectToServer()){
String sentence = Request.loginJSON(usernameForm.getText(), String.valueOf(passwordForm.getPassword())).toString();
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.loginJSON("abcdef", "abcdef").toString();
Request.responseHandler(Request.send(sentence));
System.out.println(String.valueOf(passwordForm.getPassword()));
}
String res = Request.findInResponses("status");
if (res.equals("ok")){
JOptionPane.showMessageDialog(null, "Login Succes! Welcome...", "Information", JOptionPane.PLAIN_MESSAGE);
gq.retHome();
} else{
JOptionPane.showMessageDialog(null, "Login Failed! \n"+Request.findInResponses("description"), "Information", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, "Can't Connect to the Server!", "Information", JOptionPane.ERROR_MESSAGE);
}
if (Request.serverResponse!=null){
String res = Request.findInResponses("status");
if (res.equals("ok")){
JOptionPane.showMessageDialog(null, "Login Succes! Welcome...", "Information", JOptionPane.PLAIN_MESSAGE);
GrandQuest.token = Request.findInResponses("token");
gq.retHome();
} else{
JOptionPane.showMessageDialog(null, "Login Failed! \n"+Request.findInResponses("description"), "Information", JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_loginButtonActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.signUp(usernameForm.getText(),String.valueOf(passwordForm.getPassword())).toString();
Request.responseHandler(Request.send(sentence));
}
if (Request.serverResponse!=null){
String res = Request.findInResponses("status");
switch(res){
case "ok" :
JOptionPane.showMessageDialog(null, "Congratulations! New Account created","Information",JOptionPane.PLAIN_MESSAGE);
break;
case "fail" :
JOptionPane.showMessageDialog(null, "Move Failed! \n"+Request.findInResponses("description"), "Information", JOptionPane.ERROR_MESSAGE);
break;
default :
JOptionPane.showMessageDialog(null, "Error!", "Error", JOptionPane.ERROR_MESSAGE);
break;
}
}
}//GEN-LAST:event_jButton1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel ipLabel;
......
......@@ -38,16 +38,22 @@
<EmptySpace min="-2" pref="47" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="Position" min="-2" max="-2" attributes="0"/>
<Component id="Position1" min="-2" max="-2" attributes="0"/>
<Component id="Time" min="-2" max="-2" attributes="0"/>
<Component id="MapName" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jButton5" alignment="1" min="-2" pref="96" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel4" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="Position2" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="Status" min="-2" max="-2" attributes="0"/>
<Component id="Current" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jButton5" alignment="1" min="-2" pref="96" max="-2" attributes="0"/>
</Group>
<Component id="jButton2" alignment="1" min="-2" pref="96" max="-2" attributes="0"/>
</Group>
......@@ -62,7 +68,7 @@
</Group>
</Group>
</Group>
<EmptySpace pref="65" max="32767" attributes="0"/>
<EmptySpace pref="54" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
......@@ -84,14 +90,19 @@
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="Position1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="Time" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="Position2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="Current" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="Status" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="58" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
......@@ -200,9 +211,9 @@
<Property name="text" type="java.lang.String" value="Time:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="Position1">
<Component class="javax.swing.JLabel" name="Time">
<Properties>
<Property name="text" type="java.lang.String" value="Time"/>
<Property name="text" type="java.lang.String" value="0/0/0 00:00:00"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
......@@ -213,7 +224,7 @@
<Property name="text" type="java.lang.String" value="Current Time:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="Position2">
<Component class="javax.swing.JLabel" name="Current">
<Properties>
<Property name="text" type="java.lang.String" value="Current Time"/>
</Properties>
......@@ -266,5 +277,18 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton6ActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Status:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="Status">
<Properties>
<Property name="text" type="java.lang.String" value="Status"/>
</Properties>
</Component>
</SubComponents>
</Form>
......@@ -6,17 +6,25 @@
package GUI;
import Request.Request;
import grandquest.GrandQuest;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.Timer;
import javax.swing.table.DefaultTableCellRenderer;
/**
......@@ -25,34 +33,63 @@ import javax.swing.table.DefaultTableCellRenderer;
*/
public class MapPanel extends javax.swing.JPanel {
GrandQuest gq = new GrandQuest();
int nHeight;
int nWidth;
static int nHeight;
static int nWidth;
static long counter;
int posX, posY;
static int posX, posY;
static int desiredX, desiredY;
static long moveTime;
static int countStatus;
/**
* Creates new form MapPanel
* @throws java.lang.InterruptedException
*/
public MapPanel() throws InterruptedException {
nHeight = 10;
nWidth = 10;
posX = 0; posY = 0;
initComponents();
initPosition();
mapListener();
public MapPanel() {
System.out.println("sadfka");
countStatus = 0;
posX = Integer.valueOf(Request.findInResponses("x"));
posY = Integer.valueOf(Request.findInResponses("y"));
counter = System.currentTimeMillis();
moveTime = Long.valueOf(Request.findInResponses("time"))*1000;
if(Request.connectToServer(GrandQuest.host,GrandQuest.port)){
String sentence = Request.map(GrandQuest.token).toString();
Request.responseHandler(Request.send(sentence));
}
String res = Request.findInResponses("status");
if (res.equals("ok")){
nHeight = Integer.valueOf(Request.findInResponses("height"));
nWidth = Integer.valueOf(Request.findInResponses("width"));
initComponents();
MapName.setText(Request.findInResponses("name"));
initPosition(moveTime);
mapListener();
incrementTime();
} else{
gq.retLogIn();
}
}
/**
* Assign ImageCellRenderer to each cell
* @param time
*/
public void initPosition(){
public void initPosition(long time){
for (int i = 0; i < nWidth; i++) {
map.getColumn(String.valueOf(i)).setCellRenderer(new ImageCellRenderer());
}
map.setRowHeight(400/nHeight);
setPosition(posX, posY);
Time.setText(epochToTime(time));
ImageIcon ii = new ImageIcon(getClass().getResource("/img/avatar2.gif"));
Image img = ii.getImage();
map.setValueAt(getScaledImage(img, 400/nWidth, 400/nHeight), posX, posY);
Position.setText(posX + "," + posY);
}