Package fr.esrf.tangoatk.widget.util
Class ATKGraphicsUtils
java.lang.Object
fr.esrf.tangoatk.widget.util.ATKGraphicsUtils
A class containing various low level graphics utils.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcenterDialog(Dialog dlg) Center the given dialog according to its parent and its preferredSize.static voidcenterDialog(Dialog dlg, int dlgWidth, int dlgHeight) Center the given dialog according to its parent.static voidcenterFrame(JComponent parent, Frame fr) Center the given frame according to the given componenent.static voidCenter the given frame on screen.static FontRenderContextstatic LineMetricsgetLineMetrics(String s, Font f) Returns the line metrics for the given font.static WindowgetWindowForComponent(Component aComponent) Return the parent Window of the given component.static int[]getWindowPosFromArgs(String[] args) static DimensionmeasureString(String s, Font f) Measure a string (using AA font , zoom and translation of Graphics2D are not supported)static voidpositionFrameOnScreen(Frame fr, int posx, int posy) Position the given frame at the requested location on screen.static voidprintComponent(JComponent comp, String title, boolean fitToPage, int printerResolution) Displays the print dialog and sends a component snapshot to the printer.
-
Constructor Details
-
ATKGraphicsUtils
public ATKGraphicsUtils()
-
-
Method Details
-
measureString
Measure a string (using AA font , zoom and translation of Graphics2D are not supported)- Parameters:
s- String to be measuredf- Font used- Returns:
- Dimesion of the string (in pixel)
-
getDefaultRenderContext
- Returns:
- the default render context.
-
getLineMetrics
Returns the line metrics for the given font.- Parameters:
s- String to be measuredf- Font object- Returns:
- LineMetrics
-
centerDialog
Center the given dialog according to its parent. If the dialog is not parented (null parent), It will appear at the center of the screen. The dialog is not displayed after a call to this function, a call to setVisible() is needed.Note: This function has been designed to work with 'heavyWeight' system dependant awt window which doesn't use a layout manager (null layout).
- Parameters:
dlg- the dialog.dlgWidth- desired width of the JDialog content pane.dlgHeight- desired height of the JDialog content pane.
-
centerDialog
Center the given dialog according to its parent and its preferredSize.- Parameters:
dlg- the dialog.
-
centerFrameOnScreen
Center the given frame on screen. The frame is not displayed after a call to this function, a call to setVisible() is needed.- Parameters:
fr- Frame to be centered.
-
centerFrame
Center the given frame according to the given componenent. The frame is not displayed after a call to this function, a call to setVisible() is needed.- Parameters:
parent- Parent componentfr- Frame to be centered.
-
getWindowForComponent
Return the parent Window of the given component.- Parameters:
aComponent- Child componenent- Returns:
- A handle to the parent window.
-
printComponent
public static void printComponent(JComponent comp, String title, boolean fitToPage, int printerResolution) Displays the print dialog and sends a component snapshot to the printer. Using the printerResolution can be usefull to print your component bigger or smaller. A screen typicaly has a resolution of ~100dpi. This method does not support multiple page documents.- Parameters:
comp- Component to be printed out.title- Title of the print dialog.fitToPage- True to fit the component to the page (printerResolution ignored).printerResolution- Printer resolution when fitToPage is not enabled.
-
positionFrameOnScreen
Position the given frame at the requested location on screen. The frame is not displayed after a call to this function, a call to setVisible() is needed.- Parameters:
fr- Frame to be positioned.posx- X positionposy- Y position
-
getWindowPosFromArgs
-