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

📄 loadchart.java

📁 The WLAN Traffic Visualizer is a platform independent Java program providing accurate measurement of
💻 JAVA
字号:
package view;//Copyright (C) 2008 Harald Unander, Wang Wenjuan////    This file is part of WlanTV.////    WlanTV is free software: you can redistribute it and/or modify//    it under the terms of the GNU General Public License as published by//    the Free Software Foundation, either version 3 of the License, or//    (at your option) any later version.////    WlanTV 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 WlanTV.  If not, see <http://www.gnu.org/licenses/>.import java.awt.BasicStroke;import java.awt.Color;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Shape;import java.awt.geom.Rectangle2D;import javax.swing.JPanel;import main.Main;import model.Load;@SuppressWarnings("serial")public class LoadChart extends JPanel {	private Load load;	private View parent;	public LoadChart(Load load,View parent) {		this.load = load;		this.parent = parent;	}	@Override	public void paint(Graphics g)	{		super.paint(g);		Graphics2D g2d = (Graphics2D) g;		drawLoad(g2d);	}	private void drawLoad(Graphics2D g2d) {		g2d.setPaint(Color.BLACK);		long w = load.t1-load.t0+1;		long h = (long)(load.maxLoad*1.1);//		long h;//		if (load.maxLoad*1.1 > 30000)//			h = (long)(load.maxLoad*1.1);//		else//			h = 30000;		double wf = ((double)(getWidth()-40)/w);		double hf = ((double)(getHeight()-60)/h);		g2d.setStroke(new BasicStroke(0));		g2d.setFont(Main.SMALLFONT);		double t = 0;		for (int i=0; i<load.realList.length;i++) {			long realKbps = load.realList[i];			long extraKbps = load.extraList[i];			Shape s1 = new Rectangle2D.Double(40+t*wf,h*hf-hf*realKbps,wf*load.loadStep,hf*realKbps);			Shape s2 = new Rectangle2D.Double(40+t*wf,h*hf-hf*realKbps-hf*extraKbps,wf*load.loadStep,hf*extraKbps);			Shape s3 = new Rectangle2D.Double(40+t*wf,h*hf-hf*realKbps-hf*extraKbps,wf*load.loadStep,hf*(realKbps+extraKbps));			g2d.setPaint(Color.LIGHT_GRAY);			g2d.fill(s1);			g2d.setPaint(Color.WHITE);			g2d.fill(s2);			g2d.setPaint(Color.BLACK);			g2d.draw(s3);			t += load.loadStep;//			g2d.drawString(Long.toString(kbps), (int)(t*wf),(int)(hf*(h-kbps)));		}		g2d.setPaint(Color.BLACK);		long yStep;		if (h<1000) yStep = 50;		else if (h<10000) yStep = 500;		else yStep = 1000;		for (int y=0; y<h; y+=yStep) {			g2d.drawString(Integer.toString(y),5,(int)(hf*(h-y)));		}		g2d.setPaint(Color.BLACK);//		g2d.drawString("Capture time: "+parent.getTotalCaptureTime(),40,getHeight()-45);//		g2d.drawString("View time: "+parent.getViewCaptureTime(),40,getHeight()-35);		g2d.drawString("Access time: "+parent.getFillAccessTime(),40,getHeight()-25);//		g2d.setPaint(Color.DARK_GRAY);		g2d.drawString("Average packet length: "+Integer.toString(parent.getDefaultFillPayloadLength()),40,getHeight()-15);//		g2d.setPaint(Color.RED);		g2d.drawString("Fill packet length: "+Integer.toString(parent.getFillPacketLength()),40,getHeight()-5);	}}

⌨️ 快捷键说明

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