Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/main/java/com/visualticks/BaseVisualTicksOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public abstract class BaseVisualTicksOverlay extends Overlay
Expand Down Expand Up @@ -51,6 +52,25 @@ public void onConfigChanged() {
protected abstract Color getCurrentTickTextColour();
protected abstract TickShape getTickShape();
protected abstract int getTickArc();
protected abstract boolean shouldShowCustomText();
protected abstract String getCustomTickText();

protected String[] customTickText;

protected String getTickText(int tickIndex){
String tickText = String.valueOf(tickIndex + 1);
if (shouldShowCustomText()){
if (customTickText.length > tickIndex){
tickText = customTickText[tickIndex];
}
}
return tickText;
}

protected void calculateCustomTickText() {
configChanged = false;
customTickText = Arrays.stream(getCustomTickText().split(",")).map(String::trim).toArray(String[]::new);
}

protected void calculateSizes(Graphics2D g) {
configChanged = false;
Expand All @@ -71,7 +91,7 @@ protected void calculateSizes(Graphics2D g) {
{
int boundingSize = shouldShowTickShape() ? shapeSize : 0;

String text = String.valueOf(i + 1);
String text = getTickText(i);
int textWidth = fm.stringWidth(text);
int textHeight = fm.getAscent();

Expand Down Expand Up @@ -107,6 +127,7 @@ protected void calculateSizes(Graphics2D g) {
public Dimension render(Graphics2D graphics)
{
if(configChanged) {
calculateCustomTickText();
calculateSizes(graphics);
}

Expand Down Expand Up @@ -135,7 +156,7 @@ public Dimension render(Graphics2D graphics)
}
if (shouldShowText()) {
graphics.setColor(i == getCurrentTick() ? getCurrentTickTextColour() : getTickTextColour());
graphics.drawString(String.valueOf(i + 1), tick.getFontX(), tick.getFontY());
graphics.drawString(getTickText(i), tick.getFontX(), tick.getFontY());
}
}

Expand Down
66 changes: 60 additions & 6 deletions src/main/java/com/visualticks/VisualTicksConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,30 @@ default Color currentTickTextColourOne() {
return new Color(41, 128, 185);
}

@ConfigItem(
keyName = "shouldShowCustomTextOne",
name = "Show custom text",
description = "Show custom text of the current tick",
section = tickSettings,
position = 14
)
default boolean shouldShowCustomTextOne() { return false; }

@ConfigItem(
keyName = "customTextOne",
name = "Custom text",
description = "Custom text to show on each tick, separated by commas",
section = tickSettings,
position = 15
)
default String customTextOne() { return "1,2,3"; }

@ConfigItem(
keyName = "horizontalSpacingOne",
name = "Horizontal spacing",
description = "The amount of space between ticks on the x-axis",
section = tickSettings,
position = 14
position = 16
)
@Range(min = -50)
default int horizontalSpacingOne() {
Expand All @@ -216,7 +234,7 @@ default int horizontalSpacingOne() {
name = "Vertical spacing",
description = "The amount of space between ticks on the y-axis",
section = tickSettings,
position = 15
position = 17
)
@Range(min = -50)
default int verticalSpacingOne() {
Expand Down Expand Up @@ -394,12 +412,30 @@ default Color currentTickTextColourTwo() {
return new Color(41, 128, 185);
}

@ConfigItem(
keyName = "shouldShowCustomTextTwo",
name = "Show custom text",
description = "Show custom text of the current tick",
section = tickSettingsTwo,
position = 14
)
default boolean shouldShowCustomTextTwo() { return false; }

@ConfigItem(
keyName = "customTextTwo",
name = "Custom text",
description = "Custom text to show on each tick, separated by commas",
section = tickSettingsTwo,
position = 15
)
default String customTextTwo() { return "1,2,3"; }

@ConfigItem(
keyName = "horizontalSpacingTwo",
name = "Horizontal spacing",
description = "The amount of space between ticks on the x-axis",
section = tickSettingsTwo,
position = 14
position = 16
)
@Range(min = -50)
default int horizontalSpacingTwo() {
Expand All @@ -411,7 +447,7 @@ default int horizontalSpacingTwo() {
name = "Vertical spacing",
description = "The amount of space between ticks on the y-axis",
section = tickSettingsTwo,
position = 15
position = 17
)
@Range(min = -50)
default int verticalSpacingTwo() {
Expand Down Expand Up @@ -589,12 +625,30 @@ default Color currentTickTextColourThree() {
return new Color(41, 128, 185);
}

@ConfigItem(
keyName = "shouldShowCustomTextThree",
name = "Show custom text",
description = "Show custom text of the current tick",
section = tickSettingsThree,
position = 14
)
default boolean shouldShowCustomTextThree() { return false; }

@ConfigItem(
keyName = "customTextThree",
name = "Custom text",
description = "Custom text to show on each tick, separated by commas",
section = tickSettingsThree,
position = 15
)
default String customTextThree() { return "1,2,3"; }

@ConfigItem(
keyName = "horizontalSpacingThree",
name = "Horizontal spacing",
description = "The amount of space between ticks on the x-axis",
section = tickSettingsThree,
position = 14
position = 16
)
@Range(min = -50)
default int horizontalSpacingThree() {
Expand All @@ -606,7 +660,7 @@ default int horizontalSpacingThree() {
name = "Vertical spacing",
description = "The amount of space between ticks on the y-axis",
section = tickSettingsThree,
position = 15
position = 17
)
@Range(min = -50)
default int verticalSpacingThree() {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/visualticks/VisualTicksOverlayOne.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ protected TickShape getTickShape() {
protected int getTickArc() {
return config.tickArcOne();
}

@Override
protected boolean shouldShowCustomText() { return config.shouldShowCustomTextOne(); }

@Override
protected String getCustomTickText() { return config.customTextOne(); }
}
6 changes: 6 additions & 0 deletions src/main/java/com/visualticks/VisualTicksOverlayThree.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ protected TickShape getTickShape() {
protected int getTickArc() {
return config.tickArcThree();
}

@Override
protected boolean shouldShowCustomText() { return config.shouldShowCustomTextThree(); }

@Override
protected String getCustomTickText() { return config.customTextThree(); }
}
6 changes: 6 additions & 0 deletions src/main/java/com/visualticks/VisualTicksOverlayTwo.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ protected TickShape getTickShape() {
protected int getTickArc() {
return config.tickArcTwo();
}

@Override
protected boolean shouldShowCustomText() { return config.shouldShowCustomTextTwo(); }

@Override
protected String getCustomTickText() { return config.customTextTwo(); }
}