Sample

Schnappinger/aoi/artofillusion.procedural.ClipModule

Human rating uses the original dataset scale.

Human3.11
Lines165

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
30.8Δ 1.2
Scalabrino0.6850–1; higher is more readable
34.9Δ 2.9
Dorn0.0860–1; higher is more readable
31.7Δ 0.3
Mi0.4310–1; higher is more readable
26.1Δ 5.9
LLOC67Logical lines; fewer is more readable
31.7Δ 0.3
DeepSeek V4 Pro17.330–20; mean of three runs
73.9Δ 41.9
GPT-6.1 Sol170–20; mean of three runs
55.3Δ 23.3
BTTF0.4890–1; higher is more readable
44.2Δ 12.2
Human3.111–4; original rating
32.0

Views

Source code

/* Copyright (C) 2000-2011 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.procedural; import artofillusion.*; import artofillusion.math.*; import artofillusion.ui.*; import buoy.event.*; import buoy.widget.*; import java.awt.*; import java.io.*; /** This is a Module which clips its input to a fixed range. */ public class ClipModule extends Module { double min, max; public ClipModule(Point position) { super(Translate.text("menu.clipModule"), new IOPort [] {new IOPort(IOPort.NUMBER, IOPort.INPUT, IOPort.LEFT, new String [] {"Input", "(0)"})}, new IOPort [] {new IOPort(IOPort.NUMBER, IOPort.OUTPUT, IOPort.RIGHT, new String [] {"Output"})}, position); min = 0.0; max = 1.0; } /** Get the minimum clipping value. */ public double getMinimum() { return min; } /** Set the minimum clipping value. */ public void setMinimum(double m) { min = m; } /** Get the maximum clipping value. */ public double getMaximum() { return max; } /** Set the maximum clipping value. */ public void setMaximum(double m) { max = m; } /* Clip the input value. */ public double getAverageValue(int which, double blur) { if (linkFrom[0] == null) return 0.0; double v = linkFrom[0].getAverageValue(linkFromIndex[0], blur); if (v < min) return min; if (v > max) return max; return v; } /* Calculate the error. */ public double getValueError(int which, double blur) { if (linkFrom[0] == null) return 0.0; double v = linkFrom[0].getAverageValue(linkFromIndex[0], blur); if (v < min || v > max) return 0.0; return linkFrom[0].getValueError(linkFromIndex[0], blur); } /* Calculate the gradient. */ public void getValueGradient(int which, Vec3 grad, double blur) { if (linkFrom[0] == null) { grad.set(0.0, 0.0, 0.0); return; } double v = linkFrom[0].getAverageValue(linkFromIndex[0], blur); if (v < min || v > max) grad.set(0.0, 0.0, 0.0); else linkFrom[0].getValueGradient(linkFromIndex[0], grad, blur); } /* Allow the user to set the parameters. */ public boolean edit(final ProcedureEditor editor, Scene theScene) { final ValueField minField = new ValueField(min, ValueField.NONE); final ValueField maxField = new ValueField(max, ValueField.NONE); Object listener = new Object() { void processEvent() { if (minField.getValue() <= maxField.getValue()) { min = minField.getValue(); max = maxField.getValue(); editor.updatePreview(); } } }; minField.addEventLink(ValueChangedEvent.class, listener); maxField.addEventLink(ValueChangedEvent.class, listener); ComponentsDialog dlg = new ComponentsDialog(editor.getParentFrame(), Translate.text("selectClipRange"), new Widget [] {minField, maxField}, new String [] {Translate.text("Minimum"), Translate.text("Maximum")}); if (!dlg.clickedOk()) return false; min = minField.getValue(); max = maxField.getValue(); if (min > max) { new BStandardDialog("", Translate.text("minimumAboveMaxError"), BStandardDialog.INFORMATION).showMessageDialog(editor.getParent()); return edit(editor, theScene); } return true; } /* Create a duplicate of this module. */ public Module duplicate() { ClipModule mod = new ClipModule(new Point(bounds.x, bounds.y)); mod.min = min; mod.max = max; return mod; } /* Write out the parameters. */ public void writeToStream(DataOutputStream out, Scene theScene) throws IOException { out.writeDouble(min); out.writeDouble(max); } /* Read in the parameters. */ public void readFromStream(DataInputStream in, Scene theScene) throws IOException { min = in.readDouble(); max = in.readDouble(); } }

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.5383−177.639
Source linesThe number of non-empty source lines.165+66
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.905−7.357

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

Score0.685

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.166−4.841
Indentation frequencyHow rapidly indentation changes from line to line.157+4.693
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.157−3.182
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.146.976−2.56
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.164.845+1.894
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.146.994+1.567
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.097−0.002

Intercept 0.07 + feature contributions = -2.36 (log-odds).
Score = sigmoid(-2.36) = 0.086.

Score0.431
Score67
Run 1

The code is well-structured with clear separation of concerns, following standard Java class organization: fields, constructor, getters/setters, core logic, and helper methods. Nesting is minimal—only one level in conditional blocks and the null check. Intent is clear from method and variable names (e.g., getMinimum, setMaximum, getAverageValue). Code length is proportionate to functionality; no apparent boilerplate or redundancy. Action granularity is mostly one action per line, though the constructor chains several arguments across lines, which slightly impacts readability. Reading flow follows a logical, natural progression from instantiation to core behavior to persistence. Overall, the code is highly readable with only minor areas for polish (e.g., constructor formatting and repeated null check patterns could be refactored).

Run 2

The code is well-structured and highly readable. It follows a clear class layout with fields, constructor, getters/setters, and overridden methods grouped logically. Nesting is minimal; the only nested block is an if-statement in getValueGradient, which is acceptable. Intent is clear due to descriptive method names and Javadoc comments. The code is concise without sacrificing clarity—methods are short and focused. Each line generally performs a single action, enhancing readability. The reading flow is natural: simple methods first, then more complex ones. Minor deductions include the constructor's long parameter list, which slightly reduces readability, and the edit method's anonymous inner class adds a bit of complexity. Overall, the code is clean and maintainable.

Run 3

The code is highly readable. It has a clear, logical class structure with well-named methods and descriptive Javadoc comments explaining each section's purpose. Nesting is mostly flat; the deepest blocks are two levels for simple conditionals. Intent is unambiguous due to concise method names like getMinimum, setMaximum, and getAverageValue. The code length is appropriate for the functionality, avoiding unnecessary verbosity. Action granularity is excellent—each line performs a single, clear operation. Reading flow is natural, moving from constructor to getters/setters, to core logic, then to editing, duplication, and serialization. Minor readability cost comes from the fully qualified class names in method signatures (e.g., ProcedureEditor, Scene) which add slight visual noise, and the listener object pattern in edit() could be more modern but remains understandable. Overall, this is production-quality readable code.

Run 1

Code Structure: Well-organized methods separate clipping, error calculation, gradients, editing, duplication, and serialization. Nesting: Mostly flat, with early returns; the anonymous listener adds moderate nesting in edit(). Clarity of intent: Descriptive method names and comments make the module's purpose clear, though abbreviated locals and inherited link arrays require context. Code length: Generally concise, with some repetitive input checks and routine accessor comments. Action granularity: Statements typically perform one action per line, but constructor arguments and the dialog error call are dense. Reading flow: Methods follow a natural progression, although inconsistent brace indentation, long lines, wildcard imports, and recursive retry in edit() slightly disrupt readability.

Run 2

Code Structure: Clearly separated methods organize clipping, error and gradient calculations, editing, duplication, and serialization; edit mixes UI setup and validation. Nesting: Mostly flat, using early returns, with modest nesting in the anonymous event listener. Clarity of intent: Descriptive method names and comments make the purpose clear, though short variables such as v and m and inherited link arrays require context. Code length: Generally concise; accessor comments are somewhat redundant, and input retrieval is repeated across methods. Action granularity: Statements mostly perform one action per line, but constructor arguments and dialog construction are visually dense. Reading flow: Methods follow a logical progression, aided by whitespace, but inconsistent brace indentation, wildcard imports, and recursive dialog reopening slightly hinder readability.

Run 3

Code Structure: Methods are logically separated into parameter access, clipping calculations, editing, duplication, and serialization. Nesting: Most methods are flat with early returns; the anonymous event listener introduces moderate nesting. Clarity of intent: Descriptive method names and brief comments make the clipping behavior clear, though abbreviated variables and inherited link arrays require context. Code length: Generally concise, with some repetitive accessors and input checks; the constructor is visually dense. Action granularity: Most lines perform one action, although constructor and dialog expressions combine several operations. Reading flow: Organization is natural and consistent overall, but uneven indentation, long lines, and recursive dialog reopening slightly interrupt readability.