Sample

Schnappinger/aoi/artofillusion.CreateCubeTool

Human rating uses the original dataset scale.

Human3.24
Lines134

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
27.4Δ 6.9
Scalabrino0.6870–1; higher is more readable
36.0Δ 1.6
Dorn0.2440–1; higher is more readable
44.2Δ 9.9
Mi0.7310–1; higher is more readable
87.8Δ 53.5
LLOC65Logical lines; fewer is more readable
33.2Δ 1.2
DeepSeek V4 Pro15.330–20; mean of three runs
41.3Δ 6.9
GPT-6.1 Sol15.330–20; mean of three runs
30.7Δ 3.6
BTTF0.3020–1; higher is more readable
20.5Δ 13.9
Human3.241–4; original rating
34.3

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 java.awt.*; /** CreateCubeTool is an EditingTool used for creating Cube objects. */ public class CreateCubeTool extends EditingTool { static int counter = 1; private boolean shiftDown; private Point clickPoint; private ObjectInfo objInfo; public CreateCubeTool(LayoutWindow fr) { super(fr); initButton("cube"); } public void activate() { super.activate(); theWindow.setHelpText(Translate.text("createCubeTool.helpText")); } public int whichClicks() { return ALL_CLICKS; } public String getToolTipText() { return Translate.text("createCubeTool.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 cube. Scene theScene = ((LayoutWindow) theWindow).getScene(); objInfo = new ObjectInfo(new Cube(1.0, 1.0, 1.0), new CoordinateSystem(), "Cube "+(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 cube. Scene theScene = ((LayoutWindow) theWindow).getScene(); 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. ((Cube) 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; } }

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.5620.358−185.472
Source linesThe number of non-empty source lines.134+53.6
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.014−7.522

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

Score0.687

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.134−3.708
Indentation frequencyHow rapidly indentation changes from line to line.123+3.517
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.123−2.402
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.132.907+1.448
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.106.97+0.921
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.106.948−0.865
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.133 (log-odds).
Score = sigmoid(-1.133) = 0.244.

Score0.731
Score65
Run 1

The code is generally readable but has some issues. Structure is logical, with clear class and method separation. Nesting is mostly flat, though the shiftDown logic has nested conditionals that could be simplified. Intent is clear - creating cubic objects in a 3D scene. Length is reasonable but the mouseDragged method does too much: creating objects, calculating geometry, and updating display. Action granularity is mostly good with one action per line, though some lines are dense with calculations. Reading flow is natural: setup, creation, geometric calculation, update. Main issues are the monolithic mouseDragged method and some mathematical operations that could use better variable naming or helper methods. The shiftDown logic for maintaining aspect ratio is particularly complex and could be extracted. The class has clear responsibility but the drag handling mixes too many concerns.

Run 2

The code is well-structured and readable. It has a clear class purpose, logical method separation, and consistent formatting. Nesting is generally flat, though the shiftDown block contains multiple nested if/else conditions that slightly increase complexity. Intent is clear: each method handles a distinct interaction, and variable names are descriptive (e.g., clickPoint, dragPoint, xsize). Code length is reasonable but the mouseDragged method is dense, mixing object creation, coordinate math, and UI updates. Action granularity is mostly one action per line, improving clarity. Reading flow is natural, with helpful inline comments delineating major steps. Minor deductions for the long mouseDragged method and some repetitive casting (e.g., repeated `(LayoutWindow) theWindow`), which could be refactored for brevity. Overall, the code is maintainable and easy to follow.

Run 3

The code has a clear class structure with well-named methods that map to mouse events, and the imports are organized. However, the mouseDragged method is overly long and handles too many responsibilities: object creation, size/position calculation, and UI updates. The shift-constraint logic has deeply nested conditionals that disrupt reading flow. Action granularity is inconsistent—some lines perform multiple operations (e.g., object instantiation with multiple constructor arguments). Variable declarations are grouped at the top of the method rather than near their usage, reducing locality. The intent is generally clear due to descriptive naming and comments marking logical sections, but the density of mathematical operations without explanation makes the coordinate transformation logic harder to follow. The code is readable overall but would benefit from extracting the size calculation and creation logic into helper methods.

Run 1

Code Structure: Lifecycle methods are logically organized, and comments divide dragging into creation, geometry calculation, and display updates; however, mouseDragged combines several responsibilities. Nesting: Most code is flat, but the shift-constrained sizing logic reaches three conditional levels. Clarity of intent: The class purpose and event handlers are clear, while abbreviated geometry names such as v1, v2, v3, and orig require interpretation. Code length: Overall length is reasonable, though repeated LayoutWindow casts and similar sizing branches add verbosity. Action granularity: Statements generally perform one action per line, with minor exceptions such as the counter increment embedded in object creation and grouped variable declarations. Reading flow: Consistent formatting and sequential processing make the code easy to follow, but dense mathematical expressions, missing braces on some conditionals, and an unused scene variable interrupt readability.

Run 2

Code Structure: Event-handler methods organize the tool logically, but mouseDragged combines object creation, geometry calculations, undo setup, and display updates. Nesting: Mostly shallow, with moderately nested conditionals for shift-constrained dragging. Clarity of intent: The class documentation, method names, and section comments explain the purpose well; abbreviated geometry variables such as v1, v2, v3, and orig require interpretation. Code length: Reasonably compact overall, though extracting geometry and creation helpers would make the long drag handler easier to scan. Action granularity: Most lines perform one clear action, but the object-construction expression also increments the naming counter, and grouped declarations reduce clarity slightly. Reading flow: Execution follows a natural create-calculate-update sequence. Repeated casts, dense arithmetic spacing, and brace-free conditional branches introduce minor reading friction.

Run 3

Code Structure: Event handlers organize the tool logically, and comments separate creation, geometry calculation, and display updates, though mouseDragged handles too many responsibilities. Nesting: Mostly shallow, but the shift-constrained dragging logic reaches three conditional levels. Clarity of intent: The class purpose and lifecycle are clear; terse names such as v1, v2, v3, and orig obscure the geometry calculations. Code length: Reasonably concise overall, but repeated casts, coordinate-difference expressions, and an unused scene variable add clutter. Action granularity: Most lines perform one action, although object construction combined with counter increment and chained calls slightly increases cognitive load. Reading flow: Processing follows a natural create-calculate-update sequence, supported by whitespace and comments. Grouped declarations, inconsistent spacing, and unbraced conditionals make portions harder to scan.