int extra = 0; if (type == QuantumFactory.EXPONENTIAL) extra = hStart/2;  AffineTransform transform = new AffineTransform();  transform.translate(leftBorder+70, topBorder+70); transform.scale(10, 10); g2D.setPaint(Color.lightGray); GeneralPath path = new GeneralPath(); for (int i = -7; i <= 7; i++) { path.moveTo(i, -7); path.lineTo(i, 7); } for (int i = -7; i <= 7; i++) { path.moveTo(-7, i); path.lineTo(7, i); } g2D.draw(transform.createTransformedShape(path)); g2D.setColor(axisColor);   g2D.drawLine(leftBorder, topBorder-8, leftBorder, tS+5); g2D.drawLine(leftBorder, topBorder-8, leftBorder-3, topBorder-5); g2D.drawLine(leftBorder, topBorder-8, leftBorder+3, topBorder-5); g2D.drawLine(leftBorder-5, topBorder, leftBorder, topBorder);   g2D.drawLine(leftBorder-5, tS, lS+8, tS); g2D.drawLine(lS+5, tS-3, lS+8, tS); g2D.drawLine(lS+5, tS+3, lS+8, tS); g2D.drawLine(xControl, tS, xControl, tS+5);   g2D.drawString(start, leftBorder-wStart/2, tS+hFont); g2D.drawString(end, xControl-wEnd/2, hFont+tS+extra); g2D.drawString("Pixels intensity", lS2-wInput/2, hFont/2+tS+bottomBorder+hInput);     int xStartPoints[] = {xStart1, xStart2, xStart3}; int yStartPoints[] = {yStart1+extra, yStart2+extra, yStart3+extra}; GeneralPath filledPolygonStart = new GeneralPath(); filledPolygonStart.moveTo(xStartPoints[0], yStartPoints[0]); for (int index = 1; index < xStartPoints.length; index++) filledPolygonStart.lineTo(xStartPoints[index], yStartPoints[index]); filledPolygonStart.closePath(); g2D.setColor(iStartColor); g2D.fill(filledPolygonStart);  g2D.drawString(curStart, 10, hFont+tS+bottomBorder+2*hInput);    int xEndPoints[] = {xEnd1, xEnd2, xEnd3}; int yEndPoints[] = {yEnd1+extra, yEnd2+extra, yEnd3+extra}; GeneralPath filledPolygonEnd = new GeneralPath(); filledPolygonEnd.moveTo(xEndPoints[0], yEndPoints[0]); for (int index = 1; index < xEndPoints.length; index++) filledPolygonEnd.lineTo(xEndPoints[index], yEndPoints[index]); filledPolygonEnd.closePath();  g2D.setColor(iEndColor); g2D.fill(filledPolygonEnd);  g2D.drawString(curEnd, lS2+10, hFont+tS+bottomBorder+2*hInput);   int xStartOutputPoints[] = {xStartOutput1, xStartOutput2, xStartOutput3}; int yStartOutputPoints[] = {yStartOutput1, yStartOutput2, yStartOutput3}; GeneralPath filledPolygonStartOutput = new GeneralPath(); filledPolygonStartOutput.moveTo(xStartOutputPoints[0], yStartOutputPoints[0]); for (int index = 1; index < xStartOutputPoints.length; index++) filledPolygonStartOutput.lineTo(xStartOutputPoints[index], yStartOutputPoints[index]); filledPolygonStartOutput.closePath(); g2D.setColor(ostartColor); g2D.fill(filledPolygonStartOutput);   int xEndOutputPoints[] = {xEndOutput1, xEndOutput2, xEndOutput3}; int yEndOutputPoints[] = {yEndOutput1, yEndOutput2, yEndOutput3}; GeneralPath filledPolygonEndOutput = new GeneralPath(); filledPolygonEndOutput.moveTo(xEndOutputPoints[0], yEndOutputPoints[0]); for (int index = 1; index < xEndOutputPoints.length; index++) filledPolygonEndOutput.lineTo(xEndOutputPoints[index], yEndOutputPoints[index]); filledPolygonEndOutput.closePath(); g2D.setColor(oendColor); g2D.fill(filledPolygonEndOutput); g2D.setColor(lineColor); g2D.setStroke(new BasicStroke(1.5f));  g2D.drawLine((int) staticStartPt.getX(), (int) staticStartPt.getY(), (int) startPt.getX(), (int) startPt.getY()); g2D.drawLine((int) endPt.getX(), (int) endPt.getY(), (int) staticEndPt.getX(), (int) staticEndPt.getY());  g2D.draw(quad); }
int extra = 0; if (type == QuantumFactory.EXPONENTIAL) extra = hStart/2;  if (stats == null)  paintGrid(g2D); else paintBins(g2D);   g2D.setColor(axisColor);   g2D.drawLine(leftBorder, topBorder-8, leftBorder, tS+5); g2D.drawLine(leftBorder, topBorder-8, leftBorder-3, topBorder-5); g2D.drawLine(leftBorder, topBorder-8, leftBorder+3, topBorder-5); g2D.drawLine(leftBorder-5, topBorder, leftBorder, topBorder);   g2D.drawLine(leftBorder-5, tS, lS+8, tS); g2D.drawLine(lS+5, tS-3, lS+8, tS); g2D.drawLine(lS+5, tS+3, lS+8, tS); g2D.drawLine(xControl, tS, xControl, tS+5);   g2D.drawString(start, leftBorder-wStart/2, tS+hFont); g2D.drawString(end, xControl-wEnd/2, hFont+tS+extra); g2D.drawString("Pixels intensity", lS2-wInput/2, hFont/2+tS+bottomBorder+hInput);   int xStartPoints[] = {xStart1, xStart2, xStart3}; int yStartPoints[] = {yStart1+extra, yStart2+extra, yStart3+extra}; GeneralPath filledPolygonStart = new GeneralPath(); filledPolygonStart.moveTo(xStartPoints[0], yStartPoints[0]); for (int index = 1; index < xStartPoints.length; index++) filledPolygonStart.lineTo(xStartPoints[index], yStartPoints[index]); filledPolygonStart.closePath(); g2D.setColor(iStartColor); g2D.fill(filledPolygonStart);  g2D.drawString(curStart, 10, hFont+tS+bottomBorder+2*hInput);    int xEndPoints[] = {xEnd1, xEnd2, xEnd3}; int yEndPoints[] = {yEnd1+extra, yEnd2+extra, yEnd3+extra}; GeneralPath filledPolygonEnd = new GeneralPath(); filledPolygonEnd.moveTo(xEndPoints[0], yEndPoints[0]); for (int index = 1; index < xEndPoints.length; index++) filledPolygonEnd.lineTo(xEndPoints[index], yEndPoints[index]); filledPolygonEnd.closePath();  g2D.setColor(iEndColor); g2D.fill(filledPolygonEnd);  g2D.drawString(curEnd, lS2+10, hFont+tS+bottomBorder+2*hInput);   int xStartOutputPoints[] = {xStartOutput1, xStartOutput2, xStartOutput3}; int yStartOutputPoints[] = {yStartOutput1, yStartOutput2, yStartOutput3}; GeneralPath filledPolygonStartOutput = new GeneralPath(); filledPolygonStartOutput.moveTo(xStartOutputPoints[0], yStartOutputPoints[0]); for (int index = 1; index < xStartOutputPoints.length; index++) filledPolygonStartOutput.lineTo(xStartOutputPoints[index], yStartOutputPoints[index]); filledPolygonStartOutput.closePath(); g2D.setColor(ostartColor); g2D.fill(filledPolygonStartOutput);   int xEndOutputPoints[] = {xEndOutput1, xEndOutput2, xEndOutput3}; int yEndOutputPoints[] = {yEndOutput1, yEndOutput2, yEndOutput3}; GeneralPath filledPolygonEndOutput = new GeneralPath(); filledPolygonEndOutput.moveTo(xEndOutputPoints[0], yEndOutputPoints[0]); for (int index = 1; index < xEndOutputPoints.length; index++) filledPolygonEndOutput.lineTo(xEndOutputPoints[index], yEndOutputPoints[index]); filledPolygonEndOutput.closePath(); g2D.setColor(oendColor); g2D.fill(filledPolygonEndOutput); g2D.setColor(lineColor); g2D.setStroke(new BasicStroke(1.5f));  g2D.drawLine((int) staticStartPt.getX(), (int) staticStartPt.getY(), (int) startPt.getX(), (int) startPt.getY()); g2D.drawLine((int) endPt.getX(), (int) endPt.getY(), (int) staticEndPt.getX(), (int) staticEndPt.getY());  g2D.draw(quad); }
	public void paintComponent(Graphics g)	{		super.paintComponent(g);		Graphics2D g2D = (Graphics2D) g;		g2D.setColor(getBackground());		g2D.fillRect(0, 0, width, height);		//FONT settings.		Font font = g2D.getFont();		FontMetrics fontMetrics = g2D.getFontMetrics();		int hFont = fontMetrics.getHeight();		Rectangle2D rStart = font.getStringBounds(start,									g2D.getFontRenderContext());		int wStart = (int) rStart.getWidth();		int hStart = (int) rStart.getHeight();		Rectangle2D rEnd = font.getStringBounds(end, 									g2D.getFontRenderContext());		int wEnd = (int) rEnd.getWidth();		Rectangle2D rInput = font.getStringBounds("Pixel intensity",											g2D.getFontRenderContext());		int wInput = (int) rInput.getWidth();		int hInput = (int) rInput.getHeight();	        setKnobStartY(tS+hStart+5);        setKnobEndY(hStart+5);        		int extra = 0;		if (type == QuantumFactory.EXPONENTIAL) extra = hStart/2;		//Grid		AffineTransform transform = new AffineTransform();		//140/10 = 14 then middle = 14/2		transform.translate(leftBorder+70, topBorder+70); 		transform.scale(10, 10);       		g2D.setPaint(Color.lightGray);		GeneralPath path = new GeneralPath();		for (int i = -7; i <= 7; i++) {			path.moveTo(i, -7);			path.lineTo(i, 7);		}		for (int i = -7; i <= 7; i++) {			path.moveTo(-7, i);			path.lineTo(7, i);		}		g2D.draw(transform.createTransformedShape(path));		g2D.setColor(axisColor);				//y-axis		g2D.drawLine(leftBorder, topBorder-8, leftBorder, tS+5);		g2D.drawLine(leftBorder, topBorder-8, leftBorder-3, topBorder-5);		g2D.drawLine(leftBorder, topBorder-8, leftBorder+3, topBorder-5);		g2D.drawLine(leftBorder-5, topBorder, leftBorder, topBorder);				//x-axis		g2D.drawLine(leftBorder-5, tS, lS+8, tS);		g2D.drawLine(lS+5, tS-3, lS+8, tS);		g2D.drawLine(lS+5, tS+3, lS+8, tS);		g2D.drawLine(xControl, tS, xControl, tS+5);				//input interval		g2D.drawString(start, leftBorder-wStart/2, tS+hFont);		g2D.drawString(end, xControl-wEnd/2, hFont+tS+extra);		g2D.drawString("Pixels intensity", lS2-wInput/2, 						hFont/2+tS+bottomBorder+hInput);		//g2D.drawString(curStart, 10, hFont+tS+bottomBorder+2*hInput);		//g2D.drawString(curEnd, lS2+10, hFont+tS+bottomBorder+2*hInput);				//inputStart knob		int xStartPoints[] = {xStart1, xStart2, xStart3};		int yStartPoints[] = {yStart1+extra, yStart2+extra, yStart3+extra};		GeneralPath filledPolygonStart = new GeneralPath();		filledPolygonStart.moveTo(xStartPoints[0], yStartPoints[0]);		for (int index = 1; index < xStartPoints.length; index++)			filledPolygonStart.lineTo(xStartPoints[index], yStartPoints[index]);		filledPolygonStart.closePath();		g2D.setColor(iStartColor);		g2D.fill(filledPolygonStart);		//curStart value		g2D.drawString(curStart, 10, hFont+tS+bottomBorder+2*hInput);						//inputEnd knob		int xEndPoints[] = {xEnd1, xEnd2, xEnd3};		int yEndPoints[] = {yEnd1+extra, yEnd2+extra, yEnd3+extra};		GeneralPath filledPolygonEnd = new GeneralPath();		filledPolygonEnd.moveTo(xEndPoints[0], yEndPoints[0]);		for (int index = 1; index < xEndPoints.length; index++)			filledPolygonEnd.lineTo(xEndPoints[index], yEndPoints[index]);		filledPolygonEnd.closePath();				g2D.setColor(iEndColor);		g2D.fill(filledPolygonEnd);		//curEnd value.		g2D.drawString(curEnd, lS2+10, hFont+tS+bottomBorder+2*hInput);				//outputStart knob		int xStartOutputPoints[] = {xStartOutput1, xStartOutput2, 									xStartOutput3};		int yStartOutputPoints[] = {yStartOutput1, yStartOutput2, 									yStartOutput3};		GeneralPath filledPolygonStartOutput = new GeneralPath();		filledPolygonStartOutput.moveTo(xStartOutputPoints[0],										 yStartOutputPoints[0]);		for (int index = 1; index < xStartOutputPoints.length; index++)			filledPolygonStartOutput.lineTo(xStartOutputPoints[index], 											yStartOutputPoints[index]);		filledPolygonStartOutput.closePath();		g2D.setColor(ostartColor);		g2D.fill(filledPolygonStartOutput);				//outputEnd knob. 		int xEndOutputPoints[] = {xEndOutput1, xEndOutput2, xEndOutput3};		int yEndOutputPoints[] = {yEndOutput1, yEndOutput2, yEndOutput3};		GeneralPath filledPolygonEndOutput = new GeneralPath();		filledPolygonEndOutput.moveTo(xEndOutputPoints[0], yEndOutputPoints[0]);		for (int index = 1; index < xEndOutputPoints.length; index++)			filledPolygonEndOutput.lineTo(xEndOutputPoints[index], 										yEndOutputPoints[index]);		filledPolygonEndOutput.closePath();		g2D.setColor(oendColor);		g2D.fill(filledPolygonEndOutput); 		g2D.setColor(lineColor);		g2D.setStroke(new BasicStroke(1.5f));		//draw line		g2D.drawLine((int) staticStartPt.getX(), (int) staticStartPt.getY(), 					(int) startPt.getX(), (int) startPt.getY());		g2D.drawLine((int) endPt.getX(), (int) endPt.getY(),					(int) staticEndPt.getX(), (int) staticEndPt.getY());		//draw curve		g2D.draw(quad);	}