Package edu.cmu.cs.stage3.alice.core

Examples of edu.cmu.cs.stage3.alice.core.Element


    private static edu.cmu.cs.stage3.alice.scenegraph.Visual getFirstVisualChild( edu.cmu.cs.stage3.alice.scenegraph.Container sgContainer ) {
        return (edu.cmu.cs.stage3.alice.scenegraph.Visual)getFirstChildOfClass( sgContainer, edu.cmu.cs.stage3.alice.scenegraph.Visual.class );
    }

  private static Element internalConvert( edu.cmu.cs.stage3.alice.scenegraph.Container sgContainer, int id ) {
    Element element = null;
    if( sgContainer instanceof edu.cmu.cs.stage3.alice.scenegraph.Scene ) {
      edu.cmu.cs.stage3.alice.scenegraph.Scene sgScene = (edu.cmu.cs.stage3.alice.scenegraph.Scene)sgContainer;
      edu.cmu.cs.stage3.alice.scenegraph.AmbientLight sgAmbientLight = getFirstAmbientLightChild( sgScene );
      edu.cmu.cs.stage3.alice.scenegraph.Background sgBackground = sgScene.getBackground();
      World world = new World();
View Full Code Here


      element.name.set( name );
    }
    return element;
  }
    public static Element convert( edu.cmu.cs.stage3.alice.scenegraph.Container sgContainer ) {
      Element e = internalConvert( sgContainer, 0 );
      if( e instanceof Model ) {
        ((Model)e).isFirstClass.set( Boolean.TRUE );
      }
    if( e.name.getStringValue() == null ) {
      e.name.set( "yet to be named" );
View Full Code Here

      return e;
    }
    public static void main( String[] args ) {
        try {
            edu.cmu.cs.stage3.alice.scenegraph.Component sgSrc = edu.cmu.cs.stage3.alice.scenegraph.io.XML.load( new java.io.File( args[ 0 ] ) );
            Element dst = convert( (edu.cmu.cs.stage3.alice.scenegraph.Container)sgSrc );
            dst.store( new java.io.File( args[ 1 ] ) );
    } catch( java.io.IOException ioe ) {
      ioe.printStackTrace();
        }
        System.exit( 0 );
    }
View Full Code Here

        }
        java.util.Vector openingSceneStructure = new java.util.Vector(); //CLK
        if( root.getChildCount() > 0 ) {
          Element [] children = root.getChildren();
          for( int i = 0; i < children.length; i++ ) {
            final Element child = children[i];
            // add non-group kids to a new vector so they can be added later
            if (criterion.accept( child )) {
              if( child.equals( currentValue ) ) {
                openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), new PopupItemWithIcon( factory.createItem( child ), currentValueIcon ) ) );
              } else {
                if ((child instanceof edu.cmu.cs.stage3.alice.core.Camera) || (child instanceof DirectionalLight)) {
                  cameraLight.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
                } else {
                  openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
                }
              }
            } else {
              if( (child.search( criterion ).length > 0) || criterion.accept( child ) ) {
                // if it's the current scene group its kids need to go in the main pop-up
                if (child.equals(currentGroup)) {
                  groupKids = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
                 
                  /*groupKids.add(0, structure.remove(0));
                  groupKids.addAll(structure);
                  structure = groupKids;*/
                } else {
                  // otherwise just add it as a normal group
                  delayedBindingPopupItem = new DelayedBindingPopupItem() {
                    public Object createItem() {
                      java.util.Vector subStructure = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
                      if( (subStructure.size() == 1) && criterion.accept( child ) ) {
                        if( child.equals( currentValue ) ) {
                          return new PopupItemWithIcon( factory.createItem( child ), currentValueIcon );
                        } else {
                          return factory.createItem( child );
                        }
                      } else {
                        return subStructure;
                      }
                    }
                  };
                  otherGroups.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
                }
              }
            }
          }
         
          // combine the group data with the normal structure.
          groupKids.add(0, structure.remove(0));
          groupKids.addAll(structure);
          structure = groupKids;
          structure.addAll(cameraLight);
//          finally tack on the opening scene objects as a fake group
          if( structure.size() > 1 ) {
            structure.insertElementAt( new StringObjectPair( "Separator", javax.swing.JSeparator.class ),1 );
          }
          if( openingSceneStructure.size() >= 1 ) {
            structure.addElement( new StringObjectPair( "Separator", javax.swing.JSeparator.class ) );
          }
          structure.addElement(new StringObjectPair("Opening Scene", openingSceneStructure));
          structure.addAll(otherGroups);
        }
      } else {
        //if we're in the main scene do the normal thing
        if (currentGroup == null) return makeElementStructure(root, criterion, factory, context, currentValue);
        else
          Element[] children = root.getChildren();
          java.util.Vector openingSceneStructure = new java.util.Vector(); //CLK
          for( int i = 0; i < children.length; i++ ) {
            final Element child = children[i];
           
//            add non-group kids to a new vector so they can be added later
            if( child.getChildCount() == 0 ) {
              if( criterion.accept( child ) ) {
                if( child.equals( currentValue ) ) {
                  openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), new PopupItemWithIcon( factory.createItem( child ), currentValueIcon ) ) );
                } else {
                  if ((child instanceof edu.cmu.cs.stage3.alice.core.Camera) || (child instanceof DirectionalLight)) {
                    cameraLight.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
                  } else {
                    openingSceneStructure.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
                  }
                }
              }
            } else {
              if (child.equals(currentGroup)) {
                groupKids = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
              } else if( (child.search( criterion ).length > 0) || criterion.accept( child ) ) {
                delayedBindingPopupItem = new DelayedBindingPopupItem() {
                  public Object createItem() {
                    java.util.Vector subStructure = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
                    if( (subStructure.size() == 1) && criterion.accept( child ) ) {
                      if( child.equals( currentValue ) ) {
                        return new PopupItemWithIcon( factory.createItem( child ), currentValueIcon );
                      } else {
                        return factory.createItem( child );
                      }
                    } else {
View Full Code Here

        structure.addElement( new StringObjectPair( "the entire " + (String)root.name.getValue(), factory.createItem( root ) ) );
      }
      if( root.getChildCount() > 0 ) {
        Element [] children = root.getChildren();
        for( int i = 0; i < children.length; i++ ) {
          final Element child = children[i];
          if( child.getChildCount() == 0 ) {
            if( criterion.accept( child ) ) {
              if( child.equals( currentValue ) ) {
                structure.addElement( new StringObjectPair( (String)child.name.getValue(), new PopupItemWithIcon( factory.createItem( child ), currentValueIcon ) ) );
              } else {
                if ( (child instanceof edu.cmu.cs.stage3.alice.core.Camera) || (child instanceof DirectionalLight) ) {
                  cameraLight.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) )
                } else {
                  otherModels.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
                }
              }
            }
          } else {
            if( (child.search( criterion ).length > 0) || criterion.accept( child ) ) {
              delayedBindingPopupItem = new DelayedBindingPopupItem() {
                public Object createItem() {
                  //edu.cmu.cs.stage3.alice.core.Group cGroup = edu.cmu.cs.stage3.alice.authoringtool.AuthoringTool.getSceneManager().getCurrentGroup();
                  java.util.Vector subStructure = makeSceneElementStructure( child, criterion, factory, context, currentValue,currentGroup );
                  //java.util.Vector subStructure = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
                  if( (subStructure.size() == 1) && criterion.accept( child ) ) {
                    if( child.equals( currentValue ) ) {
                      return new PopupItemWithIcon( factory.createItem( child ), currentValueIcon );
                    } else {
                      return factory.createItem( child );
                    }
                  } else {
                    return subStructure;
                  }
                }
              };
              if (child instanceof Group) {
                groups.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
              } else {
                otherModels.addElement( new StringObjectPair( (String)child.name.getValue(), delayedBindingPopupItem ) );
              }
            }
          }
        }

        if( structure.size() > 1 ) {
          structure.insertElementAt( new StringObjectPair( "Separator", javax.swing.JSeparator.class ), 1 );
        }
      }
    } else {
      Element[] children = root.getChildren();
      for( int i = 0; i < children.length; i++ ) {
        final Element child = children[i];
        if( child.getChildCount() == 0 ) {
          if( criterion.accept( child ) ) {
            if( child.equals( currentValue ) ) {
              structure.addElement( new StringObjectPair( (String)child.name.getValue(), new PopupItemWithIcon( factory.createItem( child ), currentValueIcon ) ) );
            } else {
              if ( (child instanceof edu.cmu.cs.stage3.alice.core.Camera) || (child instanceof DirectionalLight) ) {
                cameraLight.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) )
              } else {
                otherModels.addElement( new StringObjectPair( (String)child.name.getValue(), factory.createItem( child ) ) );
              }
             
            }
          }
        } else {
          if( (child.search( criterion ).length > 0) || criterion.accept( child ) ) {
            delayedBindingPopupItem = new DelayedBindingPopupItem() {
              public Object createItem() {
                java.util.Vector subStructure = makeElementStructure( child, criterion, factory, context, currentValue, currentGroup );
                if( (subStructure.size() == 1) && criterion.accept( child ) ) {
                  if( child.equals( currentValue ) ) {
                    return new PopupItemWithIcon( factory.createItem( child ), currentValueIcon );
                  } else {
                    return factory.createItem( child );
                  }
                } else {
View Full Code Here

  }
 
  public Element resolveReference( edu.cmu.cs.stage3.util.Criterion criterion ) throws edu.cmu.cs.stage3.alice.core.UnresolvableReferenceException {
    if( criterion instanceof edu.cmu.cs.stage3.alice.core.criterion.ElementKeyedCriterion ) {
      String key = ((edu.cmu.cs.stage3.alice.core.criterion.ElementKeyedCriterion)criterion).getKey();
      Element resolved = null;
      if( criterion instanceof edu.cmu.cs.stage3.alice.core.criterion.InternalReferenceKeyedCriterion ) {
        resolved = m_internalRoot.getDescendantKeyedIgnoreCase( key );
      } else if( criterion instanceof edu.cmu.cs.stage3.alice.core.criterion.ExternalReferenceKeyedCriterion ) {
        if( m_externalRoot != null ) {
                    resolved = m_externalRoot.getDescendantKeyedIgnoreCase( key );
        } else {
                    throw new edu.cmu.cs.stage3.alice.core.UnresolvableReferenceException( criterion, "external root is null" );
        }
      } else {
        Element root;
        if( m_externalRoot != null ) {
          root = m_externalRoot;
        } else {
          root = m_internalRoot;
        }
        int index = key.indexOf( Element.SEPARATOR );
        String trimmedKey;
        if( index == -1 ) {
          trimmedKey = "";
        } else {
          trimmedKey = key.substring( index+1 );
        }
        resolved = root.getDescendantKeyedIgnoreCase( trimmedKey );
      }
      if( resolved!=null ) {
        return resolved;
      } else {
                throw new edu.cmu.cs.stage3.alice.core.UnresolvableReferenceException( criterion, "internal root: " + m_internalRoot + " external root: " + m_externalRoot );
View Full Code Here

          edu.cmu.cs.stage3.alice.core.criterion.ElementNamedCriterion nameCriterion =
            new edu.cmu.cs.stage3.alice.core.criterion.ElementNamedCriterion(modelName);
          Element[] parts = person.search(nameCriterion, edu.cmu.cs.stage3.util.HowMuch.INSTANCE_AND_ALL_DESCENDANTS);
          model.isFirstClass.set(false);
          if (parts.length > 0) {
            Element part = null;
            part = parts[0];
            if (part != null) {
              edu.cmu.cs.stage3.math.Vector3 posToParent =
                ((Model) part).getPosition((edu.cmu.cs.stage3.alice.core.ReferenceFrame) part.getParent());
              edu.cmu.cs.stage3.math.Matrix33 orientToParent =
                ((Model) part).getOrientationAsAxes((edu.cmu.cs.stage3.alice.core.ReferenceFrame) part.getParent());
              part.replaceWith(model);
              if (part instanceof Model) {
                model.vehicle.set(((Model) part).vehicle.get());
                ((Model) part).vehicle.set(null);
                if (posToParent != null)
                   ((Model) model).setPositionRightNow(posToParent, (edu.cmu.cs.stage3.alice.core.ReferenceFrame) model.getParent());
View Full Code Here

      if (person != null) {
        edu.cmu.cs.stage3.alice.core.criterion.ElementNamedCriterion nameCriterion =
          new edu.cmu.cs.stage3.alice.core.criterion.ElementNamedCriterion(parentName);
        Element[] parents = person.search(nameCriterion, edu.cmu.cs.stage3.util.HowMuch.INSTANCE_AND_ALL_DESCENDANTS);
        if (parents.length > 0) {
          Element child = parents[0].getChildNamed(part.name.getStringValue());
          if (child != null) {
            part.isFirstClass.set(false);
            edu.cmu.cs.stage3.math.Vector3 posToParent = ((Model) child).getPosition((edu.cmu.cs.stage3.alice.core.ReferenceFrame) parents[0]);
            child.replaceWith(part);
            if (child instanceof Model) {
              part.vehicle.set(((Model) child).vehicle.get());
              ((Model) child).vehicle.set(null);
              if (posToParent != null)
                 ((Model) part).setPositionRightNow(posToParent, (edu.cmu.cs.stage3.alice.core.ReferenceFrame) part.getParent());
View Full Code Here

    manufactureAnyNecessaryDetails();
  }
  private void updateDetails( java.awt.event.MouseEvent mouseEvent ) {
    for( int i=0; i<details.size(); i++ ) {
      Expression detail = (Expression)details.get( i );
      if( detail.name.getStringValue().equals( "x" ) ) {
        ((Variable)detail).value.set( new Double( mouseEvent.getX() ) );
      } else if( detail.name.getStringValue().equals( "y" ) ) {
        ((Variable)detail).value.set( new Double( mouseEvent.getY() ) );
      } else if( detail.name.getStringValue().equals( "what" ) ) {
View Full Code Here

    if( aValue != null ) {
      if( aValue.equals( bValue ) ) {
                return true;
            } else {
                if( aValue instanceof Expression ) {
                    Expression aExpression = (Expression)aValue;
                    Object aValue2 = aExpression.getValue();
                    if( bValue instanceof Expression ) {
                        Expression bExpression = (Expression)bValue;
                        Object bValue2 = bExpression.getValue();
                        if( aExpression.equals( bExpression.getValue() ) ) {
                            return true;
                        } else {
                            if( aValue2 != null ) {
                                if( aValue2.equals( bExpression ) ) {
                                    return true;
                                } else {
                                    return aValue2.equals( bValue2 );
                                }
                            } else {
                                return bValue2==null;
                            }
                        }
                    } else {
                        if( aValue2 != null ) {
                            return aValue2.equals( bValue );
                        } else {
                            return bValue == null;
                        }
                    }
                } else {
                    if( bValue instanceof Expression ) {
                        Expression bExpression = (Expression)bValue;
                        Object bValue2 = bExpression.getValue();
                        if( aValue.equals( bExpression ) ) {
                            return true;
                        } else {
                            return aValue.equals( bValue2 );
                        }
                    } else {
                        return false;
                    }
                }
            }
    } else {
            if( bValue instanceof Expression ) {
                Expression bExpression = (Expression)bValue;
                Object bValue2 = bExpression.getValue();
                return bValue2 == null;
            } else {
                return bValue == null;
            }
    }
View Full Code Here

TOP

Related Classes of edu.cmu.cs.stage3.alice.core.Element

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.