|
6 | 6 | import com.demcha.compose.font.DefaultFonts; |
7 | 7 | import com.demcha.compose.document.api.DocumentPageSize; |
8 | 8 | import com.demcha.compose.document.api.DocumentSession; |
9 | | -import com.demcha.compose.document.backend.fixed.pdf.options.PdfDebugOptions; |
| 9 | +import com.demcha.compose.document.output.DocumentDebugOptions; |
10 | 10 | import com.demcha.compose.document.style.DocumentInsets; |
11 | 11 |
|
12 | 12 | import java.nio.file.Path; |
@@ -140,8 +140,7 @@ public static final class DocumentBuilder { |
140 | 140 | private DocumentPageSize pageSize = DocumentPageSize.A4; |
141 | 141 | private DocumentInsets margin = DocumentInsets.zero(); |
142 | 142 | private boolean markdown = true; |
143 | | - private boolean guideLines; |
144 | | - private PdfDebugOptions debug; |
| 143 | + private DocumentDebugOptions debug = DocumentDebugOptions.none(); |
145 | 144 | private com.demcha.compose.document.style.DocumentColor pageBackground; |
146 | 145 | private java.util.List<com.demcha.compose.document.api.PageBackgroundFill> pageBackgrounds; |
147 | 146 | private final List<FontFamilyDefinition> customFontFamilies = new ArrayList<>(); |
@@ -220,29 +219,35 @@ public DocumentBuilder markdown(boolean enabled) { |
220 | 219 | * {@link DocumentSession#toPdfBytes()}. It does not alter semantic layout |
221 | 220 | * geometry or layout snapshots.</p> |
222 | 221 | * |
| 222 | + * <p>Shorthand for toggling only the guide overlay on the current |
| 223 | + * {@link #debug(DocumentDebugOptions) debug} configuration — node-label |
| 224 | + * settings are preserved, and the call order with {@code debug(...)} |
| 225 | + * follows last-write-wins, exactly like the equivalent switches on |
| 226 | + * {@code DocumentSession} and the PDF backend builder.</p> |
| 227 | + * |
223 | 228 | * @param enabled {@code true} to draw debug guide-line overlays |
224 | 229 | * @return this builder |
225 | 230 | */ |
226 | 231 | public DocumentBuilder guideLines(boolean enabled) { |
227 | | - this.guideLines = enabled; |
| 232 | + this.debug = this.debug.withGuides(enabled); |
228 | 233 | return this; |
229 | 234 | } |
230 | 235 |
|
231 | 236 | /** |
232 | | - * Configures PDF debug overlays (guide lines and semantic node labels) |
| 237 | + * Configures debug overlays (guide lines and semantic node labels) |
233 | 238 | * for the session's convenience PDF output. |
234 | 239 | * |
235 | | - * <p>Combines with {@link #guideLines(boolean)}: when both switches are |
236 | | - * used, the guide overlay is enabled if either of them requests it. |
237 | | - * Like guide lines, debug overlays draw on top of regular content and |
238 | | - * never alter semantic layout geometry or layout snapshots.</p> |
| 240 | + * <p>Replaces the whole debug configuration; {@code null} resets to |
| 241 | + * {@link DocumentDebugOptions#none()}. Debug overlays draw on top of |
| 242 | + * regular content and never alter semantic layout geometry or layout |
| 243 | + * snapshots.</p> |
239 | 244 | * |
240 | 245 | * @param options debug overlay options, or {@code null} for none |
241 | 246 | * @return this builder |
242 | 247 | * @since 1.8.0 |
243 | 248 | */ |
244 | | - public DocumentBuilder debug(PdfDebugOptions options) { |
245 | | - this.debug = options; |
| 249 | + public DocumentBuilder debug(DocumentDebugOptions options) { |
| 250 | + this.debug = options == null ? DocumentDebugOptions.none() : options; |
246 | 251 | return this; |
247 | 252 | } |
248 | 253 |
|
@@ -410,10 +415,8 @@ public DocumentSession create() { |
410 | 415 | margin, |
411 | 416 | List.copyOf(customFontFamilies), |
412 | 417 | markdown, |
413 | | - guideLines); |
414 | | - if (debug != null) { |
415 | | - session.debug(debug.withGuides(debug.showGuides() || guideLines)); |
416 | | - } |
| 418 | + debug.showGuides()); |
| 419 | + session.debug(debug); |
417 | 420 | if (pageBackgrounds != null) { |
418 | 421 | // Explicit pageBackgrounds() call wins over a prior |
419 | 422 | // pageBackground(color). Empty list = clear; see builder Javadoc. |
|
0 commit comments