<commit_before>package gui.status;

import gui.AccountsPanel;

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.TimeUnit;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.ToolTipManager;

import qora.BlockGenerator;
import qora.account.Account;
import qora.assets.Asset;
import utils.GUIUtils;
import utils.ObserverMessage;
import controller.Controller;

@SuppressWarnings("serial")
public class ForgingStatus extends JLabel implements Observer {

	private ImageIcon forgingDisabledIcon;
	private ImageIcon forgingEnabledIcon;
	private ImageIcon forgingIcon;
	
	public ForgingStatus()
	{
		super();
		
		//CREATE ICONS
		this.forgingDisabledIcon = this.createIcon(Color.RED);
		this.forgingEnabledIcon = this.createIcon(Color.ORANGE);
		this.forgingIcon = this.createIcon(Color.GREEN);

		//TOOLTIP
		ToolTipManager.sharedInstance().setDismissDelay( (int) TimeUnit.SECONDS.toMillis(5));
		this.addMouseListener(new MouseAdapter() {
			public void mouseEntered(MouseEvent mEvt) {
				if(Controller.getInstance().getForgingStatus() == BlockGenerator.ForgingStatus.FORGING)
				{
					BigDecimal totalBalance = BigDecimal.ZERO.setScale(8);
		           	
		        	Asset asset = AccountsPanel.getAsset();
		            if(asset == null || asset.getKey() == 0l)
		            {
			        	for(Account account: Controller.getInstance().getAccounts())
			        	{
			        		totalBalance = totalBalance.add(account.getConfirmedBalance());
			        	}
		            }
		            long totalBalanceInt = totalBalance.longValue();
		            	
		            setToolTipText("Approx time to find the block: "+getTimeToGoodView((60*5+19)*Controller.getInstance().getLastBlock().getGeneratingBalance()/totalBalanceInt)+".");
				}
				else if (Controller.getInstance().getForgingStatus() == BlockGenerator.ForgingStatus.FORGING_DISABLED && Controller.getInstance().getStatus() == Controller.STATUS_OKE) 
				{
					setToolTipText("To start forging you need to unlock the wallet.");
				}
				else
				{
					setToolTipText("For forging wallet must be online and fully synchronized.");
				}
				
	    }});

		//LISTEN ON STATUS<commit_msg>Fixed a ToolTip error at zero balance and in the choice of assets.<commit_after>package gui.status;

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.TimeUnit;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.ToolTipManager;

import qora.BlockGenerator;
import qora.account.Account;
import utils.GUIUtils;
import utils.ObserverMessage;
import controller.Controller;

@SuppressWarnings("serial")
public class ForgingStatus extends JLabel implements Observer {

	private ImageIcon forgingDisabledIcon;
	private ImageIcon forgingEnabledIcon;
	private ImageIcon forgingIcon;
	
	public ForgingStatus()
	{
		super();
		
		//CREATE ICONS
		this.forgingDisabledIcon = this.createIcon(Color.RED);
		this.forgingEnabledIcon = this.createIcon(Color.ORANGE);
		this.forgingIcon = this.createIcon(Color.GREEN);

		//TOOLTIP
		ToolTipManager.sharedInstance().setDismissDelay( (int) TimeUnit.SECONDS.toMillis(5));
		this.addMouseListener(new MouseAdapter() {
			public void mouseEntered(MouseEvent mEvt) {
				if(Controller.getInstance().getForgingStatus() == BlockGenerator.ForgingStatus.FORGING)
				{
					BigDecimal totalBalance = BigDecimal.ZERO.setScale(8);
		           	
		            for(Account account: Controller.getInstance().getAccounts())
			        {
			        	totalBalance = totalBalance.add(account.getConfirmedBalance());
			        }
			        long totalBalanceInt = totalBalance.longValue();
		            
			        String timeForge = "";
			        if(totalBalanceInt>0)
			        {
			        	timeForge = getTimeToGoodView((60*5+19)*Controller.getInstance().getLastBlock().getGeneratingBalance()/totalBalanceInt);
			        }
			        else
			        {
			        	timeForge = "infinity";
			        }
			        
		            setToolTipText("Approx time to find the block: " + timeForge + ".");
				}
				else if (Controller.getInstance().getForgingStatus() == BlockGenerator.ForgingStatus.FORGING_DISABLED && Controller.getInstance().getStatus() == Controller.STATUS_OKE) 
				{
					setToolTipText("To start forging you need to unlock the wallet.");
				}
				else
				{
					setToolTipText("For forging wallet must be online and fully synchronized.");
				}
				
	    }});

		//LISTEN ON STATUS
{'fraction_non_alphanumeric': 0.10473973762166737, 'fraction_numerical': 0.0033855268726195515, 'mean_word_length': 3.4426691729323307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1994762', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1359, 'n_words': 266}