From: David G. <mu...@us...> - 2005-11-01 21:40:02
|
Update of /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/title In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6105/source/org/jfree/chart/title Modified Files: Tag: STABLE_1-0-0 ImageTitle.java Log Message: 01-11-2005 David Gilbert <dav...@ob...> * source/org/jfree/chart/title/ImageTitle.java (height): removed field, (width): removed field, (ImageTitle(Image, int, int, RectangleEdge, HorizontalAlignment, VerticalAlignment, RectangleInsets)): set width and height for block, (drawHorizontal): use block width and height, (drawVertical): use block width and height, * source/org/jfree/chart/title/junit/ImageTitleTests.java (testWidthAndHeight): new method. Index: ImageTitle.java =================================================================== RCS file: /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/title/ImageTitle.java,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -C2 -d -r1.8.2.1 -r1.8.2.2 *** ImageTitle.java 25 Oct 2005 20:58:34 -0000 1.8.2.1 --- ImageTitle.java 1 Nov 2005 21:39:53 -0000 1.8.2.2 *************** *** 86,112 **** private Image image; - /** The height used to draw the image (may involve scaling). */ - private int height; - - /** The width used to draw the image (may involve scaling). */ - private int width; - /** * Creates a new image title. * ! * @param image the image. */ public ImageTitle(Image image) { ! ! this( ! image, ! image.getHeight(null), ! image.getWidth(null), ! Title.DEFAULT_POSITION, ! Title.DEFAULT_HORIZONTAL_ALIGNMENT, ! Title.DEFAULT_VERTICAL_ALIGNMENT, ! Title.DEFAULT_PADDING ! ); ! } --- 86,98 ---- private Image image; /** * Creates a new image title. * ! * @param image the image (<code>null</code> not permitted). */ public ImageTitle(Image image) { ! this(image, image.getHeight(null), image.getWidth(null), ! Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, ! Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); } *************** *** 114,118 **** * Creates a new image title. * ! * @param image the image. * @param position the title position. * @param horizontalAlignment the horizontal alignment. --- 100,104 ---- * Creates a new image title. * ! * @param image the image (<code>null</code> not permitted). * @param position the title position. * @param horizontalAlignment the horizontal alignment. *************** *** 123,136 **** VerticalAlignment verticalAlignment) { ! this( ! image, ! image.getHeight(null), ! image.getWidth(null), ! position, ! horizontalAlignment, ! verticalAlignment, ! Title.DEFAULT_PADDING ! ); ! } --- 109,115 ---- VerticalAlignment verticalAlignment) { ! this(image, image.getHeight(null), image.getWidth(null), ! position, horizontalAlignment, verticalAlignment, ! Title.DEFAULT_PADDING); } *************** *** 139,143 **** * width and height in the given location. * ! * @param image the image (not null). * @param height the height used to draw the image. * @param width the width used to draw the image. --- 118,122 ---- * width and height in the given location. * ! * @param image the image (<code>null</code> not permitted). * @param height the height used to draw the image. * @param width the width used to draw the image. *************** *** 159,164 **** } this.image = image; ! this.height = height; ! this.width = width; } --- 138,143 ---- } this.image = image; ! setHeight(height); ! setWidth(width); } *************** *** 167,171 **** * Returns the image for the title. * ! * @return The image for the title. */ public Image getImage() { --- 146,150 ---- * Returns the image for the title. * ! * @return The image for the title (never <code>null</code>). */ public Image getImage() { *************** *** 228,236 **** double rightSpace = 0.0; RectangleInsets padding = getPadding(); ! topSpace = padding.calculateTopOutset(this.height); ! bottomSpace = padding.calculateBottomOutset(this.height); ! leftSpace = padding.calculateLeftOutset(this.width); ! rightSpace = padding.calculateRightOutset(this.width); if (getPosition() == RectangleEdge.TOP) { --- 207,217 ---- double rightSpace = 0.0; + double w = getWidth(); + double h = getHeight(); RectangleInsets padding = getPadding(); ! topSpace = padding.calculateTopOutset(h); ! bottomSpace = padding.calculateBottomOutset(h); ! leftSpace = padding.calculateLeftOutset(w); ! rightSpace = padding.calculateRightOutset(w); if (getPosition() == RectangleEdge.TOP) { *************** *** 238,243 **** } else { ! startY = chartArea.getY() + chartArea.getHeight() - bottomSpace ! - this.height; } --- 219,223 ---- } else { ! startY = chartArea.getY() + chartArea.getHeight() - bottomSpace - h; } *************** *** 247,251 **** if (horizontalAlignment == HorizontalAlignment.CENTER) { startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2.0 ! - this.width / 2.0; } else if (horizontalAlignment == HorizontalAlignment.LEFT) { --- 227,231 ---- if (horizontalAlignment == HorizontalAlignment.CENTER) { startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2.0 ! - w / 2.0; } else if (horizontalAlignment == HorizontalAlignment.LEFT) { *************** *** 253,268 **** } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { ! startX = chartArea.getX() + chartArea.getWidth() - rightSpace ! - this.width; } ! g2.drawImage( ! this.image, (int) startX, (int) startY, ! this.width, this.height, null ! ); ! return new Size2D( ! chartArea.getWidth() + leftSpace + rightSpace, ! this.height + topSpace + bottomSpace ! ); } --- 233,243 ---- } else if (horizontalAlignment == HorizontalAlignment.RIGHT) { ! startX = chartArea.getX() + chartArea.getWidth() - rightSpace - w; } ! g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, ! null); ! return new Size2D(chartArea.getWidth() + leftSpace + rightSpace, ! h + topSpace + bottomSpace); } *************** *** 286,295 **** double rightSpace = 0.0; RectangleInsets padding = getPadding(); if (padding != null) { ! topSpace = padding.calculateTopOutset(this.height); ! bottomSpace = padding.calculateBottomOutset(this.height); ! leftSpace = padding.calculateLeftOutset(this.width); ! rightSpace = padding.calculateRightOutset(this.width); } --- 261,273 ---- double rightSpace = 0.0; + double w = getWidth(); + double h = getHeight(); + RectangleInsets padding = getPadding(); if (padding != null) { ! topSpace = padding.calculateTopOutset(h); ! bottomSpace = padding.calculateBottomOutset(h); ! leftSpace = padding.calculateLeftOutset(w); ! rightSpace = padding.calculateRightOutset(w); } *************** *** 298,302 **** } else { ! startX = chartArea.getMaxX() - rightSpace - this.width; } --- 276,280 ---- } else { ! startX = chartArea.getMaxX() - rightSpace - w; } *************** *** 306,311 **** if (alignment == VerticalAlignment.CENTER) { startY = chartArea.getMinY() + topSpace ! + chartArea.getHeight() / 2.0 ! - this.height / 2.0; } else if (alignment == VerticalAlignment.TOP) { --- 284,288 ---- if (alignment == VerticalAlignment.CENTER) { startY = chartArea.getMinY() + topSpace ! + chartArea.getHeight() / 2.0 - h / 2.0; } else if (alignment == VerticalAlignment.TOP) { *************** *** 313,328 **** } else if (alignment == VerticalAlignment.BOTTOM) { ! startY = chartArea.getMaxY() - bottomSpace - this.height; } ! g2.drawImage( ! this.image, (int) startX, (int) startY, ! this.width, this.height, null ! ); ! return new Size2D( ! chartArea.getWidth() + leftSpace + rightSpace, ! this.height + topSpace + bottomSpace ! ); } --- 290,301 ---- } else if (alignment == VerticalAlignment.BOTTOM) { ! startY = chartArea.getMaxY() - bottomSpace - h; } ! g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, ! null); ! return new Size2D(chartArea.getWidth() + leftSpace + rightSpace, ! h + topSpace + bottomSpace); } |