Menu

#805 setBackgroundPaint function in ArcDialFrame not working

open
nobody
None
5
2012-11-27
2007-11-23
Anonymous
No

The use of the setBackgroundPaint function from the ArcDialFrame class does not seem to have any effect.

Here is a sample code:

DialPlot plot = new DialPlot();
ArcDialFrame arcdialframe = new ArcDialFrame(-120, -300);
arcdialframe.setForegroundPaint(Color.GREEN);
arcdialframe.setBackgroundPaint(Color.RED);
plot.setDialFrame(arcdialframe);

The DialFrame is always dispayed without a background regardless of setBackgroundPaint.

Discussion

  • xjn

    xjn - 2007-12-13

    Logged In: YES
    user_id=1959397
    Originator: NO

    Hi,

    i don't know how to submit patches.

    I think the error is in

    - org.jfree.chart.plot.dial.ArcDialFrame
    - method draw(...)
    - replace line 393 (in revision 665)
    g2.setPaint(Color.lightGray);
    with
    g2.setPaint(this.backgroundPaint);

    May be one should also change the comments for the properties 'backgroundPaint' and 'foregroundPaint' ...

    I hope I'm right :)

     
  • Nicholas Saayman

    Hi

    To overcome this I just subclassed ArcDialFrame - here is my code:

    import java.awt.Graphics2D;
    import java.awt.Shape;
    import java.awt.geom.Area;
    import java.awt.geom.Rectangle2D;

    import org.jfree.chart.plot.dial.ArcDialFrame;
    import org.jfree.chart.plot.dial.DialPlot;
    /*
    * The supplied one doesn't use the background color where drawing - fix it here
    * rather than recompile source code of library.
    */
    public class ArcDialFrameCustom extends ArcDialFrame {

    private static final long serialVersionUID = 2232424579603517918L;
    
    public ArcDialFrameCustom\(double d, double e\) \{
        super\(d, e\);
    \}
    
    public void draw\(Graphics2D g2, DialPlot plot, Rectangle2D frame,
            Rectangle2D view\) \{
        Shape window = getWindow\(frame\);
    

    Shape outerWindow = getOuterWindow(frame);

    Area area1 = new Area(outerWindow);
    Area area2 = new Area(window);
    area1.subtract(area2);
    g2.setPaint(this.getBackgroundPaint());
    g2.fill(area1);

    g2.setStroke(this.getStroke());
    g2.setPaint(this.getForegroundPaint());
    g2.draw(window);
    g2.draw(outerWindow);
    }

    }

     

Log in to post a comment.