Skip to content

Commit 07e3d7b

Browse files
committed
Add dashed line support
1 parent 741c07b commit 07e3d7b

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/main/java/ovh/neziw/visualizer/RegressionChart.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,15 @@ private void updateRendererSettings() {
9090
this.renderer.setSeriesLinesVisible(1, true);
9191
this.renderer.setSeriesShapesVisible(1, false);
9292
this.renderer.setSeriesPaint(1, this.settings.getRegressionLineColor());
93-
this.renderer.setSeriesStroke(1, new BasicStroke(2.0f));
93+
94+
final BasicStroke stroke;
95+
if (this.settings.isDashedLine()) {
96+
stroke = new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
97+
10.0f, new float[]{5.0f, 5.0f}, 0.0f);
98+
} else {
99+
stroke = new BasicStroke(2.0f);
100+
}
101+
this.renderer.setSeriesStroke(1, stroke);
94102
}
95103

96104
public void applySettings() {

src/main/java/ovh/neziw/visualizer/gui/ChartSettings.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class ChartSettings {
3232
private Color dataPointColor = Color.BLUE;
3333
private Color regressionLineColor = Color.RED;
3434
private Shape dataPointShape = new java.awt.geom.Ellipse2D.Double(-3, -3, 6, 6);
35+
private boolean dashedLine = false;
3536

3637
public double getPaddingPercent() {
3738
return this.paddingPercent;
@@ -64,5 +65,13 @@ public Shape getDataPointShape() {
6465
public void setDataPointShape(final Shape dataPointShape) {
6566
this.dataPointShape = dataPointShape;
6667
}
68+
69+
public boolean isDashedLine() {
70+
return this.dashedLine;
71+
}
72+
73+
public void setDashedLine(final boolean dashedLine) {
74+
this.dashedLine = dashedLine;
75+
}
6776
}
6877

src/main/java/ovh/neziw/visualizer/gui/ChartSettingsPanel.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.awt.Color;
2727
import java.awt.Shape;
2828
import javax.swing.JButton;
29+
import javax.swing.JCheckBox;
2930
import javax.swing.JColorChooser;
3031
import javax.swing.JLabel;
3132
import javax.swing.JOptionPane;
@@ -119,6 +120,14 @@ private void setupPanel() {
119120

120121
final JButton shapeButton = this.createShapeButton();
121122
this.add(shapeButton);
123+
124+
final JCheckBox dashedLineCheckBox = new JCheckBox("Linia przerywana",
125+
this.settings.isDashedLine());
126+
dashedLineCheckBox.addActionListener(e -> {
127+
this.settings.setDashedLine(dashedLineCheckBox.isSelected());
128+
this.onSettingsChanged.run();
129+
});
130+
this.add(dashedLineCheckBox);
122131
}
123132

124133
private JButton createColorButton(final String text,

0 commit comments

Comments
 (0)