Skip to content

Commit

Permalink
Fixed #302 - Label Marker - add an option to display the desciption
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Sep 12, 2022
1 parent 545832c commit 63ca2f8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public class ChartSettings implements IChartSettings {
private Color colorPlotCenterMarker;
private boolean showLegendMarker = false;
private Color colorLegendMarker;
boolean useSeriesLabelDescription = false; // Id is used by default.
private boolean showAxisZeroMarker = false;
private Color colorAxisZeroMarker;
private boolean showSeriesLabelMarker = false;
Expand Down Expand Up @@ -623,6 +624,18 @@ public void setColorSeriesLabelMarker(Color colorSeriesLabelMarker) {
this.colorSeriesLabelMarker = colorSeriesLabelMarker;
}

@Override
public boolean isUseSeriesLabelDescription() {

return useSeriesLabelDescription;
}

@Override
public void setUseSeriesLabelDescription(boolean useSeriesLabelDescription) {

this.useSeriesLabelDescription = useSeriesLabelDescription;
}

@Override
public boolean isCreateMenu() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2020 Lablicate GmbH.
* Copyright (c) 2017, 2022 Lablicate GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -179,6 +179,10 @@ public interface IChartSettings {

void setShowSeriesLabelMarker(boolean showSeriesLabelMarker);

boolean isUseSeriesLabelDescription();

void setUseSeriesLabelDescription(boolean useSeriesLabelDescription);

Color getColorSeriesLabelMarker();

void setColorSeriesLabelMarker(Color colorSeriesLabelMarker);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ private void setSeriesLabelMarker() {
//
seriesLabelMarker = new SeriesLabelMarker(baseChart);
seriesLabelMarker.setForegroundColor(chartSettings.getColorSeriesLabelMarker());
seriesLabelMarker.setUseDescription(chartSettings.isUseSeriesLabelDescription());
plotArea.addCustomPaintListener(seriesLabelMarker);
//
if(chartSettings.isShowSeriesLabelMarker()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2020 Lablicate GmbH.
* Copyright (c) 2017, 2022 Lablicate GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -24,10 +24,18 @@

public class SeriesLabelMarker extends AbstractBaseChartPaintListener implements IBaseChartPaintListener {

private boolean useDescription = false;

public SeriesLabelMarker(BaseChart baseChart) {

super(baseChart);
}

public void setUseDescription(boolean useDescription) {

this.useDescription = useDescription;
}

@Override
public void paintControl(PaintEvent e) {

Expand All @@ -36,8 +44,9 @@ public void paintControl(PaintEvent e) {
ISeriesSet seriesSet = baseChart.getSeriesSet();
ISeries<?>[] series = seriesSet.getSeries();
for(ISeries<?> serie : series) {
String label = serie.getId();
ISeriesSettings seriesSettings = baseChart.getSeriesSettings(label);
String id = serie.getId();
String label = useDescription ? serie.getDescription() : id;
ISeriesSettings seriesSettings = baseChart.getSeriesSettings(id);
if(seriesSettings.isVisible()) {
/*
* Only draw is series is visible.
Expand All @@ -59,4 +68,4 @@ public void paintControl(PaintEvent e) {
}
}
}
}
}

0 comments on commit 63ca2f8

Please sign in to comment.