Skip to content

Commit b6f436c

Browse files
committed
CategoryChart: remove generic parameter
1 parent fe51b7c commit b6f436c

24 files changed

Lines changed: 141 additions & 149 deletions

src/main/java/net/imagej/plot/BarSeries.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
*
4141
* @author Matthias Arzt
4242
*/
43-
public interface BarSeries<C> extends CategoryChartItem {
43+
public interface BarSeries extends CategoryChartItem {
4444

45-
Map<? extends C, Double> getValues();
45+
Map<?, Double> getValues();
4646

47-
void setValues(Map<? extends C, Double> Values);
47+
void setValues(Map<?, Double> Values);
4848

4949
ColorRGB getColor();
5050

src/main/java/net/imagej/plot/BoxSeries.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
*
4242
* @author Matthias Arzt
4343
*/
44-
public interface BoxSeries<C> extends CategoryChartItem {
44+
public interface BoxSeries extends CategoryChartItem {
4545

46-
Map<? extends C, ? extends Collection<Double>> getValues();
46+
Map<?, ? extends Collection<Double>> getValues();
4747

48-
void setValues(Map<? extends C, ? extends Collection<Double>> values);
48+
void setValues(Map<?, ? extends Collection<Double>> values);
4949

5050
ColorRGB getColor();
5151

src/main/java/net/imagej/plot/CategoryAxis.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@
3939
*
4040
* @author Matthias Arzt
4141
*/
42-
public interface CategoryAxis<C> extends Labeled {
42+
public interface CategoryAxis extends Labeled {
4343

4444
/**
4545
* Manually set the list of categories to be displayed in a {@link CategoryChart}.
4646
* The categories are displayed as ordered in the list, unless otherwise specified by calling the setOrder method.
4747
*/
48-
void setManualCategories(List<? extends C> categories);
48+
void setManualCategories(List<?> categories);
4949

5050
/** Clear the manually set list of categories. */
5151
void clearManualCategories();
5252

5353
boolean hasManualCategories();
5454

5555
/** Specify the order used to display the categories in a {@link CategoryChart}. */
56-
void setOrder(Comparator<? super C> comparator);
56+
void setOrder(Comparator<?> comparator);
5757

5858
void clearOrder();
5959

6060
/** Returns the list of categories to be displayed in the {@link CategoryChart}. */
61-
List<C> getCategories();
61+
List<Object> getCategories();
6262

6363
}

src/main/java/net/imagej/plot/CategoryChart.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,19 @@
4040
*
4141
* @author Matthias Arzt
4242
*/
43-
public interface CategoryChart<C> extends Plot {
43+
public interface CategoryChart extends Plot {
4444

45-
Class<C> getCategoryType();
45+
LineSeries addLineSeries();
4646

47-
LineSeries<C> addLineSeries();
47+
BarSeries addBarSeries();
4848

49-
BarSeries<C> addBarSeries();
50-
51-
BoxSeries<C> addBoxSeries();
49+
BoxSeries addBoxSeries();
5250

5351
NumberAxis numberAxis();
5452

55-
CategoryAxis<C> categoryAxis();
53+
CategoryAxis categoryAxis();
5654

57-
List<CategoryChartItem<C>> getItems();
55+
List<CategoryChartItem> getItems();
5856

5957
void setTitle(String title);
6058

src/main/java/net/imagej/plot/CategoryChartItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
*
3939
* @author Matthias Arzt
4040
*/
41-
public interface CategoryChartItem<C> extends Labeled {
41+
public interface CategoryChartItem extends Labeled {
4242

4343
boolean getLegendVisible();
4444

4545
void setLegendVisible(boolean visible);
4646

47-
Collection<? extends C> getCategories();
47+
Collection<Object> getCategories();
4848
}

src/main/java/net/imagej/plot/LineSeries.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
*
3939
* @author Matthias Arzt
4040
*/
41-
public interface LineSeries<C> extends CategoryChartItem {
41+
public interface LineSeries extends CategoryChartItem {
4242

43-
Map<? extends C, Double> getValues();
43+
Map<?, Double> getValues();
4444

45-
void setValues(Map<? extends C, Double> Values);
45+
void setValues(Map<?, Double> Values);
4646

4747
SeriesStyle getStyle();
4848

src/main/java/net/imagej/plot/PlotService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@ public interface PlotService extends ImageJService {
4646

4747
XYPlot newXYPlot();
4848

49-
<C> CategoryChart<C> newCategoryChart(Class<C> categoryType);
50-
49+
CategoryChart newCategoryChart();
5150
}

src/main/java/net/imagej/plot/defaultplot/DefaultBarSeries.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*
4040
* @author Matthias Arzt
4141
*/
42-
class DefaultBarSeries<C> extends DefaultCategorySeries<C> implements BarSeries<C> {
42+
class DefaultBarSeries extends DefaultCategorySeries implements BarSeries {
4343

4444
private ColorRGB color = null;
4545

src/main/java/net/imagej/plot/defaultplot/DefaultBoxSeries.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,21 @@
4343
*
4444
* @author Matthias Arzt
4545
*/
46-
class DefaultBoxSeries<C> extends AbstractChartItem implements BoxSeries<C> {
46+
class DefaultBoxSeries extends AbstractChartItem implements BoxSeries {
4747

4848
private ColorRGB color = null;
4949

50-
private Map<C, Collection<Double>> values = Collections.emptyMap();
51-
52-
public DefaultBoxSeries() { }
50+
private Map<?, Collection<Double>> values = Collections.emptyMap();
5351

5452
// -- BoxSeries methods --
5553

5654
@Override
57-
public Map<C, Collection<Double>> getValues() {
55+
public Map<?, Collection<Double>> getValues() {
5856
return values;
5957
}
6058

6159
@Override
62-
public void setValues(Map<? extends C, ? extends Collection<Double>> values) {
60+
public void setValues(Map<?, ? extends Collection<Double>> values) {
6361
this.values = Collections.unmodifiableMap(values);
6462
}
6563

@@ -76,7 +74,7 @@ public void setColor(ColorRGB color) {
7674
// -- CategoryChartItem methods --
7775

7876
@Override
79-
public Collection getCategories() {
80-
return values.keySet();
77+
public Collection<Object> getCategories() {
78+
return Collections.unmodifiableCollection( values.keySet() );
8179
}
8280
}

src/main/java/net/imagej/plot/defaultplot/DefaultCategoryAxis.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@
4242
*
4343
* @author Matthias Arzt
4444
*/
45-
class DefaultCategoryAxis<C> extends AbstractLabeled implements CategoryAxis<C> {
45+
class DefaultCategoryAxis extends AbstractLabeled implements CategoryAxis {
4646

47-
private final CategoryChart<C> chart;
47+
private final CategoryChart chart;
4848

49-
private List<? extends C> categories = null;
49+
private List categories = null;
5050

51-
private Comparator<? super C> comparator = null;
51+
private Comparator comparator = null;
5252

53-
DefaultCategoryAxis(CategoryChart<C> chart) {
53+
DefaultCategoryAxis(CategoryChart chart) {
5454
this.chart = chart;
5555
}
5656

5757
// -- CategoryAxis methods --
5858

5959
@Override
60-
public void setManualCategories(List<? extends C> categories) {
60+
public void setManualCategories(List<?> categories) {
6161
this.categories = Objects.requireNonNull(categories);
6262
}
6363

@@ -72,7 +72,7 @@ public boolean hasManualCategories() {
7272
}
7373

7474
@Override
75-
public void setOrder(Comparator<? super C> comparator) {
75+
public void setOrder(Comparator comparator) {
7676
this.comparator = Objects.requireNonNull(comparator);
7777
}
7878

@@ -82,29 +82,26 @@ public void clearOrder() {
8282
}
8383

8484
@Override
85-
public List<C> getCategories() {
86-
List<C> result = getCategoriesDefaultOrder();
85+
public List<Object> getCategories() {
86+
List<Object> result = getCategoriesDefaultOrder();
8787
if(comparator != null)
8888
result.sort(comparator);
8989
return result;
9090
}
9191

9292
// -- private helper methods
9393

94-
private List<C> getCategoriesDefaultOrder() {
94+
private List<Object> getCategoriesDefaultOrder() {
9595
if(categories == null) {
96-
Set<C> allCategories = newEmptySetOfCategories();
96+
Set<Object> allCategories = newEmptySetOfCategories();
9797
for (CategoryChartItem item : chart.getItems())
9898
allCategories.addAll(item.getCategories());
9999
return new ArrayList<>(allCategories);
100100
} else
101101
return new ArrayList<>(categories); // Make copy to avoid the list passed to setManualCategories to be sorted.
102102
}
103103

104-
private Set<C> newEmptySetOfCategories() {
105-
if(Comparable.class.isAssignableFrom(chart.getCategoryType()))
106-
return new TreeSet<>();
107-
else
108-
return new HashSet<>();
104+
private Set<Object> newEmptySetOfCategories() {
105+
return new HashSet<>();
109106
}
110107
}

0 commit comments

Comments
 (0)