Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
add radionButton so user can choose Choose whether to sleep simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Waldenth committed May 16, 2021
1 parent 7556a9e commit 0983349
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 32 deletions.
Binary file not shown.
92 changes: 67 additions & 25 deletions IDEA-Project/FuckHamSports/src/main/java/org/fuckham/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ private void initComponents() {
coordinatesTip = new JLabel();
longitudeField = new JTextField();
latitudeField = new JTextField();
needSleepTips = new JLabel();
yesButton = new JRadioButton();
noButton = new JRadioButton();

//======== this ========
setTitle("FuckHam");
Expand Down Expand Up @@ -119,6 +122,22 @@ private void initComponents() {
latitudeField.setBackground(Color.white);
latitudeField.setText("30.534736");

//---- needSleepTips ----
needSleepTips.setText("\u6a21\u62df\u4f11\u7720");
needSleepTips.setForeground(Color.white);
needSleepTips.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));

//---- yesButton ----
yesButton.setText("\u662f");
yesButton.setBackground(new Color(102, 102, 102));
yesButton.setForeground(Color.white);

//---- noButton ----
noButton.setText("\u5426");
noButton.setBackground(new Color(102, 102, 102));
noButton.setForeground(Color.white);
noButton.setSelected(true);

GroupLayout panel1Layout = new GroupLayout(panel1);
panel1.setLayout(panel1Layout);
panel1Layout.setHorizontalGroup(
Expand All @@ -131,26 +150,33 @@ private void initComponents() {
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(panel1Layout.createSequentialGroup()
.addGap(56, 56, 56)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.addGroup(panel1Layout.createParallelGroup()
.addGroup(panel1Layout.createSequentialGroup()
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.addComponent(imeiCodeTip, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)
.addComponent(imeiCodeFileld, GroupLayout.PREFERRED_SIZE, 228, GroupLayout.PREFERRED_SIZE)
.addComponent(versionComboBox, GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE)
.addComponent(versionTip, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panel1Layout.createParallelGroup()
.addComponent(timeField, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)
.addComponent(stepTip, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)
.addComponent(stepField, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)
.addComponent(timeTip, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)))
.addGroup(panel1Layout.createSequentialGroup()
.addComponent(coordinatesTip, GroupLayout.PREFERRED_SIZE, 83, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(longitudeField, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(latitudeField, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(needSleepTips)
.addGap(18, 18, 18)
.addComponent(longitudeField, GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
.addComponent(imeiCodeTip, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)
.addComponent(imeiCodeFileld, GroupLayout.PREFERRED_SIZE, 228, GroupLayout.PREFERRED_SIZE)
.addComponent(versionComboBox)
.addComponent(versionTip, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(panel1Layout.createParallelGroup()
.addComponent(timeField, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)
.addComponent(stepTip, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)
.addComponent(stepField, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)
.addComponent(timeTip, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE))
.addGroup(panel1Layout.createSequentialGroup()
.addComponent(latitudeField, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)))))
.addGap(44, 44, 44))
.addComponent(yesButton, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(noButton, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
.addGap(0, 13, Short.MAX_VALUE)))))
.addGap(29, 29, 29))
.addGroup(panel1Layout.createSequentialGroup()
.addGap(249, 249, 249)
.addComponent(startButton, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
Expand Down Expand Up @@ -179,14 +205,17 @@ private void initComponents() {
.addGap(18, 18, 18)
.addGroup(panel1Layout.createParallelGroup()
.addComponent(versionComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(stepField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(coordinatesTip, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(longitudeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(latitudeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addComponent(stepField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addComponent(timeTip, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
.addGap(23, 23, 23)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(coordinatesTip, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(longitudeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(latitudeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(needSleepTips, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
.addComponent(yesButton)
.addComponent(noButton))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
.addComponent(startButton, GroupLayout.PREFERRED_SIZE, 39, GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30))
);
Expand All @@ -204,6 +233,11 @@ private void initComponents() {
);
pack();
setLocationRelativeTo(getOwner());

//---- sleepButtonGroup ----
var sleepButtonGroup = new ButtonGroup();
sleepButtonGroup.add(yesButton);
sleepButtonGroup.add(noButton);
// JFormDesigner - End of component initialization //GEN-END:initComponents


Expand Down Expand Up @@ -231,9 +265,14 @@ public void actionPerformed(ActionEvent e) {
if(imeiCode.length()!=32){
JOptionPane.showMessageDialog(null, "IMEI码长度应为32", "错误",JOptionPane.ERROR_MESSAGE);
}else {
boolean needSleep=true;
if(noButton.isSelected()){
JOptionPane.showMessageDialog(null, "你选择了不进行休眠模拟\n这样可能导致服务器端请求时间异常.", "警告",JOptionPane.WARNING_MESSAGE);
needSleep=false;
}
MainFrame.this.setEnabled(false);
MainFrame thisMainFrame=MainFrame.this;
WorkingFrame workingFrame = new WorkingFrame(thisMainFrame,imeiCode, version, time, step,longtitude,latitude);
WorkingFrame workingFrame = new WorkingFrame(thisMainFrame,imeiCode, version, time, step,longtitude,latitude,needSleep);
workingFrame.setVisible(true);
}
}
Expand All @@ -257,6 +296,9 @@ public void actionPerformed(ActionEvent e) {
private JLabel coordinatesTip;
private JTextField longitudeField;
private JTextField latitudeField;
private JLabel needSleepTips;
private JRadioButton yesButton;
private JRadioButton noButton;
// JFormDesigner - End of variables declaration //GEN-END:variables

}
30 changes: 28 additions & 2 deletions IDEA-Project/FuckHamSports/src/main/java/org/fuckham/MainFrame.jfd
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ new FormModel {
"defaultCloseOperation": 3
"iconImage": new com.jformdesigner.model.SwingIcon( 0, "/ico.jpg" )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class org.jdesktop.layout.GroupLayout ) {
"$horizontalGroup": "par l {seq {par l {seq l {space :p:214:p, comp titleLabel:::p:138:p, space :0:0:x}, seq l {space :p:56:p, par l:::p {seq l {comp coordinatesTip:::p:83:p, space s:::p, comp longitudeField::::146:x}, comp imeiCodeTip::l:p:139:p, comp imeiCodeFileld:::p:228:p, comp versionComboBox::l:::x, comp versionTip::l:::x}, space ::60:x, par t {par l:t {comp timeField:::p:129:p, comp stepTip:::p:139:p, comp stepField::l:p:129:p, comp timeTip::l:p:139:p}, seq t {comp latitudeField:::p:146:p, space :p:10:p}}}}, space :p:44:p}, seq l {space :p:249:p, comp startButton:::p:88:p, space :::x}}"
"$verticalGroup": "par l {seq l {space :p:24:p, comp titleLabel:::p:77:p, space s:::p, par l {seq {comp imeiCodeTip:::p:25:p, space u:::p, par b {comp imeiCodeFileld::b:p::p, comp timeField::b:p::p}, par l {seq {space s:::p, comp versionTip:::p:25:p}, seq l {space :p:26:p, comp stepTip:::p:25:p}}, space s:::p, par l {comp versionComboBox:::p::p, comp stepField:::p::p}, space :p:23:p, par b {comp coordinatesTip::b:p:25:p, comp longitudeField::b:p::p, comp latitudeField::b:p::p}}, comp timeTip::l:p:25:p}, space ::24:x, comp startButton:::p:39:p, space :p:30:p}}"
"$horizontalGroup": "par l {seq {par l {seq l {space :p:214:p, comp titleLabel:::p:138:p, space :0:0:x}, seq l {space :p:56:p, par l {seq l {par l:::p {comp imeiCodeTip::l:p:139:p, comp imeiCodeFileld:::p:228:p, comp versionComboBox::l::247:x, comp versionTip::l:::x}, space :::x, par l {comp timeField:::p:129:p, comp stepTip:::p:139:p, comp stepField::l:p:129:p, comp timeTip::l:p:139:p}}, seq l {comp coordinatesTip:::p:83:p, space :::p, comp longitudeField:::p:110:p, space :::p, comp latitudeField:::p:110:p, space :::p, comp needSleepTips:::p::p, space s:::p, comp yesButton:::p:43:p, space :::p, comp noButton:::p:43:p, space :0:13:x}}}}, space :p:29:p}, seq l {space :p:249:p, comp startButton:::p:88:p, space :::x}}"
"$verticalGroup": "par l {seq l {space :p:24:p, comp titleLabel:::p:77:p, space s:::p, par l {seq l {comp imeiCodeTip:::p:25:p, space u:::p, par b {comp imeiCodeFileld::b:p::p, comp timeField::b:p::p}, par l {seq {space s:::p, comp versionTip:::p:25:p}, seq l {space :p:26:p, comp stepTip:::p:25:p}}, space s:::p, par l {comp versionComboBox:::p::p, comp stepField:::p::p}}, comp timeTip::l:p:25:p}, space :p:23:p, par b {comp coordinatesTip::b:p:25:p, comp longitudeField::b:p::p, comp latitudeField::b:p::p, comp needSleepTips::b:p:25:p, comp yesButton::b:p::p, comp noButton::b:p::p}, space ::40:x, comp startButton:::p:39:p, space :p:30:p}}"
} ) {
name: "panel1"
"background": new java.awt.Color( 102, 102, 102, 255 )
Expand Down Expand Up @@ -105,10 +105,36 @@ new FormModel {
"background": sfield java.awt.Color white
"text": "30.534736"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "needSleepTips"
"text": "模拟休眠"
"foreground": #Color0
"font": #Font0
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "yesButton"
"text": "是"
"background": new java.awt.Color( 102, 102, 102, 255 )
"foreground": new java.awt.Color( 255, 255, 255, 255 )
"$buttonGroup": new FormReference( "sleepButtonGroup" )
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "noButton"
"text": "否"
"background": new java.awt.Color( 102, 102, 102, 255 )
"foreground": new java.awt.Color( 255, 255, 255, 255 )
"$buttonGroup": new FormReference( "sleepButtonGroup" )
"selected": true
} )
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 595, 485 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "sleepButtonGroup"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 5, 500 )
} )
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
* @author dasd
*/
public class WorkingFrame extends JFrame {
public WorkingFrame(MainFrame mainFrame,String imeiCode,String version,String seconds,String steps,String longitude,String latitude) {
public WorkingFrame(MainFrame mainFrame,String imeiCode,String version,String seconds,String steps,String longitude,String latitude,boolean needSleep) {
this.imeiCode=imeiCode;
this.version=version;
this.seconds=Integer.parseInt(seconds);
this.steps=Integer.parseInt(steps);
this.longtitude=longitude;
this.latitude=latitude;
this.needSleep=needSleep;
//this.returnFrame=mainFrame;
initComponents();
this.addWindowListener(new WindowAdapter() {
Expand Down Expand Up @@ -208,6 +209,7 @@ public void actionPerformed(ActionEvent e) {
private final String latitude;
private final int seconds;
private final int steps;
private final boolean needSleep;
private boolean completed=false;

public static String lastErrorResponse="";
Expand Down Expand Up @@ -242,20 +244,32 @@ public StringBuilder doInBackground() throws IOException,InterruptedException {
logText.append("\n");

logText.append(("// 请求跑步信息:\n"));
if(!needSleep){
logText.append("不进行延时模拟\n");
progressBar.setMinimum(0);
progressBar.setMaximum(2);
}else{
progressBar.setMinimum(0);
progressBar.setMaximum(Integer.parseInt(RunFuck.RunTime));
}
logText.append(RunFuck.getRunInfo(seconds,steps,longtitude,latitude));
logText.append("\n");

progressBar.setMinimum(0);
progressBar.setMaximum(Integer.parseInt(RunFuck.RunTime));
progressBar.setStringPainted(true);

logText.append("// 开始延时模拟,时间为:").append(Integer.parseInt(RunFuck.RunTime)).append("s ;步数为:").append(Integer.parseInt(RunFuck.RunStep)).append("\n");

if(needSleep) {
logText.append("// 开始延时模拟,时间为:").append(Integer.parseInt(RunFuck.RunTime)).append("s ;步数为:").append(Integer.parseInt(RunFuck.RunStep)).append("\n");
}else{
logText.append("// 不进行延时模拟,设置跑步时间为:").append(Integer.parseInt(RunFuck.RunTime)).append("s ;步数为:").append(Integer.parseInt(RunFuck.RunStep)).append("\n");
}
curProgressData.curSecond=0;
curProgressData.log=logText.toString();
publish(curProgressData);

for(int i = 1; i<Integer.parseInt(RunFuck.RunTime); i++){
int waitTime=needSleep?Integer.parseInt(RunFuck.RunTime):2;

for(int i = 1; i<waitTime; i++){
Thread.sleep(1000);
/* 备用
curProgressData=new ProgressData();
Expand Down

0 comments on commit 0983349

Please sign in to comment.