Skip to content

Commit 6f59774

Browse files
committed
Adaptation to Removed validate() Method (from Tool/Job Builder API)
1 parent 29a64a5 commit 6f59774

2 files changed

Lines changed: 34 additions & 30 deletions

File tree

src/main/java/org/optimizationBenchmarking/utils/graphics/graphic/impl/abstr/GraphicBuilder.java

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,49 +60,54 @@ public GraphicBuilder configure(final Configuration config) {
6060
/** {@inheritDoc} */
6161
@Override
6262
public final GraphicBuilder setSize(final PhysicalDimension size) {
63-
final double w, h;
63+
GraphicBuilder._checkSize(size);
64+
this.m_size = size;
65+
return this;
66+
}
67+
68+
/**
69+
* Check a size for a graphic.
70+
*
71+
* @param size
72+
* the physical size to check
73+
*/
74+
static final void _checkSize(final PhysicalDimension size) {
75+
final double width, height;
6476
final ELength sizeUnit;
65-
double r;
77+
double inMeters;
78+
79+
if (size == null) {
80+
throw new IllegalArgumentException(//
81+
"Size of graphic cannot be set to null.");//$NON-NLS-1$
82+
}
6683

67-
if ((size == null) || ((h = size.getHeight()) <= 0d)
68-
|| ((w = size.getWidth()) <= 0d)) {
84+
if (((height = size.getHeight()) <= 0d)
85+
|| ((width = size.getWidth()) <= 0d)) {
6986
throw new IllegalArgumentException(//
70-
"Invalid graphic size: " + size);//$NON-NLS-1$
87+
"Invalid graphic size: " + size + //$NON-NLS-1$
88+
" - width or height cannot be zero or negative.");//$NON-NLS-1$
7189
}
7290

7391
sizeUnit = size.getUnit();
74-
r = sizeUnit.convertToAsDouble(w, ELength.M);
75-
if ((r <= GraphicBuilder.MIN_SIZE_M)
76-
|| (r >= GraphicBuilder.MAX_SIZE_M)) {
92+
inMeters = sizeUnit.convertToAsDouble(width, ELength.M);
93+
if ((inMeters <= GraphicBuilder.MIN_SIZE_M)
94+
|| (inMeters >= GraphicBuilder.MAX_SIZE_M)) {
7795
throw new IllegalArgumentException(//
7896
"A graphic width cannot be smaller than 0.1mm or larger than 10m, but "//$NON-NLS-1$
79-
+ w + " specified in " + sizeUnit + //$NON-NLS-1$
80-
" equals " + r + //$NON-NLS-1$
97+
+ width + " specified in " + sizeUnit + //$NON-NLS-1$
98+
" equals " + inMeters + //$NON-NLS-1$
8199
"m.");//$NON-NLS-1$
82100
}
83101

84-
r = sizeUnit.convertToAsDouble(h, ELength.M);
85-
if ((r <= GraphicBuilder.MIN_SIZE_M)
86-
|| (r >= GraphicBuilder.MAX_SIZE_M)) {
102+
inMeters = sizeUnit.convertToAsDouble(height, ELength.M);
103+
if ((inMeters <= GraphicBuilder.MIN_SIZE_M)
104+
|| (inMeters >= GraphicBuilder.MAX_SIZE_M)) {
87105
throw new IllegalArgumentException(//
88106
"A graphic height cannot be smaller than 0.1mm or larger than 10m, but "//$NON-NLS-1$
89-
+ h + " specified in " + sizeUnit + //$NON-NLS-1$
90-
" equals " + r + //$NON-NLS-1$
107+
+ height + " specified in " + sizeUnit + //$NON-NLS-1$
108+
" equals " + inMeters + //$NON-NLS-1$
91109
"m.");//$NON-NLS-1$
92110
}
93-
94-
this.m_size = size;
95-
return this;
96-
}
97-
98-
/** {@inheritDoc} */
99-
@Override
100-
protected void validate() {
101-
super.validate();
102-
if (this.m_size == null) {
103-
throw new IllegalArgumentException(//
104-
"The size of the graphic must be set."); //$NON-NLS-1$
105-
}
106111
}
107112

108113
/**
@@ -167,7 +172,7 @@ public final GraphicBuilder setQuality(final double quality) {
167172
/** {@inheritDoc} */
168173
@Override
169174
public final Graphic create() {
170-
this.validate();
175+
GraphicBuilder._checkSize(this.m_size);
171176
return ((AbstractGraphicDriver) (this.m_config.getGraphicDriver()))
172177
.createGraphic(this);
173178
}

src/main/java/org/optimizationBenchmarking/utils/graphics/graphic/impl/freeHEP/FreeHEPEMFGraphicDriver.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ public final String toString() {
138138
@SuppressWarnings("resource")
139139
@Override
140140
protected final Graphic createGraphic(final GraphicBuilder builder) {
141-
142141
final org.freehep.util.UserProperties up;
143142
final _FreeHEPEMFGraphic g;
144143
final Dimension dim;

0 commit comments

Comments
 (0)