Class StringMetrics
java.lang.Object
org.jjazz.uiutilities.api.StringMetrics
Compute string metrics.
Try to cache data whenever possible.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringMetricsCreate a StringMetrics which uses a shared Graphics2D instance from a bufferedImage.static StringMetricscreate(Graphics2D g2) Create a StringMetrics from g2 and g2.getFont().static StringMetricscreate(Graphics2D g2, Font font) Create a StringMetrics.doubleget the height of this text, including the leading (interline space).doublegetHeightNoLeading(String text) Get the height of this text, excluding the leading (interline space).getLogicalBounds(String text) Return a rectangle in baseline relative coordinates, include the leading (interline spacing).Return a rectangle in baseline relative coordinates, excluding the leading (interline spacing).Return a rectangle in baseline relative coordinates, excluding the descent and the leading (interline spacing).double
-
Method Details
-
create
Create a StringMetrics which uses a shared Graphics2D instance from a bufferedImage.- Parameters:
font-- Returns:
- Might be a cached instance.
-
create
Create a StringMetrics from g2 and g2.getFont().- Parameters:
g2-- Returns:
- Might be a cached instance.
-
create
Create a StringMetrics.- Parameters:
g2-font-- Returns:
- Might be a cached instance.
-
getLogicalBounds
Return a rectangle in baseline relative coordinates, include the leading (interline spacing).If this method is called several times in a row with the same text, the cached result is returned.
- Parameters:
text-- Returns:
-
getLogicalBoundsNoLeading
Return a rectangle in baseline relative coordinates, excluding the leading (interline spacing).If this method is called several times in a row with the same text, the cached result is returned.
- Parameters:
text-- Returns:
-
getLogicalBoundsNoLeadingNoDescent
Return a rectangle in baseline relative coordinates, excluding the descent and the leading (interline spacing).See LineMetrics or FontMetrics for more info about descent/leading.
If this method is called several times in a row with the same text, the cached result is returned.
- Parameters:
text-- Returns:
-
getWidth
-
getHeight
get the height of this text, including the leading (interline space).- Parameters:
text-- Returns:
-
getHeightNoLeading
Get the height of this text, excluding the leading (interline space).- Parameters:
text-- Returns:
-