Java Code Examples for net.fs.utils.Tools

The following examples show how to use net.fs.utils.Tools. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: NSS   Source File: ClientUI.java    License: Apache License 2.0 5 votes vote down vote up
void setSpeed(int downloadSpeed, int uploadSpeed) {
    config.setDownloadSpeed(downloadSpeed);
    config.setUploadSpeed(uploadSpeed);
    int s1 = (int) ((float) downloadSpeed * 1.1f);
    text_ds.setText(" " + Tools.getSizeStringKB(s1) + "/s ");
    int s2 = (int) ((float) uploadSpeed * 1.1f);
    text_us.setText(" " + Tools.getSizeStringKB(s2) + "/s ");
    Route.localDownloadSpeed = downloadSpeed;
    Route.localUploadSpeed = config.uploadSpeed;

    saveConfig();
}
 
Example 2
Source Project: NSS   Source File: ClientUI.java    License: Apache License 2.0 5 votes vote down vote up
public void updateUISpeed(int conn, int downloadSpeed, int uploadSpeed) {
    String string =
            " 下载:" + Tools.getSizeStringKB(downloadSpeed) + "/s"
                    + " 上传:" + Tools.getSizeStringKB(uploadSpeed) + "/s";
    if (downloadSpeedField != null) {
        downloadSpeedField.setText(string);
    }
}
 
Example 3
Source Project: finalspeed-91yun   Source File: ClientUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
void setSpeed(int downloadSpeed, int uploadSpeed) {
    config.setDownloadSpeed(downloadSpeed);
    config.setUploadSpeed(uploadSpeed);
    int s1 = (int) ((float) downloadSpeed * 1.1f);
    text_ds.setText(" " + Tools.getSizeStringKB(s1) + "/s ");
    int s2 = (int) ((float) uploadSpeed * 1.1f);
    text_us.setText(" " + Tools.getSizeStringKB(s2) + "/s ");
    Route.localDownloadSpeed = downloadSpeed;
    Route.localUploadSpeed = config.uploadSpeed;

    saveConfig();
}
 
Example 4
Source Project: finalspeed-91yun   Source File: ClientUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void updateUISpeed(int conn, int downloadSpeed, int uploadSpeed) {
    String string =
            " 下载:" + Tools.getSizeStringKB(downloadSpeed) + "/s"
                    + " 上传:" + Tools.getSizeStringKB(uploadSpeed) + "/s";
    if (downloadSpeedField != null) {
        downloadSpeedField.setText(string);
    }
}
 
Example 5
Source Project: finalspeed-91yun   Source File: ClientUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void checkUpdate() {
    for (int i = 0; i < 3; i++) {
        checkingUpdate = true;
        try {
            Properties propServer = new Properties();
            HttpURLConnection uc = Tools.getConnection(updateUrl);
            uc.setUseCaches(false);
            InputStream in = uc.getInputStream();
            propServer.load(in);
            serverVersion = Integer.parseInt(propServer.getProperty("version"));
            break;
        } catch (Exception e) {
            e.printStackTrace();
            try {
                Thread.sleep(3 * 1000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        } finally {
            checkingUpdate = false;
        }
    }
    if (this.haveNewVersion()) {
        int option = JOptionPane.showConfirmDialog(mainFrame, "发现新版本,立即更新吗?", "提醒", JOptionPane.WARNING_MESSAGE);
        if (option == JOptionPane.YES_OPTION) {
            openUrl(homeUrl);
        }
    }

}
 
Example 6
Source Project: finalspeed   Source File: ClientUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
void setSpeed(int downloadSpeed, int uploadSpeed) {
    config.setDownloadSpeed(downloadSpeed);
    config.setUploadSpeed(uploadSpeed);
    int s1 = (int) ((float) downloadSpeed * 1.1f);
    text_ds.setText(" " + Tools.getSizeStringKB(s1) + "/s ");
    int s2 = (int) ((float) uploadSpeed * 1.1f);
    text_us.setText(" " + Tools.getSizeStringKB(s2) + "/s ");
    Route.localDownloadSpeed = downloadSpeed;
    Route.localUploadSpeed = config.uploadSpeed;

    saveConfig();
}
 
Example 7
Source Project: finalspeed   Source File: ClientUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void updateUISpeed(int conn, int downloadSpeed, int uploadSpeed) {
    String string =
            " 下载:" + Tools.getSizeStringKB(downloadSpeed) + "/s"
                    + " 上传:" + Tools.getSizeStringKB(uploadSpeed) + "/s";
    if (downloadSpeedField != null) {
        downloadSpeedField.setText(string);
    }
}
 
Example 8
Source Project: finalspeed   Source File: ClientUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void checkUpdate() {
    for (int i = 0; i < 3; i++) {
        checkingUpdate = true;
        try {
            Properties propServer = new Properties();
            HttpURLConnection uc = Tools.getConnection(updateUrl);
            uc.setUseCaches(false);
            InputStream in = uc.getInputStream();
            propServer.load(in);
            serverVersion = Integer.parseInt(propServer.getProperty("version"));
            break;
        } catch (Exception e) {
            e.printStackTrace();
            try {
                Thread.sleep(3 * 1000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        } finally {
            checkingUpdate = false;
        }
    }
    if (this.haveNewVersion()) {
        int option = JOptionPane.showConfirmDialog(mainFrame, "发现新版本,立即更新吗?", "提醒", JOptionPane
                .YES_NO_CANCEL_OPTION);
        if (option == JOptionPane.YES_OPTION) {
            openUrl(homeUrl);
        }
    }

}