/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ import ilog.views.sdm.model.IlvDefaultSDMNode; /** * This is a convenience class to get simple access to some of the frequently * used properties. */ final class Node extends IlvDefaultSDMNode { /** * The orbit. */ private double orbit; /** * The angle, in degrees */ private int angle; /** * The speed, in degree/timer delay */ private int speed; /** * Create an instance of a Node. * * @param tag * the tag to use in the model. This tag is what will also be used to * identify this type of Node in the Designer when building CSS * rules. * * @param orbit * The orit of the node use to make the node turning. It's a * multipliation factor of the rays of the ellipse * @param angle * The start angle that determines the position on the ellipse * @param speed * The animation speed. The node will turn by this amount, in * degrees, during each timer interval * */ public Node(final String tag, final double orbit, final int angle, int speed) { super(tag); setOrbit(orbit); setAngle(angle); setSpeed(speed); } /** * Get the orbit of this node. * * @return the direction. */ public double getOrbit() { return orbit; } /** * Set the orbit of this node. * * @param newOrbit * the new orbit of the node. */ public void setOrbit(final double newOrbit) { orbit = newOrbit; } /** * Get the angle of this node. */ public int getAngle() { return angle; } /** * Set the angle ofthis node. It determines the position on the ellipse * trajectory * * @param newAngle * the new angle of the node. */ public void setAngle(final int newAngle) { angle = newAngle % 360; } /** * Gets the speed of this node */ int getSpeed() { return speed; } /** * Set the new speed of this node * * @param speed * The new speed, in degrees */ void setSpeed(int speed) { this.speed = speed; } /** * Convenience method to get the X coordinate of the node. * * @return the X coordinate as an integer. */ public int getX() { Object x = getProperty("x"); if (x instanceof Number) { return ((Number) x).intValue(); } else if (x == null) { return 0; } else { String sx = x.toString(); return Integer.parseInt(sx); } } /** * Convenience method to get the Y coordinate of the node. * * @return the Y coordinate as an integer. */ public int getY() { Object y = getProperty("y"); if (y instanceof Number) { return ((Number) y).intValue(); } else if (y == null) { return 0; } else { String sy = y.toString(); return Integer.parseInt(sy); } } }