|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
jview.JApplicationSwitcher
public class JApplicationSwitcher
An application switcher provides a set of applications, i.e. objects than can
be constructed from properties and supply a component via the
ComponentPresenting interface. It uses a card layout to display only
a single component at a time and is itself a JPanel. Due to unfortunate
coding, the linkage of name to components in the CardLayout is
non-transparent (can only switch to a component, but not query for), we
buffer that and provide a method getComponent(java.lang.String)
.info.getAsLong(KEY_INACTIVETIME) Switches can occur, if show(java.lang.String) is
called, cycling can be done with next() and previous(). Its
main application is in combination with RMI enabled code.
It either honors different priorities of the components to display in idle mode, or switch randomly between components. While for the former one the switcher is a priority listener, the second also works with equal-rank priorities.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
private boolean |
active
Active or inactive mode. |
private Map<String,Component> |
components
No access to the card-layout cards, thus we have to keep track. |
private static boolean |
DEFALLOWPRIORITY
Default we allow priority switches. |
private static int |
DEFHIDDENMODIFIERS
No modifiers for default. |
private static int |
DEFHIDDENSIZE
Default size. |
private static int |
DEFHIDDENSWITCH
Default no hidden buttons for clicking thru card layout. |
private static long |
DEFINACTIVETIME
Default inactive time in ms. |
private static long |
DEFSWITCHTIME
Default inactive time in ms. |
private JPanel |
hidden
This panel is a hiding panel and should be added to the main frame. |
private TimerTask |
inactive
The timer task that renders us inactive. |
private ResourceSupplying |
info
My properties, composed from a PropertyBundles. |
static String |
KEY_ALLOWPRIORITY
If true, we allow priority-based switch if we are in inactive phase. |
static String |
KEY_APPLICATIONS
The key that links names to properties of Displayables. |
static String |
KEY_HIDDENMODIFIERS
If none-zero, it represents a modifier mask to show the hidden panel. |
static String |
KEY_HIDDENSIZE
If this points to a valid GridBagConstraint, we add hiding buttons. |
static String |
KEY_HIDDENSWITCH
If this points to a valid GridBagConstraint, we add hiding buttons. |
static String |
KEY_INACTIVETIME
After last components switch, it takes this time until we're inactive. |
static String |
KEY_SWITCHTIME
On random switches the time between those. |
private Map<String,Icon> |
names
A list of all names that were sucessfully added to the layout. |
private Map<String,PriorityCaster> |
nettle
The priority caster that wants to be displayed. |
private Map<String,Integer> |
nettleprior
Their latest priorities. |
private String |
nextrank
The name of the second-highest component. |
private int |
priority
Priority of the currently shown object, or zero if not applicable. |
private int |
second
The second-rank priority. |
private String |
showing
The name of the component shown. |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
JApplicationSwitcher(Map<String,String> prop)
Constructs a new webcam grid. |
|
| Method Summary | |
|---|---|
private void |
addIt(Component c,
String key,
Icon i)
Adds this component, and stores a reference. |
protected void |
createRepresentation()
Delivers the central component. |
void |
exit()
On exit, we deregister and close our timer. |
Map<String,Icon> |
getAllComponents()
Returns a list of all components names in this card. |
Component |
getComponent(String id)
Returns the component of the given name in this panel. |
ResourceSupplying |
getComposedProperties()
Returns the ResourceSupplyings this frame refers to. |
protected Component |
getHiddenPanel()
Returns the hidden panel with the switch buttons, if available. |
private KeyValue<String,Integer> |
getHighest(String exclude)
We look in our prioity caster to get the second highest priority. |
private TimerTask |
getPriorityTask()
Returns a task that shows the highest priority if called. |
private TimerTask |
getRandomTask()
Returns a task that randomly switches to an application if called. |
void |
init()
On init, we create our representation. |
void |
next()
Switches to the next card. |
void |
previous()
Switches to the previous card. |
void |
priorityChanged(String castername,
int newprior)
Called by prioiry casters if their priority has changed. |
void |
setComposedProperties(ResourceSupplying prop)
Sets a ResourceSupplying object as a composite of the canvas. |
boolean |
show(String id)
Switches to the card of the given name. |
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String KEY_APPLICATIONS
Displayables.
public static final String KEY_ALLOWPRIORITY
public static final String KEY_INACTIVETIME
public static final String KEY_SWITCHTIME
public static final String KEY_HIDDENSWITCH
public static final String KEY_HIDDENSIZE
public static final String KEY_HIDDENMODIFIERS
private static final boolean DEFALLOWPRIORITY
private static final long DEFINACTIVETIME
private static final long DEFSWITCHTIME
private static final int DEFHIDDENSWITCH
private static final int DEFHIDDENSIZE
private static final int DEFHIDDENMODIFIERS
private ResourceSupplying info
PropertyBundles.
private Map<String,Icon> names
private Map<String,Component> components
private Map<String,PriorityCaster> nettle
private Map<String,Integer> nettleprior
private boolean active
private int priority
private String showing
private int second
private String nextrank
private TimerTask inactive
private JPanel hidden
| Constructor Detail |
|---|
public JApplicationSwitcher(Map<String,String> prop)
| Method Detail |
|---|
public void init()
init in interface Initializablepublic void setComposedProperties(ResourceSupplying prop)
ResourceSupplying object as a composite of the canvas.
Defaults the necessary parameter.
setComposedProperties in interface ResourceAwarepublic ResourceSupplying getComposedProperties()
ResourceSupplyings this frame refers to.
getComposedProperties in interface ResourceComposedprotected void createRepresentation()
public void priorityChanged(String castername,
int newprior)
priorityChanged in interface PriorityListenerprotected Component getHiddenPanel()
private void addIt(Component c,
String key,
Icon i)
public void next()
public void previous()
public Component getComponent(String id)
CardLayout does not provide this essential method.
public boolean show(String id)
public Map<String,Icon> getAllComponents()
public void exit()
exit in interface ExitCleaningprivate KeyValue<String,Integer> getHighest(String exclude)
private TimerTask getPriorityTask()
private TimerTask getRandomTask()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||