com.hfg.svg.SvgTextPath Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.svg;
import com.hfg.svg.attribute.SvgTextPathMethod;
import com.hfg.svg.attribute.SvgTextPathSide;
import com.hfg.svg.attribute.SvgTextPathSpacing;
//------------------------------------------------------------------------------
/**
* Object representation of an SVG (Scalable Vector Graphics) textPath tag.
*
* @author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class SvgTextPath extends AbstractSvgNode
{
//**************************************************************************
// CONSTRUCTORS
//**************************************************************************
//---------------------------------------------------------------------------
public SvgTextPath()
{
super(SVG.textPath);
}
//---------------------------------------------------------------------------
public SvgTextPath(String inText)
{
super(SVG.textPath);
setContent(inText);
}
//**************************************************************************
// PUBLIC METHODS
//**************************************************************************
//---------------------------------------------------------------------------
/**
* Specify the URL to the path or basic shape on which the text should be rendered.
* @param inValue the specified URL (usually structured like '#id_name')
* @return this textPath object to enable method chaining
*/
public SvgTextPath setHref(String inValue)
{
setAttribute(SvgAttr.href, inValue);
return this;
}
//---------------------------------------------------------------------------
public String getHref()
{
return getAttributeValue(SvgAttr.href);
}
//---------------------------------------------------------------------------
/**
* Specify an offset from the start of the path to use for rendering the text
* characters along the path.
* @param inValue the offset value
* @return this textPath object to enable method chaining
*/
public SvgTextPath setStartOffset(Integer inValue)
{
if (inValue != null)
{
setAttribute(SvgAttr.startOffset, inValue);
}
else
{
removeAttribute(SvgAttr.startOffset);
}
return this;
}
//---------------------------------------------------------------------------
/**
* Specify an offset from the start of the path to use for rendering the text
* characters along the path.
* @param inValue the offset value
* @return this textPath object to enable method chaining
*/
public SvgTextPath setStartOffsetPct(Integer inValue)
{
if (inValue != null)
{
setAttribute(SvgAttr.startOffset, inValue + "%");
}
else
{
removeAttribute(SvgAttr.startOffset);
}
return this;
}
//---------------------------------------------------------------------------
/**
* Specify the method to use for rendering the text characters along the path.
* @param inValue the rendering method (defaults to align)
* @return this textPath object to enable method chaining
*/
public SvgTextPath setMethod(SvgTextPathMethod inValue)
{
if (inValue != null)
{
setAttribute(SvgAttr.method, inValue.toString());
}
else
{
removeAttribute(SvgAttr.method);
}
return this;
}
//---------------------------------------------------------------------------
/**
* Specify how the spacing between text characters to be rendered along the path
* should be determined.
* @param inValue the spacing method (defaults to exact)
* @return this textPath object to enable method chaining
*/
public SvgTextPath setSpacing(SvgTextPathSpacing inValue)
{
if (inValue != null)
{
setAttribute(SvgAttr.spacing, inValue.toString());
}
else
{
removeAttribute(SvgAttr.spacing);
}
return this;
}
//---------------------------------------------------------------------------
/**
* Specify the side of the path text characters will be rendered on.
* Since SVG 2.0.
* @param inValue the side of the path (defaults to left)
* @return this textPath object to enable method chaining
*/
public SvgTextPath setSide(SvgTextPathSide inValue)
{
if (inValue != null)
{
setAttribute(SvgAttr.side, inValue.toString());
}
else
{
removeAttribute(SvgAttr.side);
}
return this;
}
//---------------------------------------------------------------------------
/**
* Specify the path or basic shape on which the text should be rendered.
* Since SVG 2.0.
* @param inValue the specified path (overrides a href attribute value)
* @return this textPath object to enable method chaining
*/
public SvgTextPath setPath(String inValue)
{
setAttribute(SvgAttr.path, inValue);
return this;
}
//---------------------------------------------------------------------------
public String getPath()
{
return getAttributeValue(SvgAttr.path);
}
}