I think I found a bug in prefuse.render.AxisRenderer.java.
The issue is that the label text disappears when you try to apply a transform by overriding the getTransform method. I think I tracked this down to the render method, specifically, line 142 in CVS:
if ( s == m_box ) {
...
When a transform is applied, this statement is not true and the labels never get drawn. s is no longer equal to m_box, but is a GeneralPath (see bug "AffineTransform.createTransformedShape destroys type information", http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4429599\). This is because of the getShape method in AbstractShapeRenderer uses createTransformedShape(rawShape) which has bug/feature 4429599.
I think a better conditional would be the same as is used in the getRawShape method:
if ( item.canGetString(VisualItem.LABEL) ) {
...
This fixes the problem with labels disappearing, but does not resolve the actual transformation. To do that, I think the render method needs to change to something like:
public void render(Graphics2D g, VisualItem item) {
Shape s = getShape(item);
GraphicsLib.paint(g, item, m_line, getStroke(item), getRenderType(item));
// check if we have a text label, if so, render it
if ( item.canGetString(VisualItem.LABEL) ) {
float x = (float)m_box.getMinX();
float y = (float)m_box.getMinY() + m_ascent;
I think I found a bug in prefuse.render.AxisRenderer.java.
The issue is that the label text disappears when you try to apply a transform by overriding the getTransform method. I think I tracked this down to the render method, specifically, line 142 in CVS:
if ( s == m_box ) {
...
When a transform is applied, this statement is not true and the labels never get drawn. s is no longer equal to m_box, but is a GeneralPath (see bug "AffineTransform.createTransformedShape destroys type information", http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4429599\). This is because of the getShape method in AbstractShapeRenderer uses createTransformedShape(rawShape) which has bug/feature 4429599.
I think a better conditional would be the same as is used in the getRawShape method:
if ( item.canGetString(VisualItem.LABEL) ) {
...
This fixes the problem with labels disappearing, but does not resolve the actual transformation. To do that, I think the render method needs to change to something like:
public void render(Graphics2D g, VisualItem item) {
Shape s = getShape(item);
GraphicsLib.paint(g, item, m_line, getStroke(item), getRenderType(item));
// check if we have a text label, if so, render it
if ( item.canGetString(VisualItem.LABEL) ) {
float x = (float)m_box.getMinX();
float y = (float)m_box.getMinY() + m_ascent;
// draw label background
GraphicsLib.paint(g, item, s, null, RENDER_TYPE_FILL);
String str = item.getString(VisualItem.LABEL);
AffineTransform origTransform = g.getTransform();
if ( this.getTransform(item) != null )
g.setTransform(this.getTransform(item));
g.setFont(item.getFont());
g.setColor(ColorLib.getColor(item.getTextColor()));
g.drawString(str, x, y);
g.setTransform(origTransform);
}
}
Does anyone see a problem with this code?
Thanks.
Is any new information for this issue?
First of all,
I do not know if the bug is really reslved.
http://bugs.sun.com/view_bug.do?bug_id=4429599
I use the code prefuse-beta-20071021, and the AxisRenderer.render is just the same as above post.
but it still some problem.
I make my own Renderer to extend AxisRenderer.
I override getTransformation() to let axis label do some rotation.
I have also some my own ControlAdapter to do on-screen mouse selection.
The transformed labed can be "correctly" selected by mouse (the position is OK)
In ControlAdapter I try to change "Label"(VisualItem) attribute(e.g. font coloe...) and repaint them.
BUT, the "Label" is not correctly repainted, only the part within the original bounding box
would be repaint.
"the original bounding box" means the VisualItem's bounding box before its transformation.
is it still a Bug?
see http://sourceforge.net/forum/message.php?msg_id=5020183