Package idare.imagenode.Utilities
Class LayoutUtils
- java.lang.Object
-
- idare.imagenode.Utilities.LayoutUtils
-
public class LayoutUtils extends Object
Class that provides several utility function to handle SVG Objects (like DOM initialization etc pp- Author:
- Thomas Pfau
-
-
Constructor Summary
Constructors Constructor Description LayoutUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.w3c.dom.svg.SVGDocument
createSVGDoc()
Create an SVG Document using a default DOM implementation.static HashMap<Comparable,String>
getLabelsForData(Vector<Comparable> entries)
Get alphanumeric unique labels for a set of entries (i.e.static FontMetrics
getSVGFontMetrics(Font font)
static Font
scaleFont(Dimension dim, Font font, Graphics g, String label)
Scale a Font so that a given label fits into a specific dimension.static Font
scaleSVGFont(Dimension dim, Font font, String label)
Scale a Font so that a given label fits into a specific dimension in an SVG context.static void
TransferGraphicsToDocument(org.w3c.dom.svg.SVGDocument doc, Dimension canvasdimension, org.apache.batik.svggen.SVGGraphics2D g)
Transfer data that was writen to anSVGGraphics2D
context to a document using a specified canvasdimension.
-
-
-
Method Detail
-
createSVGDoc
public static org.w3c.dom.svg.SVGDocument createSVGDoc()
Create an SVG Document using a default DOM implementation.- Returns:
- An SVG Document with default settings
-
getSVGFontMetrics
public static FontMetrics getSVGFontMetrics(Font font)
-
TransferGraphicsToDocument
public static void TransferGraphicsToDocument(org.w3c.dom.svg.SVGDocument doc, Dimension canvasdimension, org.apache.batik.svggen.SVGGraphics2D g)
Transfer data that was writen to anSVGGraphics2D
context to a document using a specified canvasdimension.- Parameters:
doc
- - theSVGDocument
to write to.canvasdimension
- - the target canvas dimension (can benull
, in which instance default sizes are used (400/290)g
- - TheSVGGraphics2D
Context to write in.
-
scaleSVGFont
public static Font scaleSVGFont(Dimension dim, Font font, String label)
Scale a Font so that a given label fits into a specific dimension in an SVG context.- Parameters:
dim
- - the dimension the label should fit in.font
- - the font to scale.label
- - the String that should fit into the dimension.- Returns:
- the font scaled to the provided Dimension using a default svg graphics context
-
scaleFont
public static Font scaleFont(Dimension dim, Font font, Graphics g, String label)
Scale a Font so that a given label fits into a specific dimension.- Parameters:
dim
- - the dimension the label should fit in.font
- - the font to scale.g
- - the graphics context to uselabel
- - the String that should fit into the dimension.- Returns:
- the font scaled to the provided Dimension
-
getLabelsForData
public static HashMap<Comparable,String> getLabelsForData(Vector<Comparable> entries)
Get alphanumeric unique labels for a set of entries (i.e. for labeling items or similar things) This function provides the same labels when called with the same entries- Parameters:
entries
- - Comparable objects (not necessarily of the same type)- Returns:
- a Mapping of the provided objects to alphanumeric labels.
-
-