Sample

Schnappinger/aoi/artofillusion.animation.VerticalAxis

Human rating uses the original dataset scale.

Human3
Lines108

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
32.8Δ 5.1
Scalabrino0.6290–1; higher is more readable
25.7Δ 2.0
Dorn0.3180–1; higher is more readable
49.2Δ 21.5
Mi0.6340–1; higher is more readable
70.0Δ 42.2
LLOC54Logical lines; fewer is more readable
38.0Δ 10.2
DeepSeek V4 Pro160–20; mean of three runs
47.4Δ 19.6
GPT-6.1 Sol160–20; mean of three runs
38.9Δ 11.2
BTTF0.1520–1; higher is more readable
8.3Δ 19.5
Human31–4; original rating
27.7

Views

Source code

/* Copyright (C) 2001,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.animation; import artofillusion.*; import artofillusion.ui.*; import buoy.event.*; import buoy.widget.*; import java.awt.*; import java.text.*; import java.util.*; /** This draws the vertical axis on graphs of keyframe values. */ public class VerticalAxis extends CustomWidget { private double minValue, maxValue, vscale, tickPos[]; private NumberFormat nf = NumberFormat.getNumberInstance(); private boolean lineAtBottom; private Rectangle lastBounds; public static final int TICK_SIZE = 6; public VerticalAxis() { setGraphRange(0.0, 1.0); setPreferredSize(new Dimension(50, 0)); addEventLink(RepaintEvent.class, this, "paint"); } /** Select the range for the graph. */ public void setGraphRange(double min, double max) { Rectangle dim = getBounds(); minValue = min; maxValue = max; vscale = dim.height/(max-min); // Select the vertical tick positions. double height = dim.height; if (height <= 0) return; double increment = Math.pow(10.0, Math.floor(Math.log((max-min))/Math.log(10.0))); double pixels = (height*increment)/(max-min); if (pixels < 20.0) { while (pixels < 20.0) { pixels *= 5.0; increment *= 5.0; } } else if ((max-min)/increment < 4.0) increment *= 0.5; double lowest = Math.ceil(min/increment)*increment; int num = (int) Math.ceil((max-lowest)/increment)+1; tickPos = new double [num]; for (int i = 0; i < num; i++) tickPos[i] = lowest+i*increment; } /** Set whether a line should be draw along the bottom edge. */ public void showLineAtBottom(boolean show) { lineAtBottom = show; } private void paint(RepaintEvent ev) { Graphics2D g = ev.getGraphics(); FontMetrics fm = g.getFontMetrics(g.getFont()); int labelOffset = (fm.getMaxAscent()+fm.getMaxDescent())/2; Rectangle dim = getBounds(); if (lastBounds == null || dim.width != lastBounds.width || dim.height != lastBounds.height) setGraphRange(minValue, maxValue); // Draw the ticks on the vertical axis. if (tickPos == null) return; if (tickPos.length > 1) nf.setMaximumFractionDigits((int) Math.max(0, 1-Math.log(tickPos[1]-tickPos[0])/Math.log(10))); else nf.setMaximumFractionDigits(3); for (int i = 0; i < tickPos.length; i++) { int y = dim.height-(int) Math.round(vscale*(tickPos[i]-minValue)); g.drawLine(dim.width-TICK_SIZE, y, dim.width, y); String s = nf.format(tickPos[i]); int x = dim.width-TICK_SIZE-2-fm.stringWidth(s); g.drawString(s, x, y+labelOffset); } if (lineAtBottom) g.drawLine(0, dim.height-1, dim.width, dim.height-1); } }

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.4465.459−147.36
Source linesThe number of non-empty source lines.108+43.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.4.981−7.472

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

Score0.629

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.109−2.823
Indentation frequencyHow rapidly indentation changes from line to line.98+2.653
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.98−1.828
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.107.716+1.096
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.100.982+0.825
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.100.862−0.607
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.112−0.146

Intercept 0.07 + feature contributions = -0.761 (log-odds).
Score = sigmoid(-0.761) = 0.318.

Score0.634
Score54
Run 1

The code is generally well-structured and readable. It is organized into logical methods with clear purposes, uses descriptive variable names, and maintains a reasonable level of nesting—mostly one or two levels deep. The intent of each method is easy to understand, and the action granularity is mostly good, though a few lines combine multiple operations (e.g., `int num = (int) Math.ceil(...)+1;`). The reading flow is natural, with a clear top-down traversal from field declarations to constructors, methods, and painting logic. Overall the code is concise but not terse, and the license header, while lengthy, does not significantly affect readability of the actual implementation. The tick-position calculation block could be slightly refactored for clarity, but it is still understandable with some effort.

Run 2

The code is generally well-structured and readable. It has clear field declarations, a concise constructor, and focused methods (setGraphRange, showLineAtBottom, paint). Nesting is mostly shallow; the only deeper logic is the tick-selection block in setGraphRange, which remains understandable. Intent is mostly clear from method names and comments, though the tick-increment algorithm could use a brief explanatory comment. Code length is reasonable, but setGraphRange mixes calculations with state updates, and paint mixes layout checks with drawing, slightly reducing cohesion. Action granularity is mostly one action per line, improving clarity. Reading flow is natural: setup, range selection, then painting. Minor issues: the unused `lastBounds` field is puzzling, a stray blank line/comment near 'Select the vertical tick positions' is awkward, and some variable names (dim, vscale) are abbreviated but acceptable. Overall, clean and maintainable for a custom widget.

Run 3

The code is generally well-structured and readable. Class and method responsibilities are clear, with descriptive names (setGraphRange, paint). Formatting is consistent, and helper comments explain non-obvious logic. However, some issues reduce readability: magic numbers (20.0, 4.0, 3) lack named constants or explanation; the tick-position calculation contains several nested conditional branches and a while loop that require careful reading. The paint method handles layout, formatting, and drawing in one block, which slightly reduces action granularity and reading flow. Despite this, the code is concise, avoids deep nesting, and maintains a logical flow from setup to drawing.

Run 1

Code Structure: The class is logically divided into initialization, range calculation, configuration, and painting, though painting also updates range state. Nesting: Mostly shallow, with only a modestly nested tick-spacing loop and useful early returns. Clarity of intent: Class documentation and section comments explain the purpose, but abbreviated names such as nf, dim, and num, unexplained spacing constants, and dense mathematical expressions obscure details. The lastBounds field is checked but never updated, making its intended role confusing. Code length: Compact and generally proportionate to its task, although tick-spacing calculations could benefit from a named helper. Action granularity: Most statements perform one action per line; combined field declarations slightly reduce clarity. Reading flow: Methods follow a natural sequence, and rendering proceeds clearly from setup to ticks, labels, and the optional bottom line. Inconsistent whitespace, omitted braces on short branches, and tightly packed arithmetic modestly hinder scanning.

Run 2

Code Structure: The class is logically organized into initialization, range calculation, configuration, and rendering methods. Nesting: Control flow is mostly flat, with only a shallow nested loop in tick-spacing calculation. Clarity of intent: The class documentation, method names, and section comments explain its purpose, but abbreviated names such as nf, dim, and num, unexplained numeric thresholds, and dense mathematical expressions require interpretation. Code length: The implementation is compact without significant duplication, though extra blank lines add minor visual noise. Action granularity: Statements generally perform one action per line; grouped field declarations slightly reduce clarity. Reading flow: Methods follow a natural sequence and rendering steps are easy to trace. However, inconsistent omission of braces and lastBounds being checked but never assigned make the intended resize-tracking behavior less clear.

Run 3

Code Structure: The class is logically organized into initialization, range calculation, configuration, and painting, though tick calculation could be extracted. Nesting: Mostly shallow, with only a small nested loop in tick-spacing adjustment. Clarity of intent: Class documentation, method names, and comments explain the purpose, but abbreviated names such as nf, dim, and s, unexplained numeric thresholds, and dense logarithmic expressions obscure details. The lastBounds field is checked but never updated, making the resize-handling intent less clear. Code length: Compact and generally appropriate, with some excess blank lines. Action granularity: Most lines perform one action, although combined field declarations and complex arithmetic reduce scanability. Reading flow: Methods follow a natural progression, and painting proceeds from setup to labels to the bottom line; inconsistent brace usage and tightly spaced operators slightly interrupt readability.