Package org.jdesktop.wonderland.client.cell

Examples of org.jdesktop.wonderland.client.cell.Cell


     * @inheritDoc()
     */
    public void open() {
        // Fetch the current Cell, make sure it has the movable component and
        // turn everything on.
        Cell cell = editor.getCell();
        if (cell == null) {
            return;
        }

        // Store the values currently on the Cell. This will be used when we
        // go to restore the values later
        CellTransform transform = cell.getLocalTransform();
        originalTranslation = transform.getTranslation(null);
        originalRotation = transform.getRotation(null);
        originalScaling = transform.getScaling(null);

        // OWL issue #159: we are now up to date, no local changes have been made
        isLocalChangesMade = false;

        movableComponent = cell.getComponent(MovableComponent.class);
        if (movableComponent == null) {
            translationXTF.setEnabled(false);
            translationYTF.setEnabled(false);
            translationZTF.setEnabled(false);
            rotationXTF.setEnabled(false);
            rotationYTF.setEnabled(false);
            rotationZTF.setEnabled(false);
            scaleXTF.setEnabled(false);
        }

        // Listen for changes, if there is a movable component added or removed
        // update the state of the fields. It is ok if open() is called more
        // than once, this method call will not add duplicate listeners.
        cell.addComponentChangeListener(componentListener);

        // If it does not exist, attempt to add the movable component. Create
        // a suitable message using only the server-side movable component
        // class name and send over the cell channel.
        if (movableComponent == null) {
            String className = "org.jdesktop.wonderland.server.cell." +
                    "MovableComponentMO";
            CellServerComponentMessage cscm =
                    CellServerComponentMessage.newAddMessage(
                    cell.getCellID(), className);
            ResponseMessage response = cell.sendCellMessageAndWait(cscm);
            if (response instanceof ErrorMessage) {
                logger.log(Level.WARNING, "Unable to add movable component " +
                        "for Cell " + cell.getName() + " with ID " +
                        cell.getCellID(),
                        ((ErrorMessage) response).getErrorCause());
            }
        }

        // Listen for changes in the Cell's transform. It is ok if open() is
        // called more than once, this method call will not add duplicate
        // listeners.
        cell.addTransformChangeListener(transformListener);

        // Update the GUI, set local changes to true so that messages to the
        // movable component are NOT generated.
        setLocalChanges(true);
        try {
View Full Code Here


     * @inheritDoc()
     */
    public void restore() {
        // Fetch the current Cell, there should be one, although there may not
        // be a movable component.
        Cell cell = editor.getCell();
        if (movableComponent == null) {
            logger.warning("Unable to find movable component on Cell " +
                    cell.getName());
            return;
        }

        // We revert the values to when this property sheet was originally open
        // for the Cell. We only do this if we can find a movable component
        // (which should be the case if we made any changes) AND if we have
        // explictly made changes via the GUI. This second check is necessary
        // because if a user edits the position via the affordances, and clicks
        // off the Cell in the Cell Editor, it will revert the position, when
        // not desired. (See Issue #688).
        if (isLocalChangesMade == true) {
            CellTransform transform = cell.getLocalTransform();
            transform.setTranslation(originalTranslation);
            transform.setScaling(originalScaling.x);
            transform.setRotation(originalRotation);
            movableComponent.localMoveRequest(transform);

View Full Code Here

    public void close() {
        // First restore any existing changes
        restore();

        // Finally remove any existing listeners from the Cell
        Cell cell = editor.getCell();
        cell.removeComponentChangeListener(componentListener);
        cell.removeTransformChangeListener(transformListener);
    }
View Full Code Here

    /**
     * Updates the GUI based upon the given CellTransform
     */
    public void updateGUI() {
        // Fetch the current transform from the movable component
        Cell cell = editor.getCell();
        CellTransform cellTransform = cell.getLocalTransform();
        Vector3f translation = cellTransform.getTranslation(null);
        Quaternion rotation = cellTransform.getRotation(null);
        Vector3f scale = cellTransform.getScaling(null);
        float[] angles = rotation.toAngles(new float[3]);

View Full Code Here

        float y = (Float) yTranslationModel.getValue();
        float z = (Float) zTranslationModel.getValue();

        Vector3f translation = new Vector3f(x, y, z);
        if (movableComponent != null) {
            Cell cell = editor.getCell();
            CellTransform cellTransform = cell.getLocalTransform();
            cellTransform.setTranslation(translation);
            movableComponent.localMoveRequest(cellTransform);
            editor.setPanelDirty(PositionJPanel.class, true);
        }
    }
View Full Code Here

        y = (float) Math.toRadians(y);
        z = (float) Math.toRadians(z);

        Quaternion newRotation = new Quaternion(new float[] { x, y, z });
        if (movableComponent != null) {
            Cell cell = editor.getCell();
            CellTransform cellTransform = cell.getLocalTransform();
            cellTransform.setRotation(newRotation);
            movableComponent.localMoveRequest(cellTransform);
            editor.setPanelDirty(PositionJPanel.class, true);
        }
    }
View Full Code Here

     */
    private void updateScale() {
        float x = (Float) xScaleModel.getValue();

        if (movableComponent != null) {
            Cell cell = editor.getCell();
            CellTransform cellTransform = cell.getLocalTransform();
            cellTransform.setScaling(x);
            movableComponent.localMoveRequest(cellTransform);
            editor.setPanelDirty(PositionJPanel.class, true);
        }
    }
View Full Code Here

    private class PropertiesListener implements ContextMenuActionListener {

        public void actionPerformed(ContextMenuItemEvent event) {
            // Create a new cell edit frame passing in the Cell and make
            // it visible
            Cell cell = event.getCell();
            try {
                CellPropertiesJFrame frame = getCellPropertiesJFrame();
                frame.setSelectedCell(cell);
                frame.setSize(800, 650);
                frame.setVisible(true);
View Full Code Here

    @Override
    public void commitEvent(Event event) {

        EnterExitEvent eeEvent = (EnterExitEvent) event;
        Entity e = eeEvent.getPrimaryEntity();
        Cell cell = eeEvent.getCellForEntity(e);

        if (cell != null) {
            if (eeEvent.isEnter()) {
                highlightCell(cell, true, GLOW_COLOR);
            } else {
View Full Code Here

    @Override
    public void commitEvent(Event event) {
        EnterExitEvent eee = (EnterExitEvent) event;
        Entity entity = eee.getPrimaryEntity();
        Cell cell = EnterExitEvent.getCellForEntity(entity);

        if (eee.isEnter()) {
            enter(cell);
        } else {
            exit(cell);
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.client.cell.Cell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.