public final class SVGUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static javax.swing.text.html.StyleSheet |
colorLookupStylesheet
CSS Stylesheet from Javax, to parse color values.
|
static java.text.NumberFormat |
FMT
Formatter to output numbers in a valid SVG number format.
|
static java.lang.String |
HOURGLASS_PATH
Hourglass object.
|
static java.lang.String |
HOURGLASS_STYLE
Hourglass style.
|
private static int |
NO_VALUE
Key not found value.
|
private static it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap<java.lang.String> |
SVG_COLOR_NAMES
SVG color names conversion.
|
static java.lang.String |
THROBBER_PATH
Throbber path.
|
static java.lang.String |
THROBBER_STYLE
Throbber style.
|
| Modifier | Constructor and Description |
|---|---|
private |
SVGUtil()
Private constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addCSSClass(org.w3c.dom.Element e,
java.lang.String cssclass)
Add a CSS class to an Element.
|
static java.lang.String |
colorToString(java.awt.Color col)
Convert a color name from an AWT color object to CSS syntax
Note: currently only RGB (from ARGB order) are supported.
|
static java.lang.String |
colorToString(int col)
Convert a color name from an integer RGB color to CSS syntax
Note: currently only RGB (from ARGB order) are supported.
|
static org.w3c.dom.svg.SVGPoint |
elementCoordinatesFromEvent(org.w3c.dom.Document doc,
org.w3c.dom.Element tag,
org.w3c.dom.events.Event evt)
Convert the coordinates of an DOM Event from screen into element
coordinates.
|
static java.lang.String |
fmt(double x)
Format a double according to the SVG specs.
|
static java.lang.String |
makeMarginTransform(double owidth,
double oheight,
double iwidth,
double iheight,
double margin)
Make a transform string to add margins
|
static java.lang.String |
makeMarginTransform(double owidth,
double oheight,
double iwidth,
double iheight,
double xmargin,
double ymargin)
Make a transform string to add margins
|
static java.lang.String |
makeMarginTransform(double owidth,
double oheight,
double iwidth,
double iheight,
double lmargin,
double tmargin,
double rmargin,
double bmargin)
Make a transform string to add margins
|
static org.w3c.dom.Element |
makeStyleElement(org.w3c.dom.Document document)
Make a new CSS style element for the given Document.
|
static void |
removeCSSClass(org.w3c.dom.Element e,
java.lang.String cssclass)
Remove a CSS class from an Element.
|
static void |
removeFromParent(org.w3c.dom.Element elem)
Remove an element from its parent, if defined.
|
static void |
removeLastChild(org.w3c.dom.Element tag)
Remove last child of an element, when present
|
static void |
setAtt(org.w3c.dom.Element el,
java.lang.String name,
double d)
Set a SVG attribute
|
static void |
setAtt(org.w3c.dom.Element el,
java.lang.String name,
int d)
Set a SVG attribute
|
static void |
setAtt(org.w3c.dom.Element el,
java.lang.String name,
java.lang.String d)
Set a SVG attribute
|
static void |
setCSSClass(org.w3c.dom.Element e,
java.lang.String cssclass)
Set the CSS class of an Element.
|
static void |
setStyle(org.w3c.dom.Element el,
java.lang.String d)
Set a SVG style attribute
|
static java.awt.Color |
stringToColor(java.lang.String str)
Convert a color name from SVG syntax to an AWT color object.
|
static org.w3c.dom.Element |
svgCircle(org.w3c.dom.Document document,
double cx,
double cy,
double r)
Create a SVG circle element.
|
static org.w3c.dom.Element |
svgCircleSegment(SVGPlot svgp,
double centerx,
double centery,
double angleStart,
double angleDelta,
double innerRadius,
double outerRadius)
Create a circle segment.
|
static org.w3c.dom.Element |
svgElement(org.w3c.dom.Document document,
java.lang.String name)
Create a SVG element in appropriate namespace
|
static org.w3c.dom.Element |
svgLine(org.w3c.dom.Document document,
double x1,
double y1,
double x2,
double y2)
Create a SVG line element.
|
static org.w3c.dom.Element |
svgRect(org.w3c.dom.Document document,
double x,
double y,
double w,
double h)
Create a SVG rectangle element.
|
static org.w3c.dom.Element |
svgText(org.w3c.dom.Document document,
double x,
double y,
java.lang.String text)
Create a SVG text element.
|
static org.w3c.dom.Element |
svgWaitIcon(org.w3c.dom.Document document,
double x,
double y,
double w,
double h)
Draw a simple "please wait" icon (in-progress) as placeholder for running
renderings.
|
public static final java.text.NumberFormat FMT
public static final java.lang.String HOURGLASS_PATH
public static final java.lang.String HOURGLASS_STYLE
public static final java.lang.String THROBBER_PATH
public static final java.lang.String THROBBER_STYLE
private static final it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap<java.lang.String> SVG_COLOR_NAMES
private static final int NO_VALUE
private static final javax.swing.text.html.StyleSheet colorLookupStylesheet
public static java.lang.String fmt(double x)
x - number to formatpublic static org.w3c.dom.Element svgElement(org.w3c.dom.Document document,
java.lang.String name)
document - containing documentname - node namepublic static void setAtt(org.w3c.dom.Element el,
java.lang.String name,
double d)
el - elementname - attribute named - double valuepublic static void setAtt(org.w3c.dom.Element el,
java.lang.String name,
int d)
el - elementname - attribute named - integer valuepublic static void setAtt(org.w3c.dom.Element el,
java.lang.String name,
java.lang.String d)
el - elementname - attribute named - string valuepublic static void setStyle(org.w3c.dom.Element el,
java.lang.String d)
el - elementd - style valuepublic static void setCSSClass(org.w3c.dom.Element e,
java.lang.String cssclass)
addCSSClass(org.w3c.dom.Element, java.lang.String) and
removeCSSClass(org.w3c.dom.Element, java.lang.String).e - Elementcssclass - class to set.public static void addCSSClass(org.w3c.dom.Element e,
java.lang.String cssclass)
e - Elementcssclass - class to add.public static void removeCSSClass(org.w3c.dom.Element e,
java.lang.String cssclass)
e - Elementcssclass - class to remove.public static org.w3c.dom.Element makeStyleElement(org.w3c.dom.Document document)
document - document (factory)public static org.w3c.dom.Element svgRect(org.w3c.dom.Document document,
double x,
double y,
double w,
double h)
document - document to create in (factory)x - X coordinatey - Y coordinatew - Widthh - Heightpublic static org.w3c.dom.Element svgCircle(org.w3c.dom.Document document,
double cx,
double cy,
double r)
document - document to create in (factory)cx - center Xcy - center Yr - radiuspublic static org.w3c.dom.Element svgLine(org.w3c.dom.Document document,
double x1,
double y1,
double x2,
double y2)
document - document to create in (factory)x1 - first point xy1 - first point yx2 - second point xy2 - second point ypublic static org.w3c.dom.Element svgText(org.w3c.dom.Document document,
double x,
double y,
java.lang.String text)
document - document to create in (factory)x - first point xy - first point ytext - Content of text element.public static org.w3c.dom.Element svgWaitIcon(org.w3c.dom.Document document,
double x,
double y,
double w,
double h)
document - Document.x - Lefty - Topw - Widthh - HeightSVGConstants.SVG_PATH_TAG)public static java.awt.Color stringToColor(java.lang.String str)
str - Color namepublic static java.lang.String colorToString(java.awt.Color col)
col - Color valuepublic static java.lang.String colorToString(int col)
col - Color valuepublic static java.lang.String makeMarginTransform(double owidth,
double oheight,
double iwidth,
double iheight,
double lmargin,
double tmargin,
double rmargin,
double bmargin)
owidth - Width of outer (embedding) canvasoheight - Height of outer (embedding) canvasiwidth - Width of inner (embedded) canvasiheight - Height of inner (embedded) canvaslmargin - Left margin (in inner canvas' units)tmargin - Top margin (in inner canvas' units)rmargin - Right margin (in inner canvas' units)bmargin - Bottom margin (in inner canvas' units)public static java.lang.String makeMarginTransform(double owidth,
double oheight,
double iwidth,
double iheight,
double xmargin,
double ymargin)
owidth - Width of outer (embedding) canvasoheight - Height of outer (embedding) canvasiwidth - Width of inner (embedded) canvasiheight - Height of inner (embedded) canvasxmargin - Left and right margin (in inner canvas' units)ymargin - Top and bottom margin (in inner canvas' units)public static java.lang.String makeMarginTransform(double owidth,
double oheight,
double iwidth,
double iheight,
double margin)
owidth - Width of outer (embedding) canvasoheight - Height of outer (embedding) canvasiwidth - Width of inner (embedded) canvasiheight - Height of inner (embedded) canvasmargin - Margin (in inner canvas' units)public static org.w3c.dom.svg.SVGPoint elementCoordinatesFromEvent(org.w3c.dom.Document doc,
org.w3c.dom.Element tag,
org.w3c.dom.events.Event evt)
doc - Document contexttag - Element containing the coordinate systemevt - Event to interpretpublic static void removeLastChild(org.w3c.dom.Element tag)
tag - Parentpublic static void removeFromParent(org.w3c.dom.Element elem)
elem - Element to removepublic static org.w3c.dom.Element svgCircleSegment(SVGPlot svgp, double centerx, double centery, double angleStart, double angleDelta, double innerRadius, double outerRadius)
svgp - Plot to draw tocenterx - Center X positioncentery - Center Y positionangleStart - Starting angleangleDelta - Angle deltainnerRadius - inner radiusouterRadius - outer radiusCopyright © 2019 ELKI Development Team. License information.