@@ -75,7 +75,7 @@ public class PreviewPanel extends JPanel implements MouseMotionListener, MouseWh
75
75
/**
76
76
* Back buffers used for drawing the preview.
77
77
*/
78
- private final BufferedImage main_img , height_img ;
78
+ private BufferedImage main_img ;
79
79
80
80
/**
81
81
* Font used in the preview.
@@ -137,7 +137,6 @@ static class MapMarker {
137
137
public PreviewPanel () {
138
138
139
139
main_img =new BufferedImage (MAX_WIDTH , MAX_HEIGHT , BufferedImage .TYPE_INT_RGB );
140
- height_img =new BufferedImage (MAX_WIDTH , MAX_HEIGHT , BufferedImage .TYPE_BYTE_GRAY );
141
140
142
141
setMaximumSize (new Dimension (MAX_WIDTH ,MAX_HEIGHT ));
143
142
@@ -152,7 +151,7 @@ public PreviewPanel() {
152
151
addMouseMotionListener (this );
153
152
addMouseWheelListener (this );
154
153
155
- gui_font =new Font ("Verdana " ,Font .BOLD ,10 );
154
+ gui_font =new Font ("Noto Sans JMC Combined " ,Font .BOLD ,10 );
156
155
gui_color =Color .white ;
157
156
gui_bg_color =Color .black ;
158
157
gui_bg_alpha =0.3f ;
@@ -168,10 +167,9 @@ public void paint(Graphics g) {
168
167
169
168
Graphics2D g2d = (Graphics2D ) g ;
170
169
g2d .setFont (gui_font );
171
-
172
- synchronized (main_img ) {
173
- g2d .drawImage (main_img , 0 , 0 , null );
174
- }
170
+ g2d .setRenderingHint (RenderingHints .KEY_TEXT_ANTIALIASING , RenderingHints .VALUE_TEXT_ANTIALIAS_GASP );
171
+
172
+ g2d .drawImage (main_img , 0 , 0 , null );
175
173
176
174
for (MapMarker marker :markers )
177
175
{
@@ -234,20 +232,13 @@ public void paint(Graphics g) {
234
232
screen_ez =-1 ;
235
233
}
236
234
237
-
238
235
g2d .setComposite (AlphaComposite .getInstance (AlphaComposite .SRC_OVER ,gui_bg_alpha ));
239
236
gui_text .clear ();
240
237
gui_text .add (zoom_level +"x" );
241
238
gui_text .add ("(" +px +"," +py +")" ); //$NON-NLS-2$ //$NON-NLS-3$
242
239
gui_text .add (Messages .getString ("PreviewPanel.SELECTION" ));
243
240
gui_text .add ("(" +selection_start_x +"," +selection_start_z +")" ); //$NON-NLS-2$ //$NON-NLS-3$
244
241
gui_text .add ("(" +selection_end_x +"," +selection_end_z +")" ); //$NON-NLS-2$ //$NON-NLS-3$
245
-
246
- //Commented these out because this information is now in a JSpinner on MainPanel
247
- //gui_text.add(Messages.getString("PreviewPanel.FLOOR")+alt_floor);
248
- //gui_text.add(Messages.getString("PreviewPanel.CEILING")+alt_ceil);
249
-
250
-
251
242
252
243
g2d .setColor (gui_bg_color );
253
244
g2d .fillRect (0 , 0 , 100 , 130 +gui_text .size ()*(fh +5 ));
@@ -272,64 +263,69 @@ void redraw(boolean fast)
272
263
{
273
264
int win_w =getWidth ();
274
265
int win_h =getHeight ();
266
+ BufferedImage new_main_img = new BufferedImage (win_w , win_h , BufferedImage .TYPE_INT_RGB );
267
+ BufferedImage height_img = new BufferedImage (win_w , win_h , BufferedImage .TYPE_BYTE_GRAY );
275
268
276
269
Vector <ChunkImage > chunksSnapshot ;
277
270
synchronized (chunks ) {
278
271
chunksSnapshot = (Vector <ChunkImage >)chunks .clone ();
279
272
chunksDirty = false ;
280
273
}
281
274
282
- synchronized (main_img ) {
283
- Graphics2D mg =main_img .createGraphics ();
284
- if (!fast )
285
- mg .setRenderingHint (RenderingHints .KEY_INTERPOLATION , RenderingHints .VALUE_INTERPOLATION_BILINEAR );
286
- mg .setColor (Color .black );
287
- mg .clearRect (0 , 0 , win_w , win_h );
288
-
289
- Graphics2D hg =height_img .createGraphics ();
290
- if (!fast )
291
- {
292
- hg .setRenderingHint (RenderingHints .KEY_INTERPOLATION , RenderingHints .VALUE_INTERPOLATION_BILINEAR );
293
- hg .setColor (Color .black );
294
- hg .clearRect (0 , 0 , win_w , win_h );
295
- }
296
-
297
- BufferedImage ckln =new BufferedImage (MAX_WIDTH , MAX_HEIGHT , BufferedImage .TYPE_INT_ARGB );
298
- Graphics2D cklng = ckln .createGraphics ();
299
-
300
- for (ChunkImage chunk : chunksSnapshot ) {
301
- redrawChunk (chunk , fast , cklng );
302
- }
275
+ Graphics2D mg =new_main_img .createGraphics ();
276
+ if (!fast )
277
+ mg .setRenderingHint (RenderingHints .KEY_INTERPOLATION , RenderingHints .VALUE_INTERPOLATION_BILINEAR );
278
+ mg .setColor (Color .black );
279
+ mg .clearRect (0 , 0 , win_w , win_h );
280
+
281
+ Graphics2D hg =height_img .createGraphics ();
282
+ if (!fast )
283
+ {
284
+ hg .setRenderingHint (RenderingHints .KEY_INTERPOLATION , RenderingHints .VALUE_INTERPOLATION_BILINEAR );
285
+ hg .setColor (Color .black );
286
+ hg .clearRect (0 , 0 , win_w , win_h );
287
+ }
288
+
289
+ BufferedImage ckln =new BufferedImage (MAX_WIDTH , MAX_HEIGHT , BufferedImage .TYPE_INT_ARGB );
290
+ Graphics2D cklng = ckln .createGraphics ();
291
+
292
+ for (ChunkImage chunk : chunksSnapshot ) {
293
+ redrawChunk (chunk , fast , new_main_img , height_img , cklng );
294
+ }
303
295
304
- if (!fast ) {
305
- WritableRaster height_raster = height_img .getRaster ();
306
- int h ,oh ;
307
- for (int x =0 ; x <win_w ; x ++) {
308
- for (int y =0 ; y <win_h ; y ++) {
309
- h =height_raster .getSample (x , y , 0 );
310
- if (x <(win_w -1 ) && y <(win_h -1 )) oh =height_raster .getSample (x +1 , y +1 , 0 );
311
- else oh =h ;
296
+ if (!fast ) {
297
+ WritableRaster height_raster = height_img .getRaster ();
298
+ int h , oh ;
299
+ for (int x = 0 ; x < win_w ; x ++) {
300
+ for (int y = 0 ; y < win_h ; y ++) {
301
+ h = height_raster .getSample (x , y , 0 );
302
+ if (x < (win_w - 1 ) && y < (win_h - 1 )) {
303
+ oh = height_raster .getSample (x + 1 , y + 1 , 0 );
304
+ } else {
305
+ oh = h ;
306
+ }
312
307
313
- h = h + 50 + (oh - h )* 20 ;
314
- if ( h < 0 ) h = 0 ;
315
- if (h > 255 ) h = 255 ;
308
+ h = h + 50 + (oh - h ) * 20 ;
309
+ if ( h < 0 ) h = 0 ;
310
+ if (h > 255 ) h = 255 ;
316
311
317
- height_raster .setSample (x , y , 0 , h );
318
- }
312
+ height_raster .setSample (x , y , 0 , h );
319
313
}
320
- mg .setComposite (AlphaComposite .getInstance (AlphaComposite .SRC_OVER , 0.4f ));
321
- mg .drawImage (height_img ,0 ,0 ,null );
322
314
}
323
- if (showchunks )
324
- mg .drawImage (ckln , 0 , 0 , null );
325
-
315
+ mg .setComposite (AlphaComposite .getInstance (AlphaComposite .SRC_OVER , 0.4f ));
316
+ mg .drawImage (height_img ,0 ,0 ,null );
326
317
}
318
+ if (showchunks )
319
+ mg .drawImage (ckln , 0 , 0 , null );
320
+
321
+ main_img = new_main_img ;
322
+
327
323
}
328
324
329
325
/**
330
326
* Draws a single chunk.
331
327
*/
332
- private void redrawChunk (ChunkImage chunk , boolean fast , Graphics2D cklng ) {
328
+ private void redrawChunk (ChunkImage chunk , boolean fast , BufferedImage color_img , BufferedImage height_img , Graphics2D cklng ) {
333
329
int win_w =getWidth ();
334
330
int win_h =getHeight ();
335
331
@@ -346,12 +342,9 @@ private void redrawChunk(ChunkImage chunk, boolean fast, Graphics2D cklng) {
346
342
cklng .drawLine (x +w , y , x +w , y +h );
347
343
}
348
344
349
- synchronized (main_img ) {
350
- Graphics2D mg =main_img .createGraphics ();
351
- mg .drawImage (chunk .image , x , y , w , h , null );
352
- if (!fast )
353
- height_img .createGraphics ().drawImage (chunk .height_map , x , y , w , h , null );
354
- }
345
+ color_img .createGraphics ().drawImage (chunk .image , x , y , w , h , null );
346
+ if (!fast )
347
+ height_img .createGraphics ().drawImage (chunk .height_map , x , y , w , h , null );
355
348
}
356
349
357
350
/**
0 commit comments