color-chooser_2009


Information

Created with NetLogo version NetLogo 4.0.4
Running with NetLogoLite.jar version 404.


WHAT IS IT?


This is a demonstration of several ways to present options in a chooser that are not the final values that will be used, but rather, more user-friendly.

METHOD ONE


The values in the chooser are also present in a global (or whatever) list. The list is searched for the value in the chooser, to discover the index. The index is used to look up the actual value in a second list.

Concerns:


Requires chooser values to be kept in two places: the code and the searched list. If new options are added to the chooser, one must remember to add the option to the list, and the lookup value to the lookup list.

Advantages:


While the list of choices must be a literal list, the list of actual values can include calculated and dynamic values.

METHOD TWO


The chooser items are literal lists, containing a human readable label, and another value, the actual use value. To get the value one uses LAST chooser.

Concerns:


The conversion value must be a literal value, and both the "human readable" label AND the real value will appear in the chooser. Clutter in the chooser may confuse the user.

Advantages:


Extremely concise.

METHOD THREE


The value is the chooser is the full or partial name of a reporter that returns the desired value.

Procedures

NetLogo Version: NetLogo 4.0.4

globals[ old-1 old-2 old-3 ]

to-report get-method-1
   let cnames  (list "brick" "red" "blue" "orange" "yellow" "lemon" "midnight")
   let cvalues (list  (red - 2) red   blue orange   yellow  (yellow + 2) (violet - 2) )
   report item (position method-1 cnames) cvalues
end

to-report get-method-2
   report last method-2
end
      
to-report get-method-3
   report run-result method-3
end

to-report dark-green report green - 2 end
to-report medium-green report green end
to-report light-green report green + 2 end

to-report update-view
   if get-method-1 != old-1 [ set old-1 fill get-method-1 1 tick report old-1 ]
   if get-method-2 != old-2 [ set old-2 fill get-method-2 2 tick report old-2 ]
   if get-method-3 != old-3 [ set old-3 fill get-method-3 3 tick report old-3 ]
   report "..."
end
  
to-report fill [ #color #section ]
   let band-start min-pxcor + (world-width / 3) * (#section - 1)
   let band-end   min-pxcor + (world-width / 3) * (#section    ) - 1
   ask patches with [ pxcor >= band-start and pxcor <= band-end ]
   [ set pcolor #color ]
   report #color
end

                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download color-chooser_2009 --