Sample

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

Human rating uses the original dataset scale.

Human3
Lines137

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
49.8Δ 21.4
Scalabrino0.4730–1; higher is more readable
7.2Δ 21.2
Dorn0.4120–1; higher is more readable
55.8Δ 27.4
Mi0.5620–1; higher is more readable
46.5Δ 18.2
LLOC29Logical lines; fewer is more readable
50.0Δ 21.6
DeepSeek V4 Pro15.330–20; mean of three runs
41.3Δ 12.9
GPT-6.1 Sol160–20; mean of three runs
38.9Δ 10.6
BTTF0.5680–1; higher is more readable
52.8Δ 24.4
Human31–4; original rating
28.4

Views

Source code

/* $Id: UMLTreeCellRenderer.java 17881 2010-01-12 21:09:28Z linus $ ***************************************************************************** * 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-2008 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.Component; import javax.swing.Icon; import javax.swing.JLabel; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import org.argouml.application.helpers.ResourceLoaderWrapper; import org.argouml.i18n.Translator; import org.argouml.model.Model; import org.argouml.uml.diagram.ui.UMLDiagram; /** * UMTreeCellRenderer determines how the entries in the Explorerpane * and ToDoList will be represented graphically.<p> * * In particular it makes decisions about the icons to use, * in order to display an Explorerpane artifact depending on the kind * of object to be displayed.<p> * * This class must be efficient as it is called many 1000's of times. */ public class UMLTreeCellRenderer extends DefaultTreeCellRenderer { // get localised strings once only private static String name = Translator.localize("label.name"); private static String typeName = Translator.localize("label.type"); //////////////////////////////////////////////////////////////// // TreeCellRenderer implementation /* * @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent( * javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, * boolean) */ @Override public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocusParam) { if (value instanceof DefaultMutableTreeNode) { value = ((DefaultMutableTreeNode) value).getUserObject(); } Component r = super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocusParam); if (value != null && r instanceof JLabel) { JLabel lab = (JLabel) r; // setting the icon Icon icon = ResourceLoaderWrapper.getInstance().lookupIcon(value); if (icon != null) { lab.setIcon(icon); } // setting the tooltip to type and name String type = null; if (Model.getFacade().isAModelElement(value)) { type = Model.getFacade().getUMLClassName(value); } else if (value instanceof UMLDiagram) { type = ((UMLDiagram) value).getLabelName(); } if (type != null) { StringBuffer buf = new StringBuffer(); buf.append("<html>"); buf.append(name); buf.append(' '); buf.append(lab.getText()); buf.append("<br>"); buf.append(typeName); buf.append(' '); buf.append(type); lab.setToolTipText(buf.toString()); } else { lab.setToolTipText(lab.getText()); } } return r; } }

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.2622.278−86.535
Source linesThe number of non-empty source lines.137+54.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.962−7.444

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

Score0.473

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.138−3.85
Indentation frequencyHow rapidly indentation changes from line to line.84+2.168
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.84−1.507
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.136.938+1.504
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.042+0.537
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.77.167+0.441
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.79.964+0.278

Intercept 0.07 + feature contributions = -0.358 (log-odds).
Score = sigmoid(-0.358) = 0.412.

Score0.562
Score29
Run 1

The code is well-structured and readable overall. It follows standard Java conventions, has a clear class purpose documented in Javadoc, and uses meaningful variable names (e.g., 'lab', 'type', 'buf'). The method body is mostly flat with only two nesting levels, and the action granularity is appropriate—one primary action per line. The reading flow is logical: extract user object, delegate to super, then handle icon and tooltip. Minor deductions: the copyright header is verbose and adds visual noise before the code, the mixed use of StringBuffer (when StringBuilder would suffice) is slightly dated, and the conditional chain for setting 'type' could be simplified. Additionally, the superclass call has many parameters that create moderate line-length pressure. Overall, clarity of intent is strong, structure is clean, and nesting is minimal compared to typical Swing renderer implementations.

Run 2

The code is generally well-structured and readable. It has clear organization, moderate nesting (only two levels deep), and good clarity of intent via descriptive variable names like 'lab', 'icon', and 'type'. The method performs a focused single responsibility (rendering a tree cell). However, there are minor readability issues: the initial 'if(value instanceof DefaultMutableTreeNode)' block lacks braces, which can be error-prone, and the string building for the tooltip using StringBuffer is verbose for modern Java. The code length is reasonable, and action granularity is mostly one action per line. Reading flow is natural despite the long license header. Overall, it is maintainable but could be slightly improved with consistent brace usage and using StringBuilder or String.format for tooltip construction.

Run 3

The code is generally clear and well-structured. It has a single method with a logical, sequential flow: unwrap node, call super, set icon, and set tooltip. Nesting is moderate - the main `if (value != null && r instanceof JLabel)` block contains the bulk of the logic, with one secondary else-if inside, which is acceptable. Intent is clear from method and variable names (`lab`, `type`, `icon`) plus comments. However, the tooltip construction section is somewhat verbose: the `StringBuffer` append sequence could be more concise, and separating string building into a helper method would improve readability. The initial node unwrapping and super call are concise, one action per line. The long license header, while not directly affecting method readability, adds noise. Overall, the code is readable but the tooltip building drags it down slightly.

Run 1

Code Structure: The class is logically organized, with a single rendering method that unwraps the node, delegates rendering, and configures the icon and tooltip. Nesting: Conditional depth is moderate; the outer guard contains several branches but remains manageable. Clarity of intent: Documentation, API names, and comments make the purpose clear, though abbreviated variables such as r, lab, and buf reduce clarity. Code length: The implementation is reasonably concise, but verbose tooltip construction and extensive license boilerplate increase reading overhead. Action granularity: Statements generally perform one action per line, making changes easy to follow. Reading flow: Processing follows a natural sequence and ends with a straightforward return; inconsistent indentation and heavily wrapped calls slightly interrupt the flow.

Run 2

Code Structure: A single focused renderer method follows logical stages: unwrap the node, delegate rendering, customize the icon, and set the tooltip. Nesting: Conditional nesting is moderate and easy to follow, although the outer customization guard encloses most logic. Clarity of intent: Class documentation and comments explain the purpose well; abbreviated names such as r, lab, and sel reduce clarity slightly. Code length: Implementation is reasonably concise, but repetitive buffer appends and extensive license headers add visual bulk. Action granularity: Statements generally perform one action per line, making changes easy to inspect. Reading flow: Execution proceeds naturally from obtaining the component to customizing and returning it; inconsistent tab/space indentation and heavily wrapped method arguments mildly interrupt the flow.

Run 3

Code Structure: A single focused renderer method logically separates node unwrapping, default rendering, icon selection, and tooltip construction. Nesting: Moderate nesting remains manageable, although the outer conditional encloses several branches. Clarity of intent: Class documentation and comments explain the rendering purpose; abbreviated names such as r, lab, and buf reduce clarity. Code length: Implementation is reasonably concise, but lengthy license headers and repetitive buffer appends add visual bulk. Action granularity: Statements generally perform one action per line, making individual operations easy to inspect. Reading flow: Execution follows a natural sequence and returns the rendered component at the end; inconsistent indentation and heavily wrapped method calls slightly disrupt scanning.