Friday, 25 October 2013

3D viewer navigation

The following keystrokes control navigation in the 3D viewer. For more information about navigating in the 3D viewer, see Using the Navigation Controls.
Note - The focus must be in the 3D viewer in order for these controls to take effect. Simply click anywhere in the 3D viewer to change focus.

Move leftLeft arrowLeft arrowMoves the viewer in the direction of the arrow.
Move rightRight arrowRight arrowMoves the viewer in the direction of the arrow.
Move upUp arrowUp arrowMoves the viewer in the direction of the arrow.
Move downDown arrowDown arrowMoves the viewer in the direction of the arrow.
Rotate clockwiseShift + left arrowShift + left arrowRotates the view clockwise. The earth spins counter-clockwise.
Rotate counter-clockwiseShift + right arrowShift + right arrowRotates the view counter-clockwise.
Show/hide Overview windowCTRL + MCommand/Open Apple Key + MDisplays or closes overview window.
Tilt upShift + left mouse button + drag down, Shift + down arrowShift + down arrowTilts the viewer toward "horizon" view.
Tilt downShift + left mouse button + drag up, Shift + up arrowShift + up arrowTilts the viewer toward "top-down" view.
LookCTRL + left mouse button + dragCommand/Open Apple Key + mouse button + dragPerspective points in another direction, as if you are turning your head up, down, left or right.
Zoom inScroll wheel, + key, PgUp keyScroll wheel, + keyZooms the viewer in. Tip: to use the 'Page Up' key, make sure 'Num Lock' on your keyboard is off.
Zoom outScroll wheel, - key (both keyboard and numpad), PgDn keyScroll wheel, - key (both keyboard and numpad)Zooms the viewer out. Tip: to use the 'Page Down' key, make sure 'Num Lock' on your keyboard is off.
Zoom + automatic tiltRight mouse button + drag up or downCTRL + click + drag up or downZooms the viewer in and automatically tilts your view as you approach ground level.
Stop current motionSpacebarSpacebarWhen the viewer is in motion, stops movement
Reset view to "north - up"nnRotates view so that view is 'n'orth-up.
Reset tilt to "top-down" viewuuResets angle to view scene in "top-down" or "'u'p" mode.
Reset tilt and compass view to defaultrr'R'esets angle to view "top-down" and rotates to "north-up" view. Use this feature to orient the earth in the center of the viewer.

Tip - Use the ALT key in combination with most of these keystrokes to move more slowly in the indicated direction.

Java Robot class simulating human mouse movement

Take a look in this example that I wrote. You can improve this to simulate what Joey said. I wrote it very fast and there are lots of things that can be improved (algorithm and class design). Note that I only deal with left to right movements.

import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Robot;

public class MouseMoving {

    public static void main(String[] args) {
        new MouseMoving().execute();

    public void execute() {
        new Thread( new MouseMoveThread( 100, 50, 50, 10 ) ).start();

    private class MouseMoveThread implements Runnable {

        private Robot robot;
        private int startX;
        private int startY;
        private int currentX;
        private int currentY;
        private int xAmount;
        private int yAmount;
        private int xAmountPerIteration;
        private int yAmountPerIteration;
        private int numberOfIterations;
        private long timeToSleep;

        public MouseMoveThread( int xAmount, int yAmount,
                int numberOfIterations, long timeToSleep ) {

            this.xAmount = xAmount;
            this.yAmount = yAmount;
            this.numberOfIterations = numberOfIterations;
            this.timeToSleep = timeToSleep;

            try {

                robot = new Robot();

                Point startLocation = MouseInfo.getPointerInfo().getLocation();
                startX = startLocation.x;
                startY = startLocation.y;

            } catch ( AWTException exc ) {


        public void run() {

            currentX = startX;
            currentY = startY;

            xAmountPerIteration = xAmount / numberOfIterations;
            yAmountPerIteration = yAmount / numberOfIterations;

            while ( currentX < startX + xAmount &&
                    currentY < startY + yAmount ) {

                currentX += xAmountPerIteration;
                currentY += yAmountPerIteration;

                robot.mouseMove( currentX, currentY );

                try {
                    Thread.sleep( timeToSleep );
                } catch ( InterruptedException exc ) {





Monday, 21 October 2013

Showing only close button on the JFrame undecorated

public class TestUndecoratedFrame {

    public static void main(String[] args) {
        new TestUndecoratedFrame();

    public TestUndecoratedFrame() {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {

                TitlePane titlePane = new TitlePane();

                JFrame frame = new JFrame("Testing");
                frame.setLayout(new BorderLayout());
                ((JComponent)frame.getContentPane()).setBorder(new LineBorder(Color.BLACK));
                frame.add(titlePane, BorderLayout.NORTH);
                frame.add(new JLabel("This is your content", JLabel.CENTER));
                frame.setSize(200, 200);

    public class TitlePane extends JPanel {

        public TitlePane() {
            setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1;
            gbc.anchor = GridBagConstraints.EAST;
            add(new CloseControl(), gbc);

    public class CloseControl extends JButton {

        public CloseControl() {
            setBorder(new EmptyBorder(0, 0, 8, 12));
            try {
                setRolloverIcon(new ImageIcon("/Highlighted.png"))));
                setIcon(new ImageIcon("/Normal.png"))));
            } catch (IOException ex) {
                Logger.getLogger(TestUndecoratedFrame.class.getName()).log(Level.SEVERE, null, ex);

            addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {