fr.esrf.tangoatk.widget.util
Class ATKGraphicsUtils

java.lang.Object
  extended by fr.esrf.tangoatk.widget.util.ATKGraphicsUtils

public class ATKGraphicsUtils
extends java.lang.Object

A class containing various low level graphics utils.


Constructor Summary
ATKGraphicsUtils()
           
 
Method Summary
static void centerDialog(java.awt.Dialog dlg)
          Center the given dialog according to its parent and its preferredSize.
static void centerDialog(java.awt.Dialog dlg, int dlgWidth, int dlgHeight)
          Center the given dialog according to its parent.
static void centerFrame(javax.swing.JComponent parent, java.awt.Frame fr)
          Center the given frame according to the given componenent.
static void centerFrameOnScreen(java.awt.Frame fr)
          Center the given frame on screen.
static java.awt.font.FontRenderContext getDefaultRenderContext()
          Retreive the default render context.
static java.awt.font.LineMetrics getLineMetrics(java.lang.String s, java.awt.Font f)
          Returns the line metrics for the given font.
static java.awt.Window getWindowForComponent(java.awt.Component aComponent)
          Return the parent Window of the given component.
static java.awt.Dimension measureString(java.lang.String s, java.awt.Font f)
          Measure a string (using AA font , zoom and translation of Graphics2D are not supported)
static void printComponent(javax.swing.JComponent comp, java.lang.String title, boolean fitToPage, int printerResolution)
          Displays the print dialog and sends a component snapshot to the printer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ATKGraphicsUtils

public ATKGraphicsUtils()
Method Detail

measureString

public static java.awt.Dimension measureString(java.lang.String s,
                                               java.awt.Font f)
Measure a string (using AA font , zoom and translation of Graphics2D are not supported)

Parameters:
s - String to be measured
f - Font used
Returns:
Dimesion of the string (in pixel)

getDefaultRenderContext

public static java.awt.font.FontRenderContext getDefaultRenderContext()
Retreive the default render context.


getLineMetrics

public static java.awt.font.LineMetrics getLineMetrics(java.lang.String s,
                                                       java.awt.Font f)
Returns the line metrics for the given font.

Parameters:
s - String to be measured
f - Font object
Returns:
LineMetrics

centerDialog

public static void centerDialog(java.awt.Dialog dlg,
                                int dlgWidth,
                                int dlgHeight)
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

public static void centerDialog(java.awt.Dialog dlg)
Center the given dialog according to its parent and its preferredSize.

Parameters:
dlg - the dialog.

centerFrameOnScreen

public static void centerFrameOnScreen(java.awt.Frame fr)
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

public static void centerFrame(javax.swing.JComponent parent,
                               java.awt.Frame fr)
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 component
fr - Frame to be centered.

getWindowForComponent

public static java.awt.Window getWindowForComponent(java.awt.Component aComponent)
Return the parent Window of the given component.

Parameters:
aComponent - Child componenent
Returns:
A handle to the parent window.

printComponent

public static void printComponent(javax.swing.JComponent comp,
                                  java.lang.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.