| java.lang.Object com.jidesoft.utils.PortingUtils
PortingUtils | public class PortingUtils (Code) | | A class that keeps all 1.4/1.3 different stuff.
|
Method Summary | |
public static Rectangle | containsInScreenBounds(Component invoker, Rectangle rect) To make sure the rectangle is within the screen bounds. | public static Rectangle | ensureOnScreen(Rectangle rect) Modifies the position of rect so that it is completly on screen if that is possible. | public static Rectangle | ensureVisible(Component invoker, Rectangle bounds) Ensures the rectangle is visible on the screen. | public static Rectangle | getContainingScreenBounds(Rectangle rect, boolean considerInsets) Gets the screen bounds that contains the rect. | public static Component | getCurrentFocusComponent(AWTEvent event) Gets current focused components. | public static int | getFrameState(Frame frame) Gets frame's state. | public static Rectangle | getLocalScreenBounds() Gets the local monitor's screen bounds. | public static Dimension | getLocalScreenSize(Component invoker) Gets the screen size. | public static int | getMouseModifiers(MouseEvent e) Gets mouse modifiers. | public static Area | getScreenArea() Get screen area of all monitors. | public static Rectangle | getScreenBounds(Component invoker) Gets the screen bounds. | public static Dimension | getScreenSize(Component invoker) Gets the screen size. | public static synchronized void | initializeScreenArea() If you use methods such as
PortingUtils.ensureOnScreen(java.awt.Rectangle) ,
PortingUtils.getContainingScreenBounds(java.awt.Rectangle,boolean) or
PortingUtils.getScreenArea() for the first time, it will take up to a few seconds to run because it needs to get device information. | public static synchronized void | initializeScreenArea(int priority) If you use methods such as
PortingUtils.ensureOnScreen(java.awt.Rectangle) ,
PortingUtils.getContainingScreenBounds(java.awt.Rectangle,boolean) or
PortingUtils.getScreenArea() for the first time, it will take up to a few seconds to run because it needs to get device information.
To avoid any slowness, you can call
PortingUtils.initializeScreenArea() method in the class where you will use those three methods.
This method will spawn a thread to retrieve device information thus it will return immediately.
Hopefully, when you use the three methods, the thread is done so user will not notice any slowness.
Parameters: priority - as we will use a thread to calculate the screen area, you can use this parameter to control the priority of the thread. | public static boolean | isInitalizationThreadAlive() | public static boolean | isInitalizationThreadStarted() | public static void | notifyUser() Notifies user something is wrong. | public static Rectangle | overlapWithScreenBounds(Component invoker, Rectangle rect) To make sure the rectangle has overlap with the screen bounds. | public static void | prerequisiteChecking() Checks the prerequisite needed by JIDE demos. | public static void | removeButtonBorder(AbstractButton button) Removes the button border. | public static void | removeFocus(JComponent component) Makes sure the component won't receive the focus. | public static void | setFrameState(Frame frame, int state) Sets frame's state. | public static void | withinScreen(Component invoker, Point point) Makes the point parameter is within the screen bounds. |
containsInScreenBounds | public static Rectangle containsInScreenBounds(Component invoker, Rectangle rect)(Code) | | To make sure the rectangle is within the screen bounds.
Parameters: invoker - Parameters: rect - the rectange that is in the screen bounds. |
ensureOnScreen | public static Rectangle ensureOnScreen(Rectangle rect)(Code) | | Modifies the position of rect so that it is completly on screen if that is possible.
Parameters: rect - The rectange to move onto a single screen rect after its position has been modified |
ensureVisible | public static Rectangle ensureVisible(Component invoker, Rectangle bounds)(Code) | | Ensures the rectangle is visible on the screen.
Parameters: invoker - the invoking component Parameters: bounds - the input bounds the modified bounds. |
getContainingScreenBounds | public static Rectangle getContainingScreenBounds(Rectangle rect, boolean considerInsets)(Code) | | Gets the screen bounds that contains the rect. The screen bounds consider the screen insets if any.
Parameters: rect - Parameters: considerInsets - if consider the insets. The insets is for thing like Windows Task Bar. the screen bounds that contains the rect. |
getCurrentFocusComponent | public static Component getCurrentFocusComponent(AWTEvent event)(Code) | | Gets current focused components. If 1.3, just uses event's source;
1.4, used keyboard focus manager to get the correct focused component.
Parameters: event - current focused component |
getFrameState | public static int getFrameState(Frame frame)(Code) | | Gets frame's state. In 1.3, used getState; in 1.4, uses getExtendedState.
Parameters: frame - frame's state |
getLocalScreenBounds | public static Rectangle getLocalScreenBounds()(Code) | | Gets the local monitor's screen bounds.
the screen bounds. |
getLocalScreenSize | public static Dimension getLocalScreenSize(Component invoker)(Code) | | Gets the screen size. In JDK1.4+, the returned size will exclude task bar area on Windows OS.
Parameters: invoker - the screen size. |
getMouseModifiers | public static int getMouseModifiers(MouseEvent e)(Code) | | Gets mouse modifiers. If 1.3, uses getModifiers; 1.4, getModifiersEx.
Parameters: e - mouse modifiers |
getScreenArea | public static Area getScreenArea()(Code) | | Get screen area of all monitors.
Union of all screens |
getScreenBounds | public static Rectangle getScreenBounds(Component invoker)(Code) | | Gets the screen bounds. In JDK1.4+, the returned bounds will exclude task bar area on Windows OS.
Parameters: invoker - the screen bounds. |
getScreenSize | public static Dimension getScreenSize(Component invoker)(Code) | | Gets the screen size. In JDK1.4+, the returned size will exclude task bar area on Windows OS.
Parameters: invoker - the screen size. |
initializeScreenArea | public static synchronized void initializeScreenArea(int priority)(Code) | | If you use methods such as
PortingUtils.ensureOnScreen(java.awt.Rectangle) ,
PortingUtils.getContainingScreenBounds(java.awt.Rectangle,boolean) or
PortingUtils.getScreenArea() for the first time, it will take up to a few seconds to run because it needs to get device information.
To avoid any slowness, you can call
PortingUtils.initializeScreenArea() method in the class where you will use those three methods.
This method will spawn a thread to retrieve device information thus it will return immediately.
Hopefully, when you use the three methods, the thread is done so user will not notice any slowness.
Parameters: priority - as we will use a thread to calculate the screen area, you can use this parameter to control the priority of the thread. If youare waiting for the result before the next step, you should use normal priority (which is 5). If you just want to calcualte when app starts,you can use a lower priority (such as 3). For example, AbstractComboBox needs screen size so that the popup doesn't go beyond the screen.So when AbstractComboBox is used, we will kick off the thread at priority 3. If user clicks on the drop down after the thread finished,there will be no time delay. |
isInitalizationThreadAlive | public static boolean isInitalizationThreadAlive()(Code) | | |
isInitalizationThreadStarted | public static boolean isInitalizationThreadStarted()(Code) | | |
notifyUser | public static void notifyUser()(Code) | | Notifies user something is wrong. We use Toolkit beep method by default.
|
overlapWithScreenBounds | public static Rectangle overlapWithScreenBounds(Component invoker, Rectangle rect)(Code) | | To make sure the rectangle has overlap with the screen bounds.
Parameters: invoker - Parameters: rect - the rectange that has overlap with the screen bounds. |
prerequisiteChecking | public static void prerequisiteChecking()(Code) | | Checks the prerequisite needed by JIDE demos. If the prerequisite doesn't meet, it will prompt a message box and exit.
|
removeButtonBorder | public static void removeButtonBorder(AbstractButton button)(Code) | | Removes the button border.
Parameters: button - |
removeFocus | public static void removeFocus(JComponent component)(Code) | | Makes sure the component won't receive the focus.
Parameters: component - |
setFrameState | public static void setFrameState(Frame frame, int state)(Code) | | Sets frame's state. In 1.3, uses sets frame's state; in 1.4, uses gets frame's state.
Parameters: frame - Parameters: state - |
|
|