All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.svg.SvgMarker Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.svg;



import com.hfg.util.StringUtil;
import com.hfg.util.collection.CollectionUtil;
import com.hfg.xml.XMLAttribute;
import com.hfg.xml.XMLTag;
import com.hfg.xml.XMLizable;

import java.awt.*;
import java.util.regex.Matcher;

//------------------------------------------------------------------------------
/**
 * Object representation of an SVG (Scalable Vector Graphics) 'marker' 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 SvgMarker extends AbstractSvgNode implements SvgNode { //########################################################################## // CONSTRUCTORS //########################################################################## //--------------------------------------------------------------------------- public SvgMarker() { super(SVG.marker); } //--------------------------------------------------------------------------- public SvgMarker(XMLTag inXMLTag) { this(); initFromXMLTag(inXMLTag); } //########################################################################## // PUBLIC METHODS //########################################################################## //--------------------------------------------------------------------------- public SvgMarker setId(String inValue) { setAttribute(SvgAttr.id, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setMarkerUnits(MarkerCoordinateSystem inValue) { setAttribute(SvgAttr.markerUnits, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setViewBox(Rectangle inValue) { setAttribute(SvgAttr.viewBox, String.format("%d %d %d %d", (int)inValue.getMinX(), (int)inValue.getMinY(), (int)inValue.getMaxX(), (int)inValue.getMaxY())); return this; } //--------------------------------------------------------------------------- public Rectangle getViewBox() { Rectangle rect = null; String stringValue = getAttributeValue(SvgAttr.viewBox); if (StringUtil.isSet(stringValue)) { String[] pieces = stringValue.split("\\s+"); int x = Integer.parseInt(pieces[0]); int y = Integer.parseInt(pieces[1]); rect = new Rectangle(x, y, Integer.parseInt(pieces[2]) - x, Integer.parseInt(pieces[3]) - y); } return rect; } //--------------------------------------------------------------------------- public SvgMarker setHeight(int inValue) { setAttribute(SvgAttr.markerHeight, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setHeight(String inValue) { setAttribute(SvgAttr.markerHeight, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setWidth(int inValue) { setAttribute(SvgAttr.markerWidth, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setWidth(String inValue) { setAttribute(SvgAttr.markerWidth, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setOrientation(String inValue) { setAttribute(SvgAttr.orient, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setRefX(int inValue) { setAttribute(SvgAttr.refX, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setRefX(String inValue) { setAttribute(SvgAttr.refX, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setRefY(int inValue) { setAttribute(SvgAttr.refY, inValue); return this; } //--------------------------------------------------------------------------- public SvgMarker setRefY(String inValue) { setAttribute(SvgAttr.refY, inValue); return this; } //--------------------------------------------------------------------------- public SvgPath addPath() { SvgPath path = new SvgPath(); addSubtag(path); return path; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy