Hi David!
Thanks for the patch, it works for me!
I changed it a little bit, but i don't know, if this will crash at other parts of jfreechart ( the diff is against the original 1.0.2 Version ):
Code: Select all
--- org/jfree/chart/block/LabelBlock.java 2006-08-25 15:16:44.000000000 +0200
+++ org/jfree/chart/block/LabelBlock.java 2006-10-05 11:10:39.374210600 +0200
@@ -62,6 +62,7 @@
import org.jfree.text.TextBlock;
import org.jfree.text.TextBlockAnchor;
import org.jfree.text.TextUtilities;
+import org.jfree.ui.HorizontalAlignment;
import org.jfree.ui.Size2D;
import org.jfree.util.ObjectUtilities;
import org.jfree.util.PaintUtilities;
@@ -97,6 +98,12 @@
/** The paint. */
private Paint paint;
+
+ /**
+ * Horizontal Alignment
+ */
+ private HorizontalAlignment horizontalAlignment = HorizontalAlignment.RIGHT;
+
/**
* Creates a new label block.
*
@@ -127,6 +134,7 @@
this.text = text;
this.paint = paint;
this.label = TextUtilities.createTextBlock(text, font, this.paint);
+ this.label.setLineAlignment(getHorizontalAlignment());
this.font = font;
this.toolTipText = null;
this.urlText = null;
@@ -152,6 +160,7 @@
}
this.font = font;
this.label = TextUtilities.createTextBlock(this.text, font, this.paint);
+ this.label.setLineAlignment(getHorizontalAlignment());
}
/**
@@ -174,6 +183,7 @@
}
this.paint = paint;
this.label = TextUtilities.createTextBlock(this.text, font, this.paint);
+ this.label.setLineAlignment(getHorizontalAlignment());
}
/**
@@ -325,4 +335,14 @@
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
+
+ public HorizontalAlignment getHorizontalAlignment() {
+ return horizontalAlignment;
+ }
+
+ public void setHorizontalAlignment(HorizontalAlignment horizontalAlignment) {
+ this.horizontalAlignment = horizontalAlignment;
+ if(this.label != null)
+ this.label.setLineAlignment(getHorizontalAlignment());
+ }
}
Code: Select all
--- org/jfree/chart/title/LegendTitle.java 2006-08-25 15:16:44.000000000 +0200
+++ org/jfree/chart/title/LegendTitle.java 2006-10-05 11:01:50.465967800 +0200
@@ -433,6 +433,7 @@
this.itemPaint);
labelBlock.setPadding(this.itemLabelPadding);
labelBlock.setToolTipText(item.getToolTipText());
+ labelBlock.setHorizontalAlignment(getHorizontalAlignment());
legendItem.add(labelBlock);
result = new BlockContainer(new CenterArrangement());
With these two Patches, you can set the HorizontalALignment according to the HorizontalAlignment of the LegendTitle. Please let me know which implementation strategy you chosse. I know, this one is not the best, but fast and it works for me
And thank you for the fast response!
Carsten