Repository navigation
A maintenance release focused on correctness and modernisation. Highlights:
- Builds with the current Android toolchain (compile/target SDK 37, AGP 9.4, Gradle 9.7); the core
library's minimum SDK is unchanged. - The core library's only dependency is now
androidx.annotation; the XML configuration engine
(formerly the separate Fig library) lives inandroidplot-core. - Nullability annotations across the whole public API for Kotlin callers.
- Around forty bug fixes, including several crashes, found by a code review of the library and a
large expansion of the test suite (core line coverage is now above 95%). - A reworked background render loop and demo app; see Behavior changes below for the handful of
observable differences.
Full list:
- Nullability annotations (
androidx.annotation.NonNull/Nullable) across the whole public API of
androidplot-core: every reference-typed return value and parameter of every public or protected
method and constructor is annotated, so Kotlin callers see real nullable / non-null types instead
of platform types. Kotlin code may see new compile errors where it passednullto a parameter
that is now@NonNull, or used a now-@Nullablereturn (for exampleXYSeries.getX()/
getY(),Region.getMin()/getMax(),XYPlot.getDomainOrigin()/getRangeOrigin(),
Plot.getRenderer()and formatter paint getters that returnnullwhen disabled) without a null
check. A test (NullabilityAnnotationsTest) keeps the annotations complete. - Fix
Redraweroccasionally never exiting (or never resuming) whenfinish(),pause()or
start()raced with its thread: the flag was set before the thread started, or a notify slipped
in between the thread checking its state and waiting. XYPlot.seriesToScreenY(Number)previously returned a y pixel flipped relative to
seriesToScreen(XYCoords)andscreenToSeriesY(the largest series value landed on the bottom
edge of the grid). It now agrees with them, so code that compensated for the inversion should
drop the compensation.- Removed three unused, undocumented public classes:
SimpleLineLabelFormatter,RenderBundleand
APTrace. None were referenced by the library, the demo app or the docs. - (#96) Background-mode plots are no longer forced onto a software layer, removing a full-size CPU
copy of the view from every frame.Redrawernow tolerates plots that have been garbage
collected instead of crashing, and exits on its own once none remain. - (#125) Fix grid lines and labels not being drawn for an axis with inverted boundaries (min
greater than max) when usingStepMode.INCREMENT_BY_VALorINCREMENT_BY_FIT. - (#120) Fix background-thread plots never rendering when their first layout pass gives them a
zero-sized dimension. The background render loop has been reworked while fixing this; see
Behavior changes below. - (#118) Fix pie chart segments larger than half the pie not responding to clicks over part of
their area. - (#88) Fix crash when a formatter config or
androidPlot.attribute references a color, dimension
or integer resource. Negative integer values are now accepted as well. - Fix
LineAndPointRendererthrowingIndexOutOfBoundsExceptionon every frame for an empty
series withXOrder.ASCENDING;SeriesUtils.iBoundsno longer yields a negative index for an
empty series. - Fix
LineAndPointRendererthrowing on every frame when interpolation is enabled on a series with
fewer than 3 points or a null value; such series now fall back to straight line segments. - Fix
GROW/SHRINKboundary modes latching the placeholder[-1, 1]bounds when the first
frame is drawn before any series data exists, which leftGROWstuck at -1 and gaveSHRINKan
inverted axis. - Fix
XYConstraints.contains(RectRegion)comparing the region's minimum y value against the domain
instead of its minimum x value. - Fix
FillDirection.RANGE_ORIGINfills being closed at the wrong screen coordinate; the range
origin was transformed through the domain region instead of the range region. - Fix
BarOrientation.STACKEDbars being measured from the bottom of the plot instead of from the
range origin, which produced incorrect stacks whenever the range lower boundary was not the origin.
Negative values now stack downward from the origin. - Fix
BubbleRendererproducing infinite radii when any z-val is zero or negative, and NaN radii (no
bubble drawn) when all z-vals are equal or the series has a single bubble. - Fix a plot whose data spans a single point or a flat line rendering blank:
Region.transformnow
maps a zero-length region onto the center of the target range, andXYPlotpads a calculated axis
whose min equals max so the data is centered with a visible grid. - Fix
BarFormatter.setFillPaint(null)/setBorderPaint(null)not disabling the fill / border;
the formatter shadowed the inherited paint fields sohasFillPaint()/hasLinePaint()kept
returning true andBarRendererdrew with a nullPaint. - Fix
NormedXYSeriesreturning NaN for a flat or single-point series, and drifting outside of the
[0, 1]range when the wrapped series changes after construction. Auto-calculated bounds are now
refreshed before each draw (NormedXYSeriesimplementsPlotListener) and can be refreshed
manually via the newnormalize()method. - Fix the legend (along with the plot title and border) disappearing, with an exception logged on
every frame, when a series has no title (e.g. candlestick plots), a region has no label, or there
are more legend items than the legend'sTableModelcan hold. Untitled items now draw without
text, an over-full legend draws what fits, andDynamicTableModelrounds its dynamic axis up and
sizes cells by the computed row/column count so a table such asDynamicTableModel(0, 2)fills
its width.XYSeriesRenderer.getUniqueRegionFormatters()now returns aMap(a
LinkedHashMap) instead of aHashtable. - Fix
Widget.position(...)re-adding the widget to theLayoutManageron every call, which drew
the widget again on top of everything positioned before it (e.g. the graph covering the legend
and titles afterplot.getGraph().position(...)). - Fix
FixedTableModelwrapping immediately (or laying out nothing) for any table whose rect does
not start at the plot origin. - Fix the
domainTitle*andrangeTitle*size, position, anchor and visibility XML attributes
being applied to the graph widget instead of the domain and range title widgets, so e.g.
ap:domainTitleVisible="false"hid the entire graph. - The XML configuration engine (formerly the separate Fig library) is now part of androidplot-core;
the library no longer has a dependency oncom.halfhp.fig:figlib. See the new
XML Configuration doc. - Compile and target SDK 37; build updated to AGP 9.4 / Gradle 9.7 / Kotlin 2.2.
- Snapshot builds of unreleased changes are now published to the Central snapshots repository.
- Fix crash on the render thread after restoring a
PanZoom.Statethat was captured before any
pan or zoom gesture (eg. savinggetState()inonSaveInstanceStateand rotating the device).
getState()now snapshots the plot's actual boundaries and modes for both axes, and applying a
state skips any axis edge it holds no mode for. AStateserialized by an earlier version
still deserializes (itsserialVersionUIDis pinned) and restores as a no-op.XYPlotgains
public getters for its four boundary modes. - Fix
SampledXYSeriescrashing the render thread on its first draw: the series had no active
data until a zoom factor was applied, and had no bounds when its data was too small to produce
any sampled zoom level.ZoomEstimatoralso tolerates a series without bounds. - Fix
ConcurrentModificationException(and silently skipped listeners) when aPlotListener
or series removes itself from the plot from withinonBeforeDraw/onAfterDraw. The
listener list is now aCopyOnWriteArrayList;Plot.getListeners()returns aList. - Fix
centerOnRangeOrigin(...)withBoundaryMode.FIXED,GROWorSHRINKthrowing
UnsupportedOperationExceptionon every frame; the range axis now supports the same origin
boundary modes as the domain axis. - Fix
NullPointerExceptionwhen aRectRegionwith a null (unbounded) edge is tested for
intersection, eg. a fill region added to aLineAndPointFormatter. Null now means infinity as
documented, and theRegion(v1, v2)constructor no longer swaps a null value to the wrong edge.
LineAndPointRendererdraws such a region clipped to the plot's visible bounds. - Fix
ConcurrentModificationExceptionon the render thread whenXYPlotvalue markers are
added or removed while the plot is drawing; the marker lists are nowCopyOnWriteArrayLists. - Fix
NullPointerExceptionfromSimpleXYSeries.setModel(...),resize(...)andsetXY(...)
afteruseImplicitXVals().setModelandresizekeep the x-vals implicit,setXYsets
only the y value, andsetXthrows anIllegalStateExceptionexplaining why. - Fix
LayerListOrganizer.moveBeneath(...)losing the moved element (and throwing
IndexOutOfBoundsException) andmoveAbove(...)silently moving it to the bottom when the
reference element is not in the list; both now throwIllegalArgumentExceptionand leave the
list unchanged. - Fix
PanZoomclamping a horizontal pan to the range (y) outer limits when onlyminY/maxY
outer limits are set, which snapped the data away on the first drag. - Fix
PanZoompan and zoom losing precision on large-magnitude axes such as epoch milliseconds;
small drags did not move the window and zoom quantized. The value-space math is now done in
double.PanZoom.calculateZoom(RectF, float, boolean)is deprecated in favor of aRectRegion
overload. - Fix
PieRenderer.setDonutSize(0, DonutMode.PIXELS)making the pie invisible; a donut size of 0
pixels now means no hole. - Fix pie segments with a zero value drawing their label on top of the neighbouring segment.
- Fix
Plot.removeSeries(series, rendererClass)returning false when a series that is not a
PlotListenerwas removed, and unregistering aPlotListenerseries (ex.SimpleXYSeries,
which relies on it for draw-time locking) while the series was still registered with another
renderer. - Fix
Plot.clear()andSeriesRegistry.add()/clear()mutating the series registry without
synchronizing against the render thread, which could throw aConcurrentModificationException
mid-render.
Behavior changes for RenderMode.USE_BACKGROUND_THREAD:
- The plot view is now composited with hardware acceleration when the app has it enabled. The
rendered content is unchanged since drawing still happens on an offscreen bitmap; only the copy
of that bitmap to the screen changes. Rendering cost still scales with the plot's pixel area,
so keep plots that redraw at high rates as small as the design allows. redraw()requests are no longer dropped when the render thread is busy drawing. Requests
made during a render are coalesced into one additional render pass, so the latest data is
always drawn. Apps that issueredraw()faster than the plot can draw will see one extra
frame per burst compared to previous versions.- Plots now re-render automatically when resized; previously a resized plot was blank until the
nextredraw()call. - Resizing a plot while it is rendering could previously deadlock; the locks involved are now
always taken in the same order. - Detaching and quickly re-attaching a plot (as happens when scrolling a RecyclerView) could
previously leave it without a render thread, or with recycled buffers, until its next resize.
Thread handover is now explicit and the replacement thread always renders.