2016-10-04 06:33:25 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2015 Laurent CLOUET
|
|
|
|
|
* Author Laurent CLOUET <laurent.clouet@nopnop.net>
|
|
|
|
|
*
|
2020-05-28 13:28:42 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
2016-10-04 06:33:25 +02:00
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; version 2
|
|
|
|
|
* of the License.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
2016-10-12 00:34:51 +02:00
|
|
|
|
2015-01-15 23:20:17 +01:00
|
|
|
package com.sheepit.client.standalone.swing.activity;
|
|
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
import java.awt.Component;
|
|
|
|
|
import java.awt.Container;
|
2015-07-29 16:51:34 -06:00
|
|
|
import java.awt.GridBagConstraints;
|
2016-10-12 00:34:51 +02:00
|
|
|
import java.awt.GridBagLayout;
|
|
|
|
|
import java.awt.GridLayout;
|
2015-01-15 23:20:17 +01:00
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.awt.image.BufferedImage;
|
2020-04-14 17:32:22 +02:00
|
|
|
import java.awt.Image;
|
|
|
|
|
import java.io.File;
|
2016-10-12 00:34:51 +02:00
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.util.Date;
|
2015-01-15 23:20:17 +01:00
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
2016-10-12 00:34:51 +02:00
|
|
|
import javax.swing.BorderFactory;
|
2016-10-31 15:27:20 +01:00
|
|
|
import javax.swing.BoxLayout;
|
2015-01-15 23:20:17 +01:00
|
|
|
import javax.swing.ImageIcon;
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
|
import javax.swing.JLabel;
|
2020-04-27 22:28:04 +10:00
|
|
|
import javax.swing.JOptionPane;
|
2016-10-12 00:34:51 +02:00
|
|
|
import javax.swing.JPanel;
|
2020-04-14 23:24:28 +10:00
|
|
|
import javax.swing.UIManager;
|
2016-10-12 00:34:51 +02:00
|
|
|
import javax.swing.Spring;
|
|
|
|
|
import javax.swing.SpringLayout;
|
|
|
|
|
|
2015-01-15 23:20:17 +01:00
|
|
|
import com.sheepit.client.Client;
|
2016-08-01 00:47:29 +02:00
|
|
|
import com.sheepit.client.Job;
|
2020-05-16 18:56:57 +10:00
|
|
|
import com.sheepit.client.Log;
|
2016-10-12 00:34:51 +02:00
|
|
|
import com.sheepit.client.Stats;
|
2020-09-12 10:00:24 +10:00
|
|
|
import com.sheepit.client.TransferStats;
|
2016-10-12 00:34:51 +02:00
|
|
|
import com.sheepit.client.Utils;
|
2015-01-15 23:20:17 +01:00
|
|
|
import com.sheepit.client.standalone.GuiSwing;
|
|
|
|
|
import com.sheepit.client.standalone.GuiSwing.ActivityType;
|
|
|
|
|
|
2020-10-29 22:06:00 +11:00
|
|
|
import com.sheepit.client.standalone.swing.components.CollapsibleJPanel;
|
|
|
|
|
|
2015-01-15 23:20:17 +01:00
|
|
|
public class Working implements Activity {
|
2017-05-07 20:55:17 +02:00
|
|
|
private GuiSwing parent;
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2020-10-29 22:06:00 +11:00
|
|
|
private CollapsibleJPanel session_info_panel;
|
|
|
|
|
private CollapsibleJPanel global_stats_panel;
|
|
|
|
|
private CollapsibleJPanel last_frame_panel;
|
2017-05-07 20:55:17 +02:00
|
|
|
private JLabel statusContent;
|
2020-04-26 23:35:05 +10:00
|
|
|
private String previousStatus;
|
2017-05-07 20:55:17 +02:00
|
|
|
private JLabel renderedFrameContent;
|
|
|
|
|
private JLabel remainingFrameContent;
|
|
|
|
|
private JLabel lastRenderTime;
|
|
|
|
|
private JLabel lastRender;
|
|
|
|
|
private JLabel creditEarned;
|
|
|
|
|
private JButton pauseButton;
|
|
|
|
|
private JButton exitAfterFrame;
|
|
|
|
|
private JLabel current_project_name_value;
|
|
|
|
|
private JLabel current_project_duration_value;
|
|
|
|
|
private JLabel currrent_project_progression_value;
|
2017-05-07 21:00:20 +02:00
|
|
|
private JLabel current_project_compute_method_value;
|
2017-05-07 20:55:17 +02:00
|
|
|
private JLabel user_info_points_total_value;
|
2019-02-10 13:17:39 +01:00
|
|
|
private JLabel renderable_projects_value;
|
2017-05-07 20:55:17 +02:00
|
|
|
private JLabel waiting_projects_value;
|
|
|
|
|
private JLabel connected_machines_value;
|
|
|
|
|
private JLabel user_info_total_rendertime_this_session_value;
|
2020-04-20 01:01:43 +10:00
|
|
|
private JLabel userInfoQueuedUploadsAndSizeValue;
|
2020-09-12 10:00:24 +10:00
|
|
|
private JLabel sessionDownloadsStatsValue;
|
|
|
|
|
private JLabel sessionUploadsStatsValue;
|
2020-04-14 23:24:28 +10:00
|
|
|
private String currentTheme;
|
2020-05-16 18:56:57 +10:00
|
|
|
private Log log;
|
2015-01-15 23:20:17 +01:00
|
|
|
|
|
|
|
|
public Working(GuiSwing parent_) {
|
|
|
|
|
parent = parent_;
|
|
|
|
|
|
|
|
|
|
statusContent = new JLabel("Init");
|
2020-04-20 01:01:43 +10:00
|
|
|
renderedFrameContent = new JLabel("0");
|
2016-10-12 00:34:51 +02:00
|
|
|
remainingFrameContent = new JLabel("");
|
2015-03-02 18:05:39 +00:00
|
|
|
creditEarned = new JLabel("");
|
2016-10-12 00:34:51 +02:00
|
|
|
current_project_name_value = new JLabel("");
|
|
|
|
|
current_project_duration_value = new JLabel("");
|
|
|
|
|
currrent_project_progression_value = new JLabel("");
|
2017-05-07 21:00:20 +02:00
|
|
|
current_project_compute_method_value = new JLabel("");
|
2016-10-12 00:34:51 +02:00
|
|
|
user_info_points_total_value = new JLabel("");
|
2019-02-10 13:17:39 +01:00
|
|
|
renderable_projects_value = new JLabel("");
|
2016-10-12 00:34:51 +02:00
|
|
|
waiting_projects_value = new JLabel("");
|
|
|
|
|
connected_machines_value = new JLabel("");
|
|
|
|
|
user_info_total_rendertime_this_session_value = new JLabel("");
|
2020-10-29 22:06:00 +11:00
|
|
|
lastRenderTime = new JLabel(" "); // Insert a space to ensure the component reserves the space in the screen (for the window size calculation)
|
2016-10-12 00:34:51 +02:00
|
|
|
lastRender = new JLabel("");
|
2020-04-20 01:01:43 +10:00
|
|
|
userInfoQueuedUploadsAndSizeValue = new JLabel("0");
|
2020-09-12 10:00:24 +10:00
|
|
|
sessionDownloadsStatsValue = new JLabel("0KB");
|
|
|
|
|
sessionUploadsStatsValue = new JLabel("0KB");
|
2020-04-14 23:24:28 +10:00
|
|
|
currentTheme = UIManager.getLookAndFeel().getName(); // Capture the theme on component instantiation
|
2020-04-26 23:35:05 +10:00
|
|
|
previousStatus = "";
|
2020-05-16 18:56:57 +10:00
|
|
|
log = Log.getInstance(parent_.getConfiguration());
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|
|
|
|
|
|
2020-05-28 13:28:42 +02:00
|
|
|
@Override public void show() {
|
2020-04-14 23:24:28 +10:00
|
|
|
// If the stored theme and the UIManager's theme doesn't match is bc the user has changed it
|
|
|
|
|
if (!currentTheme.equals(UIManager.getLookAndFeel().getName())) {
|
|
|
|
|
// And, as the user has changed the theme, then we must recreate all the UI elements with session data
|
|
|
|
|
// Reason being they are defined as class variables and therefore created once when the object
|
|
|
|
|
// is created the first time.
|
|
|
|
|
// As the Java swing engine applies the "look & feel" at creation time, we need to "re-create" the
|
|
|
|
|
// objects to ensure they have the right theme colors.
|
|
|
|
|
statusContent = new JLabel(statusContent.getText());
|
|
|
|
|
renderedFrameContent = new JLabel(renderedFrameContent.getText());
|
|
|
|
|
remainingFrameContent = new JLabel(remainingFrameContent.getText());
|
|
|
|
|
creditEarned = new JLabel(creditEarned.getText());
|
|
|
|
|
current_project_name_value = new JLabel(current_project_name_value.getText());
|
|
|
|
|
current_project_duration_value = new JLabel(current_project_duration_value.getText());
|
|
|
|
|
currrent_project_progression_value = new JLabel(currrent_project_progression_value.getText());
|
|
|
|
|
current_project_compute_method_value = new JLabel(current_project_compute_method_value.getText());
|
|
|
|
|
user_info_points_total_value = new JLabel(user_info_points_total_value.getText());
|
|
|
|
|
renderable_projects_value = new JLabel(renderable_projects_value.getText());
|
|
|
|
|
waiting_projects_value = new JLabel(waiting_projects_value.getText());
|
|
|
|
|
connected_machines_value = new JLabel(connected_machines_value.getText());
|
|
|
|
|
user_info_total_rendertime_this_session_value = new JLabel(user_info_total_rendertime_this_session_value.getText());
|
|
|
|
|
lastRenderTime = new JLabel(lastRenderTime.getText());
|
|
|
|
|
lastRender = new JLabel(lastRender.getText());
|
2020-04-20 01:01:43 +10:00
|
|
|
userInfoQueuedUploadsAndSizeValue = new JLabel(userInfoQueuedUploadsAndSizeValue.getText());
|
2020-09-12 10:00:24 +10:00
|
|
|
sessionDownloadsStatsValue = new JLabel(sessionDownloadsStatsValue.getText());
|
|
|
|
|
sessionUploadsStatsValue = new JLabel(sessionUploadsStatsValue.getText());
|
2020-05-28 13:28:42 +02:00
|
|
|
|
2020-04-14 23:24:28 +10:00
|
|
|
// set the new theme as the current one
|
|
|
|
|
currentTheme = UIManager.getLookAndFeel().getName();
|
|
|
|
|
}
|
2020-05-28 13:28:42 +02:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
// current project
|
2020-10-29 22:06:00 +11:00
|
|
|
JPanel current_project_panel = new JPanel(new GridLayout(5, 2));
|
2016-10-12 00:34:51 +02:00
|
|
|
current_project_panel.setBorder(BorderFactory.createTitledBorder("Project"));
|
2015-07-29 16:51:34 -06:00
|
|
|
|
2017-02-18 14:31:43 +01:00
|
|
|
JLabel current_project_status = new JLabel("Status: ", JLabel.TRAILING);
|
|
|
|
|
JLabel current_project_name = new JLabel("Name: ", JLabel.TRAILING);
|
|
|
|
|
JLabel current_project_duration = new JLabel("Rendering for: ", JLabel.TRAILING);
|
|
|
|
|
JLabel current_project_progression = new JLabel("Remaining: ", JLabel.TRAILING);
|
2017-05-07 21:00:20 +02:00
|
|
|
JLabel current_project_compute_method_label = new JLabel("Compute method: ", JLabel.TRAILING);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
current_project_panel.add(current_project_status);
|
|
|
|
|
current_project_panel.add(statusContent);
|
2015-07-29 16:51:34 -06:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
current_project_panel.add(current_project_name);
|
|
|
|
|
current_project_panel.add(current_project_name_value);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
current_project_panel.add(current_project_duration);
|
|
|
|
|
current_project_panel.add(current_project_duration_value);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
current_project_panel.add(current_project_progression);
|
|
|
|
|
current_project_panel.add(currrent_project_progression_value);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2017-05-07 21:00:20 +02:00
|
|
|
current_project_panel.add(current_project_compute_method_label);
|
|
|
|
|
current_project_panel.add(current_project_compute_method_value);
|
|
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
// user info
|
2020-10-29 22:06:00 +11:00
|
|
|
session_info_panel = new CollapsibleJPanel(new GridLayout(7, 2), this);
|
2016-10-12 00:34:51 +02:00
|
|
|
session_info_panel.setBorder(BorderFactory.createTitledBorder("Session infos"));
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2017-02-18 14:31:43 +01:00
|
|
|
JLabel user_info_credits_this_session = new JLabel("Points earned: ", JLabel.TRAILING);
|
|
|
|
|
JLabel user_info_total_rendertime_this_session = new JLabel("Duration: ", JLabel.TRAILING);
|
2020-04-20 01:01:43 +10:00
|
|
|
JLabel user_info_pending_uploads_and_size = new JLabel("Queued uploads: ", JLabel.TRAILING);
|
2020-09-12 10:00:24 +10:00
|
|
|
JLabel session_download_stats = new JLabel("Total Downloads: ", JLabel.TRAILING);
|
|
|
|
|
JLabel session_upload_stats = new JLabel("Total Uploads: ", JLabel.TRAILING);
|
2017-02-18 14:31:43 +01:00
|
|
|
JLabel user_info_rendered_frame_this_session = new JLabel("Rendered frames: ", JLabel.TRAILING);
|
2019-02-10 13:17:39 +01:00
|
|
|
JLabel global_static_renderable_project = new JLabel("Renderable projects: ", JLabel.TRAILING);
|
2015-03-02 18:05:39 +00:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
session_info_panel.add(user_info_credits_this_session);
|
|
|
|
|
session_info_panel.add(creditEarned);
|
2015-03-02 18:05:39 +00:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
session_info_panel.add(user_info_rendered_frame_this_session);
|
|
|
|
|
session_info_panel.add(renderedFrameContent);
|
2015-03-02 18:05:39 +00:00
|
|
|
|
2020-04-20 01:01:43 +10:00
|
|
|
session_info_panel.add(user_info_pending_uploads_and_size);
|
|
|
|
|
session_info_panel.add(userInfoQueuedUploadsAndSizeValue);
|
|
|
|
|
|
2020-09-12 10:00:24 +10:00
|
|
|
session_info_panel.add(session_download_stats);
|
|
|
|
|
session_info_panel.add(sessionDownloadsStatsValue);
|
|
|
|
|
|
|
|
|
|
session_info_panel.add(session_upload_stats);
|
|
|
|
|
session_info_panel.add(sessionUploadsStatsValue);
|
|
|
|
|
|
2019-02-10 13:17:39 +01:00
|
|
|
session_info_panel.add(global_static_renderable_project);
|
|
|
|
|
session_info_panel.add(renderable_projects_value);
|
|
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
session_info_panel.add(user_info_total_rendertime_this_session);
|
|
|
|
|
session_info_panel.add(user_info_total_rendertime_this_session_value);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
// global stats
|
2020-10-29 22:06:00 +11:00
|
|
|
global_stats_panel = new CollapsibleJPanel(new GridLayout(4, 2), this);
|
2016-10-12 00:34:51 +02:00
|
|
|
global_stats_panel.setBorder(BorderFactory.createTitledBorder("Global stats"));
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2017-02-18 14:31:43 +01:00
|
|
|
JLabel global_stats_machine_connected = new JLabel("Machines connected: ", JLabel.TRAILING);
|
|
|
|
|
JLabel global_stats_remaining_frame = new JLabel("Remaining frames: ", JLabel.TRAILING);
|
2019-02-10 13:17:39 +01:00
|
|
|
JLabel global_stats_waiting_project = new JLabel("Active projects: ", JLabel.TRAILING);
|
2017-02-18 14:31:43 +01:00
|
|
|
JLabel global_stats_user_points = new JLabel("User's points: ", JLabel.TRAILING);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
global_stats_panel.add(global_stats_waiting_project);
|
|
|
|
|
global_stats_panel.add(waiting_projects_value);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
global_stats_panel.add(global_stats_machine_connected);
|
|
|
|
|
global_stats_panel.add(connected_machines_value);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
global_stats_panel.add(global_stats_remaining_frame);
|
|
|
|
|
global_stats_panel.add(remainingFrameContent);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
global_stats_panel.add(global_stats_user_points);
|
|
|
|
|
global_stats_panel.add(user_info_points_total_value);
|
2015-01-15 23:20:17 +01:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
// last frame
|
2020-10-29 22:06:00 +11:00
|
|
|
last_frame_panel = new CollapsibleJPanel(new GridLayout(2, 2), this);
|
2016-10-31 15:27:20 +01:00
|
|
|
last_frame_panel.setLayout(new BoxLayout(last_frame_panel, BoxLayout.Y_AXIS));
|
2020-04-20 01:01:43 +10:00
|
|
|
last_frame_panel.setBorder(BorderFactory.createTitledBorder("Last uploaded frame"));
|
2016-10-12 00:34:51 +02:00
|
|
|
lastRender.setIcon(new ImageIcon(new BufferedImage(200, 120, BufferedImage.TYPE_INT_ARGB)));
|
2016-10-31 15:27:20 +01:00
|
|
|
lastRender.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
|
|
|
lastRenderTime.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
|
|
|
last_frame_panel.add(lastRenderTime);
|
2016-10-12 00:34:51 +02:00
|
|
|
last_frame_panel.add(lastRender);
|
2015-07-29 16:51:34 -06:00
|
|
|
|
2022-03-14 11:29:28 +00:00
|
|
|
JLabel labelImage = GuiSwing.createLogoWithWatermark();
|
2016-10-12 00:34:51 +02:00
|
|
|
labelImage.setAlignmentX(Component.CENTER_ALIGNMENT);
|
2021-06-22 15:41:56 +02:00
|
|
|
parent.getContentPanel().add(labelImage);
|
2016-10-12 00:34:51 +02:00
|
|
|
|
|
|
|
|
JPanel buttonsPanel = new JPanel(new GridLayout(2, 2));
|
2015-01-15 23:20:17 +01:00
|
|
|
|
|
|
|
|
JButton settingsButton = new JButton("Settings");
|
|
|
|
|
settingsButton.addActionListener(new SettingsAction());
|
|
|
|
|
|
2020-04-26 23:35:05 +10:00
|
|
|
pauseButton = new JButton("Pause getting new jobs");
|
2017-01-29 21:03:38 +01:00
|
|
|
Client client = parent.getClient();
|
|
|
|
|
if (client != null && client.isSuspended()) {
|
2020-04-26 23:35:05 +10:00
|
|
|
pauseButton.setText("Resume getting jobs");
|
2017-01-29 21:03:38 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-15 23:20:17 +01:00
|
|
|
pauseButton.addActionListener(new PauseAction());
|
2015-07-29 16:51:34 -06:00
|
|
|
|
2015-10-27 21:00:44 +00:00
|
|
|
JButton blockJob = new JButton("Block this project");
|
|
|
|
|
blockJob.addActionListener(new blockJobAction());
|
|
|
|
|
|
2020-04-27 22:28:04 +10:00
|
|
|
exitAfterFrame = new JButton("Exit");
|
2015-08-05 19:58:11 +01:00
|
|
|
exitAfterFrame.addActionListener(new ExitAfterAction());
|
|
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
buttonsPanel.add(settingsButton);
|
|
|
|
|
buttonsPanel.add(pauseButton);
|
|
|
|
|
buttonsPanel.add(blockJob);
|
|
|
|
|
buttonsPanel.add(exitAfterFrame);
|
|
|
|
|
|
2021-06-22 15:41:56 +02:00
|
|
|
parent.getContentPanel().setLayout(new GridBagLayout());
|
2016-10-12 00:34:51 +02:00
|
|
|
GridBagConstraints global_constraints = new GridBagConstraints();
|
|
|
|
|
global_constraints.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
|
global_constraints.weightx = 1;
|
|
|
|
|
global_constraints.gridx = 0;
|
|
|
|
|
|
2021-06-22 15:41:56 +02:00
|
|
|
parent.getContentPanel().add(new JLabel(" "), global_constraints); // Add a separator between logo and first panel
|
|
|
|
|
parent.getContentPanel().add(current_project_panel, global_constraints);
|
|
|
|
|
parent.getContentPanel().add(global_stats_panel, global_constraints);
|
|
|
|
|
parent.getContentPanel().add(session_info_panel, global_constraints);
|
|
|
|
|
parent.getContentPanel().add(last_frame_panel, global_constraints);
|
|
|
|
|
parent.getContentPanel().add(new JLabel(" "), global_constraints); // Add a separator between last panel and buttons
|
|
|
|
|
parent.getContentPanel().add(buttonsPanel, global_constraints);
|
2016-10-12 00:34:51 +02:00
|
|
|
|
2020-06-09 14:47:39 +10:00
|
|
|
// Set the proper size for the Working (if coming from Settings screen, the window size will be too big for the content!)
|
2020-09-12 10:00:24 +10:00
|
|
|
parent.setSize(520, 820);
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|
|
|
|
|
|
2020-10-29 22:06:00 +11:00
|
|
|
public void resizeWindow() {
|
|
|
|
|
parent.revalidate();
|
|
|
|
|
parent.repaint();
|
|
|
|
|
|
|
|
|
|
// Calculate the proper size based on the status of the panels (opened/collapsed)
|
|
|
|
|
parent.setSize(520, (int) (session_info_panel.getHeight() + global_stats_panel.getHeight() + last_frame_panel.getHeight()) + 400);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-15 23:20:17 +01:00
|
|
|
public void setStatus(String msg_) {
|
2020-04-26 23:35:05 +10:00
|
|
|
setStatus(msg_, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStatus(String msg_, boolean overwriteSuspendedMsg) {
|
|
|
|
|
Client client = parent.getClient();
|
|
|
|
|
|
|
|
|
|
if (!msg_.equals("")) {
|
|
|
|
|
this.previousStatus = msg_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (client != null && client.isSuspended()) {
|
|
|
|
|
if (overwriteSuspendedMsg) {
|
|
|
|
|
statusContent.setText("<html>" + msg_ + "</html>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
statusContent.setText("<html>" + msg_ + "</html>");
|
|
|
|
|
}
|
2016-10-12 00:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRenderingProjectName(String msg_) {
|
|
|
|
|
current_project_name_value.setText("<html>" + (msg_.length() > 26 ? msg_.substring(0, 26) : msg_) + "</html>");
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|
|
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
public void setRemainingTime(String time_) {
|
|
|
|
|
currrent_project_progression_value.setText("<html>" + time_ + "</html>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRenderingTime(String time_) {
|
|
|
|
|
current_project_duration_value.setText("<html>" + time_ + "</html>");
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-07 21:00:20 +02:00
|
|
|
public void setComputeMethod(String computeMethod_) {
|
|
|
|
|
this.current_project_compute_method_value.setText(computeMethod_);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-12 10:00:24 +10:00
|
|
|
public void displayTransferStats(TransferStats downloads, TransferStats uploads) {
|
|
|
|
|
sessionDownloadsStatsValue.setText(String.format("%s @ %s/s", downloads.getSessionTraffic(), downloads.getAverageSessionSpeed()));
|
|
|
|
|
sessionUploadsStatsValue.setText(String.format("%s @ %s/s", uploads.getSessionTraffic(), uploads.getAverageSessionSpeed()));
|
|
|
|
|
updateTime();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
public void displayStats(Stats stats) {
|
|
|
|
|
DecimalFormat df = new DecimalFormat("##,##,##,##,##,##,##0");
|
|
|
|
|
remainingFrameContent.setText(df.format(stats.getRemainingFrame()));
|
|
|
|
|
creditEarned.setText(df.format(stats.getCreditsEarnedDuringSession()));
|
|
|
|
|
user_info_points_total_value.setText(df.format(stats.getCreditsEarned()));
|
2019-02-10 13:17:39 +01:00
|
|
|
renderable_projects_value.setText(df.format(stats.getRenderableProject()));
|
2016-10-12 00:34:51 +02:00
|
|
|
waiting_projects_value.setText(df.format(stats.getWaitingProject()));
|
|
|
|
|
connected_machines_value.setText(df.format(stats.getConnectedMachine()));
|
2020-04-20 01:01:43 +10:00
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
updateTime();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-20 01:01:43 +10:00
|
|
|
public void displayUploadQueueStats(int queueSize, long queueVolume) {
|
2020-05-28 13:28:42 +02:00
|
|
|
userInfoQueuedUploadsAndSizeValue.setText(
|
|
|
|
|
String.format("%d%s%s", queueSize, (queueSize > 0 ? String.format(" (%.2fMB) ", (queueVolume / 1024.0 / 1024.0)) : ""),
|
|
|
|
|
(queueSize == this.parent.getConfiguration().getMaxUploadingJob() ? "- Queue full!" : "")));
|
2020-04-27 22:28:04 +10:00
|
|
|
|
|
|
|
|
// If the user has requested to exit, then we need to update the JButton with the queue size
|
|
|
|
|
if (this.exitAfterFrame.getText().startsWith("Cancel")) {
|
|
|
|
|
Client client = parent.getClient();
|
|
|
|
|
|
|
|
|
|
if (client != null) {
|
|
|
|
|
if (client.isRunning()) {
|
|
|
|
|
queueSize++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-28 13:28:42 +02:00
|
|
|
exitAfterFrame.setText(String.format("Cancel exit (%s frame%s to go)", queueSize, (queueSize > 1 ? "s" : "")));
|
2020-04-27 22:28:04 +10:00
|
|
|
}
|
2020-04-20 01:01:43 +10:00
|
|
|
}
|
|
|
|
|
|
2020-09-12 10:00:24 +10:00
|
|
|
public synchronized void updateTime() {
|
2016-10-12 00:34:51 +02:00
|
|
|
if (this.parent.getClient().getStartTime() != 0) {
|
2020-05-28 13:28:42 +02:00
|
|
|
user_info_total_rendertime_this_session_value
|
|
|
|
|
.setText(Utils.humanDuration(new Date((new Date().getTime() - this.parent.getClient().getStartTime()))));
|
2016-10-12 00:34:51 +02:00
|
|
|
}
|
|
|
|
|
Job job = this.parent.getClient().getRenderingJob();
|
|
|
|
|
if (job != null && job.getProcessRender() != null && job.getProcessRender().getStartTime() > 0) {
|
2020-05-28 13:28:42 +02:00
|
|
|
current_project_duration_value
|
|
|
|
|
.setText("<html>" + Utils.humanDuration(new Date((new Date().getTime() - job.getProcessRender().getStartTime()))) + "</html>");
|
2016-10-12 00:34:51 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
current_project_duration_value.setText("");
|
|
|
|
|
}
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRenderedFrame(int n) {
|
|
|
|
|
renderedFrameContent.setText(String.valueOf(n));
|
|
|
|
|
showLastRender();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void showLastRender() {
|
|
|
|
|
Client client = parent.getClient();
|
|
|
|
|
if (client != null) {
|
2016-10-31 15:27:20 +01:00
|
|
|
Job lastJob = client.getPreviousJob();
|
2020-04-14 17:32:22 +02:00
|
|
|
if (lastJob != null) {
|
|
|
|
|
ImageIcon icon = null;
|
|
|
|
|
int idInt = Integer.parseInt(lastJob.getId());
|
|
|
|
|
if (idInt == 1) {
|
|
|
|
|
icon = new ImageIcon(getClass().getResource("/frame_compute_method.jpg"));
|
|
|
|
|
}
|
|
|
|
|
else if (idInt < 20) {
|
|
|
|
|
icon = new ImageIcon(getClass().getResource("/frame_power_detection.jpg"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-01-15 23:20:17 +01:00
|
|
|
try {
|
2020-04-14 17:32:22 +02:00
|
|
|
String path = lastJob.getOutputImagePath();
|
2020-05-28 13:28:42 +02:00
|
|
|
|
2020-04-14 17:32:22 +02:00
|
|
|
BufferedImage img = ImageIO.read(new File(path));
|
|
|
|
|
float width = img.getWidth();
|
|
|
|
|
float height = img.getHeight();
|
|
|
|
|
float factor = 1.0f;
|
|
|
|
|
if (height > 200) {
|
|
|
|
|
factor = 200f / height;
|
|
|
|
|
}
|
|
|
|
|
if (width * factor > 200) {
|
|
|
|
|
factor = Math.min(factor, 200f / width);
|
2016-09-11 13:33:34 +02:00
|
|
|
}
|
2020-04-26 23:35:05 +10:00
|
|
|
icon = new ImageIcon(img.getScaledInstance((int) (width * factor), (int) (height * factor), Image.SCALE_FAST));
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|
2020-10-29 21:01:24 +11:00
|
|
|
catch (Exception e) {
|
2020-05-16 18:56:57 +10:00
|
|
|
log.error(String.format("Working::showLastRender() Unable to load/preview rendered frame [%s]. Exception %s",
|
2020-10-29 21:01:24 +11:00
|
|
|
lastJob.getOutputImagePath(), e.getMessage()));
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-05-28 13:28:42 +02:00
|
|
|
|
2020-04-14 17:32:22 +02:00
|
|
|
if (icon != null) {
|
|
|
|
|
lastRender.setIcon(icon);
|
|
|
|
|
// don't use lastJob.getProcessRender().getDuration() due to timezone
|
|
|
|
|
if (lastJob.getProcessRender().getDuration() > 1) {
|
2020-05-28 13:28:42 +02:00
|
|
|
lastRenderTime.setText("Render time : " + Utils
|
|
|
|
|
.humanDuration(new Date(lastJob.getProcessRender().getEndTime() - lastJob.getProcessRender().getStartTime())));
|
2020-04-14 17:32:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-12 00:34:51 +02:00
|
|
|
private void alignPanel(Container parent, int rows, int cols, Spring width) {
|
|
|
|
|
SpringLayout layout;
|
|
|
|
|
try {
|
|
|
|
|
layout = (SpringLayout) parent.getLayout();
|
|
|
|
|
}
|
|
|
|
|
catch (ClassCastException exc) {
|
|
|
|
|
System.err.println("The first argument to makeCompactGrid must use SpringLayout.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Spring x = Spring.constant(0);
|
|
|
|
|
for (int c = 0; c < cols; c++) {
|
|
|
|
|
for (int r = 0; r < rows; r++) {
|
|
|
|
|
SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
|
|
|
|
|
constraints.setX(x);
|
|
|
|
|
constraints.setWidth(width);
|
|
|
|
|
}
|
|
|
|
|
x = Spring.sum(x, width);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Spring y = Spring.constant(0);
|
|
|
|
|
for (int r = 0; r < rows; r++) {
|
|
|
|
|
Spring height = Spring.constant(0);
|
|
|
|
|
for (int c = 0; c < cols; c++) {
|
|
|
|
|
height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());
|
|
|
|
|
}
|
|
|
|
|
for (int c = 0; c < cols; c++) {
|
|
|
|
|
SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);
|
|
|
|
|
constraints.setY(y);
|
|
|
|
|
constraints.setHeight(height);
|
2015-03-02 18:05:39 +00:00
|
|
|
}
|
2016-10-12 00:34:51 +02:00
|
|
|
y = Spring.sum(y, height);
|
2015-03-02 18:05:39 +00:00
|
|
|
}
|
2016-10-12 00:34:51 +02:00
|
|
|
|
|
|
|
|
SpringLayout.Constraints pCons = layout.getConstraints(parent);
|
|
|
|
|
pCons.setConstraint(SpringLayout.SOUTH, y);
|
|
|
|
|
pCons.setConstraint(SpringLayout.EAST, x);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Spring getBestWidth(Container parent, int rows, int cols) {
|
|
|
|
|
Spring x = Spring.constant(0);
|
|
|
|
|
Spring width = Spring.constant(0);
|
|
|
|
|
for (int c = 0; c < cols; c++) {
|
|
|
|
|
|
|
|
|
|
for (int r = 0; r < rows; r++) {
|
|
|
|
|
width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SpringLayout.Constraints getConstraintsForCell(int row, int col, Container parent, int cols) {
|
|
|
|
|
SpringLayout layout = (SpringLayout) parent.getLayout();
|
|
|
|
|
Component c = parent.getComponent(row * cols + col);
|
|
|
|
|
return layout.getConstraints(c);
|
2015-03-02 18:05:39 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-15 23:20:17 +01:00
|
|
|
class PauseAction implements ActionListener {
|
|
|
|
|
|
2020-05-28 13:28:42 +02:00
|
|
|
@Override public void actionPerformed(ActionEvent e) {
|
2015-01-15 23:20:17 +01:00
|
|
|
Client client = parent.getClient();
|
|
|
|
|
if (client != null) {
|
2015-01-17 22:40:24 +01:00
|
|
|
if (client.isSuspended()) {
|
2020-04-26 23:35:05 +10:00
|
|
|
pauseButton.setText("Pause getting new jobs");
|
2015-01-17 22:40:24 +01:00
|
|
|
client.resume();
|
2020-04-26 23:35:05 +10:00
|
|
|
setStatus(previousStatus);
|
2015-01-17 22:40:24 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2020-04-26 23:35:05 +10:00
|
|
|
pauseButton.setText("Resume getting jobs");
|
2015-01-17 22:40:24 +01:00
|
|
|
client.suspend();
|
2020-04-26 23:35:05 +10:00
|
|
|
setStatus("");
|
2015-01-17 22:40:24 +01:00
|
|
|
}
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SettingsAction implements ActionListener {
|
2020-05-28 13:28:42 +02:00
|
|
|
@Override public void actionPerformed(ActionEvent e) {
|
2015-01-15 23:20:17 +01:00
|
|
|
if (parent != null) {
|
|
|
|
|
parent.showActivity(ActivityType.SETTINGS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-05 19:58:11 +01:00
|
|
|
class ExitAfterAction implements ActionListener {
|
2020-05-28 13:28:42 +02:00
|
|
|
@Override public void actionPerformed(ActionEvent e) {
|
2015-08-05 19:58:11 +01:00
|
|
|
Client client = parent.getClient();
|
|
|
|
|
if (client != null) {
|
|
|
|
|
if (client.isRunning()) {
|
2020-05-28 13:28:42 +02:00
|
|
|
String[] exitJobOptions = { "Exit after current Jobs", "Exit Immediately", "Do Nothing" };
|
2020-04-27 22:28:04 +10:00
|
|
|
int jobsQueueSize = client.getUploadQueueSize() + (client.isRunning() ? 1 : 0);
|
2020-05-28 13:28:42 +02:00
|
|
|
|
|
|
|
|
int userDecision = JOptionPane.showOptionDialog(null, String.format(
|
|
|
|
|
"<html>You have <strong>%d frame%s</strong> being uploaded or rendered. Do you want to finish the jobs or exit now?.\n\n",
|
|
|
|
|
jobsQueueSize, // Add the current frame to the total count ONLY if the client is running
|
|
|
|
|
(jobsQueueSize > 1 ? "s" : ""), (jobsQueueSize > 1 ? (jobsQueueSize + " ") : ""), (jobsQueueSize > 1 ? "s" : "")),
|
|
|
|
|
"Exit Now or Later", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, exitJobOptions,
|
2020-04-27 22:28:04 +10:00
|
|
|
exitJobOptions[2]); // Make the "Do nothing" button the default one to avoid mistakes
|
|
|
|
|
|
|
|
|
|
if (userDecision == 0) {
|
2020-05-28 13:28:42 +02:00
|
|
|
exitAfterFrame.setText(String.format("Cancel exit (%s frame%s to go)", jobsQueueSize, (jobsQueueSize > 1 ? "s" : "")));
|
2020-04-27 22:28:04 +10:00
|
|
|
|
|
|
|
|
client.askForStop();
|
|
|
|
|
}
|
|
|
|
|
else if (userDecision == 1) {
|
|
|
|
|
client.stop();
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
2015-08-05 19:58:11 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2020-04-27 22:28:04 +10:00
|
|
|
exitAfterFrame.setText("Exit");
|
2015-08-05 19:58:11 +01:00
|
|
|
client.cancelStop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-05 19:35:13 +01:00
|
|
|
|
2015-10-27 21:00:44 +00:00
|
|
|
class blockJobAction implements ActionListener {
|
2020-05-28 13:28:42 +02:00
|
|
|
@Override public void actionPerformed(ActionEvent e) {
|
2015-10-27 21:00:44 +00:00
|
|
|
Client client = parent.getClient();
|
|
|
|
|
if (client != null) {
|
2016-08-01 00:47:29 +02:00
|
|
|
Job job = client.getRenderingJob();
|
|
|
|
|
if (job != null) {
|
2017-02-19 14:19:48 +01:00
|
|
|
job.block();
|
2016-08-01 00:47:29 +02:00
|
|
|
}
|
2015-10-27 21:00:44 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-15 23:20:17 +01:00
|
|
|
}
|