{"size": 2762, "ext": "js", "max_stars_repo_path": "src/Standard/RadiusHandle.js", "max_stars_repo_name": "enquora/hotdraw.js", "max_stars_repo_stars_event_min_datetime": "2017-02-04T02:15:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-02T16:48:15.000Z", "max_issues_repo_path": "src/Standard/RadiusHandle.js", "max_issues_repo_name": "enquora/hotdraw.js", "max_issues_repo_issues_event_min_datetime": "2016-03-24T07:06:36.000Z", "max_issues_repo_issues_event_max_datetime": "2016-03-25T20:12:15.000Z", "max_forks_repo_path": "src/Standard/RadiusHandle.js", "max_forks_repo_name": "enquora/hotdraw.js", "max_forks_repo_forks_event_min_datetime": "2017-02-12T01:54:40.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-16T06:04:33.000Z"}
{"max_stars_count": 16, "max_issues_count": 2, "max_forks_count": 11, "avg_line_length": 34.525, "max_line_length": 136, "alphanum_fraction": 0.5981173063}
/**
 * Hotdraw.js : RadiusHandle
 *
 * {Comments are copied from the Java Implementation of HotDraw}
 *
 * A Handle to manipulate the radius of a round corner rectangle.
 * 
 * @author    Adnan M.Sagar, Phd. <adnan@websemantics.ca>
 * @copyright 2004-2017 Web Semantics, Inc.
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
 * @link      http://websemantics.ca
 * @since     16th February 2005 
 * @package   websemantics/hotdraw/standard
 */

RadiusHandle.prototype = new AbstractHandle();

function RadiusHandle( /* RoundRectangleFigure */ owner) {
    var argv = RadiusHandle.arguments;
    var argc = RadiusHandle.length;
    this.className = "RadiusHandle";
    /* Point */
    this.fRadius = null;
    /* RoundRectangleFigure */
    this.fOwner = null;
    /* int */
    this.OFFSET = 4;
    if (argv.length > 0) this.initRadiusHandle(owner);
}
//*************
// Initializes the RadiusHandle 
//*************
RadiusHandle.prototype.initRadiusHandle = function(owner) {
    this.initAbstractHandle(owner);
    this.fOwner = owner;
    this.color = "red";
}
//*************
// Create SVG Content
//*************
RadiusHandle.prototype.createSVGContent = function( /* Graphics */ g) {
    /* Rectangle */
    var r = this.displayBox();
    g.setColor(this.color);
    this.shape = g.drawOval(r.x + r.width / 2, r.y + r.height / 2, r.width, r.height);
    this.shape.setStrokeWidth(0.5);
    this.shape.setStrokeColor("black");
    this.shape.setCursor(this.getCursorName());
}
//*************
// Locates the handle on the figure by forwarding the request to its figure.
//*************
/* Point */
RadiusHandle.prototype.locate = function() {
    /* Point */
    var radius = this.fOwner.getArc();
    /* Rectangle */
    var r = this.fOwner.displayBox();
    return new Point(r.x + radius.x / 2 + this.OFFSET, r.y + radius.y / 2 + this.OFFSET);
}
//*************
// Tracks the start of the interaction. The default implementation does nothing.
//*************
RadiusHandle.prototype.invokeStart = function( /* int */ x, /* int */ y, /* DrawingView */ view) {
    this.fRadius = this.fOwner.getArc();
    this.fRadius.x = this.fRadius.x / 2;
    this.fRadius.y = this.fRadius.y / 2;
}
//*************
// Tracks a step of the interaction.
//*************
RadiusHandle.prototype.invokeStep = function( /* int */ x, /* int */ y, /* int */ anchorX, /* int */ anchorY, /* DrawingView */ view) {
    var dx = x - anchorX;
    var dy = y - anchorY;
    /* Rectangle */
    r = this.fOwner.displayBox();
    var rx = geom.range(0, r.width, 2 * (this.fRadius.x + dx));
    var ry = geom.range(0, r.height, 2 * (this.fRadius.y + dy));
    this.fOwner.setArc(rx, ry);
}