001/*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016package org.opengion.hayabusa.io;
017
018import org.jfree.chart.imagemap.URLTagFragmentGenerator;
019
020/**
021 * Generates URLs using the HTML href attribute for image map area tags.
022 */
023public class HybsURLTagFragmentGenerator implements URLTagFragmentGenerator {
024        private final String href ;
025
026        /**
027         * デフォルトコンストラクター
028         *
029         */
030        public HybsURLTagFragmentGenerator() {
031                href = " href=\"";
032        }
033
034        /**
035         * 引数指定のコンストラクター
036         *
037         * 引数のターゲットに応じて、href に target 属性を追加しておきます。
038         * ターゲットが、null の場合は、デフォルトコンストラクターと同じ結果になります。
039         *
040         * @param       target ターゲット
041         */
042        public HybsURLTagFragmentGenerator( final String target ) {
043                if( target == null ) {
044                        href = " href=\"";
045                }
046                else {
047                        href = " target=\"" + target + "\" href=\"" ;
048                }
049        }
050
051        /**
052         * 引数の URLテキストを使用して、href アドレス部を作成します。
053         *
054         * @param       urlText URLテキスト
055         *
056         * @return      hrefアドレス
057         * @og.rtnNotNull
058         */
059        public String generateURLFragment( final String urlText ) {
060                return href + urlText + "\"";
061        }
062
063}