Sample

Schnappinger/aoi/artofillusion.TransformPointsDialog

Human rating uses the original dataset scale.

Human3.72
Lines116

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
29.8Δ 12.1
Scalabrino0.6740–1; higher is more readable
32.2Δ 9.7
Dorn0.2850–1; higher is more readable
46.9Δ 5.0
Mi0.7190–1; higher is more readable
86.8Δ 44.9
LLOC58Logical lines; fewer is more readable
36.0Δ 5.9
DeepSeek V4 Pro16.670–20; mean of three runs
59.9Δ 18.0
GPT-6.1 Sol160–20; mean of three runs
38.9Δ 3.0
BTTF0.2690–1; higher is more readable
18.5Δ 23.4
Human3.721–4; original rating
41.9

Views

Source code

/* Copyright (C) 1999-2004 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.ui.*; import buoy.event.*; import buoy.widget.*; import java.awt.*; import java.util.*; /** This class implements the dialog box which is used for the "Transform Points" command. It allows the user enter values by which to translate, rotate, and scale the selected Points. It also allows them to specify whether the rotation and scaling should be done with respect to the origin of object coordinates, or the center of the selected points. */ public class TransformPointsDialog extends BDialog { private double finalValues[]; private ValueField fields[]; private BComboBox centerChoice; public TransformPointsDialog(BFrame parent) { super(parent, Translate.text("transformPoints"), true); fields = new ValueField [9]; layoutDialog(); pack(); setResizable(false); UIUtilities.centerDialog(this, parent); fields[0].requestFocus(); setVisible(true); } public double [] getValues() { return finalValues; } public boolean useSelectionCenter() { return (centerChoice.getSelectedIndex() == 0); } private void layoutDialog() { FormContainer content = new FormContainer(4, 6); setContent(content); LayoutInfo eastLayout = new LayoutInfo(LayoutInfo.EAST, LayoutInfo.NONE, new Insets(0, 0, 0, 5), null); content.add(Translate.label("Move"), 0, 1, eastLayout); content.add(Translate.label("Rotate"), 0, 2, eastLayout); content.add(Translate.label("Scale"), 0, 3, eastLayout); content.add(new BLabel("X"), 1, 0); content.add(new BLabel("Y"), 2, 0); content.add(new BLabel("Z"), 3, 0); for (int i = 0; i < 9; i++) content.add(fields[i] = new ValueField(Double.NaN, ValueField.NONE), (i%3)+1, (i/3)+1); RowContainer row = new RowContainer(); content.add(row, 0, 4, 4, 1); row.add(Translate.label("transformAround")); row.add(centerChoice = new BComboBox(new String [] { Translate.text("centerOfSelection"), Translate.text("objectOrigin") })); RowContainer buttons = new RowContainer(); content.add(buttons, 0, 5, 4, 1); buttons.add(Translate.button("ok", this, "doOk")); buttons.add(Translate.button("cancel", this, "dispose")); addEventLink(WindowClosingEvent.class, this, "dispose"); addAsListener(this); } private void doOk() { finalValues = new double [9]; for (int i = 0; i < finalValues.length; i++) { finalValues[i] = fields[i].getValue(); if (Double.isNaN(finalValues[i])) finalValues[i] = (i < 6 ? 0.0 : 1.0); } dispose(); } /** Pressing Return and Escape are equivalent to clicking OK and Cancel. */ private void keyPressed(KeyPressedEvent ev) { int code = ev.getKeyCode(); if (code == KeyPressedEvent.VK_ENTER) doOk(); if (code == KeyPressedEvent.VK_ESCAPE) dispose(); } /** Add this as a listener to every Widget. */ private void addAsListener(Widget w) { w.addEventLink(KeyPressedEvent.class, this, "keyPressed"); if (w instanceof WidgetContainer) { Iterator iter = ((WidgetContainer) w).getChildren().iterator(); while (iter.hasNext()) addAsListener((Widget) iter.next()); } } }

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.4862.152−160.451
Source linesThe number of non-empty source lines.116+46.4
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.948−7.422

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

Score0.674

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.116−3.071
Indentation frequencyHow rapidly indentation changes from line to line.105+2.895
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.105−1.989
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.114.954+1.197
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.106.974+0.922
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.94−0.864
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.105−0.08

Intercept 0.07 + feature contributions = -0.92 (log-odds).
Score = sigmoid(-0.92) = 0.285.

Score0.719
Score58
Run 1

The code is well-structured with clear separation of concerns: constructor, public API, dialog layout, event handling, and utility methods. Nesting is minimal and manageable, with only one level inside loops and conditionals. Intent is clear throughout, with descriptive method names like layoutDialog, doOk, and useSelectionCenter. Code length is appropriate—neither overly verbose nor terse. Action granularity is generally good, though some lines (e.g., content.add(fields[i] = new ValueField(...), ...)) combine multiple actions. Reading flow is natural, with layout code grouped logically and helper methods placed after their callers. Minor deductions: the ternary expression for default values in doOk is slightly dense, and the keyPressed method uses two separate if statements where else-if would be more idiomatic. Overall, this is clean, maintainable GUI code that follows good practices.

Run 2

The code is well-structured and readable. It has clear class and method names, logical organization of UI layout, and consistent indentation. The dialog layout is built in a flat, step-by-step manner with one action per line, which aids readability. The 'doOk' and 'keyPressed' methods are concise and show clear intent. Nesting is minimal, mostly limited to a single loop or conditional. The only minor drawbacks are the slightly dense layout code with hardcoded grid positions and the use of a magic number (9) for the field array size without a named constant. Overall, the code is straightforward, maintainable, and easy for another developer to follow.

Run 3

The code is generally well-structured and readable. It follows a clear logical layout with separate methods for dialog setup, event handling, and value retrieval. Nesting is minimal, with only small loops and one level of recursion in the listener registration. Intent is mostly clear from method names and comments, though the layout coordinates in layoutDialog() use magic numbers that could be clearer. Code length is reasonable, though the layout method is somewhat verbose. Action granularity is good, with one main action per line in most cases. Reading flow is natural: fields are declared at the top, constructor follows, then public API, then private helper methods. Some minor issues: the grid coordinates (0,1), (1,0), etc. are not self-documenting, and the loop in doOk() mixes value extraction with default assignment, slightly reducing clarity. Overall, this is readable code with only minor opportunities for improvement.

Run 1

Code Structure: Clear separation of initialization, layout, value extraction, keyboard handling, and listener registration. Nesting: Shallow loops and conditionals keep control flow easy to follow; recursive listener registration is straightforward. Clarity of intent: Descriptive method names and comments explain the dialog's purpose, but numeric array indices, hard-coded dimensions, and the i < 6 default rule require readers to infer the translation/rotation/scale mapping. Code length: Compact and appropriate for a small dialog, though layoutDialog contains repetitive UI setup. Action granularity: Most lines perform one action, but assignments embedded in content.add and row.add combine initialization with insertion. Reading flow: Methods follow a natural construction-to-interaction progression, with consistent formatting. Unbraced control statements, wildcard imports, and legacy array declaration syntax slightly reduce readability.

Run 2

Code Structure: Responsibilities are logically separated into construction, layout, value handling, keyboard handling, and listener registration. Nesting: Control flow is shallow, with only modest nesting in value normalization and recursive listener setup. Clarity of intent: Descriptive method names and comments explain the dialog's purpose, but numeric indices, fixed dimensions, and the implicit translation/rotation/scaling array mapping require interpretation. Code length: The implementation is reasonably concise; most layout statements are necessary rather than redundant. Action granularity: Most lines perform one action, though assignments embedded in widget-add calls combine initialization and placement. Reading flow: Methods follow a natural setup-to-interaction progression, aided by consistent formatting. Wildcard imports, raw Iterator usage, omitted braces, and compact index arithmetic slightly reduce readability.

Run 3

Code Structure: Well organized into constructor, accessors, layout setup, confirmation handling, and event helpers. Nesting: Shallow loops and conditionals keep control flow easy to follow; recursive listener registration is straightforward. Clarity of intent: Descriptive method names and class documentation explain the dialog's purpose, but numeric indices, grid coordinates, and the implicit mapping of nine fields to transformation types require inference. Code length: Compact and appropriate for a small dialog, although layoutDialog contains a dense sequence of UI setup operations. Action granularity: Most lines perform one action, but assignments embedded in content.add and row.add combine initialization with insertion. Reading flow: Methods follow a natural initialization-to-interaction progression, with consistent formatting. Missing braces on single-statement control blocks, raw iterator usage, and tightly spaced index arithmetic slightly reduce readability.