Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The command

ColorData["Atoms", "Panel"]

indicates RGBColors of "Atoms" by clicking a panel.

As I don't want to reinvent the wheel, I asked myself:

How to transform ColorData["Atoms", "Panel"] in a clickPanel for chemical elements, which could be used as argument for other functions like ElementData[] or IsotopeData[]?

share|improve this question
    
What is the question? If this is not a question but instead intended to be instructional for others please edit the post to make it a question (it can be very simple) then post the majority of this as a self-answer. Thanks. –  Mr.Wizard Jul 19 at 7:23
1  
@ Mr.Wizeard: Thx, I followed your suggestions, and brought it in Q&A form. –  hieron Jul 24 at 5:33
    
You will notice that you already have a combined four votes. :-) –  Mr.Wizard Jul 24 at 6:19

1 Answer 1

simple version

With a single codeline, ColorData["Atoms", "Panel"], can be transformed in a click panel for ElementData[].

{ColorData["Atoms", "Panel"] // ReplaceAll[#, RuleDelayed[ "MouseClicked", $_] :> (RuleDelayed["MouseClicked", atomClicked = Part[RuleDelayed["MouseClicked", $], 2, 2, 2, 1, 1, 1]])] &, Dynamic[atomClicked, Initialization :> (atomClicked = "H")]}

simple click panel for periodic table

changing size or removing panel

now it would be nice to change the panel size.This could be done simply by using

... // Magnify[#, 2] &

but maybe not the best solution.Therefore I added another function, which replaces ImageSize in Graphics.

(*version2 >>> shows how to remove the panel and how to change image size*)
Clear@"`*"
atomClicked = "H";(*init>>>important*)
imageSize[size_] := 
 ReplaceAll[#, 
   Graphics[x_, {y__}] :> Graphics[x, {ImageSize -> size, y}]] &;
atomClickedFunction = 
  ReplaceAll[#, 
    RuleDelayed[
      "MouseClicked", $_] :> (RuleDelayed["MouseClicked", 
           atomClicked = 
            Part[RuleDelayed["MouseClicked", $], 2, 2, 2, 1, 1, 1]])] &;
{ColorData["Atoms", "Panel"] // atomClickedFunction // imageSize@600 //
      First (*removes Panel*), atomClicked, 
    ElementData[atomClicked, "AlternateStandardNames" (* >>>
     latin names,
     only for latin abbreviations available in ElementData[]*)], 
    ElementData[atomClicked, "AtomicNumber"], 
    ElementData[atomClicked, "StandardName"], 
    ElementData[atomClicked, "DiscoveryYear"], 
    ElementData[atomClicked, "DiscoveryCountries"]} // Column // 
  Framed // Dynamic

a clickPanel for ElementData[ ] now

Transformed in a clickPanel for ElementData[ ] now.

Implementing the code in form of a Module with optionPatterns and more ... could be the next step ...

Just an idea ...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.