1 |
/* AppletTag.java - representation of an HTML APPLET tag |
/* AppletTag.java - representation of an HTML APPLET tag |
2 |
Copyright (C) 2003, 2004 Thomas Fitzsimmons <fitzsim@redhat.com> |
Copyright (C) 2003, 2004, 2005 Thomas Fitzsimmons <fitzsim@redhat.com> |
3 |
|
|
4 |
This file is part of GCJ Applet Viewer. |
This file is part of GCJ Applet Viewer. |
5 |
|
|
108 |
|
|
109 |
while (tagTokenizer.nextToken() != '>') |
while (tagTokenizer.nextToken() != '>') |
110 |
{ |
{ |
111 |
|
if (tagTokenizer.ttype == StreamTokenizer.TT_EOF) |
112 |
|
break; |
113 |
|
|
114 |
if (tagTokenizer.ttype == StreamTokenizer.TT_WORD) |
if (tagTokenizer.ttype == StreamTokenizer.TT_WORD) |
115 |
{ |
{ |
116 |
if (tagTokenizer.sval.equals("name")) |
if (tagTokenizer.sval.equals("name")) |
425 |
} |
} |
426 |
token = tagTokenizer.nextToken(); |
token = tagTokenizer.nextToken(); |
427 |
} |
} |
428 |
|
|
429 |
|
// If we hit EOF, just go ahead with whatever we've got. Some |
430 |
|
// pages don't properly terminate; besides which our parser is a |
431 |
|
// bit bogus anyway. |
432 |
|
if (currentTag != null) |
433 |
|
{ |
434 |
|
currentTag.parseArchives(); |
435 |
|
return currentTag; |
436 |
|
} |
437 |
|
|
438 |
return null; |
return null; |
439 |
} |
} |
440 |
|
|
449 |
public static Dimension getSize (AppletTag tag) |
public static Dimension getSize (AppletTag tag) |
450 |
{ |
{ |
451 |
NumberFormat numberFormat; |
NumberFormat numberFormat; |
452 |
Dimension size = new Dimension(); |
Dimension size = new Dimension(320, 200); |
453 |
|
|
454 |
try |
try |
455 |
{ |
{ |
456 |
String widthStr = (String) tag.parameters.get("width"); |
String widthStr = (String) tag.parameters.get("width"); |
457 |
|
|
458 |
if (widthStr.charAt(widthStr.length() - 1) == '%') |
if (widthStr != null) |
459 |
numberFormat = NumberFormat.getPercentInstance(Locale.US); |
{ |
460 |
else |
if (widthStr.charAt(widthStr.length() - 1) == '%') |
461 |
numberFormat = NumberFormat.getInstance(Locale.US); |
numberFormat = NumberFormat.getPercentInstance(Locale.US); |
462 |
|
else |
463 |
|
numberFormat = NumberFormat.getInstance(Locale.US); |
464 |
|
|
465 |
// FIXME: Handle percentage somehow. |
// FIXME: Handle percentage somehow. |
466 |
size.width = numberFormat.parse(widthStr).intValue(); |
size.width = numberFormat.parse(widthStr).intValue(); |
467 |
|
} |
468 |
} |
} |
469 |
catch (ParseException e) |
catch (ParseException e) |
470 |
{ |
{ |
471 |
// Use default. |
// Use default. |
|
size.width = 320; |
|
472 |
} |
} |
473 |
|
|
474 |
try |
try |
475 |
{ |
{ |
476 |
String heightStr = (String) tag.parameters.get("height"); |
String heightStr = (String) tag.parameters.get("height"); |
477 |
|
|
478 |
if (heightStr.charAt(heightStr.length() - 1) == '%') |
if (heightStr != null) |
479 |
numberFormat = NumberFormat.getPercentInstance(Locale.US); |
{ |
480 |
else |
if (heightStr.charAt(heightStr.length() - 1) == '%') |
481 |
numberFormat = NumberFormat.getInstance(Locale.US); |
numberFormat = NumberFormat.getPercentInstance(Locale.US); |
482 |
|
else |
483 |
|
numberFormat = NumberFormat.getInstance(Locale.US); |
484 |
|
|
485 |
// FIXME: Handle percentage somehow. |
// FIXME: Handle percentage somehow. |
486 |
size.height = numberFormat.parse(heightStr).intValue(); |
size.height = numberFormat.parse(heightStr).intValue(); |
487 |
|
} |
488 |
} |
} |
489 |
catch (ParseException e) |
catch (ParseException e) |
490 |
{ |
{ |
491 |
// Use default. |
// Use default. |
|
size.height = 200; |
|
492 |
} |
} |
493 |
|
|
494 |
return size; |
return size; |