All Downloads are FREE. Search and download functionalities are using the official Maven repository.

us.ihmc.scs2.definition.yoGraphic.YoGraphicPoint2DDefinition Maven / Gradle / Ivy

package us.ihmc.scs2.definition.yoGraphic;

import java.util.Objects;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import us.ihmc.scs2.definition.yoComposite.YoTuple2DDefinition;

/**
 * A {@code YoGraphicPoint2DDefinition} is a template for creating 2D point and which components can
 * be backed by {@code YoVariable}s. 
* *

* A 2D yoGraphic is rendered in the overhead plotter panel and it can be back by * {@code YoVariable}s allowing it to move and change at runtime. *

*

* The {@code YoGraphicPoint2DDefinition} is to be passed before initialization of a session (either * before starting a simulation or when creating a yoVariable server), such that the SCS GUI can use * the definitions and create the actual graphics. *

*

* See {@link YoGraphicDefinitionFactory} for factory methods simplifying the creation of yoGraphic * definitions. *

* * @author Sylvain Bertrand */ @XmlRootElement(name = "YoGraphicPoint2D") public class YoGraphicPoint2DDefinition extends YoGraphic2DDefinition { /** The position for the point. */ private YoTuple2DDefinition position; /** The size of the graphic, when rendered as a circle, it corresponds to the diameter. */ private String size; /** * The graphic name used to retrieve the type of graphic to visualize the point as. Here are some * examples: *
    *
  • "plus":
    * *
  • "cross":
    * *
  • "circle":
    * *
  • "circle_plus":
    * *
  • "circle_cross":
    * *
  • "diamond":
    * *
  • "diamond_plus":
    * *
  • "square":
    * *
  • "square_cross":
    * *
*/ private String graphicName; /** * Creates a new yoGraphic definition for rendering a point. *

* Its components need to be initialized. See {@link YoGraphicDefinitionFactory} for factories to * facilitate creation. *

*/ public YoGraphicPoint2DDefinition() { registerTuple2DField("position", this::getPosition, this::setPosition); registerStringField("size", this::getSize, this::setSize); registerStringField("graphicName", this::getGraphicName, this::setGraphicName); } /** * Sets the position for the point. * * @param position the position for the point. */ @XmlElement public void setPosition(YoTuple2DDefinition position) { this.position = position; } /** * Sets the size of the graphic, when rendered as a circle, it corresponds to the diameter. *

* Using this method sets it to a constant value. *

* * @param size the size of the graphic. */ public void setSize(double size) { this.size = Double.toString(size); } /** * Sets the size of the graphic, when rendered as a circle, it corresponds to the diameter. *

* Using this method allows to back the size with a {@code YoVariable} by giving the variable * name/fullname. *

* * @param size the size of the graphic. */ @XmlElement public void setSize(String size) { this.size = size; } /** * Sets the type of the graphic: *
    *
  • "plus":
    * *
  • "cross":
    * *
  • "circle":
    * *
  • "circle_plus":
    * *
  • "circle_cross":
    * *
  • "diamond":
    * *
  • "diamond_plus":
    * *
  • "square":
    * *
  • "square_cross":
    * *
* * @param graphicName the name of the graphic to use. */ @XmlElement public void setGraphicName(String graphicName) { this.graphicName = graphicName; } public YoTuple2DDefinition getPosition() { return position; } public String getSize() { return size; } public String getGraphicName() { return graphicName; } @Override public boolean equals(Object object) { if (object == this) { return true; } else if (!super.equals(object)) { return false; } else if (object instanceof YoGraphicPoint2DDefinition other) { if (!Objects.equals(position, other.position)) return false; if (!Objects.equals(size, other.size)) return false; if (!Objects.equals(graphicName, other.graphicName)) return false; return true; } else { return false; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy