#219 CompositeTitle enhancement to support entity generation

closed-accepted
None
5
2008-07-09
2008-06-30
No

Currently (1.0.10), the CompositeTitle class ignores the params parameter object in the method:

public Object draw(Graphics2D, Rectangle2D, Object)

The impact of this is that, for example when combining multiple LegendTitle objects inside single CompositeTitle (for the purposes of a combined border, positioning, etc), neither legend is able to generate ChartMouseEvents via the underlying ChartPanel.

When the same legends are added directly to the chart, instead of being added via the CompositeTitle, then expected ChartMouseEvents are generated.

It appears that this deficiency can be addressed by a simple patch to CompositeTitle, replacing the two existing draw methods with new versions:

/**
* Draws the title on a Java 2D graphics device (such as the screen or a
* printer).
*
* @param g2 the graphics device.
* @param area the area allocated for the title.
*/
public void draw(Graphics2D g2, Rectangle2D area) {
this.draw(g2, area, null);
}

/**
* Draws the block within the specified area.
*
* @param g2 the graphics device.
* @param area the area.
* @param params ignored (<code>null</code> permitted).
*
* @return An {@link org.jfree.chart.block.EntityBlockResult} or
* <code>null</code>.
*/
public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
drawBorder(g2, area);
area = trimBorder(area);
area = trimPadding(area);
return container.draw(g2, area, params);
}

Discussion

  • Eric Penfold

    Eric Penfold - 2008-06-30

    Unified Diff Patch for above enhancement

     
  • David Gilbert

    David Gilbert - 2008-07-02
    • assigned_to: nobody --> mungady
    • status: open --> closed-accepted
     
  • David Gilbert

    David Gilbert - 2008-07-02

    Logged In: YES
    user_id=112975
    Originator: NO

    Hi Eric,

    Nice catch, thanks! I committed your change to Subversion for inclusion in the next release (1.0.11).

    Regards,

    Dave Gilbert
    JFreeChart Project Leader

     
  • Eric Penfold

    Eric Penfold - 2008-07-09
    • status: closed-accepted --> open-accepted
     
  • Eric Penfold

    Eric Penfold - 2008-07-09

    Logged In: YES
    user_id=1320268
    Originator: YES

    After further testing, it looks like the above version of draw(Graphics2D, Rectangle2D, Object) doesnt correctly handle border painting (it ignores the margin). After looking at TextTitle etc, I believe the following line should be inserted before the drawBorder method call:

    area = trimMargin(area);

    Arguably, it might also be useful to add backgroundPaint member (see TextTitle) to CompositeTitle, along with getBackgroundPaint() and setBackgroundPaint(Paint) methods. It looks pretty straightforward; I can provide a patch for this if desired.

     
  • David Gilbert

    David Gilbert - 2008-07-09
    • status: open-accepted --> closed-accepted
     
  • David Gilbert

    David Gilbert - 2008-07-09

    Logged In: YES
    user_id=112975
    Originator: NO

    The backgroundPaint option has been committed to Subversion for inclusion in the next release (1.0.11).

    Regards,

    Dave

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks