Sample

Schnappinger/aoi/artofillusion.object.ReferenceImage

Human rating uses the original dataset scale.

Human2.43
Lines175

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
30.1Δ 16.9
Scalabrino0.7740–1; higher is more readable
56.5Δ 43.3
Dorn0.1370–1; higher is more readable
36.0Δ 22.8
Mi0.8160–1; higher is more readable
96.7Δ 83.5
LLOC67Logical lines; fewer is more readable
31.7Δ 18.5
DeepSeek V4 Pro17.330–20; mean of three runs
73.9Δ 60.7
GPT-6.1 Sol170–20; mean of three runs
55.3Δ 42.1
BTTF0.3680–1; higher is more readable
30.4Δ 17.2
Human2.431–4; original rating
13.2

Views

Source code

/* Copyright (C) 2007 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.object; import artofillusion.math.*; import artofillusion.*; import artofillusion.animation.*; import javax.imageio.*; import java.awt.*; import java.awt.image.*; import java.io.*; /** * A ReferenceImage is an object that displays an image for use during modelling. When drawn * in a ViewerCanvas, it is a rectangle with the image mapped to it, but when rendered by a * Renderer, it is invisible. */ public class ReferenceImage extends Object3D { private double width, height; private Image image; /** * Create a ReferenceImage whose width and height are both 1.0, and with no image set. */ public ReferenceImage() { width = 1.0; height = 1.0; } public ReferenceImage(Image image) { this.image = image; width = 0.01*image.getWidth(null); height = 0.01*image.getHeight(null); } /** * Get the Image displayed by this object. */ public Image getImage() { return image; } /** * Set the Image displayed by this object. */ public void setImage(Image image) { this.image = image; } public boolean canSetTexture() { return false; } public Object3D duplicate() { ReferenceImage ri = new ReferenceImage(); ri.image = image; ri.width = width; ri.height = height; return ri; } public void copyObject(Object3D obj) { ReferenceImage ri = (ReferenceImage) obj; image = ri.image; width = ri.width; height = ri.height; } public BoundingBox getBounds() { return new BoundingBox(-0.5*width, 0.5*width, -0.5*height, 0.5*height, 0.0, 0.0); } public void setSize(double xsize, double ysize, double zsize) { width = xsize; height = ysize; } public WireframeMesh getWireframeMesh() { Vec3 vert[] = new Vec3[] {new Vec3(-0.5*width, 0.5*height, 0.0), new Vec3(0.5*width, 0.5*height, 0.0), new Vec3(0.5*width, -0.5*height, 0.0), new Vec3(-0.5*width, -0.5*height, 0.0)}; int from[] = new int[] {0, 1, 2, 3}; int to[] = new int[] {1, 2, 3, 0}; return new WireframeMesh(vert, from, to); } public Keyframe getPoseKeyframe() { return new NullKeyframe(); } public void applyPoseKeyframe(Keyframe k) { } /** * This method is overridden to render the reference image into the ViewerCanvas. */ public void renderObject(ObjectInfo obj, ViewerCanvas canvas, Vec3 viewDir) { if (image == null) super.renderObject(obj, canvas, viewDir); else canvas.renderImage(image, new Vec3(-0.5*width, -0.5*height, 0.0), new Vec3(0.5*width, -0.5*height, 0.0), new Vec3(0.5*width, 0.5*height, 0.0), new Vec3(-0.5*width, 0.5*height, 0.0)); } /** * Reconstruct a ReferenceImage that was saved to a file. */ public ReferenceImage(DataInputStream in, Scene theScene) throws IOException { super(in, theScene); short version = in.readShort(); if (version != 0) throw new InvalidObjectException(""); width = in.readDouble(); height = in.readDouble(); byte imageData[] = new byte [in.readInt()]; in.readFully(imageData); image = ImageIO.read(new ByteArrayInputStream(imageData)); } public void writeToFile(DataOutputStream out, Scene theScene) throws IOException { super.writeToFile(out, theScene); out.writeShort(0); out.writeDouble(width); out.writeDouble(height); // Save the image to the file. ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (image instanceof RenderedImage) ImageIO.write((RenderedImage) image, "png", baos); else { // We need to copy it into a BufferedImage. BufferedImage bi = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D g = bi.createGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); ImageIO.write(bi, "png", baos); } out.writeInt(baos.size()); out.write(baos.toByteArray()); } }

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.5517.836−182.089
Source linesThe number of non-empty source lines.175+70
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.92−7.381

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

Score0.774

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.176−5.195
Indentation frequencyHow rapidly indentation changes from line to line.151+4.486
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.151−3.044
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.174.771+2.033
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.116.966−1.289
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.116.977+1.083
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.095+0.017

Intercept 0.07 + feature contributions = -1.839 (log-odds).
Score = sigmoid(-1.839) = 0.137.

Score0.816
Score67
Run 1

The code is well-structured and generally readable. It follows standard Java conventions with clear class and method organization. Methods are concise and serve single purposes, aiding clarity. Nesting is minimal, with only one multi-line if/else block in writeToFile. The reading flow is natural: fields, constructors, simple getters/setters, then behavior methods. Most lines perform exactly one action. Minor drawbacks: the renderObject method has a somewhat lengthy single call for the image branch, and the serialization constructor could be slightly more segmented, but neither significantly harms readability. Comments are helpful and appropriately placed. Overall, the code demonstrates good style and maintainability.

Run 2

The code is highly readable with a clear, logical structure. It is well-organized into constructors, getters/setters, and overridden methods, each with a single responsibility. Nesting is minimal—only one level in conditional blocks—keeping the code flat and easy to follow. Intent is clearly expressed through method names and Javadoc comments on non-obvious behaviors (e.g., rendering only in ViewerCanvas). The code is concise, avoiding unnecessary repetition, though the long array initializations and the multi-argument renderImage call slightly reduce readability. Action granularity is mostly one action per line, but some lines combine array creation and multiple element initializations. Reading flow is natural, progressing from simple properties to complex serialization logic. Overall, the code is approachable for a developer familiar with the domain, with only minor verbosity in arrays and method calls preventing a perfect score.

Run 3

The code is well-structured and highly readable. It follows a logical class organization with clear method separation and consistent Javadoc comments for public methods, aiding comprehension. Nesting is minimal, with only one if-else block in renderObject and writeToFile, keeping the logic flat and easy to follow. Intent is unambiguous: each method has a single, obvious responsibility (e.g., duplicate, getBounds, renderObject). Code length is appropriate—not overly verbose, with concise expressions for calculations. Action granularity is mostly one action per line, though a few lines (e.g., array initializations, renderImage call) pack multiple values but still remain readable. Reading flow is natural, progressing from constructors to simple getters/setters, then to more complex methods. Minor deductions for slightly dense lines like the Vec3 array declaration and lack of comments on non-public methods, but overall the code is clear, maintainable, and easy to understand.

Run 1

Code Structure: Well-organized class with small, focused methods for geometry, rendering, copying, and serialization. Nesting: Minimal, with simple conditionals and only one shallow conversion block. Clarity of intent: Descriptive method names and useful documentation explain the object's purpose; abbreviated locals, unexplained numeric constants, empty overrides, and an empty exception message reduce clarity slightly. Code length: Generally concise, though repeated corner-coordinate calculations add duplication. Action granularity: Most lines perform one action, but array initializers and rendering calls pack several vector constructions together. Reading flow: Consistent formatting and straightforward control flow make the code easy to follow; long expressions, wildcard imports, and omitted braces on simple conditionals introduce minor friction.

Run 2

Code Structure: Well organized into short, focused methods covering image access, geometry, rendering, and serialization, though constructors are separated. Nesting: Very shallow, with straightforward conditionals and no complex loops. Clarity of intent: Class documentation and descriptive method names clearly establish purpose; abbreviated locals, unexplained numeric constants, and an empty exception message reduce clarity slightly. Code length: Mostly concise, with some repetitive corner-coordinate construction and generous whitespace. Action granularity: Statements generally perform one action per line, although dense array initializers and long rendering arguments require extra parsing. Reading flow: Consistent formatting and simple sequential logic make the code easy to follow; wildcard imports, older array declaration syntax, and omitted braces on conditionals slightly weaken readability.

Run 3

Code Structure: Well-organized class with small, focused methods separating image access, geometry, rendering, and persistence. Nesting: Minimal nesting; conditionals are simple and easy to follow. Clarity of intent: Descriptive method names and helpful documentation establish the purpose, though abbreviated variables, unexplained scaling constants, and an empty exception message reduce clarity. Code length: Mostly concise without unnecessary complexity; repeated rectangle-coordinate calculations add minor duplication. Action granularity: Statements generally perform one action per line, although dense vertex initializers and long rendering arguments require extra parsing. Reading flow: Consistent formatting and straightforward sequential logic support natural reading, but wildcard imports, omitted conditional braces, and placing the deserialization constructor near the end slightly weaken navigation and consistency.