Skip to main content
Engineering LibreTexts

11.7: More on Colors

  • Page ID
    45936
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Colors are pretty useful to designate a property (e.g., gray if the class is abstract). They may also be employed to represent a continuous distribution. For example, the color intensity may indicate the result of a metric. Consider the previous script in which the node color intensity conveys the number of lines of code:

    view interaction action: #browse.
    view shape rectangle
        width: [ :each | each instVarNames size * 3 ];
        height: [ :each | each methods size ];
        linearFillColor: #numberOfLinesOfCode within: Collection withAllSubclasses.
    view nodes: Collection withAllSubclasses.
    view edgesFrom: #superclass.
    view treeLayout.
    

    Figure \(\PageIndex{1}\) shows the resulting picture. The message linearFillColor:within: takes as first argument a block function that return a numerical value. The second argument is a group of elements that is used to scale the intensity of each node. The block function is applied to each element of the group. The fading scales from white (0 line of code) to black (the maximum lines of code). The maximum intensity is given by the maximum #numberOfLinesOfCode for all the subclasses of Collection. Variants of linearFillColor:within: are linearXXXFillColor:within:, where XXX is one among Blue, Green, Red, Yellow.

    The visualization named ’System complexity’ (from Polymetric Views— A Lightweight Visual Approach to Reverse Engineering’ (Transactions on Software Engineering, 2003) shows for each class the number of methods, the number of instance variables and the number of lines of code. Differences in size between classes might suggest some maintenance activities.

    The system complexity visualization.
    Figure \(\PageIndex{1}\): The system complexity visualization: nodes are classes; height is the number of lines of methods; width the number of variables; color conveys about the number of lines of code.

    A color may be assigned to an object identity using identityFillColorOf:. The argument is either a block or a symbol, evaluated against the domain object. A color is associated with the result of the argument.


    This page titled 11.7: More on Colors is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Alexandre Bergel, Damien Cassou, Stéphane Ducasse, Jannik Laval (Square Bracket Associates) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.