private String getItemName(Entity entity) {
   mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
   if (mainItemComponent.itemIdentifier != null && !mainItemComponent.itemIdentifier.isEmpty()) {
     return mainItemComponent.itemIdentifier;
   } else {
     int type = EntityUtils.getType(entity);
     switch (type) {
       case EntityFactory.IMAGE_TYPE:
         return "Image";
       case EntityFactory.NINE_PATCH:
         return "9PatchImage";
       case EntityFactory.LABEL_TYPE:
         return "Label";
       case EntityFactory.COMPOSITE_TYPE:
         return "CompositeItem";
       case EntityFactory.PARTICLE_TYPE:
         return "ParticleEffect";
       case EntityFactory.LIGHT_TYPE:
         return "Light";
       case EntityFactory.SPINE_TYPE:
         return "Spine";
       case EntityFactory.SPRITE_TYPE:
         return "SpriteAnimation";
       case EntityFactory.SPRITER_TYPE:
         return "SpriterAnimation";
       case EntityFactory.COLOR_PRIMITIVE:
         return "Primitive";
       default:
         return "unknown";
     }
   }
 }
 @Override
 public void begin(Entity entity, T actionData) {
   DimensionsComponent dimensionsComponent =
       ComponentRetriever.get(entity, DimensionsComponent.class);
   actionData.startWidth = dimensionsComponent.width;
   actionData.startHeight = dimensionsComponent.height;
 }
  public static Object[] payloadInitialState(Entity entity) {
    PolygonComponent polygonComponent = ComponentRetriever.get(entity, PolygonComponent.class);
    Object[] payload = new Object[3];
    payload[0] = entity;
    payload[1] = cloneData(polygonComponent.vertices);

    return payload;
  }
 @Override
 protected void update(float percent, Entity entity, T actionData) {
   DimensionsComponent dimensionsComponent =
       ComponentRetriever.get(entity, DimensionsComponent.class);
   dimensionsComponent.width =
       actionData.startWidth + (actionData.endHeight - actionData.startWidth) * percent;
   dimensionsComponent.height =
       actionData.startHeight + (actionData.endHeight - actionData.startHeight) * percent;
 }
Esempio n. 5
0
  @Override
  public void undoAction() {
    Entity viewingEntity = EntityUtils.getByUniqueId(entityId);
    LayerMapComponent layerMapComponent =
        ComponentRetriever.get(viewingEntity, LayerMapComponent.class);
    layerMapComponent.swap(targetName, sourceName);

    facade.sendNotification(DONE);
  }
  @Override
  public void undoAction() {
    Entity entity = EntityUtils.getByUniqueId(entityId);

    PolygonComponent polygonComponent = ComponentRetriever.get(entity, PolygonComponent.class);
    polygonComponent.vertices = dataFrom;

    // if it's image update polygon sprite data
    TextureRegionComponent textureRegionComponent =
        ComponentRetriever.get(entity, TextureRegionComponent.class);
    if (textureRegionComponent != null && textureRegionComponent.isPolygon) {
      DimensionsComponent dimensionsComponent =
          ComponentRetriever.get(entity, DimensionsComponent.class);
      dimensionsComponent.setPolygon(polygonComponent);
      textureRegionComponent.setPolygonSprite(polygonComponent);
    }

    Overlap2DFacade.getInstance().sendNotification(Overlap2D.ITEM_DATA_UPDATED, entity);
  }
 private Node addTreeNode(Entity item, Node parentNode) {
   Node node = new Node(new VisLabel(parentNode == null ? "root" : getItemName(item)));
   MainItemComponent mainItemComponent = ComponentRetriever.get(item, MainItemComponent.class);
   node.setObject(mainItemComponent.uniqueId);
   if (parentNode != null) {
     parentNode.add(node);
   } else {
     tree.add(node);
   }
   return node;
 }
  private Node addTreeRoot(
      Entity entity,
      Node parentNode) { // was like this addTreeRoot(CompositeItem compoiteItem, Node parentNode)
    Node node = addTreeNode(entity, parentNode);
    if (parentNode == null) rootNode = node;

    NodeComponent nodeComponent = ComponentRetriever.get(entity, NodeComponent.class);

    if (nodeComponent != null) {
      for (Entity item : nodeComponent.children) {
        if (EntityUtils.getType(entity) == EntityFactory.COMPOSITE_TYPE) {
          addTreeRoot(item, node);
        } else {
          addTreeNode(item, node);
        }
      }
    }
    return node;
  }