Skip to content

Commit

Permalink
removed duplicate styling properties from axis
Browse files Browse the repository at this point in the history
  • Loading branch information
ennerf committed Aug 8, 2023
1 parent 2a5d513 commit f2e05d2
Show file tree
Hide file tree
Showing 20 changed files with 112 additions and 212 deletions.
22 changes: 17 additions & 5 deletions chartfx-chart/src/main/java/io/fair_acc/chartfx/axes/Axis.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import io.fair_acc.chartfx.ui.css.LineStyle;
import io.fair_acc.chartfx.ui.css.TextStyle;
import io.fair_acc.dataset.events.BitState;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
Expand Down Expand Up @@ -112,17 +114,27 @@ public interface Axis extends AxisDescription {
*/
Side getSide();

StringConverter<Number> getTickLabelFormatter();

/**
* @return the fill for all tick labels
* @return the style for the axis label
*/
Paint getTickLabelFill();
TextStyle getAxisLabel();

/**
* @return the font for all tick labels
* @return the style for all tick labels
*/
Font getTickLabelFont();
TextStyle getTickLabelStyle();

StringConverter<Number> getTickLabelFormatter();
/**
* @return the style for all major tick marks
*/
LineStyle getMajorTickStyle();

/**
* @return the style for all minor tick marks
*/
LineStyle getMinorTickStyle();

/**
* @return the gap between the tick mark lines and the chart canvas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import javafx.scene.CacheHint;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
Expand Down Expand Up @@ -83,11 +81,6 @@ protected void invalidated() {
};

protected AbstractAxis() {
super();
// Can we remove these? Axes without a chart don't work anymore.
VBox.setVgrow(this, Priority.ALWAYS);
HBox.setHgrow(this, Priority.ALWAYS);

// Canvas settings
setMouseTransparent(false);
setPickOnBounds(true);
Expand All @@ -100,15 +93,11 @@ protected AbstractAxis() {
getChildren().add(canvas);

// set default axis title/label alignment
updateTickLabelAlignment();
updateAxisLabelAlignment();
sideProperty().addListener((ch, o, n) -> {
updateAxisLabelAlignment();
updateTickLabelAlignment();
});
tickLabelRotationProperty().addListener((ch, o, n) -> {
updateTickLabelAlignment();
});
PropUtil.initAndRunOnChange(this::updateAxisLabelAlignment,
sideProperty());
PropUtil.initAndRunOnChange(this::updateTickLabelAlignment,
sideProperty(),
getTickLabelStyle().rotateProperty());
}

protected AbstractAxis(final double lowerBound, final double upperBound) {
Expand Down Expand Up @@ -920,7 +909,7 @@ public void drawAxis() {

}

protected double measureTickMarkLength(final Double major) {
protected double measureTickMarkLength(final double major) {
// N.B. this is a known performance hot-spot -> start optimisation here
tmpTickMark.setValue(major, getTickMarkLabel(major));
return getSide().isHorizontal() ? tmpTickMark.getWidth() : tmpTickMark.getHeight();
Expand Down
Loading

0 comments on commit f2e05d2

Please sign in to comment.