zoom = height / maximum ; actualPoint = lastPoint; if ( ((float) (actualPoint.getValue()/10) * zoom)  >  ((height / 5f)*4f)) zoom = (zoom / 5f)*4f; k=startx;
drawBoardBuffer.setForeground(graph.getGraphColor1()); drawBoardBuffer.drawText(graph.getName() + " avg: " + ((double)graph.getAvg()/100) + " kb/s," + " max: " + ((double)graph.getMax()/100) + " kb/s", 20, parent.getClientArea().height-drawBoardBuffer.getFontMetrics().getHeight() ,true);   double value = (double)graph.getLast().getValue()/100; String boxString = String.valueOf(value) + " kb/s";
	public void paint() {		//setting the Canvas Background to the parents Background					if (parent.getClientArea().height < 45) return;				Image imageBuffer = new Image(null, parent.getBounds());		GC drawBoardBuffer = new GC(imageBuffer);		drawBoardBuffer.setBackground(new Color(null,50,50,50));		drawBoardBuffer.setForeground(new Color(null,0,0,0));		drawBoardBuffer.fillGradientRectangle(0,0,parent.getClientArea().width,parent.getClientArea().height, true);				//g2d.setColor(green);				int startx = 20;				int k = startx;		int which = 0;		float maximum = 20f;		float height = (float) (parent.getClientArea().height - drawBoardBuffer.getFontMetrics().getHeight() - 2);		int width = parent.getClientArea().width;		int graphWidth = (width / 2) - startx;		float zoom, valueY;						while (graphs[which]!=null)		{				StatisticPoint lastPoint = graphs[which].getLast();			StatisticPoint actualPoint = lastPoint;								int red = graphs[which].getGraphColor().getRed();			int green = graphs[which].getGraphColor().getGreen();			int blue = graphs[which].getGraphColor().getBlue();													Color graphColor = new Color(null,red,green,blue);			drawBoardBuffer.setBackground(graphColor);			drawBoardBuffer.setForeground(new Color(null, red > 100 ? red - 100 : red,														  green > 100 ? green - 100 : green, 														  blue > 100 ? blue - 100 : blue));			zoom = 0;			valueY = 0;					// find highest				while ( (k<=width/2) && (actualPoint.getPrev()!=null))			{								valueY = (float) (actualPoint.getValue()/10);				if (valueY > maximum) maximum = valueY; 				actualPoint = actualPoint.getPrev();				k++;				}							// calculate zoom			zoom = height / maximum ;			actualPoint = lastPoint;				if ( ((float) (actualPoint.getValue()/10) * zoom)  >  ((height / 5f)*4f)) 				zoom = (zoom / 5f)*4f;			k=startx;						// draw gradient lines			while ( (k<=width/2) && (actualPoint.getPrev()!=null))	{											valueY = (float) (actualPoint.getValue()/10);					valueY = height - (valueY * zoom);								//drawBoardBuffer.drawLine(k,height,k,valueY);								drawBoardBuffer.fillGradientRectangle(k,(int)height+1,1,(int)(valueY-height),true);				actualPoint = actualPoint.getPrev();				k++;			}									// draw grid			drawBoardBuffer.setForeground(new Color(null,0,128,64));						for (int i = startx -1 ; i < startx + graphWidth; i+=20) 				drawBoardBuffer.drawLine(i,0,i,(int)height + 1);										for (int i = (int)height + 1; i > 0; i-=20)						drawBoardBuffer.drawLine(startx,i,startx+graphWidth,i);									// old grid scale			// for (int dummy=0; dummy<1; dummy++) {			//	int value=dummy*2;			//	drawBoardBuffer.drawText("  " + value,0,height-8-(int)zoom*value*10, true);			// }						// just for temporary fun; this might overflow pretty quickly									 drawBoardBuffer.setForeground(graphColor);			 drawBoardBuffer.drawText(graphs[which].getName() + 				 " avg: " + ((double)graphs[which].getAvg()/100) + " kb/s," +				 " max: " + ((double)graphs[which].getMax()/100) + " kb/s",				 20, parent.getClientArea().height-drawBoardBuffer.getFontMetrics().getHeight() ,true);							// draw floating box						double value = (double)graphs[which].getLast().getValue()/100;			String boxString = String.valueOf(value) + " kb/s";						int textPosition = (int) (height - (float) (graphs[which].getLast().getValue()/10) * zoom);			int boxWidth = drawBoardBuffer.textExtent(boxString).x + 20;			int boxHeight = drawBoardBuffer.textExtent(boxString).y + 5;							drawBoardBuffer.setForeground(new Color(null,0,0,0));			drawBoardBuffer.setBackground(new Color(null,255,255,255));			drawBoardBuffer.fillRoundRectangle(startx+10,textPosition-3,boxWidth,boxHeight,18,18);			drawBoardBuffer.drawRoundRectangle(startx+10,textPosition-3,boxWidth,boxHeight,18,18);			drawBoardBuffer.drawText(boxString,startx+20,textPosition);			drawBoardBuffer.setForeground(new Color(null, 255,255,0));			drawBoardBuffer.drawLine(startx+10,textPosition,startx,textPosition);							which++;		}					drawBoard.drawImage(imageBuffer, 0,0);		imageBuffer.dispose();		drawBoardBuffer.dispose();	}