@@ -226,31 +226,32 @@ public final String dump() {
226226 *
227227 * @implSpec Remember to invoke {@code super.dump(sb, indent)} first, then add all children using
228228 * {@link #dumpChild(StringBuilder, String, String, Graphic)}.
229- * @implNote All the props from {@link #getProps(boolean )} are automatically added by invoking the
230- * super method.
229+ * @implNote All the props from {@link #getProps(PropStyle )} are automatically added by invoking
230+ * the super method.
231231 */
232232 protected final void dump (StringBuilder sb , String indent ) {
233- sb .append (indent )
233+ sb .append (" \033 [1m" )
234234 .append (getClass ().getSimpleName ())
235+ .append ("\033 [0m" )
235236 .append ("\n " );
236- getProps (true ).forEach ((k , v ) -> dumpField (sb , indent , k , v ));
237+ getProps (PropStyle . ANSI_ESCAPE_CODES ).forEach ((k , v ) -> dumpField (sb , indent , k , v ));
237238 getChildren ().forEach ((k , v ) -> dumpChild (sb , indent , k , v ));
238239 }
239240
240241 private void dumpField (StringBuilder sb , String indent , String name , Object value ) {
241242 sb .append (indent )
242- .append ("├─ " )
243+ .append ("├─ \033 [2m " )
243244 .append (name )
244- .append (": " )
245+ .append ("\033 [0m : " )
245246 .append (value )
246247 .append ("\n " );
247248 }
248249
249250 private void dumpChild (StringBuilder sb , String indent , String name , Graphic child ) {
250251 sb .append (indent )
251- .append ("├─ " )
252+ .append ("├─ \033 [2m " )
252253 .append (name )
253- .append (": \n " );
254+ .append ("\033 [0m: " );
254255 child .dump (sb , indent + "│ " );
255256 }
256257
@@ -272,21 +273,35 @@ protected String getInspectLabel() {
272273 return "graphic" ;
273274 }
274275
276+
277+ /**
278+ * Properties of the graphic.
279+ *
280+ * <p>Same as {@link #getProps(PropStyle)}, with {@link PropStyle#PLAIN} as the style.
281+ *
282+ * @implSpec The returned map is supposed to be mutable in non final-classes that override this
283+ * method so that it's easier for subclasses to add more entries to it.
284+ * @see #getProps(PropStyle)
285+ */
286+ protected SequencedMap <String , String > getProps () {
287+ return getProps (PropStyle .PLAIN );
288+ }
289+
275290 /**
276291 * Properties of the graphic.
277292 *
278293 * <p>These are used to produce various representations of the graphic.
279294 *
280- * @param plainText Whether the value strings be in plain text ({@code true}) or formatted in HTML
281- * markup ({@code false}) .
295+ * @param propStyle Whether the value strings be in plain text, formatted in HTML or ANSI escape
296+ * codes markup .
282297 * @implSpec The returned map is supposed to be mutable in non final-classes that override this
283298 * method so that it's easier for subclasses to add more entries to it.
284299 * @see #dump(StringBuilder, String)
285300 * @see #toString()
286301 * @see GuiGraphicPropertiesPanel
287302 * @see GuiGraphicTreeCellRenderer
288303 */
289- protected SequencedMap <String , String > getProps (boolean plainText ) {
304+ protected SequencedMap <String , String > getProps (PropStyle propStyle ) {
290305 // We use LinkedHashMap as the implementation class because:
291306 // 1. We care about insertion order
292307 // 2. We never perform random reads on the map, just forEach iterations
@@ -327,7 +342,7 @@ public int hashCode() {
327342 public final String toString () {
328343 return getClass ().getSimpleName ()
329344 + "["
330- + getProps (true ).entrySet ().stream ()
345+ + getProps (PropStyle . PLAIN ).entrySet ().stream ()
331346 .map (e -> e .getKey () + "=" + e .getValue ())
332347 .collect (Collectors .joining (", " ))
333348 + "]" ;
@@ -351,4 +366,13 @@ public Graphic getGraphic() {
351366 return Graphic .this ;
352367 }
353368 }
369+
370+ /**
371+ * @hidden
372+ */
373+ protected enum PropStyle {
374+ PLAIN ,
375+ ANSI_ESCAPE_CODES ,
376+ HTML ,
377+ }
354378}
0 commit comments