Class ATKGraphicsUtils

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

public class ATKGraphicsUtils extends Object
A class containing various low level graphics utils.
  • Constructor Details

    • ATKGraphicsUtils

      public ATKGraphicsUtils()
  • Method Details

    • measureString

      public static Dimension measureString(String s, 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 FontRenderContext getDefaultRenderContext()
      Returns:
      the default render context.
    • getLineMetrics

      public static LineMetrics getLineMetrics(String s, 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(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(Dialog dlg)
      Center the given dialog according to its parent and its preferredSize.
      Parameters:
      dlg - the dialog.
    • centerFrameOnScreen

      public static void centerFrameOnScreen(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(JComponent parent, 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 Window getWindowForComponent(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(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

      public static void positionFrameOnScreen(Frame fr, int posx, int posy)
      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 position
      posy - Y position
    • getWindowPosFromArgs

      public static int[] getWindowPosFromArgs(String[] args)