Skip to content

Commit

Permalink
Refactoring of ContourDataSetRenderer
Browse files Browse the repository at this point in the history
* New Contour plot performance sample: WaterfallPerformanceSample
* modified caching of ticks and layoutChildren in AbstractAxis
  * solves #46
* refactoring of multi-threading and point reduction parameters
  * added 2D contour data reduction algorithm
  * are now in common parent for both the ErrorDataSetRenderer and
    ContourDataSetRenderer (<-> minimisation of duplicate code for getters,
    setters and property API method calls)
* renamed+moved 'Cache'->'ArrayCache' & added new generic Cache<K,V>
  * added corresponding JUnit tests
* added/updated generic timed/limited cache HashMap implementation
  * implementation courtesy @HanSolo
* removed getDataCount() & ..(int dimIndex) overrides in DataSet2D
  * follow-up of getDataCount() -> getDataCount(int) in default DS impls.
    N.B rationale: getDataCount(int) must be overwritten in 2- and
    higher-dime datasets since they may be different for each dimension
* new ColorGradient function to return cached interpol. ([0,1]) colours
  * added corresponding JUnit tests
* changed vertical Y axis in TestDataSetSource
  * newest samples appear at 0 seconds and older ones have negative values
* minimised DataSet3D::getZ() usage and fixed y-inversion for fast contour
  • Loading branch information
RalphSteinhagen committed Jan 27, 2020
1 parent b18768b commit 8d289df
Show file tree
Hide file tree
Showing 58 changed files with 5,969 additions and 2,354 deletions.
543 changes: 272 additions & 271 deletions chartfx-chart/src/main/java/de/gsi/chart/Chart.java

Large diffs are not rendered by default.

399 changes: 199 additions & 200 deletions chartfx-chart/src/main/java/de/gsi/chart/XYChart.java

Large diffs are not rendered by default.

223 changes: 133 additions & 90 deletions chartfx-chart/src/main/java/de/gsi/chart/axes/spi/AbstractAxis.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import de.gsi.chart.Chart;
import de.gsi.chart.axes.Axis;
import de.gsi.chart.axes.AxisLabelOverlapPolicy;
import de.gsi.chart.ui.css.StylishBooleanProperty;
import de.gsi.chart.ui.css.StylishDoubleProperty;
import de.gsi.chart.ui.css.StylishIntegerProperty;
import de.gsi.chart.ui.css.StylishObjectProperty;
import de.gsi.chart.ui.css.StylishStringProperty;
import de.gsi.chart.ui.geometry.Side;
import de.gsi.dataset.event.AxisChangeEvent;
import de.gsi.dataset.event.EventListener;
import de.gsi.dataset.event.UpdateEvent;
import de.gsi.dataset.utils.NoDuplicatesList;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
Expand Down Expand Up @@ -53,6 +40,20 @@
import javafx.scene.text.TextAlignment;
import javafx.util.StringConverter;

import de.gsi.chart.Chart;
import de.gsi.chart.axes.Axis;
import de.gsi.chart.axes.AxisLabelOverlapPolicy;
import de.gsi.chart.ui.css.StylishBooleanProperty;
import de.gsi.chart.ui.css.StylishDoubleProperty;
import de.gsi.chart.ui.css.StylishIntegerProperty;
import de.gsi.chart.ui.css.StylishObjectProperty;
import de.gsi.chart.ui.css.StylishStringProperty;
import de.gsi.chart.ui.geometry.Side;
import de.gsi.dataset.event.AxisChangeEvent;
import de.gsi.dataset.event.EventListener;
import de.gsi.dataset.event.UpdateEvent;
import de.gsi.dataset.utils.NoDuplicatesList;

/**
* Class containing the properties, getters and setters for the AbstractNumericAxis class
* <p>
Expand Down Expand Up @@ -104,10 +105,15 @@ public abstract class AbstractAxisParameter extends Pane implements Axis {
* computed), ALSO add maybe a zoom range (ie. limited by user-set/auto-range range)
*/
protected double oldAxisLength = -1;

protected boolean rangeValid;
protected boolean measureInvalid;
protected boolean tickLabelsVisibleInvalid;
protected double oldAxisMin = -Double.MAX_VALUE;
protected double oldAxisMax = -Double.MAX_VALUE;
protected double oldTickUnit = -Double.MAX_VALUE;

protected BooleanProperty valid = new SimpleBooleanProperty(this, "valid", false);
protected final ObservableList<Double> majorTickMarkValues = FXCollections
.observableArrayList(new NoDuplicatesList<Double>());
protected final ObservableList<Double> minorTickMarkValues = FXCollections
.observableArrayList(new NoDuplicatesList<Double>());
protected final ObservableList<TickMark> majorTickMarks = FXCollections
.observableArrayList(new NoDuplicatesList<TickMark>());
protected final ObservableList<TickMark> minorTickMarks = FXCollections
Expand Down Expand Up @@ -208,11 +214,11 @@ public void set(final double value) {

/** true if tick mark labels should be displayed */
private final BooleanProperty tickLabelsVisible = new StylishBooleanProperty(
StyleableProperties.TICK_LABELS_VISIBLE, this, "tickLabelsVisible", true, () -> { // update // tick
for (final TickMark tick : majorTickMarks) {
StyleableProperties.TICK_LABELS_VISIBLE, this, "tickLabelsVisible", true, () -> { // update tick
for (final TickMark tick : getTickMarks()) {
tick.setVisible(AbstractAxisParameter.this.tickLabelsVisible.get());
}
tickLabelsVisibleInvalid = true;
invalidate();
invokeListener(new AxisChangeEvent(this));
});

Expand All @@ -238,7 +244,7 @@ public void set(final double value) {
for (final TickMark tm : getTickMarks()) {
tm.setFont(f);
}
measureInvalid = true;
invalidate();
invokeListener(new AxisChangeEvent(this));
});

Expand Down Expand Up @@ -283,8 +289,8 @@ public void set(final double value) {

@Override
protected void invalidated() {
invalidate();
invokeListener(new AxisChangeEvent(AbstractAxisParameter.this));
measureInvalid = true;
}
};

Expand Down Expand Up @@ -335,7 +341,7 @@ public String getName() {

@Override
protected void invalidated() {
invalidateRange();
invalidate();
invokeListener(new AxisChangeEvent(AbstractAxisParameter.this));
}
};
Expand Down Expand Up @@ -368,15 +374,13 @@ protected void invalidated() {
private final BooleanProperty autoGrowRanging = new StylishBooleanProperty(StyleableProperties.AUTO_GROW_RANGING,
this, "autoGrowRanging", false, this::requestAxisLayout);

protected boolean isInvertedAxis = false; // internal use (for performance

// reason)
protected boolean isInvertedAxis = false; // internal use (for performance reason)
private final BooleanProperty invertAxis = new SimpleBooleanProperty(this, "invertAxis", false) {

@Override
protected void invalidated() {
isInvertedAxis = get();
invalidateRange();
invalidate();
// layoutChildren();
// layout();
invokeListener(new AxisChangeEvent(AbstractAxisParameter.this));
Expand All @@ -394,7 +398,7 @@ protected void invalidated() {
} else {
setMinorTickCount(AbstractAxisParameter.DEFAULT_MINOR_TICK_COUNT);
}
invalidateRange();
invalidate();
// layoutChildren();
// layout();
invokeListener(new AxisChangeEvent(AbstractAxisParameter.this));
Expand Down Expand Up @@ -455,7 +459,7 @@ protected void invalidated() {
if (isAutoRanging() || isAutoGrowRanging()) {
return;
}
invalidateRange();
invalidate();
invokeListener(new AxisChangeEvent(AbstractAxisParameter.this));
}
};
Expand Down Expand Up @@ -515,12 +519,16 @@ public AbstractAxisParameter() {
if (!isAutoRanging() && !isAutoGrowRanging()) {
invokeListener(new AxisChangeEvent(this));
}
invalidate();
};
minProperty().addListener(userLimitChangeListener);
maxProperty().addListener(userLimitChangeListener);
majorTickStyle.applyCss();
minorTickStyle.applyCss();
axisLabel.applyCss();

widthProperty().addListener((ch, o, n) -> invalidate());
heightProperty().addListener((ch, o, n) -> invalidate());
}

@Override
Expand Down Expand Up @@ -747,6 +755,13 @@ public ObservableList<TickMark> getMinorTickMarks() {
return minorTickMarks;
}

/**
* @return observable list containing of each minor TickMark values on this axis
*/
public ObservableList<Double> getMinorTickMarkValues() {
return minorTickMarkValues;
}

/**
* @return the minorTickStyle for custom user-code based styling
*/
Expand Down Expand Up @@ -822,6 +837,13 @@ public ObservableList<TickMark> getTickMarks() {
return majorTickMarks;
}

/**
* @return observable list containing of each major TickMark values on this axis
*/
public ObservableList<Double> getTickMarkValues() {
return majorTickMarkValues;
}

/**
* Returns tick unit value expressed in data units.
*
Expand All @@ -847,6 +869,15 @@ public AxisRange getUserRange() {
return userRange;
}

/**
* Mark the current axis invalid, this will cause anything that depends on the axis range or physical size to be
* recalculated on the next
* layout iteration.
*/
public void invalidate() {
valid.set(false);
}

/**
* This is {@code true} when the axis labels and data point order should be inverted
*
Expand Down Expand Up @@ -963,6 +994,13 @@ public boolean isTimeAxis() {
return timeAxis.get();
}

/**
* @return true if current axis range and physical size calculations are valid
*/
public boolean isValid() {
return valid.get();
}

public IntegerProperty maxMajorTickLabelCountProperty() {
return maxMajorTickLabelCount;
}
Expand Down Expand Up @@ -1012,6 +1050,7 @@ public boolean set(final double min, final double max) {
autoNotification().set(oldState);
final boolean changed = (oldMin != min) || (oldMax != max);
if (changed) {
invalidate();
invokeListener(new AxisChangeEvent(this));
}
return changed;
Expand Down Expand Up @@ -1057,7 +1096,7 @@ public void setAnimated(final boolean value) {
public void setAnimationDuration(final int value) {
animationDurationProperty().set(value);
}

/**
* This is true when the axis determines its range from the data automatically and grows it if necessary
*
Expand All @@ -1067,6 +1106,7 @@ public void setAnimationDuration(final int value) {
public void setAutoGrowRanging(final boolean state) {
if (state) {
setAutoRanging(false);
invalidate();
requestAxisLayout();
}
autoGrowRanging.set(state);
Expand Down Expand Up @@ -1231,6 +1271,8 @@ public void setUnitScaling(final MetricPrefix prefix) {
unitScaling.set(prefix.getPower());
}

// -------------- UPDATER ROUTINE PROTOTYPES

@Override
public ObjectProperty<Side> sideProperty() {
return side;
Expand All @@ -1240,12 +1282,12 @@ public ObjectProperty<Paint> tickLabelFillProperty() {
return tickLabelFill;
}

// -------------- UPDATER ROUTINE PROTOTYPES

public ObjectProperty<Font> tickLabelFontProperty() {
return tickLabelFont;
}

// -------------- STYLESHEET HANDLING

public ObjectProperty<StringConverter<Number>> tickLabelFormatterProperty() {
return tickLabelFormatter;
}
Expand All @@ -1254,8 +1296,6 @@ public DoubleProperty tickLabelGapProperty() {
return tickLabelGap;
}

// -------------- STYLESHEET HANDLING

public DoubleProperty tickLabelRotationProperty() {
return tickLabelRotation;
}
Expand Down Expand Up @@ -1318,14 +1358,6 @@ protected double decadeRange() {
return Math.log10(range);
}

/**
* Mark the current range invalid, this will cause anything that depends on the range to be recalculated on the next
* layout.
*/
protected void invalidateRange() {
rangeValid = false;
}

protected void setScale(final double scale) {
this.scale.set(scale);
}
Expand All @@ -1340,7 +1372,7 @@ protected void updateAxisLabelAndUnit() {

final String axisPrefix = MetricPrefix.getShortPrefix(getUnitScaling());
if ((axisUnit == null) && (axisPrefix != null)) {
axisUnit = " a.u.";
axisUnit = "a.u.";
}

if (axisUnit == null) {
Expand All @@ -1349,7 +1381,8 @@ protected void updateAxisLabelAndUnit() {
axisLabel.setText(new StringBuilder().append(axisPrimaryLabel).append(" [").append(axisPrefix)
.append(axisUnit).append("]").toString());
}
axisLabel.applyCss();
// axisLabel.applyCss();
invalidate();
}

protected void updateScaleAndUnitPrefix() {
Expand All @@ -1371,6 +1404,15 @@ protected void updateScaleAndUnitPrefix() {

}

/**
* valid flag property.
* This will cause anything that depends on the axis range or physical size to be recalculated on the next layout
* iteration.
*/
protected BooleanProperty validProperty() {
return valid;
}

ReadOnlyDoubleWrapper scalePropertyImpl() {
return scale;
}
Expand All @@ -1397,8 +1439,7 @@ private static class StyleableProperties {
private static final CssMetaData<AbstractAxisParameter, Side> SIDE = new CssMetaData<>("-fx-side",
new EnumConverter<>(Side.class)) {

@SuppressWarnings("unchecked") // sideProperty() is
// StyleableProperty<Side>
@SuppressWarnings("unchecked") // sideProperty() is StyleableProperty<Side>
@Override
public StyleableProperty<Side> getStyleableProperty(final AbstractAxisParameter n) {
return (StyleableProperty<Side>) n.sideProperty();
Expand Down Expand Up @@ -1520,8 +1561,7 @@ public boolean isSettable(final AbstractAxisParameter n) {
private static final CssMetaData<AbstractAxisParameter, Paint> TICK_LABEL_FILL = new CssMetaData<>(
"-fx-tick-label-fill", PaintConverter.getInstance(), Color.BLACK) {

@SuppressWarnings("unchecked") // tickLabelFillProperty() is
// StyleableProperty<Paint>
@SuppressWarnings("unchecked") // tickLabelFillProperty() is StyleableProperty<Paint>
@Override
public StyleableProperty<Paint> getStyleableProperty(final AbstractAxisParameter n) {
return (StyleableProperty<Paint>) n.tickLabelFillProperty();
Expand Down

0 comments on commit 8d289df

Please sign in to comment.