org.malai.widget
Class WidgetUtilities

java.lang.Object
  extended by org.malai.widget.WidgetUtilities

public class WidgetUtilities
extends java.lang.Object

This singleton provides common methods for widgets.

This file is part of Malai.
Copyright (c) 2009-2012 Arnaud BLOUIN

Malai is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Malai is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

11/02/2010

Since:
0.2
Version:
0.2
Author:
Arnaud BLOUIN

Field Summary
static WidgetUtilities INSTANCE
          The singleton of the class.
 
Constructor Summary
protected WidgetUtilities()
          Initialise the singleton.
 
Method Summary
 void attachAddedComponent(SwingEventManager eventManager, java.awt.Component comp)
          Attaches the given component to the event manager of the panel if it exists.
 boolean contains(java.awt.Component[] subComponents, java.lang.Object obj)
          Tests if the given object is contained into the given components.
 boolean contains(java.awt.Component component, double x, double y)
          Tests if the given point is into the pickable object.
 Pickable getPickableAt(java.awt.Component component, java.awt.Component[] subComponents, double x, double y)
           
 Picker getPicker(java.awt.Component component)
           
 Picker getPickerAt(java.awt.Component component, java.awt.Component[] subComponents, double x, double y)
           
 java.awt.geom.Point2D getRelativePoint(java.awt.Component[] comps, double x, double y, java.lang.Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final WidgetUtilities INSTANCE
The singleton of the class.

Constructor Detail

WidgetUtilities

protected WidgetUtilities()
Initialise the singleton.

Since:
0.2
Method Detail

contains

public boolean contains(java.awt.Component[] subComponents,
                        java.lang.Object obj)
Tests if the given object is contained into the given components.

Parameters:
subComponents - The components to test.
obj - The object to test.
Returns:
True: the given is contained into the given components. Otherwise, false.
Since:
0.2

contains

public boolean contains(java.awt.Component component,
                        double x,
                        double y)
Tests if the given point is into the pickable object.

Parameters:
component - The concerned widget.
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
True if the given point is into the pickable object.
Since:
0.1

getPicker

public Picker getPicker(java.awt.Component component)
Parameters:
component - The concerned widget.
Returns:
The picker object that contains the pickable object.
Since:
0.2

getPickerAt

public Picker getPickerAt(java.awt.Component component,
                          java.awt.Component[] subComponents,
                          double x,
                          double y)
Parameters:
component - The component to test.
subComponents - The sub-components of the given component.
x - The x-coordinate to test.
y - The Y-coordinate to test.
Returns:
True if the given component and one of its sub-components contains the given point.
Since:
0.2

getPickableAt

public Pickable getPickableAt(java.awt.Component component,
                              java.awt.Component[] subComponents,
                              double x,
                              double y)
Parameters:
component - The concerned widget.
subComponents - All the components that contains the given component.
x - The x-coordinate of the position used to get the pickable object.
y - The y-coordinate of the position used to get the pickable object.
Returns:
The pickable object at the given position.
Since:
0.2

getRelativePoint

public java.awt.geom.Point2D getRelativePoint(java.awt.Component[] comps,
                                              double x,
                                              double y,
                                              java.lang.Object o)
Parameters:
comps - The components contained by a widget.
x - The x-coordinate of the position to convert.
y - The y-coordinate of the position to convert.
o - An object contained by the calling picker. This function will computed the real position of the given point in o.
Returns:
Converts the given point in to fit the coordinates of the given object contained by the picker. For instance, given an object o1 that contains an other object o2 at position (10, 10). o1.getRelativePoint(30, 30, o2) will return (20, 20).
Since:
0.2

attachAddedComponent

public void attachAddedComponent(SwingEventManager eventManager,
                                 java.awt.Component comp)
Attaches the given component to the event manager of the panel if it exists.

Parameters:
comp - The component to attach.
eventManager - The event manager where the given component will be attached.
Since:
0.2