Sample

Schnappinger/aoi/artofillusion.spmanager.SPMTranslate

Human rating uses the original dataset scale.

Human2.9
Lines514

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
37.5Δ 16.7
Scalabrino0.8890–1; higher is more readable
86.0Δ 65.2
Dorn0.0010–1; higher is more readable
11.9Δ 8.9
Mi0.5890–1; higher is more readable
58.4Δ 37.6
LLOC107Logical lines; fewer is more readable
22.8Δ 2.0
DeepSeek V4 Pro130–20; mean of three runs
21.1Δ 0.3
GPT-6.1 Sol140–20; mean of three runs
16.2Δ 4.6
BTTF0.4120–1; higher is more readable
36.0Δ 15.2
Human2.91–4; original rating
20.8

Views

Source code

/* * Copyright (C) 2003 by Francois Guillet * Copyright (C) 2003 by Peter Eastman for original Translate.java code * 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.spmanager; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.text.*; import java.util.*; import java.util.zip.*; import buoy.event.*; import buoy.widget.*; //import artofillusion.ui.*; import artofillusion.*; import java.io.*; /** * This class extends AoI Translate Class so that i) the spmanager properties * file is used instead of AoI properties file ii) buoy objects are returned * *@author pims *@created 27 mai 2004 */ public class SPMTranslate { private static Locale locale = Locale.getDefault(); private static ResourceBundle resources; /** * Set the locale to be used for generating text. * *@param l The new locale value */ public static void setLocale( Locale l ) { locale = l; /* File dir = new File( ModellingApp.PLUGIN_DIRECTORY ); if ( dir.exists() ) { String[] files = dir.list(); for ( int i = 0; i < files.length; i++ ) if ( files[i].startsWith( "SPManager" ) ) { ZipFile zf = null; try { zf = new ZipFile( new File( ModellingApp.PLUGIN_DIRECTORY, files[i] ) ); } catch ( IOException ex ) { continue; // Not a zip file. } if ( zf != null ) { JarClassLoader jcl = new JarClassLoader( zf ); resources = ResourceBundle.getBundle( "spmanager", locale, jcl ); } } } else { System.out.println( "Dir does not exist" ); }*/ resources = ResourceBundle.getBundle("spmanager", locale); } /** * Get the locale currently used for generating text. * *@return The locale value */ public static Locale getLocale() { return locale; } /** * Get a Menu whose text is given by the property "menu.(name)". * *@param name Description of the Parameter *@return Description of the Return Value */ public static BMenu bMenu( String name ) { try { return new BMenu( resources.getString( "menu." + name ) ); } catch ( MissingResourceException ex ) { return new BMenu( name ); } } /** * Get a BMenuItem whose text is given by the property "menu.(name)". This * checks for a property called "menu.shortcut.(name)", and if it is found, * sets the menu shortcut accordingly. No event link is added. * *@param name Description of the Parameter *@return Description of the Return Value */ public static BMenuItem bMenuItem( String name ) { return bMenuItem( name, null, null, null ); } /** * Description of the Method * *@param name Description of the Parameter *@param target Description of the Parameter *@param method Description of the Parameter *@return Description of the Return Value */ public static BMenuItem bMenuItem( String name, java.lang.Object target, String method ) { return bMenuItem( name, CommandEvent.class, target, method ); } /** * Description of the Method * *@param name Description of the Parameter *@param eventType Description of the Parameter *@param target Description of the Parameter *@param method Description of the Parameter *@return Description of the Return Value */ public static BMenuItem bMenuItem( String name, java.lang.Class eventType, java.lang.Object target, String method ) { String command = name; BMenuItem item = null; try { command = resources.getString( "menu." + name ); String shortcut = resources.getString( "menu." + name + ".shortcut" ); if ( shortcut.length() > 1 && shortcut.charAt( 0 ) == '^' ) item = new BMenuItem( command, new Shortcut( shortcut.charAt( 1 ), Shortcut.SHIFT_MASK | Shortcut.DEFAULT_MASK ) ); else if ( shortcut.length() > 0 ) item = new BMenuItem( command, new Shortcut( shortcut.charAt( 0 ) ) ); } catch ( MissingResourceException ex ) { item = new BMenuItem( command ); } if ( eventType != null ) item.addEventLink( eventType, target, method ); return item; } /** * Get a BCheckboxMenuItem whose text is given by the property * "checkbox.(name)". State specifies the initial state of the item. * *@param name Description of the Parameter *@param state Description of the Parameter *@return Description of the Return Value */ public static BCheckBoxMenuItem bCheckBoxMenuItem( String name, boolean state ) { String command = name; try { command = resources.getString( "menu." + name ); } catch ( MissingResourceException ex ) { } BCheckBoxMenuItem item = new BCheckBoxMenuItem( command, state ); return item; } /** * Get a BButton whose text is given by the property "button.(name)". * *@param name Description of the Parameter *@return Description of the Return Value */ public static BButton bButton( String name ) { return bButton( name, null, null, null ); } /** * Description of the Method * *@param name Description of the Parameter *@param target Description of the Parameter *@param method Description of the Parameter *@return Description of the Return Value */ public static BButton bButton( String name, java.lang.Object target, String method ) { return bButton( name, CommandEvent.class, target, method ); } /** * Description of the Method * *@param name Description of the Parameter *@param eventType Description of the Parameter *@param target Description of the Parameter *@param method Description of the Parameter *@return Description of the Return Value */ public static BButton bButton( String name, java.lang.Class eventType, Object target, String method ) { String command = name; try { command = resources.getString( "button." + name ); } catch ( MissingResourceException ex ) { } BButton button = new BButton( command ); if ( eventType != null ) button.addEventLink( eventType, target, method ); return button; } /** * Get a BRadioButton whose text is given by the property "radio.(name)". * group is the RadioButtonGroup the radio button created button will * belong to. * *@param name Description of the Parameter *@param state Description of the Parameter *@param group Description of the Parameter *@return Description of the Return Value */ public static BRadioButton bRadioButton( String name, boolean state, RadioButtonGroup group ) { return bRadioButton( name, state, group, null, null ); } /** * Description of the Method * *@param name Description of the Parameter *@param state Description of the Parameter *@param group Description of the Parameter *@param target Description of the Parameter *@param method Description of the Parameter *@return Description of the Return Value */ public static BRadioButton bRadioButton( String name, boolean state, RadioButtonGroup group, Object target, String method ) { String command = name; try { command = resources.getString( "radio." + name ); } catch ( MissingResourceException ex ) { } BRadioButton radio = new BRadioButton( command, state, group ); //radio.setText(command); //radio.setState(state); if ( target != null ) group.addEventLink( SelectionChangedEvent.class, target, method ); return radio; } /** * These functions are for compatibility with the AWT preview window * *@param name Description of the Parameter *@param listener Description of the Parameter *@return Description of the Return Value */ public static Button button( String name, ActionListener listener ) { return button( name, null, listener ); } /** * These functions are for compatibility with the AWT preview window * *@param name Description of the Parameter *@param suffix Description of the Parameter *@param listener Description of the Parameter *@return Description of the Return Value */ public static Button button( String name, String suffix, ActionListener listener ) { String command = name; try { command = resources.getString( "button." + name ); } catch ( MissingResourceException ex ) { } if ( suffix != null ) command += suffix; Button b = new Button( command ); if ( listener != null ) { b.setActionCommand( name ); b.addActionListener( listener ); } return b; } /** * returns a BCheckBox whose label is given by the property * "checkbox.name". state is the initial state of the checkbox * *@param name Description of the Parameter *@param state Description of the Parameter *@return Description of the Return Value */ public static BCheckBox bCheckBox( String name, boolean state ) { return bCheckBox( name, state, null, null ); } /** * Description of the Method * *@param name Description of the Parameter *@param state Description of the Parameter *@param target Description of the Parameter *@param method Description of the Parameter *@return Description of the Return Value */ public static BCheckBox bCheckBox( String name, boolean state, Object target, String method ) { String command = name; try { command = resources.getString( "checkbox." + name ); } catch ( MissingResourceException ex ) { } BCheckBox b = new BCheckBox( command, state ); if ( target != null ) b.addEventLink( ValueChangedEvent.class, target, method ); return b; } /** * Get a Label whose text is given by the property "label.name". If the * property is not found, this simply uses name. * *@param name Description of the Parameter *@return Description of the Return Value */ public static BLabel bLabel( String name ) { return bLabel( name, null ); } /** * Description of the Method * *@param name Description of the Parameter *@param args Description of the Parameter *@return Description of the Return Value */ public static BLabel bLabel( String name, Object[] args ) { try { name = resources.getString( "label." + name ); } catch ( MissingResourceException ex ) { } if ( args != null ) { return new BLabel( MessageFormat.format( name, args ) ); } return new BLabel( name ); } /** * Get the text given by the property "name". If the property is not found, * this simply returns name. * *@param name Description of the Parameter *@return Description of the Return Value */ public static String text( String name ) { try { return resources.getString( "text." + name ); } catch ( MissingResourceException ex ) { return name; } } /** * Get the text given by the property "name". If the property is not found, * this simply uses name. Any occurrance of the pattern "{0}" in the text * string will be replaced with the string representation of arg1. * *@param name Description of the Parameter *@param arg1 Description of the Parameter *@return Description of the Return Value */ public static String text( String name, Object arg1 ) { String pattern = name; try { pattern = resources.getString( "text." + name ); } catch ( MissingResourceException ex ) { } return MessageFormat.format( pattern, new Object[]{arg1} ); } /** * Get the text given by the property "name". If the property is not found, * this simply uses name. Any occurrances of the patterns "{0}" and "{1}" * in the text string will be replaced with the strings representations of * arg1 and arg2, respectively. * *@param name Description of the Parameter *@param arg1 Description of the Parameter *@param arg2 Description of the Parameter *@return Description of the Return Value */ public static String text( String name, Object arg1, Object arg2 ) { String pattern = name; try { pattern = resources.getString( "text." + name ); } catch ( MissingResourceException ex ) { } return MessageFormat.format( pattern, new Object[]{arg1, arg2} ); } /** * Get the text given by the property "name". If the property is not found, * this simply uses name. That string and the args array are then passed to * MessageFormat.format() so that any variable fields can be replaced with * the correct values. * *@param name Description of the Parameter *@param args Description of the Parameter *@return Description of the Return Value */ public static String text( String name, Object args[] ) { String pattern = name; try { pattern = resources.getString( "text." + name ); } catch ( MissingResourceException ex ) { } return MessageFormat.format( pattern, args ); } }

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.8386.192−276.744
Source linesThe number of non-empty source lines.514+205.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.4.334−6.501

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

Score0.889

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.515−17.198
Indentation frequencyHow rapidly indentation changes from line to line.314+10.124
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.314−6.784
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.513.841+6.773
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.130.965−1.882
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.130.983+1.309
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.04+0.557

Intercept 0.07 + feature contributions = -7.032 (log-odds).
Score = sigmoid(-7.032) = 0.001.

Score0.589
Score107
Run 1

The code is moderately readable. Its structure is mostly logical, with clear method grouping and consistent Javadoc. However, many methods share a repetitive try/catch pattern for resource lookup, and the empty catch blocks are a significant clarity issue. Nesting is shallow, which is good, but the ‘bMenuItem’ method is longer and contains more conditional nesting than the rest. Intent is generally clear from method names, but some descriptions are vague (‘Description of the Method’). Large blocks of commented-out code and unused imports add noise. Length is reasonable overall, though the repetition could be reduced through a helper method. Action granularity is mostly one action per line, aiding readability. Reading flow is natural, following a predictable pattern of overloaded methods and resource lookup.

Run 2

The code has a clear, consistent structure and follows a repetitive pattern for localization, making intent reasonably clear. Nesting is mostly flat (only one level of try/catch), and each method performs a single action. However, readability is hindered by several issues: large blocks of commented-out code remain in setLocale(), the method overloads are very repetitive (especially bMenuItem/bButton/bRadioButton), and exception handling uses empty catch blocks that silently swallow missing resources. Imports include unused ones, and the Javadocs are generic placeholders like 'Description of the Method'. Finally, the code length is unnecessarily long due to duplicated logic, reducing overall readability.

Run 3

The code has a clear overall purpose (localization wrapper) and follows a consistent, repetitive pattern, but readability is hampered by several issues. Structure is logical but methods are very repetitive, inflating length. Nesting is mostly shallow, which is good, but the large commented-out block in setLocale adds clutter. Clarity of intent is mixed: method names are descriptive, but Javadoc comments are largely placeholder-style ('Description of the Method') and provide little value. Action granularity is generally fine, with one main operation per line, though some methods pack multiple concerns (resource lookup, fallback, event linking). Reading flow is natural but disrupted by excessive boilerplate and unused imports. The repeated try/catch with empty catch blocks obscures the fallback logic. Overall, it is understandable but verbose and inconsistently documented.

Run 1

Code Structure: Methods are logically grouped by widget type, with overloads delegating to shared implementations, but localization lookup logic is repeatedly duplicated. Nesting: Active code remains shallow, mostly using simple try/catch blocks and conditionals. Clarity of intent: Method names and resource prefixes communicate the localization purpose, but placeholder Javadoc, inaccurate comments, empty catch blocks, and implicit resource initialization reduce clarity. Code length: Small methods are individually concise, yet repetitive documentation, excessive whitespace, duplicated fallback handling, and a large commented-out implementation unnecessarily inflate the class. Action granularity: Statements generally perform one action per line; some shortcut constructors are lengthy but understandable. Reading flow: Consistent method patterns make the class predictable to scan, while wildcard imports, inconsistent qualification and brace usage, obsolete comments, and the mixture of Buoy and AWT helpers introduce distractions.

Run 2

1. Code Structure: Methods are logically grouped by widget type, with overloads delegating to shared implementations; repeated resource-lookup logic could be centralized. 2. Nesting: Active code is mostly flat, using shallow try/catch blocks and simple conditionals. 3. Clarity of intent: Method names and resource prefixes communicate localization and widget creation, but placeholder documentation, inaccurate comments, empty catches, and unclear initialization requirements weaken clarity. 4. Code length: Individual methods are short, but duplicated lookup logic, verbose boilerplate documentation, unused imports, and a large commented-out block unnecessarily inflate the class. 5. Action granularity: Statements generally perform one action per line, though some constructor expressions are lengthy. 6. Reading flow: Consistent formatting and predictable lookup/create/register/return sequences make the code easy to follow. Dead code, inconsistent naming, and unbraced conditionals interrupt that flow.

Run 3

Code Structure: Methods are logically grouped by widget type, with straightforward overload delegation, but repeated resource lookup logic could be centralized. Nesting: Active code is mostly shallow, with simple conditionals and try/catch blocks. Clarity of intent: Descriptive method names make localization and widget creation understandable, but placeholder Javadocs, inaccurate property-key descriptions, and empty catch blocks weaken clarity. Code length: The class is unnecessarily long due to duplicated lookup patterns, verbose boilerplate documentation, excessive whitespace, and a large commented-out implementation. Action granularity: Most statements perform one action per line, although shortcut construction expressions are somewhat dense. Reading flow: Consistent formatting and predictable lookup-create-link-return sequences aid scanning; commented-out code, wildcard imports, inconsistent naming, and mixed AWT/Buoy APIs interrupt the flow.