Title: Element Interaction: An Element includes the following targets: TARGET_POSITION : Allows the element to be repositioned TARGET_SIZE : Allows the element to be resized The actual position (and implementation) of the target depends on the element. Cop
| 33 | * @version June 2005 |
| 34 | */ |
| 35 | public abstract class Element implements org.opensourcephysics.display3d.core.Element { |
| 36 | static final int SENSIBILITY = 5; // The accuracy for the mouse to find a point on the screen |
| 37 | // Configuration variables |
| 38 | private boolean visible = true; // is the object visible? |
| 39 | private double x = 0.0, y = 0.0, z = 0.0; // position of the element |
| 40 | private double sizeX = 1.0, sizeY = 1.0, sizeZ = 1.0; // the size of the element in each dimension |
| 41 | private String name = ""; //$NON-NLS-1$ |
| 42 | private Transformation transformation = null; |
| 43 | private Style style = new Style(this); |
| 44 | private Group group = null; |
| 45 | private double factorX = 1.0; |
| 46 | private double factorY = 1.0; |
| 47 | private double factorZ = 1.0; |
| 48 | // Implementation variables |
| 49 | private boolean elementChanged = true, needsToProject = true; |
| 50 | private DrawingPanel3D panel; |
| 51 | // Variables for interaction |
| 52 | private ArrayList<InteractionListener> listeners = new ArrayList<InteractionListener>(); |
| 53 | protected final InteractionTarget targetPosition = new InteractionTarget(this, TARGET_POSITION); |
| 54 | protected final InteractionTarget targetSize = new InteractionTarget(this, TARGET_SIZE); |
| 55 | |
| 56 | /** |
| 57 | * Returns the DrawingPanel3D in which it (or its final ancestor group) |
| 58 | * is displayed. |
| 59 | * @return DrawingPanel3D |
| 60 | */ |
| 61 | @Override |
| 62 | final public DrawingPanel3D getDrawingPanel3D() { |
| 63 | Element el = this; |
| 64 | while(el.group!=null) { |
| 65 | el = el.group; |
| 66 | } |
| 67 | return el.panel; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * To be used internally by DrawingPanel3D only! Sets the panel for this element. |
| 72 | * @param _panel DrawingPanel3D |
| 73 | */ |
| 74 | void setPanel(DrawingPanel3D _panel) { |
| 75 | this.panel = _panel; |
| 76 | this.factorX = _panel.getScaleFactorX(); |
| 77 | this.factorY = _panel.getScaleFactorY(); |
| 78 | this.factorZ = _panel.getScaleFactorZ(); |
| 79 | elementChanged = true; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Returns the group to which the element belongs |
| 84 | * @return Group Returns null if it doesn't belong to a group |
| 85 | */ |
| 86 | final Group getGroup() { |
| 87 | return group; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Returns the top group to which the element belongs |
| 92 | * @return Group Returns null if it doesn't belong to a group |
nothing calls this directly
no outgoing calls
no test coverage detected