3030import net .rptools .lib .image .ImageUtil ;
3131import net .rptools .maptool .client .AppPreferences ;
3232import net .rptools .maptool .client .MapTool ;
33- import net .rptools .maptool .client .swing .ImageLabel ;
3433import net .rptools .maptool .client .swing .SwingUtil ;
34+ import net .rptools .maptool .client .swing .label .FlatImageLabel ;
35+ import net .rptools .maptool .client .swing .label .FlatImageLabelFactory ;
3536import net .rptools .maptool .client .ui .theme .Borders ;
3637import net .rptools .maptool .client .ui .theme .Icons ;
3738import net .rptools .maptool .client .ui .theme .RessourceManager ;
3839import net .rptools .maptool .client .ui .token .AbstractTokenOverlay ;
3940import net .rptools .maptool .client .ui .token .BarTokenOverlay ;
4041import net .rptools .maptool .model .InitiativeList .TokenInitiative ;
4142import net .rptools .maptool .model .Token ;
42- import net .rptools .maptool .util .GraphicsUtil ;
4343import net .rptools .maptool .util .ImageManager ;
4444
4545/**
@@ -64,7 +64,7 @@ public class InitiativeListCellRenderer extends JPanel
6464 private final InitiativePanel panel ;
6565
6666 /** Used to draw the background of the item. */
67- private ImageLabel backgroundImageLabel ;
67+ private FlatImageLabel backgroundFlatImageLabel ;
6868
6969 /**
7070 * The text height for the background image label. Only the text is painted inside, the token
@@ -158,11 +158,18 @@ public Component getListCellRendererComponent(
158158 setBorder (UNSELECTED_BORDER );
159159 return this ;
160160 } // endif
161- backgroundImageLabel =
162- token .isVisible ()
163- ? token .getType () == Token .Type .NPC ? GraphicsUtil .BLUE_LABEL : GraphicsUtil .GREY_LABEL
164- : GraphicsUtil .DARK_GREY_LABEL ;
165- name .setForeground (Color .BLACK );
161+
162+ var labelRenderFactory = new FlatImageLabelFactory ();
163+ backgroundFlatImageLabel = labelRenderFactory .getMapImageLabel (token );
164+
165+ // We still use the UI text so use the map label color preferences
166+ if (!token .isVisible ()) {
167+ name .setForeground (AppPreferences .nonVisibleTokenMapLabelForeground .get ());
168+ } else if (token .getType () == Token .Type .NPC ) {
169+ name .setForeground (AppPreferences .npcMapLabelForeground .get ());
170+ } else {
171+ name .setForeground (AppPreferences .pcMapLabelForeground .get ());
172+ }
166173 name .setFont (name .getFont ().deriveFont (token .isVisible () ? Font .PLAIN : Font .ITALIC ));
167174
168175 // Show the indicator?
@@ -233,7 +240,8 @@ protected void paintComponent(Graphics g) {
233240 boolean initStateSecondLine = panel .isInitStateSecondLine () && panel .isShowInitState ();
234241 Dimension s = name .getSize ();
235242 int th = (textHeight + 2 ) * (initStateSecondLine ? 2 : 1 );
236- backgroundImageLabel .renderLabel ((Graphics2D ) g , 0 , (s .height - th ) / 2 , s .width , th );
243+ // render an image label with set dimensions and without text
244+ backgroundFlatImageLabel .render ((Graphics2D ) g , 0 , (s .height - th ) / 2 , s .width , th , "" );
237245 super .paintComponent (g );
238246 }
239247
@@ -247,7 +255,7 @@ public Dimension getPreferredSize() {
247255 int th = textHeight * (initStateSecondLine ? 2 : 1 );
248256 Insets insets = getInsets ();
249257 if (getIcon () != null ) th = Math .max (th , getIcon ().getIconHeight ());
250- s .height = th + insets .top + insets .bottom - 4 ;
258+ s .height = th + insets .top + insets .bottom ;
251259 return s ;
252260 }
253261 }
0 commit comments