Sample

Schnappinger/argoUML/org.argouml.uml.ui.UMLComboBox2

Human rating uses the original dataset scale.

Human3.42
Lines217

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
41.8Δ 3.9
Scalabrino0.8120–1; higher is more readable
65.4Δ 27.5
Dorn0.0970–1; higher is more readable
32.7Δ 5.3
Mi0.5680–1; higher is more readable
50.8Δ 12.9
LLOC56Logical lines; fewer is more readable
37.3Δ 0.7
DeepSeek V4 Pro14.670–20; mean of three runs
34.8Δ 3.1
GPT-6.1 Sol15.330–20; mean of three runs
30.7Δ 7.3
BTTF0.4110–1; higher is more readable
35.6Δ 2.3
Human3.421–4; original rating
38.0

Views

Source code

/* $Id: UMLComboBox2.java 19630 2011-08-05 07:59:26Z bobtarling $ ***************************************************************************** * Copyright (c) 2009 Contributors - see below * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * tfmorris ***************************************************************************** * * Some portions of this file was previously release using the BSD License: */ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this // software and its documentation without fee, and without a written // agreement is hereby granted, provided that the above copyright notice // and this paragraph appear in all copies. This software program and // documentation are copyrighted by The Regents of the University of // California. The software program and documentation are supplied "AS // IS", without any accompanying services from The Regents. The Regents // does not warrant that the operation of the program will be // uninterrupted or error-free. The end-user understands that the program // was developed for research purposes and is advised not to rely // exclusively on the program for any reason. IN NO EVENT SHALL THE // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. package org.argouml.uml.ui; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import javax.swing.Action; import javax.swing.ComboBoxModel; import javax.swing.JComboBox; import javax.swing.ListCellRenderer; import org.argouml.ui.LookAndFeelMgr; import org.argouml.ui.targetmanager.TargetEvent; import org.argouml.ui.targetmanager.TargetListener; import org.argouml.ui.targetmanager.TargettableModelView; /** * ComboBox for selecting UML Elements. * @deprecated in 0.31.5 by Bob Tarling. Property panel controls are now * internal to the property panel component */ @Deprecated public class UMLComboBox2 extends JComboBox implements TargettableModelView, TargetListener, JComboBox.KeySelectionManager { private static final int KEY_TIME_THRESHOLD_MILLIS = 1500; private String searchString = ""; private long lastKeyEventTime; /** * Constructor for UMLComboBox2. * @deprecated As of ArgoUml version unknown (before 0.13.5), * replaced by {@link #UMLComboBox2(UMLComboBoxModel2, Action, boolean)} * @param model the ComboBoxModel */ @Deprecated UMLComboBox2(UMLComboBoxModel2 model) { super(model); setFont(LookAndFeelMgr.getInstance().getStandardFont()); addActionListener(this); addPopupMenuListener(model); } /** * Construct a UMLComboBox2. * * @param model a UMLComboBoxModel2 which provides UML elements for the user * to choose from * @param action action to invoke when an item is selected * @param showIcon true if an icon should be shown in front of the items */ public UMLComboBox2(UMLComboBoxModel2 model, Action action, boolean showIcon) { super(model); setFont(LookAndFeelMgr.getInstance().getStandardFont()); lastKeyEventTime = 0; addActionListener(action); // setDoubleBuffered(true); setKeySelectionManager(this); setRenderer(new UMLListCellRenderer2(showIcon)); addPopupMenuListener(model); } /* * @see java.awt.event.ActionListener#actionPerformed(ActionEvent) */ @Override public void actionPerformed(ActionEvent arg0) { int i = getSelectedIndex(); if (i >= 0) { doIt(arg0); } } /** * Implementation of the JComboBox.KeySelectionManager interface. Helps with * navigating through the ComboBox when using the keyboard. * * @param key The key which has been pressed * @param model Current ComboBoxModel * @return int The index of the item that is to be selected * @see javax.swing.JComboBox.KeySelectionManager#selectionForKey(char, javax.swing.ComboBoxModel) */ public int selectionForKey(char key, ComboBoxModel model) { long now = System.currentTimeMillis(); int index = -1; int startAtIndex = 0; // Implements backspace functionality if (searchString != null && key == KeyEvent.VK_BACK_SPACE && searchString.length() > 0) { searchString = searchString.substring(0, searchString.length() - 1); } else { if (lastKeyEventTime + KEY_TIME_THRESHOLD_MILLIS < now) { searchString = Character.toString(key); } else { searchString = searchString + key; startAtIndex = getSelectedIndex(); if (startAtIndex < 0) { startAtIndex = 0; } } } String umlElemName = ""; String searchStringLowerCase = searchString.toLowerCase(); ListCellRenderer cellRenderer = getRenderer(); for (int i = startAtIndex, length = model.getSize(); i < length; i++) { Object value = model.getElementAt(i); if (cellRenderer instanceof UMLListCellRenderer2) { umlElemName = ((UMLListCellRenderer2) cellRenderer).makeText(value); } else { umlElemName = value.toString(); } if (umlElemName.toLowerCase().startsWith(searchStringLowerCase)) { index = i; break; } } lastKeyEventTime = now; return index; } /** * The 'body' of the actionPerformed method. Is only called if there is * actually a selection made. * * @param event the event */ protected void doIt(@SuppressWarnings("unused") ActionEvent event) { } /** * Utility method to get the current target. * * @return Object */ public Object getTarget() { return ((UMLComboBoxModel2) getModel()).getTarget(); } /* * @see org.argouml.ui.targetmanager.TargettableModelView#getTargettableModel() */ public TargetListener getTargettableModel() { return (TargetListener) getModel(); } /* * @see org.argouml.ui.targetmanager.TargetListener#targetAdded(org.argouml.ui.targetmanager.TargetEvent) */ public void targetAdded(TargetEvent e) { if (e.getNewTarget() != getTarget()) { removeActionListener(this); } } /* * @see org.argouml.ui.targetmanager.TargetListener#targetRemoved(org.argouml.ui.targetmanager.TargetEvent) */ public void targetRemoved(TargetEvent e) { removeActionListener(this); } /* * @see org.argouml.ui.targetmanager.TargetListener#targetSet(org.argouml.ui.targetmanager.TargetEvent) */ public void targetSet(TargetEvent e) { addActionListener(this); } }

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.4165.539−137.463
Source linesThe number of non-empty source lines.217+86.8
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.952−7.428

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

Score0.812

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.218−6.682
Indentation frequencyHow rapidly indentation changes from line to line.137+4.002
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.137−2.723
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.216.857+2.621
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.110.945−1.034
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.110.972+0.986
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.043+0.525

Intercept 0.07 + feature contributions = -2.235 (log-odds).
Score = sigmoid(-2.235) = 0.097.

Score0.568
Score56
Run 1

The code is generally readable but has some issues. Structure is logical with clear method separation, but the long license header and deprecated constructs add clutter. Nesting is acceptable, with only one level in the key selection loop. Intent is mostly clear via Javadoc, though some methods like 'doIt' are vague. Code length is reasonable; the main method is somewhat long but not bloated. Action granularity is mixed - some lines combine multiple operations. Reading flow is decent but could be improved with more consistent formatting and line breaks. Overall, it is maintainable but not exemplary.

Run 2

The code is generally well-structured and readable. It is organized into clear sections (constructors, action listener, key selection manager, target listener methods) with Javadoc comments explaining purpose. Nesting is minimal; the `selectionForKey` method has one `if-else` block and a `for` loop, but the logic remains reasonably flat. Intent is mostly clear, especially for deprecated constructors and the keyboard navigation logic. However, the `selectionForKey` method is somewhat long and mixes concerns: building the search string, iterating through the model, and rendering cell text. This reduces clarity slightly. Action granularity is good, with one main operation per line. Reading flow is natural, though the method signature formatting with the `implements` clause is a bit awkward. Overall, it is maintainable code with only minor issues regarding method length and focus.

Run 3

The code is moderately readable. It has clear class structure and Javadoc comments, but suffers from long legacy license headers that obscure the actual code. The class implements too many interfaces and mixes concerns (view, listener, key manager). Nesting is mostly shallow. The 'selectionForKey' method is the weakest part: it has multiple responsibilities, multiple local variables with non-descriptive names (e.g., 'index', 'now'), and an awkward if-else structure. The 'targetAdded' method contains logic that is not obvious (removing action listener conditionally). Several methods are deprecated but still heavily documented, adding noise. Action granularity is acceptable but inconsistent. Overall the intention is understandable, but clarity is reduced by deprecated superclass responsibilities and legacy boilerplate.

Run 1

Code Structure: Well-organized class with focused constructors, keyboard selection logic, and target-event handlers; constructor setup is slightly duplicated. Nesting: Mostly shallow, though selectionForKey contains nested conditionals that could be flattened. Clarity of intent: Descriptive method names, a named timeout constant, and useful documentation explain the purpose; doIt, arg0, and implicit listener-management behavior are less clear. Code length: Most methods are concise, but extensive boilerplate comments and some redundant initialization add visual bulk. Action granularity: Generally one action per line, with only conventional loop initialization combining declarations. Reading flow: Methods follow a sensible sequence and the keyboard-search algorithm is understandable, but inconsistent brace placement, indentation, legacy raw types, and a commented-out statement interrupt an otherwise natural flow.

Run 2

Code Structure: Constructors, keyboard selection, and target-listener methods are logically separated, although the class combines several responsibilities. Nesting: Generally shallow, with moderately nested conditionals in selectionForKey that could be flattened. Clarity of intent: Documentation, descriptive field names, and the timeout constant explain the main purpose; doIt, arg0, and implicit listener-management behavior are less clear. Code length: Most methods are concise, but extensive boilerplate comments, duplicated constructor setup, and a commented-out statement add clutter. Action granularity: Statements generally perform one action per line; the loop initializer combines two declarations but remains understandable. Reading flow: Method ordering and straightforward control flow support reading, while inconsistent indentation, brace placement, raw types, and repeated casts create minor friction.

Run 3

Code Structure: Fields, constructors, keyboard selection, and target-listener methods are logically grouped, though the class combines several responsibilities. Nesting: Mostly shallow; keyboard-search handling reaches moderate nesting and could be flattened. Clarity of intent: Descriptive identifiers, a named timeout constant, and documentation explain the main purpose, but doIt, arg0, and listener-registration behavior are less explicit. Code length: Implementation is reasonably compact, although extensive headers, repetitive documentation, and a commented-out statement add visual bulk. Action granularity: Statements generally perform one action per line; the loop initializer is slightly denser. Reading flow: Methods follow a sensible sequence, but inconsistent indentation and brace placement, raw types, casts, and mixing search-state updates with item matching interrupt otherwise straightforward reading.