petite/src/wombat/scheme/libraries/types/TreeData.java
private void draw(Graphics2D g, int x, int y, int left, int right, int skip) {
		if (Value == null) return;

		// Calculate a weighted midpoint so that off balance TreeDatas will draw pleasantly.
		int leftSize = 1 + (Left != null && Left instanceof TreeData ? ((TreeData) Left).size() : 1);
		int rightSize = 1 + (Right != null && Right instanceof TreeData ? ((TreeData) Right).size() : 1);
		double leftWeight = (double) leftSize / ((double) leftSize + (double) rightSize);
		int mid = left + (int) ((double) (right - left) * leftWeight);

		// Calculate the view points for the left and right subTreeDatas (yes, even if they won't be drawn)
		int leftX = (left + mid) / 2;
		int rightX = (mid + right) / 2;

		// Left subTreeData.
		if (Left != null && (!((Left instanceof TreeData) && ((TreeData) Left).isEmpty))) {
			g.drawLine(x, y, leftX, y + skip);
			if (Left instanceof TreeData) {
				((TreeData) Left).draw(g, leftX, y + skip, left, mid, skip);
			} else {
				drawThing(Left, g, leftX, y + skip, false);
			}
		}

		// Right subTreeData.
		if (Right != null && (!((Right instanceof TreeData) && ((TreeData) Right).isEmpty))) {
			g.drawLine(x, y, rightX, y + skip);
			if (Right instanceof TreeData) {
				((TreeData) Right).draw(g, rightX, y + skip, mid, right, skip);
			} else {
				drawThing(Right, g, rightX, y + skip, false);
			}
		}

		// My node.
		drawThing(Value, g, x, y, true);
	}
/**
	 * Draw the current node.
	 * @param g The graphics object.
	 * @param x The x-location to draw it at.
	 * @param y The y-location to draw it at.
	 * @param left The leftmost x-cordinate to draw this node or it's children.
	 * @param right The rightmost x-coordinate to draw this node or it's children.
	 * @param skip The amount in the y-coordinate to skip between levels.
	 */
Draw the current node.
@param g The graphics object.
@param x The x-location to draw it at.
@param y The y-location to draw it at.
@param left The leftmost x-cordinate to draw this node or it's children.
@param right The rightmost x-coordinate to draw this node or it's children.
@param skip The amount in the y-coordinate to skip between levels.
Draw the current node . @param g The graphics object . @param x The x - location to draw it at . @param y The y - location to draw it at . @param left The leftmost x - cordinate to draw this node or it ' s children . @param right The rightmost x - coordinate to draw this node or it ' s children . @param skip The amount in the y - coordinate to skip between levels .
private void draw(Graphics2D g, int x, int y, int left, int right, int skip) {
		if (Value == null) return;
		int leftSize = 1 + (Left != null && Left instanceof TreeData ? ((TreeData) Left).size() : 1);
		int rightSize = 1 + (Right != null && Right instanceof TreeData ? ((TreeData) Right).size() : 1);
		double leftWeight = (double) leftSize / ((double) leftSize + (double) rightSize);
		int mid = left + (int) ((double) (right - left) * leftWeight);
		int leftX = (left + mid) / 2;
		int rightX = (mid + right) / 2;
		if (Left != null && (!((Left instanceof TreeData) && ((TreeData) Left).isEmpty))) {
			g.drawLine(x, y, leftX, y + skip);
			if (Left instanceof TreeData) {
				((TreeData) Left).draw(g, leftX, y + skip, left, mid, skip);
			} else {
				drawThing(Left, g, leftX, y + skip, false);
			}
		}
		if (Right != null && (!((Right instanceof TreeData) && ((TreeData) Right).isEmpty))) {
			g.drawLine(x, y, rightX, y + skip);
			if (Right instanceof TreeData) {
				((TreeData) Right).draw(g, rightX, y + skip, mid, right, skip);
			} else {
				drawThing(Right, g, rightX, y + skip, false);
			}
		}
		drawThing(Value, g, x, y, true);
	}
private void draw ( Graphics2D g , int x , int y , int left , int right , int skip ) { if ( Value == null ) return ; int leftSize = 1 + ( Left != null && Left instanceof TreeData ? ( ( TreeData ) Left ) . size ( ) : 1 ) ; int rightSize = 1 + ( Right != null && Right instanceof TreeData ? ( ( TreeData ) Right ) . size ( ) : 1 ) ; double leftWeight = ( double ) leftSize / ( ( double ) leftSize + ( double ) rightSize ) ; int mid = left + ( int ) ( ( double ) ( right - left ) * leftWeight ) ; int leftX = ( left + mid ) / 2 ; int rightX = ( mid + right ) / 2 ; if ( Left != null && ( ! ( ( Left instanceof TreeData ) && ( ( TreeData ) Left ) . isEmpty ) ) ) { g . drawLine ( x , y , leftX , y + skip ) ; if ( Left instanceof TreeData ) { ( ( TreeData ) Left ) . draw ( g , leftX , y + skip , left , mid , skip ) ; } else { drawThing ( Left , g , leftX , y + skip , false ) ; } } if ( Right != null && ( ! ( ( Right instanceof TreeData ) && ( ( TreeData ) Right ) . isEmpty ) ) ) { g . drawLine ( x , y , rightX , y + skip ) ; if ( Right instanceof TreeData ) { ( ( TreeData ) Right ) . draw ( g , rightX , y + skip , mid , right , skip ) ; } else { drawThing ( Right , g , rightX , y + skip , false ) ; } } drawThing ( Value , g , x , y , true ) ; }
Draw the current node.
Draw the current node .
// Calculate a weighted midpoint so that off balance TreeDatas will draw pleasantly. // Calculate the view points for the left and right subTreeDatas (yes, even if they won't be drawn) // Left subTreeData. // Right subTreeData. // My node.