⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 preformance.java

📁 这是一个在linux环境下
💻 JAVA
字号:
package fr.umlv.projet.fenetre.preformance;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JPanel;

/**
 * This is the Panel Preformance which contains eight small Panel:
 * <@link fr.umlv.projet.fenetre.preformance.PourcentCpu percent_CpuUsed>,
 * <@link fr.umlv.projet.fenetre.preformance.PourcentFichier percent_MemoryUsed>,
 * <@link fr.umlv.projet.fenetre.preformance.Historique History_CpuUsed,History_MemoryUsed>,
 * <@link fr.umlv.projet.fenetre.preformance.PanelTotal Totaux>,
 * <@link fr.umlv.projet.fenetre.preformance.MemoirPh Memoir_physique>,
 * <@link fr.umlv.projet.fenetre.preformance.MemNoyau Memoir_Noyau>,
 * <@link fr.umlv.projet.fenetre.preformance.Charge Charge_dediee>.
 * and we dispart the Panel Preformance to two parts pp1(UP) and pp2(DOWN) .
 * @author Owner
 *
 */

public class Preformance extends JPanel{
	private GridBagLayout gb1;
	private GridBagConstraints gbc1;
	private GridBagLayout gb2;
	private GridBagConstraints gbc2;
	private Historique Hcpu = new Historique();
	private Historique Hfichier = new Historique();
	private PourcentCpu cpu = new PourcentCpu();
	private PourcentFichier fichier = new PourcentFichier();
	private PanelTotal PanelT = new PanelTotal();
	private MemoirPh MemPh = new MemoirPh();
	private Charge charge = new Charge();
	private MemNoyau MemN = new MemNoyau();
	
	public Preformance(){
		JPanel p1 = new JPanel();
		JPanel p2 = new JPanel();
		JPanel p3 = new JPanel();
		JPanel p4 = new JPanel();
		JPanel p5 = new JPanel();
		JPanel p6 = new JPanel();
		JPanel p7 = new JPanel();
		JPanel p8 = new JPanel();
		JPanel pp1 = new JPanel();
		JPanel pp2 = new JPanel();
		gb1 = new GridBagLayout();
		gb2 = new GridBagLayout();
		this.setLayout(new GridLayout(2,1));
		pp1.setLayout(gb1);
		pp2.setLayout(gb2);
		gbc1 = new GridBagConstraints();
		gbc2 = new GridBagConstraints();
		
		
		p1.setBorder(BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder(),
				"Util de l'UC",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Arial", 0, 10)));
		
		p2.setBorder(BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder(),
				"Historique de l'Utilisation de l'UC",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Arial", 0, 10)));
		
		
		p3.setBorder(BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder(),
				"Util.du fichier",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Arial", 0, 10)));
		
		p4.setBorder(BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder(),
				"Historique d'utlisation du ficher dechange",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Arial", 0, 10)));
		
		p5.setBorder(BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder(),
				"Totaux",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Arial", 0, 10)));
		
		p6.setBorder(BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder(),
				"Memoire Physique(kb)",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Arial", 0, 10)));
		
		p7.setBorder(javax.swing.BorderFactory.createTitledBorder(
				javax.swing.BorderFactory.createEtchedBorder(),
				"Charge dediee(kb)", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Arial", 0, 10)));
		
		p8.setBorder(javax.swing.BorderFactory.createTitledBorder(
				javax.swing.BorderFactory.createEtchedBorder(),
				"Memoire pour le no yau(kb)",
				javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
				javax.swing.border.TitledBorder.DEFAULT_POSITION,
				new java.awt.Font("Arial", 0, 10)));  
		
		/*******************ligne zero**************************/	
		p1.setLayout(new BorderLayout());
		p1.add(cpu,BorderLayout.CENTER);
		
		
		gbc1.fill= GridBagConstraints.BOTH;
		gbc1.weightx = 12;
		gbc1.weighty = 25;
		addComponenentUP(p1,pp1,0,0,1,2);
		
		p2.setLayout(new BorderLayout());
		Hcpu.setSize(100,100);
		p2.add(Hcpu,BorderLayout.CENTER);
		
		gbc1.weightx = 100;
		gbc1.weighty = 150;
		gbc1.fill= GridBagConstraints.BOTH;
		addComponenentUP(p2,pp1,1,0,6,2);
		
		
		/****************premiere ligne*************************/
		p3.setLayout(new BorderLayout());
		p3.add(fichier,BorderLayout.CENTER);
		
		gbc1.weightx = 12;
		gbc1.weighty = 25;
		gbc1.fill= GridBagConstraints.BOTH;
		addComponenentUP(p3,pp1,0,2,1,2);
		
		p4.setLayout(new BorderLayout());
		p4.add(Hfichier,BorderLayout.CENTER);
		
		gbc1.weightx = 100;
		gbc1.weighty = 150;
		gbc1.fill= GridBagConstraints.BOTH;
		addComponenentUP(p4,pp1,1,2,6,2);
		
		/*******************deuxieme ligne*************************/
		p5.setLayout(new BorderLayout());
		p5.add(PanelT,BorderLayout.CENTER);
		
		gbc2.fill= GridBagConstraints.BOTH;
		gbc2.weightx = 30;
		gbc2.weighty = 5;
		gbc1.anchor = GridBagConstraints.SOUTHWEST;
		addComponenentDown(p5,pp2,0,0,2,1);
		
		p6.setLayout(new BorderLayout());
		p6.add(MemPh,BorderLayout.CENTER);
		
		gbc2.fill= GridBagConstraints.BOTH;
		gbc2.weightx = 30;
		gbc2.weighty = 5;
		gbc1.anchor = GridBagConstraints.SOUTHWEST;
		addComponenentDown(p6,pp2,2,0,2,1);
		
		gbc2.fill= GridBagConstraints.BOTH;
		addComponenentDown(new JPanel(),pp2,4,0,1,1);
		/*******************troisieme ligne******************************/
		p7.setLayout(new BorderLayout());
		p7.add(charge,BorderLayout.CENTER);
		
		gbc2.fill= GridBagConstraints.BOTH;
		gbc2.weightx = 30;
		gbc2.weighty = 5;
		gbc1.anchor = GridBagConstraints.SOUTHWEST;
		addComponenentDown(p7,pp2,0,1,2,1);
		
		p8.setLayout(new BorderLayout());
		p8.add(MemN,BorderLayout.CENTER);
		
		gbc2.fill= GridBagConstraints.BOTH;
		gbc2.weightx = 30;
		gbc2.weighty = 5;
		gbc1.anchor = GridBagConstraints.SOUTHWEST;
		addComponenentDown(p8,pp2,2,1,2,1);
		
		gbc2.fill= GridBagConstraints.BOTH;
		addComponenentDown(new JPanel(),pp2,4,1,1,1);
		/****************************************************************/	
		
		/************************bas*************************************/
		gbc2.fill= GridBagConstraints.BOTH;
		gbc2.weightx = 90;
		gbc2.weighty = 5;
		addComponenentDown(new JPanel(),pp2,0,2,6,1);
		/****************************************************************/
		this.add(pp1);
		this.add(pp2);
	}
	
	/**
	 * this fonction is to add a component to the pp1 with the GridBagLayout.
	 * @param component the component to add.
	 * @param pp here it's pp1.
	 * @param column the column of the position where the component wants to add.
	 * @param row the row of the position where the component wants to add.
	 * @param width the width of the component.
	 * @param height the height of the component.
	 */
	private void addComponenentUP(Component component, JPanel pp, int column, int row, int width, int height) {
		gbc1.gridx = column;
		gbc1.gridy = row;
		
		gbc1.gridwidth = width;
		gbc1.gridheight = height;
		
		gb1.setConstraints(component,gbc1);
		pp.add(component);
	}
	
	
	/**
	 * this fonction is to add a component to the pp2 with the GridBagLayout.
	 * @param component the component to add.
	 * @param pp here it's pp2.
	 * @param column the column of the position where the component wants to add.
	 * @param row the row of the position where the component wants to add.
	 * @param width the width of the component.
	 * @param height the height of the component.
	 */
	private void addComponenentDown(Component component, JPanel pp, int column, int row, int width, int height) {
		gbc2.gridx = column;
		gbc2.gridy = row;
		
		gbc2.gridwidth = width;
		gbc2.gridheight = height;
		
		gb2.setConstraints(component,gbc2);
		pp.add(component);
	}
	/**
	 * @return the Panel Hcpu of the Preformance.
	 */
	public Historique getHcpu(){
		return Hcpu;
	}
	
	/**
	 * @return the Panel Hfichier of the Preformance.
	 */
	public Historique getHf(){
		return Hfichier;
	}
	
	/**
	 * @return the Panel cpu of the Preformance.
	 */
	public PourcentCpu getcpu(){
		return cpu;
	}
	
	/**
	 * @return the Panel fichier of the Preformance.
	 */
	public PourcentFichier getfichier(){
		return fichier;
	}
	
	/**
	 * refresh the image strick of the percent of cpu used.
	 * @param pc the percent of cpu used.
	 * @param pourcent the character string to display the percent.
	 */
	public void refreshCpu(int pc,String pourcent){
		cpu.refresh(pc,pourcent);
	}
	/**
	 * refresh the image strick of the percent of memory used.
	 * @param MemOccup the value of the memory used(kb).
	 * @param total the value of the memory total(kb).
	 */
	public void refreshfichier(int MemOccup,int total){
		fichier.refresh(MemOccup,total);
	}
	
	
	/**
	 * refresh the image histroy of the percent of the cpu used 
	 * @param debut debut to define the abscissa of begining to draw de cell.
	 * @param data the value of percent of cpu used.
	 * @param c the color of the image histroy(Cpu is green,Memory is yellow).
	 */
	public void refreshHCpu(int debut,int data,Color c){
		Hcpu.refresh(debut,data,c);
	}
	
	/**
	 * refresh the image histroy of the percent of the memory used 
	 * @param debut debut to define the abscissa of begining to draw de cell.
	 * @param data the data of percent memory used. 
	 * @param c the color of the image histroy(Cpu is green,Memory is yellow).
	 */
	public void refreshHF(int debut,int data,Color c){
		Hfichier.refresh(debut,data,c);
	}
	
	/**
	 * refresh the Panel totaux.
	 * @param Handles 
	 * @param Threads the number of Threads.
	 * @param processus the number of Processus.
	 */
	public void refreshPanelTotal(String Handles,String Threads,String processus){
		PanelT.refresh(Handles,Threads,processus);
	}
	
	/**
	 * refresh the Panel  Memoire phsyques
	 * @param Total the value total of Memory physics.
	 * @param Disponible the value of Memory(physics) free.
	 * @param CacheSys
	 */
	public void refreshMemoirPh(String Total,String Disponible,String CacheSys){
		MemPh.refresh(Total,Disponible,CacheSys);
	}
	
	/**
	 * refresh the Panel Charge dediee
	 * @param Total Total the memory used of the computer.
	 * @param Limit the limit of de memory of the computer.
	 * @param Pic the biggest value of the memory used.
	 */
	public void refreshCharge(int Total,int Limit,int Pic){
		charge.refresh(Total,Limit,Pic);
	}
	
	/**
	 * refresh the Panel Memoire Noyau
	 * @param Total
	 * @param Paginee
	 * @param NPaginee
	 */
	public void refreshMemNoyau(String Total,String Paginee,String NPaginee){
		MemN.refresh(Total,Paginee,NPaginee);
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -