📄 orbitbehavior.java
字号:
* @since Java 3D 1.3 */ public void TransYFactor(Object[] yFactor) { if (! (yFactor.length == 1 && yFactor[0] instanceof Double)) throw new IllegalArgumentException("TransYFactor must be a Double"); setTransYFactor(((Double)yFactor[0]).doubleValue()); } /** * Sets the zoom factor. The factor is used to determine how many * units to zoom the view for each pixel of mouse movement. * The view is zoomed factor * 0.01 units for each pixel of mouse * movement. For proportional zoom, the view is zoomed factor * 1% * of the distance from the center of rotation for each pixel of * mouse movement. The default factor is 1.0. * @param zfactor The movement multiplier */ public synchronized void setZoomFactor(double zfactor) { zoomFactor = zfactor; if (proportionalZoom) { zoomMul = NOMINAL_PZOOM_FACTOR * zfactor; } else { zoomMul = NOMINAL_ZOOM_FACTOR * zfactor; } } /** * Property which sets the zoom factor. * Used by ConfiguredUniverse. * @param zFactor array of length 1 containing instance of Double * @since Java 3D 1.3 */ public void ZoomFactor(Object[] zFactor) { if (! (zFactor.length == 1 && zFactor[0] instanceof Double)) throw new IllegalArgumentException("ZoomFactor must be a Double"); setZoomFactor(((Double)zFactor[0]).doubleValue()); } /** * Returns the x rotation movement multiplier * @return The movement multiplier for x rotation */ public double getRotXFactor() { return rotXFactor; } /** * Returns the y rotation movement multiplier * @return The movement multiplier for y rotation */ public double getRotYFactor() { return rotYFactor; } /** * Returns the x translation movement multiplier * @return The movement multiplier for x translation */ public double getTransXFactor() { return transXFactor; } /** * Returns the y translation movement multiplier * @return The movement multiplier for y translation */ public double getTransYFactor() { return transYFactor; } /** * Returns the zoom movement multiplier * @return The movement multiplier for zoom */ public double getZoomFactor() { return zoomFactor; } /** * Enables or disables rotation. The default is true. * @param enabled true or false to enable or disable rotate */ public synchronized void setRotateEnable(boolean enabled) { rotateEnabled = enabled; } /** * Property which enables or disables rotation. * Used by ConfiguredUniverse. * @param enabled array of length 1 containing instance of Boolean * @since Java 3D 1.3 */ public void RotateEnable(Object[] enabled) { if (! (enabled.length == 1 && enabled[0] instanceof Boolean)) throw new IllegalArgumentException("RotateEnable must be Boolean"); setRotateEnable(((Boolean)enabled[0]).booleanValue()); } /** * Enables or disables zoom. The default is true. * @param enabled true or false to enable or disable zoom */ public synchronized void setZoomEnable(boolean enabled) { zoomEnabled = enabled; } /** * Property which enables or disables zoom. * Used by ConfiguredUniverse. * @param enabled array of length 1 containing instance of Boolean * @since Java 3D 1.3 */ public void ZoomEnable(Object[] enabled) { if (! (enabled.length == 1 && enabled[0] instanceof Boolean)) throw new IllegalArgumentException("ZoomEnable must be Boolean"); setZoomEnable(((Boolean)enabled[0]).booleanValue()); } /** * Enables or disables translate. The default is true. * @param enabled true or false to enable or disable translate */ public synchronized void setTranslateEnable(boolean enabled) { translateEnabled = enabled; } /** * Property which enables or disables translate. * Used by ConfiguredUniverse. * @param enabled array of length 1 containing instance of Boolean * @since Java 3D 1.3 */ public void TranslateEnable(Object[] enabled) { if (! (enabled.length == 1 && enabled[0] instanceof Boolean)) throw new IllegalArgumentException ("TranslateEnable must be Boolean"); setTranslateEnable(((Boolean)enabled[0]).booleanValue()); } /** * Retrieves the state of rotate enabled * @return the rotate enable state */ public boolean getRotateEnable() { return rotateEnabled; } /** * Retrieves the state of zoom enabled * @return the zoom enable state */ public boolean getZoomEnable() { return zoomEnabled; } /** * Retrieves the state of translate enabled * @return the translate enable state */ public boolean getTranslateEnable() { return translateEnabled; } boolean rotate(MouseEvent evt) { if (rotateEnabled) { if ((leftButton == ROTATE) && (!evt.isAltDown() && !evt.isMetaDown())) { return true; } if ((middleButton == ROTATE) && (evt.isAltDown() && !evt.isMetaDown())) { return true; } if ((rightButton == ROTATE) && (!evt.isAltDown() && evt.isMetaDown())) { return true; } } return false; } boolean zoom(MouseEvent evt) { if (zoomEnabled) { if (evt instanceof java.awt.event.MouseWheelEvent) { return true; } if ((leftButton == ZOOM) && (!evt.isAltDown() && !evt.isMetaDown())) { return true; } if ((middleButton == ZOOM) && (evt.isAltDown() && !evt.isMetaDown())) { return true; } if ((rightButton == ZOOM) && (!evt.isAltDown() && evt.isMetaDown())) { return true; } } return false; } boolean translate(MouseEvent evt) { if (translateEnabled) { if ((leftButton == TRANSLATE) && (!evt.isAltDown() && !evt.isMetaDown())) { return true; } if ((middleButton == TRANSLATE) && (evt.isAltDown() && !evt.isMetaDown())) { return true; } if ((rightButton == TRANSLATE) && (!evt.isAltDown() && evt.isMetaDown())) { return true; } } return false; } /** * Sets the minimum radius for the OrbitBehavior. The zoom will * stop at this distance from the center of rotation. The default * is 0.0. The minimum will have no affect if the STOP_ZOOM constructor * flag is not set. * @param r the minimum radius * @exception IllegalArgumentException if the radius is less than 0.0 */ public synchronized void setMinRadius(double r) { if (r < 0.0) { throw new IllegalArgumentException(J3dUtilsI18N.getString("OrbitBehavior1")); } minRadius = r; } /** * Property which sets the minimum radius for the OrbitBehavior. * Used by ConfiguredUniverse. * @param r array of length 1 containing instance of Double * @since Java 3D 1.3 */ public void MinRadius(Object[] r) { if (! (r.length == 1 && r[0] instanceof Double)) throw new IllegalArgumentException("MinRadius must be a Double"); setMinRadius(((Double)r[0]).doubleValue()); } /** * Returns the minimum orbit radius. The zoom will stop at this distance * from the center of rotation if the STOP_ZOOM constructor flag is set. * @return the minimum radius */ public double getMinRadius() { return minRadius; } /** * Set reverse translate behavior. The default is false. * @param state if true, reverse translate behavior * @since Java 3D 1.3 */ public void setReverseTranslate(boolean state) { reverseTrans = state; } /** * Property which sets reverse translate behavior. * Used by ConfiguredUniverse. * @param state array of length 1 containing instance of Boolean * @since Java 3D 1.3 */ public void ReverseTranslate(Object[] state) { if (! (state.length == 1 && state[0] instanceof Boolean)) throw new IllegalArgumentException ("ReverseTranslate must be Boolean"); setReverseTranslate(((Boolean)state[0]).booleanValue()); } /** * Set reverse rotate behavior. The default is false. * @param state if true, reverse rotate behavior * @since Java 3D 1.3 */ public void setReverseRotate(boolean state) { reverseRotate = state; } /** * Property which sets reverse rotate behavior. * Used by ConfiguredUniverse. * @param state array of length 1 containing instance of Boolean * @since Java 3D 1.3 */ public void ReverseRotate(Object[] state) { if (! (state.length == 1 && state[0] instanceof Boolean)) throw new IllegalArgumentException("ReverseRotate must be Boolean"); setReverseRotate(((Boolean)state[0]).booleanValue()); } /** * Set reverse zoom behavior. The default is false. * @param state if true, reverse zoom behavior * @since Java 3D 1.3 */ public void setReverseZoom(boolean state) { reverseZoom = state; } /** * Property which sets reverse zoom behavior. * Used by ConfiguredUniverse. * @param state array of length 1 containing instance of Boolean * @since Java 3D 1.3 */ public void ReverseZoom(Object[] state) { if (! (state.length == 1 && state[0] instanceof Boolean)) throw new IllegalArgumentException("ReverseZoom must be Boolean"); setReverseZoom(((Boolean)state[0]).booleanValue()); } /** * Set proportional zoom behavior. The default is false. * @param state if true, use proportional zoom behavior * @since Java 3D 1.3 */ public synchronized void setProportionalZoom(boolean state) { proportionalZoom = state; if (state) { zoomMul = NOMINAL_PZOOM_FACTOR * zoomFactor; } else { zoomMul = NOMINAL_ZOOM_FACTOR * zoomFactor; } } /** * Property which sets proportional zoom behavior. * Used by ConfiguredUniverse. * @param state array of length 1 containing instance of Boolean * @since Java 3D 1.3 */ public void ProportionalZoom(Object[] state) { if (! (state.length == 1 && state[0] instanceof Boolean)) throw new IllegalArgumentException ("ProportionalZoom must be Boolean"); setProportionalZoom(((Boolean)state[0]).booleanValue()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -