Package com.iizigo.term
Class TermUtil
java.lang.Object
com.iizigo.term.TermUtil
Utilities class.
- Author:
- Christopher Mindus
- Field SummaryFields
- Constructor SummaryConstructors
- Method SummaryModifier and TypeMethodDescription- static Font- deriveFont- (Graphics g, Font font, int cxFont, int cyFont) Derives a new font from another one by scaling it.- static String[]Get available fonts.- static String[]Get available monospaced fonts.- static FontMetrics- getFontMetrics- (Component c, Font f) Gets the FontMetrics from the component in question or default toolkit if component is null.- static FontMetricsGets the FontMetrics from the default toolkit.- static Graphics2DGets a screen compatible Graphics2D instance that is preset for font (text) anti-aliasing and fractional metrics (instead of Integers).- static Graphics2D- getGraphics- (JComponent component) Gets the graphics of a JComponent.- static booleanChecks if a font is available.- static void- setTextAntiAlias- (Graphics g, boolean on) Sets or removes text anti-aliasing (only when using Java2D).
- Field Details- INSETS_0An easy way to do- new Insets(0,0,0,0).
 
- Constructor Details- TermUtilpublic TermUtil()
 
- Method Details- getAvailableFontsGet available fonts.- Workaround for JDK 1.7 Bug ID 7083197: Font returns BOLD version if i ask for PLAIN after getAllFonts() call. - Returns:
- list of available font names or null if error.
 
- hasFontChecks if a font is available.- Parameters:
- font- The font name.
- Returns:
- true if font exists, false otherwise.
 
- getGraphicsGets a screen compatible Graphics2D instance that is preset for font (text) anti-aliasing and fractional metrics (instead of Integers).- Returns:
- The Graphics2D instance: DO NOT FORGET TO CALL dispose()on it when you are done with it.
 
- getGraphicsGets the graphics of a JComponent. If the method- JComponent.getGraphics()returns- null, the Graphics2D from- getGraphics()is returned.- The Graphics2D instance is preset for font (text) anti-aliasing and fractional metrics (instead of Integers). - Parameters:
- component- The JComponent.
- Returns:
- The Graphics2D instance: DO NOT FORGET TO CALL dispose()on it when you are done with it.
 
- getFontMetricsGets the FontMetrics from the default toolkit. This method is deprecated in the Toolkit implementation, so it may be removed. Use this method for safety.- Returns:
- The font metrics for the screen.
 
- getFontMetricsGets the FontMetrics from the component in question or default toolkit if component is null. This method is deprecated in the Toolkit implementation, so it may be removed. Use this method for safety.- Parameters:
- c- The component, or null for none.
- f- The font.
- Returns:
- The font metrics for the component or the screen.
 
- getAvailableMonospacedFontsGet available monospaced fonts.- Returns:
- list of available font names or null if error.
 
- deriveFontDerives a new font from another one by scaling it.- Parameters:
- g- The Graphics2D object.
- font- The font.
- cxFont- The width of the font in pixels.
- cyFont- The height of the font in pixels.
- Returns:
- The new font with the specified size.
 
- setTextAntiAliasSets or removes text anti-aliasing (only when using Java2D).- Parameters:
- g- The graphics.
- on- The flag.