|
|||||||||
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.Box
brbrain.GUI
brbrain.PoseGUI
brbrain.PoseSequenceGUI
public class PoseSequenceGUI
GUI for PoseSequence
s.
The GUI displays the current actual pose, which may be different from any pose in the sequence.
A current sequence pose is also always maintained (getCurrentSequencePose()
, getCurrentSequenceIndex()
), which is one of
the poses in the sequence, if any.
It is legal to create a new PoseSequenceGUI with an empty sequence, but
all of the mutators will fail until one of the insertPose*()
methods is called at least once.
It is not legal to remove the last remaining pose in a sequence.
insertPose*()
, removePose()
, previousPose()
,
and nextPose()
all synchronize the current actual pose values with
the current sequence pose values, and set a flag indicating that the
hardware will be updated with the new current actual pose on the next
sync.
User edits to the current actual pose, as well as syncs thereof from the
hardware, will be discarded on the next removePose()
, previousPose()
, or nextPose()
, but will be saved as the new current
sequence pose by insertPose*()
.
A morph time in milliseconds is maintained (setMSMorphTime(int)
/getMSMorphTime()
) which, if positive, is used to
compute the AX12Register.AX12_MOVING_SPEED
of newly inserted poses
to achive the specified morph time from the previous pose in the sequence,
if any. If there is no previous pose, or if msMorphTime
is
non-positive, the moving speed of all dynamixels in newly added poses is set
to defaultMovingSpeed
.
A speed factor (setSpeedFactor(float)
/getSpeedFactor()
) is also
maintained which, if not 1.0, multiplies the AX12Register.AX12_MOVING_SPEED
of the current actual pose whenever it is
updated from the current sequence pose, and inversely for updates in the
opposite direction.
Copyright (C) 2007 Marsette A. Vona, III
This program 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.
This program is distributed in the hope that it will be useful, but 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.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class brbrain.PoseGUI |
---|
PoseGUI.DynamixelBox, PoseGUI.RegisterNameBox, PoseGUI.ValueBox |
Nested classes/interfaces inherited from class brbrain.GUI |
---|
GUI.RemoveTask |
Nested classes/interfaces inherited from class javax.swing.Box |
---|
javax.swing.Box.AccessibleBox, javax.swing.Box.Filler |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected javax.swing.JCheckBox |
autoSetSpeedCheckBox
|
protected javax.swing.JTextField |
currentIndexField
|
protected int |
currentSequenceIndex
the current sequence pose index, zero based, or -1 if none |
protected Pose |
currentSequencePose
the current sequence pose or null if none |
protected javax.swing.JLabel |
currentSizeLabel
|
private static java.lang.String |
cvsid
|
static int |
DEF_MOVING_SPEED
default defaultMovingSpeed |
static int |
DEF_MS_MORPH_TIME
default msMorphTime |
protected int |
defaultMovingSpeed
default moving speed for inserted poses |
protected javax.swing.JTextField |
defaultMovingSpeedField
|
protected javax.swing.JButton |
insAfterButton
|
protected javax.swing.JButton |
insBeforeButton
|
protected javax.swing.JTextField |
morphTimeField
|
protected int |
msMorphTime
current morph time in milliseconds for inserted poses |
protected javax.swing.JButton |
nextButton
|
protected javax.swing.JButton |
pauseButton
|
protected SequencePlaybackController |
playbackController
our sequence playback controller |
protected javax.swing.JButton |
playButton
|
protected boolean |
playing
whether we're currently in play mode |
PoseSequence |
poseSequence
the sequence |
protected javax.swing.JButton |
prevButton
|
protected javax.swing.JButton |
removeButton
|
protected javax.swing.JButton |
rewindButton
|
protected java.util.ListIterator<Pose> |
sequenceIterator
iterator we always use for all mutations |
protected javax.swing.JCheckBox |
setGoalFromPresentCheckBox
|
protected float |
speedFactor
the current speed factor, initially 1.0 |
protected javax.swing.JTextField |
speedFactorField
|
protected javax.swing.JCheckBox |
speedOverrideCheckBox
|
protected javax.swing.JButton |
updateButton
|
Fields inherited from class brbrain.GUI |
---|
lastFrame, MAX_SPLIT_LABEL_CHARS |
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 | |
---|---|
PoseSequenceGUI(PoseSequence poseSequence,
int registerAxis,
java.lang.String[] dynamixelNames,
boolean showRegisterNames,
boolean[] registerEditable,
boolean enableShowEstop,
boolean showADCs,
boolean showManualSync,
boolean showAutoSync)
Make a new GUI for an existing sequence. |
|
PoseSequenceGUI(PoseSequence poseSequence,
int registerAxis,
java.lang.String[] dynamixelNames,
boolean showRegisterNames,
boolean editable,
boolean enableShowEstop,
boolean showADCs,
boolean showManualSync,
boolean showAutoSync)
make a gui where everything is either editable or not |
Method Summary | |
---|---|
protected void |
addGUI(GUI gui)
adds the current actual pose gui with a titled border |
protected void |
applySpeedFactor()
Update the speed of the current actual pose from that of the current sequence pose, if any, according to speedFactor . |
protected void |
didSync(Pose pose,
BRBrain brBrain,
boolean didWrite,
boolean didRead,
boolean setFormats,
boolean savedAndRestoredFormat,
int syncNum,
long startTime,
long duration)
Calls SequencePlaybackController.controlPlayback(brbrain.PoseSequenceGUI, brbrain.Pose, brbrain.Pose, int) as
necessary. |
int |
getCurrentSequenceIndex()
get current sequence index or -1 if none |
Pose |
getCurrentSequencePose()
get current sequence pose or null if none |
int |
getDefaultMovingSpeed()
get the default moving speed for inserted poses |
int |
getMSMorphTime()
get the morph time in milliseconds for inserted poses |
float |
getSpeedFactor()
get the current speed factor |
protected void |
handleEditCurrentIndex(java.lang.String s)
handle edits to current index field |
protected void |
handleEditDefaultMovingSpeed(java.lang.String s)
handle edits to default moving speed field |
protected void |
handleEditMorphTime(java.lang.String s)
handle edits to morph time field |
protected void |
handleEditSpeedFactor(java.lang.String s)
handle edits to speed factor field |
boolean |
hasNextPose()
check if there are more poses after the current one in the sequence |
boolean |
hasPreviousPose()
check if there are more poses before the current one in the sequence |
protected Pose |
insertPose(Pose prevSequencePose)
common insert impl |
Pose |
insertPoseAfter()
Inserts the current actual pose as a new pose in the sequence after the current sequence pose (or as the first in the sequence). |
Pose |
insertPoseBefore()
similar to insertPoseAfter() |
boolean |
isPlaying()
check if in play mode |
Pose |
nextPose()
Move to the next pose in the sequence. |
Pose |
peekNextPose()
return the next pose, null if none, but don't change to it |
Pose |
peekPreviousPose()
return the previous pose, null if none, but don't change to it |
Pose |
previousPose()
Move to the previous pose in the sequence. |
protected void |
refresh()
refresh the gui components |
Pose |
removePose()
Removes the current sequence pose. |
Pose |
rewindToFirstPose()
rewind to the first pose in sequence, if any |
int |
setCurrentSequenceIndex(int currentSequenceIndex)
Covers setCurrentSequenceIndex(int, boolean) , always writes to
hardware. |
int |
setCurrentSequenceIndex(int currentSequenceIndex,
boolean writeToHardware)
Move to the specified pose in the sequence. |
int |
setDefaultMovingSpeed(int defaultMovingSpeed)
set the default moving speed for inserted poses |
int |
setMSMorphTime(int msMorphTime)
set the morph time in milliseconds for inserted poses |
SequencePlaybackController |
setSequencePlaybackController(SequencePlaybackController playbackController)
set the sequence playback controller |
protected void |
setSpeed(Pose prevSequencePose,
Pose currentSequencePose)
set speed of currentSequencePose |
float |
setSpeedFactor(float speedFactor)
set the current speed factor. |
protected void |
updateCurrentActualPose()
Update the current actual pose from the current sequence pose and speedFactor . |
void |
updateCurrentSequencePose()
Update the current sequence pose from the current actual pose. |
Methods inherited from class brbrain.PoseGUI |
---|
addToRefreshList, autoSync, autoSync, autoSync, autoSync, consEditable, doEstop, getPose, getSyncStats, handleEditAutoSync, refreshFromPose, removeFromRefreshList, setPose, setSyncDefaults, setSyncFormats, setSyncFormats, setUseNaturalUnits, setUseNaturalUnits, sync, sync, sync, useAllLabelledNaturalUnits |
Methods inherited from class brbrain.GUI |
---|
addRemoveTask, addTitledBorder, addTitledBorder, dbgLayout, dbgLayout, makeSplitLabel, otherAxis, wrapInFrame, wrapInFrame |
Methods inherited from class javax.swing.Box |
---|
createGlue, createHorizontalBox, createHorizontalGlue, createHorizontalStrut, createRigidArea, createVerticalBox, createVerticalGlue, createVerticalStrut, getAccessibleContext, paintComponent, setLayout |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String cvsid
public static final int DEF_MS_MORPH_TIME
msMorphTime
public static final int DEF_MOVING_SPEED
defaultMovingSpeed
public final PoseSequence poseSequence
protected java.util.ListIterator<Pose> sequenceIterator
protected Pose currentSequencePose
protected int currentSequenceIndex
protected int msMorphTime
protected int defaultMovingSpeed
protected float speedFactor
protected boolean playing
protected SequencePlaybackController playbackController
protected javax.swing.JButton prevButton
protected javax.swing.JButton rewindButton
protected javax.swing.JButton pauseButton
protected javax.swing.JButton playButton
protected javax.swing.JButton nextButton
protected javax.swing.JTextField currentIndexField
protected javax.swing.JLabel currentSizeLabel
protected javax.swing.JButton insBeforeButton
protected javax.swing.JButton updateButton
protected javax.swing.JButton removeButton
protected javax.swing.JButton insAfterButton
protected javax.swing.JCheckBox autoSetSpeedCheckBox
protected javax.swing.JCheckBox setGoalFromPresentCheckBox
protected javax.swing.JTextField speedFactorField
protected javax.swing.JTextField defaultMovingSpeedField
protected javax.swing.JCheckBox speedOverrideCheckBox
protected javax.swing.JTextField morphTimeField
Constructor Detail |
---|
public PoseSequenceGUI(PoseSequence poseSequence, int registerAxis, java.lang.String[] dynamixelNames, boolean showRegisterNames, boolean[] registerEditable, boolean enableShowEstop, boolean showADCs, boolean showManualSync, boolean showAutoSync)
Make a new GUI for an existing sequence.
If the sequence is not empty then its first pose becomes the current sequence pose and is written to the hardware on the next sync.
See class header doc for additional details.
public PoseSequenceGUI(PoseSequence poseSequence, int registerAxis, java.lang.String[] dynamixelNames, boolean showRegisterNames, boolean editable, boolean enableShowEstop, boolean showADCs, boolean showManualSync, boolean showAutoSync)
Method Detail |
---|
protected void handleEditCurrentIndex(java.lang.String s)
protected void handleEditSpeedFactor(java.lang.String s)
protected void handleEditMorphTime(java.lang.String s)
protected void handleEditDefaultMovingSpeed(java.lang.String s)
protected void addGUI(GUI gui)
addGUI
in class PoseGUI
public int getCurrentSequenceIndex()
public Pose getCurrentSequencePose()
public int setMSMorphTime(int msMorphTime)
public int getMSMorphTime()
public int setDefaultMovingSpeed(int defaultMovingSpeed)
public int getDefaultMovingSpeed()
public Pose insertPoseAfter()
Inserts the current actual pose as a new pose in the sequence after the current sequence pose (or as the first in the sequence).
The goal position of the inserted pose will be set from the present position of the current actual pose iff the corresponding GUI checkbox is selected.
If there is a pose before the newly inserted pose, the newly inserted
pose AX12Register.AX12_MOVING_SPEED
will be set to achieve the
current msMorphTime
, if positive.
The newly inserted pose is written to the hardware on the next sync, and becomes the new current sequence pose.
public Pose insertPoseBefore()
insertPoseAfter()
protected Pose insertPose(Pose prevSequencePose)
protected void setSpeed(Pose prevSequencePose, Pose currentSequencePose)
public Pose removePose()
Removes the current sequence pose.
The new current sequence pose becomes the pose after the one which was removed, if any, else the last pose in the sequence, and is written to the hardware on the next sync.
java.lang.IllegalStateException
- if the sequence currently has fewer than
two posesprotected void updateCurrentActualPose()
Update the current actual pose from the current sequence pose and
speedFactor
.
public void updateCurrentSequencePose()
Update the current sequence pose from the current actual pose.
public Pose nextPose()
Move to the next pose in the sequence.
The current sequence pose is incremented, and is written to the hardware on the next sync.
java.lang.IllegalStateException
- if the current sequence pose is the last
in the sequence or if the sequence is emptypublic Pose previousPose()
Move to the previous pose in the sequence.
The current sequence pose is decremented, and is written to the hardware on the next sync.
java.lang.IllegalStateException
- if the current sequence pose is the first
in the sequence or if the sequence is emptypublic Pose rewindToFirstPose()
public int setCurrentSequenceIndex(int currentSequenceIndex, boolean writeToHardware)
Move to the specified pose in the sequence.
The current sequence pose is set to the one with the specified zero-based index, and is written to the hardware on the next sync unless otherwise specified.
java.lang.IllegalStateException
- if the specified index is negative or
greater than or equal to the size of the sequencepublic int setCurrentSequenceIndex(int currentSequenceIndex)
Covers setCurrentSequenceIndex(int, boolean)
, always writes to
hardware.
public boolean hasNextPose()
public Pose peekNextPose()
public boolean hasPreviousPose()
public Pose peekPreviousPose()
public float getSpeedFactor()
public boolean isPlaying()
public SequencePlaybackController setSequencePlaybackController(SequencePlaybackController playbackController)
public float setSpeedFactor(float speedFactor)
set the current speed factor.
Updates all the AX12Register.AX12_MOVING_SPEED
values of the
current actual pose appropriately.
java.lang.IllegalArgumentException
- if speedFactor is not positiveprotected void applySpeedFactor()
Update the speed of the current actual pose from that of the current
sequence pose, if any, according to speedFactor
.
protected void refresh()
refresh
in class PoseGUI
protected void didSync(Pose pose, BRBrain brBrain, boolean didWrite, boolean didRead, boolean setFormats, boolean savedAndRestoredFormat, int syncNum, long startTime, long duration)
Calls SequencePlaybackController.controlPlayback(brbrain.PoseSequenceGUI, brbrain.Pose, brbrain.Pose, int)
as
necessary.
didSync
in class PoseGUI
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |