From 94aabc6a40badf334d300804059a7202537a4467 Mon Sep 17 00:00:00 2001 From: DamonHD Date: Tue, 4 Jun 2024 14:07:40 +0100 Subject: [PATCH] Created DataVizBeatPoint. --- RELEASES.txt | 2 +- .../org/hd/d/statsHouse/data/DataBounds.java | 2 +- .../d/statsHouse/data/DataVizBeatPoint.java | 39 +++++++++++++++++++ .../org/hd/d/statsHouse/midi/MIDITune.java | 10 ++--- 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 javasrc/org/hd/d/statsHouse/data/DataVizBeatPoint.java diff --git a/RELEASES.txt b/RELEASES.txt index f63dcbe..82c17a8 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -13,7 +13,7 @@ or release/freeze points. SIGNIFICANT CHANGES SINCE LAST RELEASE ====================================== - DHD20240604: added optional dataLabels and dataRendered to MIDITune. + DHD20240604: added optional DataVizBeatPoint dataRendered to MIDITune. diff --git a/javasrc/org/hd/d/statsHouse/data/DataBounds.java b/javasrc/org/hd/d/statsHouse/data/DataBounds.java index 4c31633..0c499db 100644 --- a/javasrc/org/hd/d/statsHouse/data/DataBounds.java +++ b/javasrc/org/hd/d/statsHouse/data/DataBounds.java @@ -24,7 +24,7 @@ * 0 for no such main stream, 1+ for stream, possibly larger than streams * @param maxVal maximum (non-zero) value in the data; non-negative. * @param firstDate first data row date as raw String; can be null - * @param lkastDate last data row date as raw String; can be null + * @param lastDate last data row date as raw String; can be null */ public record DataBounds(int streams, int mainDataStream, float maxVal, String firstDate, String lastDate) { diff --git a/javasrc/org/hd/d/statsHouse/data/DataVizBeatPoint.java b/javasrc/org/hd/d/statsHouse/data/DataVizBeatPoint.java new file mode 100644 index 0000000..2bdee91 --- /dev/null +++ b/javasrc/org/hd/d/statsHouse/data/DataVizBeatPoint.java @@ -0,0 +1,39 @@ +/* +Copyright (c) 2024, Damon Hart-Davis + +Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package org.hd.d.statsHouse.data; + +import java.util.List; + +/**Data Visualisation for a data point per simple (typically 4/4) beat. + * + * @param dataLabels column labels for dataRendered (not containing nulls or commas); + * may be null + * @param dataRendered the set of key data as rendered in the tune, + * with the outer List usually one item per bar beat, + * and the inner list an ordered list of the key items rendered in that beat maybe normalised; + * may be null + */ +public record DataVizBeatPoint( + List dataLabels, + List> dataRendered + ) + { + public DataVizBeatPoint + { + if(null != dataLabels) { dataLabels = List.copyOf(dataLabels); } // Defensive copy. + } + } diff --git a/javasrc/org/hd/d/statsHouse/midi/MIDITune.java b/javasrc/org/hd/d/statsHouse/midi/MIDITune.java index eaa0020..e8255b5 100644 --- a/javasrc/org/hd/d/statsHouse/midi/MIDITune.java +++ b/javasrc/org/hd/d/statsHouse/midi/MIDITune.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Objects; +import org.hd.d.statsHouse.data.DataVizBeatPoint; import org.hd.d.statsHouse.generic.TuneSectionPlan; /**A representation of a full MIDI 'tune' created from data. @@ -35,15 +36,13 @@ * may be null * @param dataLabels column labels for dataRendered (not containing nulls or commas); * may be null - * @param dataRendered the set of key data as rendered in the tune, - * with the outer List usually one item per bar beat, - * and the inner list an ordered list of the key items rendered in that beat maybe normalised; + * @param dataRendered the set of key data as rendered in the tune; * may be null */ public record MIDITune(List dataMelody, List supportTracks, TuneSectionPlan plan, - List dataLabels, List> dataRendered) + DataVizBeatPoint dataRendered) { public MIDITune { @@ -53,7 +52,6 @@ public record MIDITune(List dataMelody, Objects.requireNonNull(supportTracks); if(supportTracks.stream().anyMatch(t -> t == null)) { throw new IllegalArgumentException(); } supportTracks = List.copyOf(supportTracks); // Defensive copy. - if(null != dataLabels) { dataLabels = List.copyOf(dataLabels); } // Defensive copy. } /**Data melody and support track and plan, no rendered data. */ @@ -61,7 +59,7 @@ public MIDITune( final List dataMelody, final List supportTracks, final TuneSectionPlan plan) - { this(dataMelody, supportTracks, plan, null, null); } + { this(dataMelody, supportTracks, plan, null); } /**Data melody and support track, no plan nor rendered data. */ public MIDITune(