batik入門記その4 〜Squiggle-the SVG Browser解析編3〜

UserAgentについて調べてみることにした。そもそも、UserAgentなるものは以下の二つがある。

  • org.apache.batik.bridge.UserAgent
  • org.apache.batik.swing.svg.SVGUserAgent

それぞれ、

 public interface UserAgent
  An interface that provides access to the User Agent informations 
 needed by the bridge. 

 public interface SVGUserAgent
  This interface must be implemented to provide client services to 
 a JSVGComponent. 

となっている。UserAgentって何?ドキュメントにも何もんだか記載がないためようわからない。そもそもこの二つって非常に似ててわかりづらいよ。ざっと見API同じなんですけど…全く継承関係ないんですよね。

全然見えてこないので、とりあえずSVGBrowserでどうなってるかを調べることにする。なのでJSVGViewerFrameにZoomIn。う〜ん、独自にSVGUserAgentを実装している。そっか、mustなんだもんね。

 protected class UserAgent implements SVGUserAgent{…}

駄目だ…まるでわからない。アプリ(独自実装のViewr)固有の設定情報、エラー発生時の挙動等を記述するっぽいのだがそんなに必要なのか?と正直思う。JSVGCanvasではそのUserAgent(中身はSVGUserAgent)を受け取って、UserAgentは自分で作っている。中身の方はというと、SVGUserAgentに頼れる所は処理を委譲して、それ以外であれば自分(UserAgent)で処理をしている。これ以上は深入り出来そうにないので悔しいけれど無視して進むことにしよう。