public abstract class AbstractUnitConverter extends com.jgoodies.common.bean.Bean implements UnitConverter
UnitConverter
interface that
minimizes the effort required to convert font-dependent sizes to pixels.DefaultUnitConverter
,
Size
,
Sizes
,
Serialized FormConstructor and Description |
---|
AbstractUnitConverter() |
Modifier and Type | Method and Description |
---|---|
int |
centimeterAsPixel(double cm,
Component component)
Converts Centimeters and returns pixels using the resolution of the
given component's graphics object.
|
protected static int |
centimeterAsPixel(double cm,
int dpi)
Converts Centimeters and returns pixels using the specified resolution.
|
protected double |
computeAverageCharWidth(FontMetrics metrics,
String testString)
Computes and returns the average character width
of the specified test string using the given FontMetrics.
|
int |
dialogUnitXAsPixel(int dluX,
Component c)
Converts horizontal dialog units and returns pixels.
|
protected int |
dialogUnitXAsPixel(int dluX,
double dialogBaseUnitsX)
Converts horizontal dialog units and returns pixels.
|
int |
dialogUnitYAsPixel(int dluY,
Component c)
Converts vertical dialog units and returns pixels.
|
protected int |
dialogUnitYAsPixel(int dluY,
double dialogBaseUnitsY)
Converts vertical dialog units and returns pixels.
|
protected int |
getDefaultScreenResolution()
Computes and returns the default resolution.
|
protected abstract double |
getDialogBaseUnitsX(Component component)
Gets and returns the horizontal dialog base units.
|
protected abstract double |
getDialogBaseUnitsY(Component component)
Gets and returns the vertical dialog base units.
|
protected int |
getScreenResolution(Component c)
Returns the components screen resolution or the default screen
resolution if the component is null or has no toolkit assigned yet.
|
int |
inchAsPixel(double in,
Component component)
Converts Inches and returns pixels using the specified resolution.
|
protected static int |
inchAsPixel(double in,
int dpi)
Converts Inches and returns pixels using the specified resolution.
|
int |
millimeterAsPixel(double mm,
Component component)
Converts Millimeters and returns pixels using the resolution of the
given component's graphics object.
|
protected static int |
millimeterAsPixel(double mm,
int dpi)
Converts Millimeters and returns pixels using the specified resolution.
|
protected static int |
pointAsPixel(double pt,
int dpi)
Converts DTP Points and returns pixels using the specified resolution.
|
int |
pointAsPixel(int pt,
Component component)
Converts DTP Points and returns pixels using the resolution of the
given component's graphics object.
|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPropertyChangeSupport, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
public int inchAsPixel(double in, Component component)
inchAsPixel
in interface UnitConverter
in
- the Inchescomponent
- the component that provides the graphics objectpublic int millimeterAsPixel(double mm, Component component)
millimeterAsPixel
in interface UnitConverter
mm
- Millimeterscomponent
- the component that provides the graphics objectpublic int centimeterAsPixel(double cm, Component component)
centimeterAsPixel
in interface UnitConverter
cm
- Centimeterscomponent
- the component that provides the graphics objectpublic int pointAsPixel(int pt, Component component)
pointAsPixel
in interface UnitConverter
pt
- DTP Pointscomponent
- the component that provides the graphics objectpublic int dialogUnitXAsPixel(int dluX, Component c)
dialogUnitXAsPixel
in interface UnitConverter
dluX
- the horizontal dialog unitsc
- a Component that provides the font and graphicspublic int dialogUnitYAsPixel(int dluY, Component c)
dialogUnitYAsPixel
in interface UnitConverter
dluY
- the vertical dialog unitsc
- a Component that provides the font and graphicsprotected abstract double getDialogBaseUnitsX(Component component)
component
- a Component that provides the font and graphicsprotected abstract double getDialogBaseUnitsY(Component component)
component
- a Component that provides the font and graphicsprotected static final int inchAsPixel(double in, int dpi)
in
- the Inchesdpi
- the resolutionprotected static final int millimeterAsPixel(double mm, int dpi)
mm
- Millimetersdpi
- the resolutionprotected static final int centimeterAsPixel(double cm, int dpi)
cm
- Centimetersdpi
- the resolutionprotected static final int pointAsPixel(double pt, int dpi)
pt
- DTP Pointsdpi
- the resolution in dpiprotected int dialogUnitXAsPixel(int dluX, double dialogBaseUnitsX)
dluX
- the horizontal dialog unitsdialogBaseUnitsX
- the horizontal dialog base unitsprotected int dialogUnitYAsPixel(int dluY, double dialogBaseUnitsY)
dluY
- the vertical dialog unitsdialogBaseUnitsY
- the vertical dialog base unitsprotected double computeAverageCharWidth(FontMetrics metrics, String testString)
metrics
- used to compute the test string's widthtestString
- the string that shall represent an "average" textprotected int getScreenResolution(Component c)
c
- the component to ask for a toolkitprotected int getDefaultScreenResolution()
Copyright © 2002-2014 JGoodies Software GmbH. All Rights Reserved.