Multitouch Table FH Ingolstadt: Unterschied zwischen den Versionen

Zur Navigation springen Zur Suche springen
keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
== Gatterzeux ==
 
== dasSwing vom+ BenMT4J ==
[[Datei:Mttproject-mt4j-swingtexture.png|300px]]
 
MT4J offers the possibility to integrate Swing Components and thereby enables the user
to include existing applications of single Swing components.
To display these components, MT4J provides a SwingTextureRenderer-Object.
In a sample application, the SwingTextureRenderer was added to a MTTextKeyboard as a child
component.
During the evaluation of the SwingTextureRenderer, especially 2 things were of great interest:
# which rendering update frequency is necessary, to provide a smooth user experience, is the
#:performance of SwingTextureRenderers sufficient for that
 
# how is possible, to forward MT4J user input to the swing application
 
concerning 1.
An update-rate of 150ms has proven to be appropriate, however higher rate were possible as well,
100ms and even below.
A possible pitfall is the code-location, in which the scheduleRefresh-method of SwingTextureRenderers (str)
is invoked. The method may only be called in the updateComponent-method of its parent-object (in this case:
MTTextKeyboard)
 
@Override
public void updateComponent(long timeDelta) {
if (str != null) {
totalDelta += timeDelta;
if (totalDelta >= 150) {
totalDelta = 0;
str.scheduleRefresh();
}
}
super.updateComponent(timeDelta);
}
 
 
concerning 2.
In the example only keyboard input was considered, meaning that touch-gestures on a Swing-component were
no forwarded to swing as mouse event.
As a first step, the objective was setting the focus to the Swing-component, which was supposed to process the key events.
In the following, the events were just pushed into the event queue.
 
protected void onKeyboardButtonClicked(MTKey clickedKey, boolean shiftPressed) {
/* submitKeyEvent(char newChar) */
final String newChar = clickedKey.getCharacterToWrite();
Toolkit toolkit = Toolkit.getDefaultToolkit();
EventQueue queue = toolkit.getSystemEventQueue();
try {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
swing_app.getEditorWindow().getTextPane().requestFocusInWindow();
queue.postEvent(new KeyEvent(swing_app.getEditorWindow().getTextPane(),
KeyEvent.KEY_TYPED,
System.currentTimeMillis(),
0,
KeyEvent.VK_UNDEFINED,
newChar));
}
});
} catch (Exception ex) {
}
System.out.println(newChar);
}
 
Unfortunately, this solution turned out to be a dead end.
The events could't be dispatched/processed by the Swing-component.
A possible way to go, is sending the event no to the Swing-component (e.g. JFrame) but to the
underlying document-object.
 
protected void onKeyboardButtonClicked(MTKey clickedKey, boolean shiftPressed) {
/* submitKeyEvent(char newChar) */
final String newChar = clickedKey.getCharacterToWrite();
try {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
swing_app.getEditorWindow().getTextPane().replaceSelection(newChar);
swing_app.getEditorWindow().getTextPane().updateUI();
}
});
} catch (Exception ex) {
}
System.out.println(newChar);
}
 
 
== virtual band markus ==
6

Bearbeitungen

Navigationsmenü