@Override public void reset() { this.mVisible = true; this.mCullingEnabled = false; this.mIgnoreUpdate = false; this.mChildrenVisible = true; this.mChildrenIgnoreUpdate = false; this.mRotation = 0; this.mScaleX = 1; this.mScaleY = 1; this.mSkewX = 0; this.mSkewY = 0; this.resetRotationCenter(); this.resetSkewCenter(); this.resetScaleCenter(); this.mColor.reset(); this.resetEntityModifiers(); if (this.mChildren != null) { final SmartList<IEntity> children = this.mChildren; for (int i = children.size() - 1; i >= 0; i--) { final IEntity child = children.get(i); child.reset(); } } }
public Link mute2(Group g) { final Group g1 = cl1.getContainer(); final Group g2 = cl2.getContainer(); if (g1 == g && g2 == g) { return null; } return this; }
public boolean insideGroup(Group g) { if (EntityUtils.equals(cl1.getContainer(), g) && ((IEntityMutable) cl1).isGroup() == false && EntityUtils.equals(cl2.getContainer(), g) && ((IEntityMutable) cl2).isGroup() == false) { return true; } return false; }
@Override public boolean detachSelf() { final IEntity parent = this.mParent; if (parent != null) { return parent.detachChild(this); } else { return false; } }
public boolean isBetween(IEntity cl1, IEntity cl2) { if (cl1.equals(this.cl1) && cl2.equals(this.cl2)) { return true; } if (cl1.equals(this.cl2) && cl2.equals(this.cl1)) { return true; } return false; }
@Override public IEntity getRootEntity() { IEntity rootEntity = this; while (rootEntity.hasParent()) { rootEntity = rootEntity.getParent(); } return rootEntity; }
@Override public void attachChild(final IEntity pEntity) throws IllegalStateException { this.assertEntityHasNoParent(pEntity); if (this.mChildren == null) { this.allocateChildren(); } this.mChildren.add(pEntity); pEntity.setParent(this); pEntity.onAttached(); }
public static boolean isPureInnerLink3(IGroup group, Link link) { if (group.isGroup() == false) { throw new IllegalArgumentException(); } final IEntity e1 = link.getEntity1(); final IEntity e2 = link.getEntity2(); final IGroup group1 = e1.getParentContainer(); final IGroup group2 = e2.getParentContainer(); if (isParent(group2, group) == isParent(group1, group)) { return true; } return false; }
@Override public IEntity getChildByTag(final int pTag) { if (this.mChildren == null) { return null; } for (int i = this.mChildren.size() - 1; i >= 0; i--) { final IEntity child = this.mChildren.get(i); if (child.getTag() == pTag) { return child; } } return null; }
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) { pGLState.pushModelViewGLMatrix(); { this.onApplyTransformations(pGLState); final SmartList<IEntity> children = this.mChildren; if ((children == null) || !this.mChildrenVisible) { /* Draw only self. */ this.preDraw(pGLState, pCamera); this.draw(pGLState, pCamera); this.postDraw(pGLState, pCamera); } else { if (this.mChildrenSortPending) { ZIndexSorter.getInstance().sort(this.mChildren); this.mChildrenSortPending = false; } final int childCount = children.size(); int i = 0; { /* Draw children behind this Entity. */ for (; i < childCount; i++) { final IEntity child = children.get(i); if (child.getZIndex() < 0) { child.onDraw(pGLState, pCamera); } else { break; } } } /* Draw self. */ this.preDraw(pGLState, pCamera); this.draw(pGLState, pCamera); this.postDraw(pGLState, pCamera); { /* Draw children in front of this Entity. */ for (; i < childCount; i++) { try { children.get(i).onDraw(pGLState, pCamera); } catch (IndexOutOfBoundsException ex) { } } } } } pGLState.popModelViewGLMatrix(); }
@Override public <L extends List<IEntity>> L query(final IEntityMatcher pEntityMatcher, final L pResult) { final int childCount = this.getChildCount(); for (int i = 0; i < childCount; i++) { final IEntity child = this.mChildren.get(i); if (pEntityMatcher.matches(child)) { pResult.add(child); } child.query(pEntityMatcher, pResult); } return pResult; }
public FeatureDescriptor wGetFeatureDescriptor(IEntity child) { if (child.wGetParent() == this) return new EntityFeatureDescriptorImpl( wGetEntityDescriptor(), null, null, child.wGetEntityDescriptor(), false, false, false, false, false); throw new IllegalStateException(WholeMessages.null_model); }
private void assertEntityHasNoParent(final IEntity pEntity) throws IllegalStateException { if (pEntity.hasParent()) { final String entityClassName = pEntity.getClass().getSimpleName(); final String currentParentClassName = pEntity.getParent().getClass().getSimpleName(); final String newParentClassName = this.getClass().getSimpleName(); throw new IllegalStateException( "pEntity '" + entityClassName + "' already has a parent: '" + currentParentClassName + "'. New parent: '" + newParentClassName + "'!"); } }
@SuppressWarnings("unchecked") @Override public <L extends List<S>, S extends IEntity> L queryForSubclass( final IEntityMatcher pEntityMatcher, final L pResult) throws ClassCastException { final int childCount = this.getChildCount(); for (int i = 0; i < childCount; i++) { final IEntity child = this.mChildren.get(i); if (pEntityMatcher.matches(child)) { pResult.add((S) child); } child.queryForSubclass(pEntityMatcher, pResult); } return pResult; }
@Override public Transformation getSceneToLocalTransformation() { if (this.mSceneToLocalTransformation == null) { this.mSceneToLocalTransformation = new Transformation(); } // TODO Cache if parent(recursive) not dirty. final Transformation sceneToLocalTransformation = this.mSceneToLocalTransformation; sceneToLocalTransformation.setTo(this.getParentToLocalTransformation()); final IEntity parent = this.mParent; if (parent != null) { sceneToLocalTransformation.preConcat(parent.getSceneToLocalTransformation()); } return sceneToLocalTransformation; }
protected void onManagedUpdate(final float pSecondsElapsed) { if (this.mEntityModifiers != null) { this.mEntityModifiers.onUpdate(pSecondsElapsed); } if (this.mUpdateHandlers != null) { this.mUpdateHandlers.onUpdate(pSecondsElapsed); } if ((this.mChildren != null) && !this.mChildrenIgnoreUpdate) { final SmartList<IEntity> children = this.mChildren; final int entityCount = children.size(); for (int i = 0; i < entityCount; i++) { final IEntity child = children.get(i); child.onUpdate(pSecondsElapsed); } } }
public Link( IEntity cl1, IEntity cl2, LinkType type, String label, int length, String qualifier1, String qualifier2, String labeldistance, String labelangle, HtmlColor specificColor) { if (length < 1) { throw new IllegalArgumentException(); } if (cl1 == null || cl2 == null) { throw new IllegalArgumentException(); } if (cl1.getEntityType() == EntityType.STATE_CONCURRENT) { throw new IllegalArgumentException(); } if (cl2.getEntityType() == EntityType.STATE_CONCURRENT) { throw new IllegalArgumentException(); } if (cl1 instanceof EntityMutable == false) { throw new IllegalArgumentException(); } if (cl2 instanceof EntityMutable == false) { throw new IllegalArgumentException(); } this.cl1 = cl1; this.cl2 = cl2; this.type = type; this.label = label; this.length = length; this.qualifier1 = qualifier1; this.qualifier2 = qualifier2; this.labeldistance = labeldistance; this.labelangle = labelangle; this.specificColor = specificColor; if (qualifier1 != null) { cl1.setNearDecoration(true); } if (qualifier2 != null) { cl2.setNearDecoration(true); } }
@Override public Transformation getLocalToSceneTransformation() { if (this.mLocalToSceneTransformation == null) { this.mLocalToSceneTransformation = new Transformation(); } // TODO Cache if parent(recursive) not dirty. final Transformation localToSceneTransformation = this.mLocalToSceneTransformation; localToSceneTransformation.setTo(this.getLocalToParentTransformation()); final IEntity parent = this.mParent; if (parent != null) { localToSceneTransformation.postConcat(parent.getLocalToSceneTransformation()); } return localToSceneTransformation; }
@SuppressWarnings("unchecked") @Override public <S extends IEntity> S queryFirstForSubclass(final IEntityMatcher pEntityMatcher) { final int childCount = this.getChildCount(); for (int i = 0; i < childCount; i++) { final IEntity child = this.mChildren.get(i); if (pEntityMatcher.matches(child)) { return (S) child; } final S childQueryFirst = child.queryFirstForSubclass(pEntityMatcher); if (childQueryFirst != null) { return childQueryFirst; } } return null; }
@Override public void toString(final StringBuilder pStringBuilder) { pStringBuilder.append(this.getClass().getSimpleName()); if ((this.mChildren != null) && (this.mChildren.size() > 0)) { final SmartList<IEntity> children = this.mChildren; pStringBuilder.append(" ["); final int childCount = children.size(); for (int i = 0; i < childCount; i++) { final IEntity child = children.get(i); child.toString(pStringBuilder); if (i < (childCount - 1)) { pStringBuilder.append(", "); } } pStringBuilder.append(']'); } }
/** * Copies the properties from the original entity to the historyEntity * * @param original * @param historyEntity * @throws DataAccessException */ public static void createHistoryEntity(IEntity original, IHistory historyEntity) throws DataAccessException { // copy all try { BeanInfo info = Introspector.getBeanInfo(original.getClass()); Class<? extends IHistory> targetClass = historyEntity.getClass(); Object[] noArgs = new Object[0]; PropertyDescriptor[] descs = info.getPropertyDescriptors(); // loop through all properties for (int i = 0; i < descs.length; i++) { if (!descs[i].getName().equals("id") && !descs[i].getName().equals("version") && !descs[i].getName().equals("callbacks")) { Method mRead = descs[i].getReadMethod(); // this is the proper way to check if a method is PUBLIC // because a method can also be final (the proxy entities used by Hibernate change the // public into public final) if (mRead != null && (mRead.getModifiers() & Modifier.PUBLIC) > 0) { // Method mWrite = descs[i].getWriteMethod(); // create writer from 'target' Method mWrite = null; try { PropertyDescriptor descr = new PropertyDescriptor(descs[i].getName(), targetClass); mWrite = descr.getWriteMethod(); } catch (Throwable t) { } // has a writer method? if (mWrite != null) { // get the value from the source Object value = mRead.invoke(original, noArgs); // copy map if (value instanceof Map) { Map<Object, Object> newMap = new HashMap<Object, Object>(); newMap.putAll((Map<?, ?>) value); value = newMap; // copy collection } else if (value instanceof Collection) { Collection<Object> newSet; if (value instanceof List) { newSet = new ArrayList<Object>(); } else { newSet = new HashSet<Object>(); // (Collection)value.getClass().newInstance(); } newSet.addAll((Collection<?>) value); value = newSet; } mWrite.invoke(historyEntity, new Object[] {value}); } else { if (!mRead.getName().equals("getClass")) { System.out.println("WARNING: No setter method for property " + descs[i].getName()); } } } } } } catch (Exception e) { throw new DataAccessException("Cant create History object: " + e, e); } }
public EntityDescriptor<?> wGetEntityDescriptor(IEntity child) { if (child.wGetParent() == this) return CommonsEntityDescriptorEnum.Any; throw new WholeIllegalArgumentException(WholeMessages.null_model); }
public IEntity wGet(IEntity child) { if (child.wGetParent() == this) return child; throw new IllegalStateException(WholeMessages.null_model); }
public boolean wEquals(IEntity entity) { return entity.equals(this); }
public boolean wContains(IEntity child) { if (child.wGetParent() == this) return true; return false; }
@Override public void setPosition(final IEntity pOtherEntity) { this.setPosition(pOtherEntity.getX(), pOtherEntity.getY()); }
@Override public void call(final IEntity pEntity) { pEntity.setParent(null); pEntity.onDetached(); }