You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FontEventAdapter.java 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fonts;
  19. import java.util.Map;
  20. import org.apache.fop.events.Event;
  21. import org.apache.fop.events.EventBroadcaster;
  22. import org.apache.fop.events.model.EventSeverity;
  23. /**
  24. * Event listener interface for font-related events. This interface extends FontEventListener
  25. * and EventProducer for integration into FOP's event subsystem.
  26. */
  27. public class FontEventAdapter implements FontEventListener {
  28. private EventBroadcaster eventBroadcaster;
  29. /**
  30. * Creates a new FontEventAdapter.
  31. * @param broadcaster the event broadcaster to send the generated events to
  32. */
  33. public FontEventAdapter(EventBroadcaster broadcaster) {
  34. this.eventBroadcaster = broadcaster;
  35. }
  36. /**
  37. * Returns the event group ID.
  38. * @return the event group ID
  39. */
  40. protected String getEventGroupID() {
  41. return getClass().getName();
  42. }
  43. /** {@inheritDoc} */
  44. public void fontSubstituted(Object source, FontTriplet requested, FontTriplet effective) {
  45. Map params = new java.util.HashMap();
  46. params.put("requested", requested);
  47. params.put("effective", effective);
  48. Event ev = new Event(source, getEventGroupID() + ".fontSubstituted",
  49. EventSeverity.WARN, params);
  50. this.eventBroadcaster.broadcastEvent(ev);
  51. }
  52. /** {@inheritDoc} */
  53. public void fontLoadingErrorAtAutoDetection(Object source, String fontURL, Exception e) {
  54. Map params = new java.util.HashMap();
  55. params.put("fontURL", fontURL);
  56. params.put("e", e);
  57. Event ev = new Event(source, getEventGroupID() + ".fontLoadingErrorAtAutoDetection",
  58. EventSeverity.WARN, params);
  59. this.eventBroadcaster.broadcastEvent(ev);
  60. }
  61. /** {@inheritDoc} */
  62. public void glyphNotAvailable(Object source, char ch, String fontName) {
  63. Map params = new java.util.HashMap();
  64. params.put("ch", new Character(ch));
  65. params.put("fontName", fontName);
  66. Event ev = new Event(source, getEventGroupID() + ".glyphNotAvailable",
  67. EventSeverity.WARN, params);
  68. this.eventBroadcaster.broadcastEvent(ev);
  69. }
  70. }