Menu

#116 Chart's Y label acts weird

next_bugfix_release
open
nobody
5
2014-02-17
2014-01-08
Paulius
No

Hi,
Stumbled on a kinda bug I think its might be JTabbedPane fault cuz it's repaint method bugged.
So when you add chart to JTabbedPane and fire popup menu to show, Y axis label moves from its original position and one more label paints itself into chart area which disappears only when you close popup menu. I've tried to add setRequestToRepaint() to mouse action, but it only removes the duplicate label, but not the originals positioning. I'll add .java to replicate this bug.

Also the Log10 axis numbers can be lower than 1, it cannot be lower than 0. ( http://pastebin.com/5089G1M8 )

Also the zoom on zooming panel felt a bit clunky cuz zooming too the corners was too hard, because of the mouse coordinates restrictions in the code. Fixed it a bit and watnted to ask if this could be included to the official lib, cuz under LGPL I cannot modify your lib...
( http://pastebin.com/ELc18RzN )

Thanks for a great lib and hope you'll respond soon :)

1 Attachments

Discussion

  • Paulius

    Paulius - 2014-01-09

    So it seems this problem is even uglier then you retrace your chart with new data. So I've decided to play with the AxisTitlePainterDefault.class. The rotation seemed to be not working correctly so after a bit of searching and testing I've found a better method to draw a rotated text:

    private void drawString(Graphics g, double x, double y, String label) {
    
             Graphics2D g2D = (Graphics2D)g;
    
            // Create a rotation transformation for the font.
            AffineTransform fontAT = new AffineTransform();
    
            // get the current font
            Font theFont = g2D.getFont();
    
            // Derive a new font using a rotatation transform
            fontAT.rotate(270 * java.lang.Math.PI/180);
            Font theDerivedFont = theFont.deriveFont(fontAT);
    
            // set the derived font in the Graphics2D context
            g2D.setFont(theDerivedFont);
    
            // Render a string using the derived font
            g2D.drawString(label, (int)x, (int)y);
    
            // put the original font back
            g2D.setFont(theFont);
        }
    }
    

    I've found it here - http://greybeardedgeek.net/2009/05/15/rotated-text-in-java-swing-2d/
    Now it work correctly - no Y axis label jumping or new labels appearing on the chart. Hope you'll include this method in bug fix release.

     
  • Achim Westermann

    Hi Paulius,

    please stick to one bug per ticket.
    I don't currently get what all you are addressing.

    I need 1 bug / 1 problem per ticket. And ideally a JUnit test that isolates to bug to reproduce it (and have a regression test for further releases). Else I would first have to try to isolate that bug, then reproduce it, then fix it and finally to write a regression test to avoid, that in future releases I will break things again. It's about sharing and helping community in OpenSource.

    cheers,
    Achim

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB