1
1
/* ClasspathFontPeer.java -- Font peer used by GNU Classpath.
2
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
2
+ Copyright (C) 2003, 2004, 2014 Free Software Foundation, Inc.
3
3
4
4
This file is part of GNU Classpath.
5
5
@@ -129,7 +129,8 @@ public LRUCache(int max)
129
129
super (max , 0.75f , true );
130
130
max_entries = max ;
131
131
}
132
- protected boolean removeEldestEntry (Map .Entry eldest )
132
+ @ Override
133
+ protected boolean removeEldestEntry (Map .Entry <K ,V > eldest )
133
134
{
134
135
return size () > max_entries ;
135
136
}
@@ -191,7 +192,7 @@ protected static String faceNameToFamilyName (String name)
191
192
return name ;
192
193
}
193
194
194
- public static void copyStyleToAttrs (int style , Map attrs )
195
+ public static void copyStyleToAttrs (int style , Map < TextAttribute , Object > attrs )
195
196
{
196
197
if ((style & Font .BOLD ) == Font .BOLD )
197
198
attrs .put (TextAttribute .WEIGHT , TextAttribute .WEIGHT_BOLD );
@@ -204,18 +205,18 @@ public static void copyStyleToAttrs (int style, Map attrs)
204
205
attrs .put (TextAttribute .POSTURE , TextAttribute .POSTURE_REGULAR );
205
206
}
206
207
207
- protected static void copyFamilyToAttrs (String fam , Map attrs )
208
+ protected static void copyFamilyToAttrs (String fam , Map < TextAttribute , Object > attrs )
208
209
{
209
210
if (fam != null )
210
211
attrs .put (TextAttribute .FAMILY , fam );
211
212
}
212
213
213
- public static void copySizeToAttrs (float size , Map attrs )
214
+ public static void copySizeToAttrs (float size , Map < TextAttribute , Object > attrs )
214
215
{
215
216
attrs .put (TextAttribute .SIZE , new Float (size ));
216
217
}
217
218
218
- protected static void copyTransformToAttrs (AffineTransform trans , Map attrs )
219
+ protected static void copyTransformToAttrs (AffineTransform trans , Map < TextAttribute , Object > attrs )
219
220
{
220
221
if (trans != null )
221
222
{
@@ -255,12 +256,12 @@ protected void setStandardAttributes (String name, String family, int style,
255
256
}
256
257
257
258
258
- protected void setStandardAttributes (String name , Map attribs )
259
+ protected void setStandardAttributes (String name , Map < TextAttribute , Object > attribs )
259
260
{
260
261
String family = this .familyName ;
261
262
AffineTransform trans = this .transform ;
262
- float size = this .size ;
263
- int style = this .style ;
263
+ float setSize = this .size ;
264
+ int setStyle = this .style ;
264
265
265
266
if (attribs .containsKey (TextAttribute .FAMILY ))
266
267
family = (String ) attribs .get (TextAttribute .FAMILY );
@@ -272,27 +273,27 @@ protected void setStandardAttributes (String name, Map attribs)
272
273
{
273
274
Float weight = (Float ) attribs .get (TextAttribute .WEIGHT );
274
275
if (weight .floatValue () >= TextAttribute .WEIGHT_BOLD .floatValue ())
275
- style += Font .BOLD ;
276
+ setStyle += Font .BOLD ;
276
277
}
277
278
278
279
if (attribs .containsKey (TextAttribute .POSTURE ))
279
280
{
280
281
Float posture = (Float ) attribs .get (TextAttribute .POSTURE );
281
282
if (posture .floatValue () >= TextAttribute .POSTURE_OBLIQUE .floatValue ())
282
- style += Font .ITALIC ;
283
+ setStyle += Font .ITALIC ;
283
284
}
284
285
285
286
if (attribs .containsKey (TextAttribute .SIZE ))
286
287
{
287
288
Float sz = (Float ) attribs .get (TextAttribute .SIZE );
288
- size = sz .floatValue ();
289
+ setSize = sz .floatValue ();
289
290
290
291
// Pango doesn't accept 0 as a font size.
291
- if (size < 1 )
292
- size = 1 ;
292
+ if (setSize < 1 )
293
+ setSize = 1 ;
293
294
}
294
295
else
295
- size = 12 ;
296
+ setSize = 12 ;
296
297
297
298
if (attribs .containsKey (TextAttribute .TRANSFORM ))
298
299
{
@@ -301,10 +302,10 @@ protected void setStandardAttributes (String name, Map attribs)
301
302
trans = ta .getTransform ();
302
303
}
303
304
304
- setStandardAttributes (name , family , style , size , trans );
305
+ setStandardAttributes (name , family , setStyle , setSize , trans );
305
306
}
306
307
307
- protected void getStandardAttributes (Map attrs )
308
+ protected void getStandardAttributes (Map < TextAttribute , Object > attrs )
308
309
{
309
310
copyFamilyToAttrs (this .familyName , attrs );
310
311
copySizeToAttrs (this .size , attrs );
@@ -315,15 +316,15 @@ protected void getStandardAttributes (Map attrs)
315
316
316
317
/* Begin public API */
317
318
318
- public ClasspathFontPeer (String name , Map attrs )
319
+ public ClasspathFontPeer (String name , Map < TextAttribute , Object > attrs )
319
320
{
320
321
setStandardAttributes (name , attrs );
321
322
}
322
323
323
324
public ClasspathFontPeer (String name , int style , int size )
324
325
{
325
- setStandardAttributes (name , (String )null , style ,
326
- ( float ) size , (AffineTransform )null );
326
+ setStandardAttributes (name , (String )null , style , size ,
327
+ (AffineTransform )null );
327
328
}
328
329
329
330
/**
@@ -333,7 +334,7 @@ public ClasspathFontPeer (String name, int style, int size)
333
334
* useful if you are sharing peers between Font objects. Otherwise it may
334
335
* be ignored.
335
336
*/
336
-
337
+ @ SuppressWarnings ( "unused" )
337
338
public String getName (Font font )
338
339
{
339
340
return logicalName ;
@@ -346,7 +347,7 @@ public String getName (Font font)
346
347
* useful if you are sharing peers between Font objects. Otherwise it may
347
348
* be ignored.
348
349
*/
349
-
350
+ @ SuppressWarnings ( "unused" )
350
351
public String getFamily (Font font )
351
352
{
352
353
return familyName ;
@@ -359,7 +360,7 @@ public String getFamily (Font font)
359
360
* useful if you are sharing peers between Font objects. Otherwise it may
360
361
* be ignored.
361
362
*/
362
-
363
+ @ SuppressWarnings ( "unused" )
363
364
public String getFamily (Font font , Locale lc )
364
365
{
365
366
return familyName ;
@@ -372,7 +373,7 @@ public String getFamily (Font font, Locale lc)
372
373
* useful if you are sharing peers between Font objects. Otherwise it may
373
374
* be ignored.
374
375
*/
375
-
376
+ @ SuppressWarnings ( "unused" )
376
377
public String getFontName (Font font )
377
378
{
378
379
return faceName ;
@@ -385,7 +386,7 @@ public String getFontName (Font font)
385
386
* useful if you are sharing peers between Font objects. Otherwise it may
386
387
* be ignored.
387
388
*/
388
-
389
+ @ SuppressWarnings ( "unused" )
389
390
public String getFontName (Font font , Locale lc )
390
391
{
391
392
return faceName ;
@@ -398,7 +399,7 @@ public String getFontName (Font font, Locale lc)
398
399
* useful if you are sharing peers between Font objects. Otherwise it may
399
400
* be ignored.
400
401
*/
401
-
402
+ @ SuppressWarnings ( "unused" )
402
403
public float getSize (Font font )
403
404
{
404
405
return size ;
@@ -411,7 +412,7 @@ public float getSize (Font font)
411
412
* useful if you are sharing peers between Font objects. Otherwise it may
412
413
* be ignored.
413
414
*/
414
-
415
+ @ SuppressWarnings ( "unused" )
415
416
public boolean isPlain (Font font )
416
417
{
417
418
return style == Font .PLAIN ;
@@ -424,7 +425,7 @@ public boolean isPlain (Font font)
424
425
* useful if you are sharing peers between Font objects. Otherwise it may
425
426
* be ignored.
426
427
*/
427
-
428
+ @ SuppressWarnings ( "unused" )
428
429
public boolean isBold (Font font )
429
430
{
430
431
return ((style & Font .BOLD ) == Font .BOLD );
@@ -437,7 +438,7 @@ public boolean isBold (Font font)
437
438
* useful if you are sharing peers between Font objects. Otherwise it may
438
439
* be ignored.
439
440
*/
440
-
441
+ @ SuppressWarnings ( "unused" )
441
442
public boolean isItalic (Font font )
442
443
{
443
444
return ((style & Font .ITALIC ) == Font .ITALIC );
@@ -450,13 +451,13 @@ public boolean isItalic (Font font)
450
451
* useful if you are sharing peers between Font objects. Otherwise it may
451
452
* be ignored.
452
453
*/
453
-
454
- public Font deriveFont (Font font , int style , float size )
454
+ @ SuppressWarnings ( "unused" )
455
+ public Font deriveFont (Font font , int newStyle , float newSize )
455
456
{
456
- Map attrs = new HashMap ();
457
+ Map < TextAttribute , Object > attrs = new HashMap < TextAttribute , Object > ();
457
458
getStandardAttributes (attrs );
458
- copyStyleToAttrs (style , attrs );
459
- copySizeToAttrs (size , attrs );
459
+ copyStyleToAttrs (newStyle , attrs );
460
+ copySizeToAttrs (newSize , attrs );
460
461
return tk ().getFont (logicalName , attrs );
461
462
}
462
463
@@ -467,12 +468,12 @@ public Font deriveFont (Font font, int style, float size)
467
468
* useful if you are sharing peers between Font objects. Otherwise it may
468
469
* be ignored.
469
470
*/
470
-
471
- public Font deriveFont (Font font , float size )
471
+ @ SuppressWarnings ( "unused" )
472
+ public Font deriveFont (Font font , float newSize )
472
473
{
473
- Map attrs = new HashMap ();
474
+ Map < TextAttribute , Object > attrs = new HashMap < TextAttribute , Object > ();
474
475
getStandardAttributes (attrs );
475
- copySizeToAttrs (size , attrs );
476
+ copySizeToAttrs (newSize , attrs );
476
477
return tk ().getFont (logicalName , attrs );
477
478
}
478
479
@@ -483,12 +484,12 @@ public Font deriveFont (Font font, float size)
483
484
* useful if you are sharing peers between Font objects. Otherwise it may
484
485
* be ignored.
485
486
*/
486
-
487
- public Font deriveFont (Font font , int style )
487
+ @ SuppressWarnings ( "unused" )
488
+ public Font deriveFont (Font font , int newStyle )
488
489
{
489
- Map attrs = new HashMap ();
490
+ Map < TextAttribute , Object > attrs = new HashMap < TextAttribute , Object > ();
490
491
getStandardAttributes (attrs );
491
- copyStyleToAttrs (style , attrs );
492
+ copyStyleToAttrs (newStyle , attrs );
492
493
return tk ().getFont (logicalName , attrs );
493
494
}
494
495
@@ -499,12 +500,12 @@ public Font deriveFont (Font font, int style)
499
500
* useful if you are sharing peers between Font objects. Otherwise it may
500
501
* be ignored.
501
502
*/
502
-
503
- public Font deriveFont (Font font , int style , AffineTransform t )
503
+ @ SuppressWarnings ( "unused" )
504
+ public Font deriveFont (Font font , int newStyle , AffineTransform t )
504
505
{
505
- Map attrs = new HashMap ();
506
+ Map < TextAttribute , Object > attrs = new HashMap < TextAttribute , Object > ();
506
507
getStandardAttributes (attrs );
507
- copyStyleToAttrs (style , attrs );
508
+ copyStyleToAttrs (newStyle , attrs );
508
509
copyTransformToAttrs (t , attrs );
509
510
return tk ().getFont (logicalName , attrs );
510
511
}
@@ -516,10 +517,10 @@ public Font deriveFont (Font font, int style, AffineTransform t)
516
517
* useful if you are sharing peers between Font objects. Otherwise it may
517
518
* be ignored.
518
519
*/
519
-
520
+ @ SuppressWarnings ( "unused" )
520
521
public Font deriveFont (Font font , AffineTransform t )
521
522
{
522
- Map attrs = new HashMap ();
523
+ Map < TextAttribute , Object > attrs = new HashMap < TextAttribute , Object > ();
523
524
getStandardAttributes (attrs );
524
525
copyTransformToAttrs (t , attrs );
525
526
return tk ().getFont (logicalName , attrs );
@@ -532,8 +533,9 @@ public Font deriveFont (Font font, AffineTransform t)
532
533
* useful if you are sharing peers between Font objects. Otherwise it may
533
534
* be ignored.
534
535
*/
535
-
536
- public Font deriveFont (Font font , Map attrs )
536
+ @ SuppressWarnings ("unused" )
537
+ public Font deriveFont (Font font ,
538
+ Map <? extends AttributedCharacterIterator .Attribute ,?> attrs )
537
539
{
538
540
return tk ().getFont (logicalName , attrs );
539
541
}
@@ -545,10 +547,10 @@ public Font deriveFont (Font font, Map attrs)
545
547
* useful if you are sharing peers between Font objects. Otherwise it may
546
548
* be ignored.
547
549
*/
548
-
549
- public Map getAttributes (Font font )
550
+ @ SuppressWarnings ( "unused" )
551
+ public Map < TextAttribute ,?> getAttributes (Font font )
550
552
{
551
- HashMap h = new HashMap ();
553
+ HashMap < TextAttribute , Object > h = new HashMap < TextAttribute , Object > ();
552
554
getStandardAttributes (h );
553
555
return h ;
554
556
}
@@ -560,8 +562,8 @@ public Map getAttributes (Font font)
560
562
* useful if you are sharing peers between Font objects. Otherwise it may
561
563
* be ignored.
562
564
*/
563
-
564
- public AttributedCharacterIterator .Attribute [] getAvailableAttributes (Font font )
565
+ @ SuppressWarnings ( "unused" )
566
+ public static AttributedCharacterIterator .Attribute [] getAvailableAttributes (Font font )
565
567
{
566
568
AttributedCharacterIterator .Attribute a [] =
567
569
new AttributedCharacterIterator .Attribute [5 ];
@@ -580,7 +582,7 @@ public AttributedCharacterIterator.Attribute[] getAvailableAttributes(Font font)
580
582
* useful if you are sharing peers between Font objects. Otherwise it may
581
583
* be ignored.
582
584
*/
583
-
585
+ @ SuppressWarnings ( "unused" )
584
586
public AffineTransform getTransform (Font font )
585
587
{
586
588
if (transform == null )
@@ -595,7 +597,7 @@ public AffineTransform getTransform (Font font)
595
597
* useful if you are sharing peers between Font objects. Otherwise it may
596
598
* be ignored.
597
599
*/
598
-
600
+ @ SuppressWarnings ( "unused" )
599
601
public boolean isTransformed (Font font )
600
602
{
601
603
return ! transform .isIdentity ();
@@ -608,13 +610,12 @@ public boolean isTransformed (Font font)
608
610
* useful if you are sharing peers between Font objects. Otherwise it may
609
611
* be ignored.
610
612
*/
611
-
613
+ @ SuppressWarnings ( "unused" )
612
614
public float getItalicAngle (Font font )
613
615
{
614
616
if ((style & Font .ITALIC ) == Font .ITALIC )
615
617
return TextAttribute .POSTURE_OBLIQUE .floatValue ();
616
- else
617
- return TextAttribute .POSTURE_REGULAR .floatValue ();
618
+ return TextAttribute .POSTURE_REGULAR .floatValue ();
618
619
}
619
620
620
621
@@ -625,7 +626,7 @@ public float getItalicAngle (Font font)
625
626
* useful if you are sharing peers between Font objects. Otherwise it may
626
627
* be ignored.
627
628
*/
628
-
629
+ @ SuppressWarnings ( "unused" )
629
630
public int getStyle (Font font )
630
631
{
631
632
return style ;
0 commit comments