#542 CategoryAxis Error

closed-fixed
General (896)
9
2006-08-18
2005-08-31
agustin_ane
No

I found a bug in CategoryAxis

When set CategoryLabelPositions a rotated angle,
CategoryAxis draw the labels smaller than the space
reserved, this is notorious if the label is long or
have a multiple lines.

I found and fix this bag, fixed sources are attached.

I don't know if this is a better solution, but it's
works.

PD.
Sorry , my english is too bad :(

Discussion

  • agustin_ane

    agustin_ane - 2005-08-31

    Sources Fixed

     
  • Joubie

    Joubie - 2006-05-24

    Logged In: YES
    user_id=864842

    The problem is due to the fact that in the initial call to
    CategoryAxis.reserveSpace() the full plot area is used as
    argument for the call to refreshTicks() to calculate the
    space needed for the labels. When the labels are actually
    written, the plotArea has had the space for the axis+labels
    subtracted, so that the second calculation of the space for
    the labels comes up with a much smaller value (stored in
    state.max in the call to refreshTicks). My solution was to
    add the dataArea as an argument to drawCategoryLabels, so
    that the same height is calculated. This breaks the
    description of how CategoryLabelPositions should work
    (fraction of the plot area rather than the full data area).
    See attached diff - needs changes to the 3D category axis
    and SubCategoryAxis. Not pretty and probably not the
    solution you want. Would be good if this could be fixed though!

    Cheers,

    Adriaan

    *** CategoryAxis.java 2006-05-24 12:15:53.000000000 +0300
    --- CategoryAxis.java- 2006-05-24 11:56:01.000000000 +0300
    ***************
    *** 761,767 ****

    // draw the category labels and axis label
    AxisState state = new AxisState(cursor);
    ! state = drawCategoryLabels(g2, plotArea, dataArea,
    edge, state, plotSt ate);
    state = drawLabel(getLabel(), g2, plotArea,
    dataArea, edge, state);

    return state;
    --- 761,767 ----

    // draw the category labels and axis label
    AxisState state = new AxisState(cursor);
    ! state = drawCategoryLabels(g2, dataArea, edge,
    state, plotState);
    state = drawLabel(getLabel(), g2, plotArea,
    dataArea, edge, state);

    return state;
    ***************
    *** 782,788 ****
    * @return The updated axis state (never
    <code>null</code>).
    */
    protected AxisState drawCategoryLabels(Graphics2D g2,
    - Rectangle2D
    plotArea,
    Rectangle2D
    dataArea,
    RectangleEdge edge,
    AxisState state,
    --- 782,787 ----
    ***************
    *** 793,799 ****
    }

    if (isTickLabelsVisible()) {
    ! List ticks = refreshTicks(g2, state, plotArea,
    edge);
    state.setTicks(ticks);

    int categoryIndex = 0;
    --- 792,798 ----
    }

    if (isTickLabelsVisible()) {
    ! List ticks = refreshTicks(g2, state, dataArea,
    edge);
    state.setTicks(ticks);

    int categoryIndex = 0;

     
  • David Gilbert

    David Gilbert - 2006-08-16
    • priority: 5 --> 9
    • assigned_to: nobody --> mungady
     
  • David Gilbert

    David Gilbert - 2006-08-18

    Logged In: YES
    user_id=112975

    Thanks Adriaan...I've applied the fix to CVS ready for the
    upcoming 1.0.2 release.

    Regards,

    Dave Gilbert
    JFreeChart Project Leader

     
  • David Gilbert

    David Gilbert - 2006-08-18
    • status: open --> closed-fixed
     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks