Skip to content

Commit 2dd14c3

Browse files
committed
Corrected model for Title and Font
#175
1 parent 01b0adb commit 2dd14c3

File tree

7 files changed

+67
-140
lines changed

7 files changed

+67
-140
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## 1.4.2
1+
## 1.5.0
22
* Added ``JsonIgnore`` to certain fields to help prevent infinite loops #174
3+
* Corrected model for ``Title`` and ``Font`` #175
34

45
## 1.4.1
56
* Use ``Number`` instead of ``BigDecimal`` in some additional places #159 (@aripddev)

chartjs-java-model-demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>chartjs-java-model-demo</artifactId>
9-
<version>1.4.2-SNAPSHOT</version>
9+
<version>1.5.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<organization>

chartjs-java-model/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>chartjs-java-model</artifactId>
9-
<version>1.4.2-SNAPSHOT</version>
9+
<version>1.5.0-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>chartjs-java-model</name>

chartjs-java-model/src/main/java/software/xdev/chartjs/model/enums/TitlePosition.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/Title.java

Lines changed: 45 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -16,180 +16,130 @@
1616
package software.xdev.chartjs.model.options;
1717

1818
import software.xdev.chartjs.model.color.Color;
19-
import software.xdev.chartjs.model.enums.FontStyle;
20-
import software.xdev.chartjs.model.enums.TitlePosition;
19+
import software.xdev.chartjs.model.options.scales.Font;
2120

2221

2322
public class Title
2423
{
24+
protected String align;
25+
protected Color color;
2526
protected Boolean display;
26-
protected TitlePosition position;
27-
protected Boolean fullWidth;
28-
protected Integer fontSize;
29-
protected String fontFamily;
30-
protected Color fontColor;
31-
protected FontStyle fontStyle;
27+
protected Boolean fullSize;
28+
protected String position;
29+
protected Font font;
3230
protected Integer padding;
3331
protected String text;
3432

3533
/**
36-
* @see #setDisplay(Boolean)
37-
*/
38-
public Boolean getDisplay()
39-
{
40-
return this.display;
41-
}
42-
43-
/**
44-
* <p>
45-
* Display the title block
46-
* </p>
47-
*
48-
* <p>
49-
* Default {@code false}
50-
* </p>
34+
* @see #setAlign(String)
5135
*/
52-
public Title setDisplay(final Boolean display)
36+
public String getAlign()
5337
{
54-
this.display = display;
55-
return this;
38+
return this.align;
5639
}
5740

5841
/**
59-
* @see #setPosition(TitlePosition)
60-
*/
61-
public TitlePosition getPosition()
62-
{
63-
return this.position;
64-
}
65-
66-
/**
67-
* <p>
68-
* Position of the title. Only 'top' or 'bottom' are currently allowed
69-
* </p>
42+
* Alignment of the title
7043
*
71-
* <p>
72-
* Default {@code 'top'}
73-
* </p>
44+
* <p>Default: center</p>
7445
*/
75-
public Title setPosition(final TitlePosition position)
46+
public Title setAlign(final String align)
7647
{
77-
this.position = position;
48+
this.align = align;
7849
return this;
7950
}
8051

8152
/**
82-
* @see #setFullWidth(Boolean)
53+
* @see #setColor(Color)
8354
*/
84-
public Boolean getFullWidth()
55+
public Color getColor()
8556
{
86-
return this.fullWidth;
57+
return this.color;
8758
}
8859

8960
/**
90-
* <p>
91-
* Marks that this box should take the full width of the canvas (pushing down other boxes)
92-
* </p>
93-
*
94-
* <p>
95-
* Default {@code true}
96-
* </p>
61+
* Color of text
9762
*/
98-
public Title setFullWidth(final Boolean fullWidth)
63+
public Title setColor(final Color color)
9964
{
100-
this.fullWidth = fullWidth;
65+
this.color = color;
10166
return this;
10267
}
10368

10469
/**
105-
* @see #setFontSize(Integer)
70+
* @see #setFullSize(Boolean)
10671
*/
107-
public Integer getFontSize()
72+
public Boolean getFullSize()
10873
{
109-
return this.fontSize;
74+
return this.fullSize;
11075
}
11176

11277
/**
113-
* <p>
114-
* Font size inherited from global configuration
115-
* </p>
78+
* Marks that this box should take the full width/height of the canvas. If false, the box is sized and placed
79+
* above/beside the chart area.
11680
*
117-
* <p>
118-
* Default {@code 12}
119-
* </p>
81+
* <p>Default: true</p>
12082
*/
121-
public Title setFontSize(final Integer fontSize)
83+
public Title setFullSize(final Boolean fullSize)
12284
{
123-
this.fontSize = fontSize;
85+
this.fullSize = fullSize;
12486
return this;
12587
}
12688

127-
/**
128-
* @see #setFontFamily(String)
129-
*/
130-
public String getFontFamily()
89+
public Font getFont()
13190
{
132-
return this.fontFamily;
91+
return this.font;
13392
}
13493

135-
/**
136-
* <p>
137-
* Font family inherited from global configuration
138-
* </p>
139-
*
140-
* <p>
141-
* Default {@code "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"}
142-
* </p>
143-
*/
144-
public Title setFontFamily(final String fontFamily)
94+
public Title setFont(final Font font)
14595
{
146-
this.fontFamily = fontFamily;
96+
this.font = font;
14797
return this;
14898
}
14999

150100
/**
151-
* @see #setFontColor(Color)
101+
* @see #setDisplay(Boolean)
152102
*/
153-
public Color getFontColor()
103+
public Boolean getDisplay()
154104
{
155-
return this.fontColor;
105+
return this.display;
156106
}
157107

158108
/**
159109
* <p>
160-
* Font color inherited from global configuration
110+
* Display the title block
161111
* </p>
162112
*
163113
* <p>
164-
* Default {@code "#666"}
114+
* Default {@code false}
165115
* </p>
166116
*/
167-
public Title setFontColor(final Color fontColor)
117+
public Title setDisplay(final Boolean display)
168118
{
169-
this.fontColor = fontColor;
119+
this.display = display;
170120
return this;
171121
}
172122

173123
/**
174-
* @see #setFontStyle(FontStyle)
124+
* @see #setPosition(String)
175125
*/
176-
public FontStyle getFontStyle()
126+
public String getPosition()
177127
{
178-
return this.fontStyle;
128+
return this.position;
179129
}
180130

181131
/**
182132
* <p>
183-
* Font styling of the title, follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit).
133+
* Position of the title. Only 'top' or 'bottom' are currently allowed
184134
* </p>
185135
*
186136
* <p>
187-
* Default {@code 'bold'}
137+
* Default {@code 'top'}
188138
* </p>
189139
*/
190-
public Title setFontStyle(final FontStyle fontStyle)
140+
public Title setPosition(final String position)
191141
{
192-
this.fontStyle = fontStyle;
142+
this.position = position;
193143
return this;
194144
}
195145

chartjs-java-model/src/main/java/software/xdev/chartjs/model/options/scales/Font.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class Font
2424
protected Number size;
2525
protected FontStyle style;
2626
protected Number weight;
27+
protected String lineHeight;
2728

2829
public String getFamily()
2930
{
@@ -95,4 +96,20 @@ public Font setWeight(final Number weight)
9596
this.weight = weight;
9697
return this;
9798
}
99+
100+
/**
101+
* @see #setLineHeight(String)
102+
*/
103+
public String getLineHeight()
104+
{
105+
return this.lineHeight;
106+
}
107+
108+
/**
109+
* Height of an individual line of text
110+
*/
111+
public void setLineHeight(final String lineHeight)
112+
{
113+
this.lineHeight = lineHeight;
114+
}
98115
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>software.xdev</groupId>
88
<artifactId>chartjs-java-model-root</artifactId>
9-
<version>1.4.2-SNAPSHOT</version>
9+
<version>1.5.0-SNAPSHOT</version>
1010
<packaging>pom</packaging>
1111

1212
<organization>

0 commit comments

Comments
 (0)