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

📄 historique.java

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

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;

/**
 * The Panel to display the histroy of the change of datas,we use a list to 
 * save the data.
 * @author HUANG Wei & MA Xiao Jun
 * {@see fr.umlv.projet.fenetre.preformance.Preformance}
 */

public class Historique extends JPanel {
	private List<Integer> l = new ArrayList<Integer>();
	private int debut = 0;
	private int distance = 3;	//the distance to move of the cell when it is refreshed
	private int w = 0;
	private int h = 0;
	private Color color = Color.GREEN;
	public List<Integer> getl(){
		return l;
	}
	
	protected@Override void paintComponent(Graphics graphic){
		Graphics2D g = (Graphics2D)graphic; 
		super.paintComponent(g);
		this.setBackground(Color.BLACK);
		w = this.getWidth();
		h = this.getHeight();
		int i = h;
		while(i > 0){
			g.drawLine(0,i,w,i);
			g.setPaint(new Color(0, 100, 60));
			i =i - 10;
		}
		
		int j = w - debut;
		while(j > 0){
			g.drawLine(j,0,j,h);
			g.setPaint(new Color(0, 100, 60));	
			j = j - 10;
		}

	
		if(l != null){
			int index = l.size() - 1;
			while(index >= 1){
				int f1 = l.get(index)*h/10000;
				int f2 = l.get(index-1)*h/10000;
					g.setColor(this.color);
				g.drawLine(w,
						h - f1,
						w - distance,
						h - f2);
				w = w - distance;
				if(w < -distance)
					break;
				index --;
			}
		}
	}
	
	/**
	 * to refresh the image of histroy.
	 * @param debut to define the abscissa of begining to draw de cell.
	 * @param data the value current which used to draw image.
	 * @param c the color of the image histroy(Cpu is green,Memory is yellow).
	 */
	public void refresh(int debut,int data,Color c) {
		this.debut = debut;
		this.l.add(data);
		this.color = c;
	}
	
}

⌨️ 快捷键说明

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