Skip to content

Commit

Permalink
treewide: apply clang-format
Browse files Browse the repository at this point in the history
Treewide application of clang-format 16. This became necessary because
there are a lot of changes from the previously used outdated
clang-format 13.

Applied by running `find . -regex '.*\.\(java\)' -exec clang-format -style=file -i {} \;`

Also restyled by whitespace
  • Loading branch information
wirew0rm committed Sep 25, 2023
1 parent 41b64d1 commit dcf44cd
Show file tree
Hide file tree
Showing 443 changed files with 4,577 additions and 4,085 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @author ennerf
*/
public interface AggregateDurationMeasure extends DurationMeasure {

/**
* Records the measure determined by all start and stop calls. Resets statistics.
*/
Expand All @@ -28,5 +27,4 @@ public void recordResult() {
// no-op
}
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ public int getAsInt() {
}

final int level;

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* @author ennerf
*/
public interface DurationMeasure {

/**
* Called when an action begins. Sets the start timestamp.
*/
Expand Down Expand Up @@ -42,5 +41,4 @@ public void stop() {
// no-op
}
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @author ennerf
*/
public interface Measurable {

/**
* @param recorder records benchmark measurements
*/
Expand All @@ -17,7 +16,6 @@ public interface Measurable {
* classes where the implementation is optional.
*/
public interface EmptyDefault {
default void setRecorder(MeasurementRecorder recorder) {};
default void setRecorder(MeasurementRecorder recorder){};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
@FunctionalInterface
public interface MeasurementRecorder {

/**
* @param tag a descriptive name to disambiguate multiple measures
* @param level the detail level of the measured value
Expand Down Expand Up @@ -194,5 +193,4 @@ default MeasurementRecorder removePostfix() {
}

public static final MeasurementRecorder DISABLED = (tag, level) -> TimeMeasure.DISABLED;

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* @author ennerf
*/
public class RecordingDurationMeasure implements DurationMeasure {

public static DurationMeasure newNanoTime(TimeMeasure recorder) {
return new RecordingDurationMeasure(TimeUnit.NANOSECONDS, System::nanoTime, recorder);
}
Expand Down Expand Up @@ -67,7 +66,6 @@ public DurationMeasure ignoreMissingStart() {
protected boolean ignoreMissingStart = false;

public static class Sum extends RecordingDurationMeasure implements AggregateDurationMeasure {

public Sum(TimeUnit clockUnit, LongSupplier clock, TimeMeasure recorder) {
super(clockUnit, clock, recorder);
}
Expand All @@ -86,7 +84,5 @@ public void recordResult() {
}

long sum = 0;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/
@FunctionalInterface
public interface TimeMeasure {

/**
* Records a raw time measurement. Useful for recording
* durations from existing timestamps.
Expand All @@ -29,15 +28,14 @@ public interface TimeMeasure {
* @return wrapped measure
* @param <T> type of the wrapped measure
*/
default <T> T wrap(Function<TimeMeasure, T> enabledFunc, T disabledFallback) {
default<T> T wrap(Function<TimeMeasure, T> enabledFunc, T disabledFallback) {
return enabledFunc.apply(this);
}

/**
* A default implementation that does nothing and may be eliminated at runtime
*/
static final TimeMeasure DISABLED = new TimeMeasure() {

@Override
public <T> T wrap(Function<TimeMeasure, T> enabledFunc, T disabledFallback) {
return disabledFallback;
Expand All @@ -48,5 +46,4 @@ public void recordTime(TimeUnit unit, long time) {
// no-op
}
};

}
1 change: 0 additions & 1 deletion chartfx-chart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,3 @@
</build>

</project>

41 changes: 17 additions & 24 deletions chartfx-chart/src/main/java/io/fair_acc/chartfx/Chart.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

import io.fair_acc.bench.DurationMeasure;
import io.fair_acc.bench.Measurable;
import io.fair_acc.bench.MeasurementRecorder;
import io.fair_acc.chartfx.ui.css.*;
import io.fair_acc.chartfx.ui.layout.TitleLabel;
import io.fair_acc.chartfx.ui.layout.ChartPane;
import io.fair_acc.chartfx.ui.layout.FullSizePane;
import io.fair_acc.chartfx.ui.*;
import io.fair_acc.chartfx.utils.PropUtil;
import io.fair_acc.dataset.AxisDescription;
import io.fair_acc.dataset.events.EventSource;
import io.fair_acc.dataset.events.BitState;
import io.fair_acc.dataset.events.ChartBits;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.application.Platform;
Expand All @@ -35,6 +22,9 @@
import javafx.scene.layout.*;
import javafx.util.Duration;

import io.fair_acc.bench.DurationMeasure;
import io.fair_acc.bench.Measurable;
import io.fair_acc.bench.MeasurementRecorder;
import io.fair_acc.chartfx.axes.Axis;
import io.fair_acc.chartfx.axes.spi.AbstractAxis;
import io.fair_acc.chartfx.axes.spi.DefaultNumericAxis;
Expand All @@ -43,9 +33,19 @@
import io.fair_acc.chartfx.plugins.ChartPlugin;
import io.fair_acc.chartfx.renderer.Renderer;
import io.fair_acc.chartfx.renderer.spi.LabelledMarkerRenderer;
import io.fair_acc.chartfx.ui.*;
import io.fair_acc.chartfx.ui.css.*;
import io.fair_acc.chartfx.ui.geometry.Side;
import io.fair_acc.chartfx.ui.layout.ChartPane;
import io.fair_acc.chartfx.ui.layout.FullSizePane;
import io.fair_acc.chartfx.ui.layout.TitleLabel;
import io.fair_acc.chartfx.utils.FXUtils;
import io.fair_acc.chartfx.utils.PropUtil;
import io.fair_acc.dataset.AxisDescription;
import io.fair_acc.dataset.DataSet;
import io.fair_acc.dataset.events.BitState;
import io.fair_acc.dataset.events.ChartBits;
import io.fair_acc.dataset.events.EventSource;
import io.fair_acc.dataset.utils.AssertUtils;
import io.fair_acc.dataset.utils.NoDuplicatesList;

Expand All @@ -61,20 +61,19 @@
* @author hbraeun, rstein, major refactoring, re-implementation and re-design
*/
public abstract class Chart extends Region implements EventSource, Measurable {

// The chart has two different states, one that includes everything and is only ever on the JavaFX thread, and
// a thread-safe one that receives dataSet updates and forwards them on the JavaFX thread.
protected final BitState state = BitState.initDirty(this, BitState.ALL_BITS)
.addChangeListener(ChartBits.ChartLayout, (src, bits) -> super.requestLayout())
.addChangeListener(ChartBits.KnownMask, (src, bits) -> ensureJavaFxPulse());
.addChangeListener(ChartBits.ChartLayout, (src, bits) -> super.requestLayout())
.addChangeListener(ChartBits.KnownMask, (src, bits) -> ensureJavaFxPulse());

// DataSets are the only part that can potentially get updated from different threads, so we use a separate
// state object that can handle multithreaded updates. The state always represents the current aggregate state
// of all datasets, but the JavaFX change listener may not forward the dirty bits to the chart until the next frame.
// This creates a race condition where delta bits that are already cleared in the datasets may end up dirtying the
// chart and trigger an unnecessary redraw. To avoid this issue we ignore the delta and pass the current state.
protected final BitState dataSetState = BitState.initDirtyMultiThreaded(this, BitState.ALL_BITS)
.addChangeListener(FXUtils.runOnFxThread((src, deltaBits) -> state.setDirty(src.getBits())));
.addChangeListener(FXUtils.runOnFxThread((src, deltaBits) -> state.setDirty(src.getBits())));

private static final String CHART_CSS = Objects.requireNonNull(Chart.class.getResource("chart.css")).toExternalForm();
private static final CssPropertyFactory<Chart> CSS = new CssPropertyFactory<>(Region.getClassCssMetaData());
Expand Down Expand Up @@ -110,7 +109,7 @@ public abstract class Chart extends Region implements EventSource, Measurable {

// Outer chart elements
protected final ChartPane measurementPane = StyleUtil.addStyles(new ChartPane(), "chart-measurement-pane");
protected final ChartPane titleLegendPane = StyleUtil.addStyles(new ChartPane(),"chart-title-pane", "chart-legend-pane");
protected final ChartPane titleLegendPane = StyleUtil.addStyles(new ChartPane(), "chart-title-pane", "chart-legend-pane");
protected final ChartPane axesAndCanvasPane = StyleUtil.addStyles(new ChartPane(), "chart-content");

// Outer area with hidden toolbars
Expand All @@ -123,7 +122,6 @@ public abstract class Chart extends Region implements EventSource, Measurable {

protected final TitleLabel titleLabel = StyleUtil.addStyles(new TitleLabel(), "chart-title");


// Listeners
protected final ListChangeListener<Renderer> rendererChangeListener = this::rendererChanged;
protected final ListChangeListener<Axis> axesChangeListenerLocal = this::axesChangedLocal;
Expand Down Expand Up @@ -275,7 +273,6 @@ public Chart(Axis... axes) {
measurementPane.addCenter(titleLegendPane);
menuPane.setContent(measurementPane);
getChildren().add(menuPane);

}

@Override
Expand Down Expand Up @@ -860,7 +857,6 @@ protected void pluginsChanged(final ListChangeListener.Change<? extends ChartPlu
protected void rendererChanged(final ListChangeListener.Change<? extends Renderer> change) {
FXUtils.assertJavaFxThread();
while (change.next()) {

// handle added renderer
for (Renderer renderer : change.getAddedSubList()) {
for (DataSet dataset : renderer.getDatasets()) {
Expand All @@ -883,15 +879,13 @@ protected void rendererChanged(final ListChangeListener.Change<? extends Rendere
styleableNodes.getChildren().remove(renderer.getNode());
renderer.setChart(null);
}

}

updateDataSetIndices();

// reset change to allow derived classes to add additional listeners to renderer changes
change.reset();
fireInvalidated(ChartBits.ChartLayout, ChartBits.ChartRenderers, ChartBits.ChartLegend);

}

/**
Expand Down Expand Up @@ -964,5 +958,4 @@ public void setRecorder(MeasurementRecorder recorder) {
private DurationMeasure benchUpdateAxisRange = DurationMeasure.DISABLED;
private DurationMeasure benchDrawAxes = DurationMeasure.DISABLED;
private DurationMeasure benchDrawCanvas = DurationMeasure.DISABLED;

}
31 changes: 9 additions & 22 deletions chartfx-chart/src/main/java/io/fair_acc/chartfx/XYChart.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package io.fair_acc.chartfx;

import io.fair_acc.chartfx.axes.spi.AxisRange;
import io.fair_acc.chartfx.plugins.ChartPlugin;
import io.fair_acc.chartfx.renderer.spi.ErrorDataSetRenderer;
import io.fair_acc.chartfx.ui.css.DataSetNode;
import io.fair_acc.chartfx.utils.PropUtil;
import io.fair_acc.bench.MeasurementRecorder;
import io.fair_acc.dataset.events.ChartBits;
import io.fair_acc.bench.DurationMeasure;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
Expand All @@ -18,14 +10,22 @@
import javafx.geometry.Orientation;
import javafx.scene.canvas.GraphicsContext;

import io.fair_acc.bench.DurationMeasure;
import io.fair_acc.bench.MeasurementRecorder;
import io.fair_acc.chartfx.axes.Axis;
import io.fair_acc.chartfx.axes.spi.AxisRange;
import io.fair_acc.chartfx.plugins.ChartPlugin;
import io.fair_acc.chartfx.renderer.PolarTickStep;
import io.fair_acc.chartfx.renderer.Renderer;
import io.fair_acc.chartfx.renderer.spi.ErrorDataSetRenderer;
import io.fair_acc.chartfx.renderer.spi.GridRenderer;
import io.fair_acc.chartfx.renderer.spi.LabelledMarkerRenderer;
import io.fair_acc.chartfx.ui.css.DataSetNode;
import io.fair_acc.chartfx.ui.geometry.Side;
import io.fair_acc.chartfx.utils.FXUtils;
import io.fair_acc.chartfx.utils.PropUtil;
import io.fair_acc.dataset.DataSet;
import io.fair_acc.dataset.events.ChartBits;
import io.fair_acc.dataset.utils.AssertUtils;

/**
Expand Down Expand Up @@ -204,19 +204,10 @@ public void updateAxisRange() {
// Update the axis definitions of all datasets. We do it here, so we can make better
// use of multi-threading. The datasets are already locked, so we can use a parallel
// stream without extra synchronization.
getRenderers().stream()
.flatMap(renderer -> renderer.getDatasetNodes().stream())
.filter(DataSetNode::isVisible)
.map(DataSetNode::getDataSet)
.filter(ds -> ds.getBitState().isDirty(ChartBits.DataSetData, ChartBits.DataSetRange))
.distinct()
.forEach(dataset -> dataset.getAxisDescriptions().parallelStream()
.filter(axisD -> !axisD.isDefined() || axisD.getBitState().isDirty())
.forEach(axisDescription -> dataset.recomputeLimits(axisDescription.getDimIndex())));
getRenderers().stream().flatMap(renderer -> renderer.getDatasetNodes().stream()).filter(DataSetNode::isVisible).map(DataSetNode::getDataSet).filter(ds -> ds.getBitState().isDirty(ChartBits.DataSetData, ChartBits.DataSetRange)).distinct().forEach(dataset -> dataset.getAxisDescriptions().parallelStream().filter(axisD -> !axisD.isDefined() || axisD.getBitState().isDirty()).forEach(axisDescription -> dataset.recomputeLimits(axisDescription.getDimIndex())));

// Update each axis
for (Axis axis : getAxes()) {

// Determine the current range
axisRange.clear();
for (Renderer renderer : getRenderers()) {
Expand All @@ -237,9 +228,7 @@ public void updateAxisRange() {
if (changed && (axis.isAutoRanging() || axis.isAutoGrowRanging())) {
axis.invalidateRange();
}

}

}

private final AxisRange axisRange = new AxisRange();
Expand Down Expand Up @@ -295,7 +284,6 @@ protected void redrawCanvas() {
gridRenderer.render();
benchDrawGrid.stop();
}

}

/**
Expand Down Expand Up @@ -341,5 +329,4 @@ public void setRecorder(MeasurementRecorder recorder) {

private DurationMeasure benchDrawGrid = DurationMeasure.DISABLED;
private DurationMeasure benchDrawData = DurationMeasure.DISABLED;

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package io.fair_acc.chartfx.axes;

import io.fair_acc.bench.Measurable;
import io.fair_acc.chartfx.ui.css.LineStyle;
import io.fair_acc.chartfx.ui.css.TextStyle;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
Expand All @@ -12,9 +9,12 @@
import javafx.scene.canvas.GraphicsContext;
import javafx.util.StringConverter;

import io.fair_acc.bench.Measurable;
import io.fair_acc.chartfx.axes.spi.AxisRange;
import io.fair_acc.chartfx.axes.spi.MetricPrefix;
import io.fair_acc.chartfx.axes.spi.TickMark;
import io.fair_acc.chartfx.ui.css.LineStyle;
import io.fair_acc.chartfx.ui.css.TextStyle;
import io.fair_acc.chartfx.ui.geometry.Side;
import io.fair_acc.dataset.AxisDescription;

Expand Down Expand Up @@ -362,6 +362,5 @@ public interface Axis extends AxisDescription, Measurable.EmptyDefault {
* This is needed e.g. when plugins adjust the axes and at the same time need to perform
* transformations with the modified ranges.
*/
default void updateCachedTransforms() {};

default void updateCachedTransforms(){};
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.fair_acc.chartfx.axes;

import javafx.beans.property.ObjectProperty;

import io.fair_acc.chartfx.axes.spi.format.DefaultTickUnitSupplier;
import io.fair_acc.dataset.spi.fastutil.DoubleArrayList;
import javafx.beans.property.ObjectProperty;

/**
* @author rstein
Expand Down Expand Up @@ -56,10 +57,9 @@ public interface AxisLabelFormatter {

/**
* Called just before new TickMarks are computed
*
*
* @param newMajorTickMarks for which the labels should be computed
* @param unitScaling scaling applied to the raw data set units
*/
void updateFormatter(DoubleArrayList newMajorTickMarks, double unitScaling);

}
Loading

0 comments on commit dcf44cd

Please sign in to comment.