package org.kne.cloud.network.klalb.ui;

import javax.swing.JPanel;
import java.awt.GridLayout;
import javax.swing.JLabel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.SwingConstants;

import org.kne.cloud.network.klalb.KLALBUtils;

public class DoubleBandwidthLabel extends JPanel {
	private JLabel lblNewLabel_1;
	private JLabel lblNewLabel;
	/*public DoubleBandwidthLabel() {
		setLayout(new GridLayout(2, 1, 0, 0));
		setPreferredSize(new Dimension(120, 60));
		
		lblNewLabel_1 = new JLabel(KLALBUtils.defaultUnit(0)+"MB/s");
		lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		add(lblNewLabel_1);
		
		lblNewLabel = new JLabel(KLALBUtils.defaultUnit(0*8)+"Mbps");
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		add(lblNewLabel);
	}*/
	public DoubleBandwidthLabel(String string) {
		setLayout(new GridLayout(2, 1, 0, 0));
		setPreferredSize(new Dimension(140, 60));
		
		lblNewLabel_1 = new JLabel(string+"B/s");
		lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		add(lblNewLabel_1);
		
		lblNewLabel = new JLabel(string+"bps");
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 24));
		add(lblNewLabel);
	}
	public void setLabelForeground(Color color) {
		lblNewLabel_1.setForeground(color);
		lblNewLabel.setForeground(color);
	}
	
	public void setBandwidth(long bandwidth) {
		lblNewLabel_1.setText(KLALBUtils.convertIUintDefalut(bandwidth)+"B/s");
		lblNewLabel.setText(KLALBUtils.convertUintDefalut(bandwidth*8L)+"bps");
	}
}
