Sample

Schnappinger/aoi/artofillusion.CreateCylinderTool

Human rating uses the original dataset scale.

Human3.79
Lines143

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
25.8Δ 18.6
Scalabrino0.6690–1; higher is more readable
31.5Δ 12.9
Dorn0.1920–1; higher is more readable
40.9Δ 3.5
Mi0.7310–1; higher is more readable
88.1Δ 43.7
LLOC70Logical lines; fewer is more readable
29.7Δ 14.7
DeepSeek V4 Pro160–20; mean of three runs
47.4Δ 3.0
GPT-6.1 Sol150–20; mean of three runs
25.7Δ 18.6
BTTF0.2410–1; higher is more readable
15.5Δ 28.9
Human3.791–4; original rating
44.4

Views

Source code

/* Copyright (C) 1999-2008 by Peter Eastman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package artofillusion; import artofillusion.animation.*; import artofillusion.math.*; import artofillusion.object.*; import artofillusion.ui.*; import buoy.event.*; import buoy.widget.*; import java.awt.*; /** CreateCylinderTool is an EditingTool used for creating Cylinder objects. */ public class CreateCylinderTool extends EditingTool { static int counter = 1; private boolean shiftDown; private Point clickPoint; private double ratio = 1.0; private ObjectInfo objInfo; public CreateCylinderTool(LayoutWindow fr) { super(fr); initButton("cylinder"); } public void activate() { super.activate(); theWindow.setHelpText(Translate.text("createCylinderTool.helpText")); } public int whichClicks() { return ALL_CLICKS; } public String getToolTipText() { return Translate.text("createCylinderTool.tipText"); } public void mousePressed(WidgetMouseEvent e, ViewerCanvas view) { clickPoint = e.getPoint(); shiftDown = e.isShiftDown(); } public void mouseDragged(WidgetMouseEvent e, ViewerCanvas view) { if (objInfo == null) { // Create the cylinder. Scene theScene = ((LayoutWindow) theWindow).getScene(); objInfo = new ObjectInfo(new Cylinder(1.0, 1.0, 1.0, ratio), new CoordinateSystem(), "Cylinder "+(counter++)); objInfo.addTrack(new PositionTrack(objInfo), 0); objInfo.addTrack(new RotationTrack(objInfo), 1); UndoRecord undo = new UndoRecord(theWindow, false); int sel[] = ((LayoutWindow) theWindow).getSelectedIndices(); ((LayoutWindow) theWindow).addObject(objInfo, undo); undo.addCommand(UndoRecord.SET_SCENE_SELECTION, new Object [] {sel}); theWindow.setUndoRecord(undo); ((LayoutWindow) theWindow).setSelection(theScene.getNumObjects()-1); } // Determine the size and position for the cylinder. Camera cam = view.getCamera(); Point dragPoint = e.getPoint(); Vec3 v1, v2, v3, orig, xdir, ydir, zdir; double xsize, ysize, zsize; if (shiftDown) { if (Math.abs(dragPoint.x-clickPoint.x) > Math.abs(dragPoint.y-clickPoint.y)) { if (dragPoint.y < clickPoint.y) dragPoint.y = clickPoint.y - Math.abs(dragPoint.x-clickPoint.x); else dragPoint.y = clickPoint.y + Math.abs(dragPoint.x-clickPoint.x); } else { if (dragPoint.x < clickPoint.x) dragPoint.x = clickPoint.x - Math.abs(dragPoint.y-clickPoint.y); else dragPoint.x = clickPoint.x + Math.abs(dragPoint.y-clickPoint.y); } } v1 = cam.convertScreenToWorld(clickPoint, Camera.DEFAULT_DISTANCE_TO_SCREEN); v2 = cam.convertScreenToWorld(new Point(dragPoint.x, clickPoint.y), Camera.DEFAULT_DISTANCE_TO_SCREEN); v3 = cam.convertScreenToWorld(dragPoint, Camera.DEFAULT_DISTANCE_TO_SCREEN); orig = v1.plus(v3).times(0.5); if (dragPoint.x < clickPoint.x) xdir = v1.minus(v2); else xdir = v2.minus(v1); if (dragPoint.y < clickPoint.y) ydir = v3.minus(v2); else ydir = v2.minus(v3); xsize = xdir.length(); ysize = ydir.length(); xdir = xdir.times(1.0/xsize); ydir = ydir.times(1.0/ysize); zdir = xdir.cross(ydir); zsize = Math.min(xsize, ysize); // Update the size and position, and redraw the display. ((Cylinder) objInfo.getObject()).setSize(xsize, ysize, zsize); objInfo.getCoords().setOrigin(orig); objInfo.getCoords().setOrientation(zdir, ydir); objInfo.clearCachedMeshes(); theWindow.setModified(); theWindow.updateImage(); } public void mouseReleased(WidgetMouseEvent e, ViewerCanvas view) { objInfo = null; } public void iconDoubleClicked() { ValueSlider ratioSlider = new ValueSlider(0.0, 1.0, 100, ratio); ComponentsDialog dlg = new ComponentsDialog(theFrame, Translate.text("editCylinderTitle"), new Widget [] {ratioSlider}, new String [] {Translate.text("radiusRatio")}); if (dlg.clickedOk()) ratio = ratioSlider.getValue(); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.6290.174−207.576
Source linesThe number of non-empty source lines.143+57.2
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.5.018−7.528

Intercept 8.87 + feature contributions = -149.033 (log-odds).
Score = sigmoid(-149.033) = 0.

Score0.669

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.143−4.027
Indentation frequencyHow rapidly indentation changes from line to line.132+3.829
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.131−2.585
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.141.863+1.573
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.115.965−1.247
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.116+1.067
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.109−0.115

Intercept 0.07 + feature contributions = -1.435 (log-odds).
Score = sigmoid(-1.435) = 0.192.

Score0.731
Score70
Run 1

The code is structured logically with clear sections for event handling, shape creation, and sizing. It is mostly flat with reasonable nesting, though the shift-constrained drag logic involves extended if-else blocks that add some depth. Intent is generally clear, with helpful comments marking major steps, but the geometric calculations and repeated typecasts reduce clarity. Length is moderate, though the mouseDragged method is lengthy and could be decomposed for readability. Action granularity is mostly one action per line, but some lines are dense. Reading flow is natural, though the dragged logic would benefit from helper methods. Overall, it is readable but somewhat verbose in places.

Run 2

The code is well-structured with clear method separation and logical organization. Nesting is minimal, with only a few levels for shift-key handling. Intent is generally clear, with helpful comments marking major steps like cylinder creation and sizing. Code length is reasonable and not verbose. Most lines perform a single action, though some long constructor calls span multiple actions. Reading flow is natural, moving from setup through interaction to cleanup. Minor deductions: some dense coordinate calculations could be extracted for clarity, and the shift-key constraint block is slightly complex without a comment explaining its purpose. Overall, very readable.

Run 3

The code is generally well-structured and readable. It follows a logical organization with clear method separation and consistent naming conventions. The class has a single responsibility and methods are appropriately sized. Nesting is minimal, with only a few conditional blocks that remain shallow. Intent is mostly clear - method names like mouseDragged and iconDoubleClicked clearly indicate their purpose, though some mathematical operations for cylinder sizing could use brief explanatory comments. Code length is reasonable for the functionality provided. Action granularity is good, with one main action per line and appropriate spacing between logical sections. The reading flow is natural, moving from initialization through interaction handling to cleanup. Minor deductions for slightly complex geometry calculations that could benefit from extraction into helper methods, and the license header adds length without contributing to readability. Overall, this is solid, maintainable code that would be easy for another developer to understand and modify.

Run 1

Code Structure: Event-handler methods organize the tool logically, but mouseDragged combines object creation, undo setup, geometry calculations, and display updates. Nesting: Mostly shallow, with a moderately nested shift-key constraint block. Clarity of intent: The class name, handler names, and section comments explain the purpose; terse variables such as v1, v2, v3, and orig make the geometry harder to follow. Code length: Reasonably compact overall, although extracting helper methods would make the long drag handler easier to scan. Action granularity: Most lines perform one action, but object construction, counter increment, and repeated casts introduce some dense expressions. Reading flow: The progression from creation to sizing to redraw is natural, supported by whitespace and comments. Grouped declarations, omitted braces on conditionals, and repeated arithmetic slightly reduce readability.

Run 2

Code Structure: Event-handler methods organize responsibilities logically, but mouseDragged combines object creation, undo setup, geometric calculations, and rendering updates. Nesting: Most code is flat; the Shift-constrained dragging logic reaches three conditional levels and could be simplified. Clarity of intent: Descriptive method names and section comments explain the overall purpose, while abbreviated variables such as v1, orig, and sel obscure geometric details. Code length: The class is reasonably concise, although extracting geometry and object initialization helpers would make the long drag handler easier to scan. Action granularity: Statements generally perform one action per line, with a few dense constructor expressions and an inline counter increment. Reading flow: Initialization, calculation, and update stages follow a natural sequence, but repeated casts, compact arithmetic formatting, and inconsistent brace usage introduce minor friction.

Run 3

Code Structure: Event-handler methods provide logical organization, and comments separate creation, geometry calculation, and display updates, though mouseDragged combines several responsibilities. Nesting: Most code is flat, but the Shift-constrained sizing logic has three nested conditional levels. Clarity of intent: Class and method names clearly describe cylinder creation; abbreviated geometry variables, unexplained constants, and repeated casts make details harder to interpret. Code length: Generally economical, although extracting geometry and object initialization helpers would shorten the main handler and reduce cognitive load. Action granularity: Statements mostly perform one action per line, with minor exceptions such as incrementing counter inside object construction and declaring several variables together. Reading flow: The sequence from input capture to creation, sizing, and redraw is natural, supported by consistent formatting and comments; dense expressions and unbraced conditionals slightly interrupt readability.