<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Depth-First: Tag firefly</title>
    <link>http://depth-first.com/articles/tag/firefly</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>Googling for Molecules with InChIMatic and Firefly</title>
      <description>&lt;p&gt;&lt;center&gt;&lt;a href="http://depth-first.com/articles/tag/firefly"&gt;&lt;img src="http://depth-first.com/demo/20070815/screenshot.png"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;A &lt;a href="http://depth-first.com/articles/tag/inchimatic"&gt;series of D-F articles&lt;/a&gt; have discussed &lt;a href="http://inchimatic.com"&gt;InChIMatic&lt;/a&gt;, a Web application that lets you structure-search the Web using popular search engines such as Google. Recent articles have also described &lt;a href="http://depth-first.com/articles/tag/firefly"&gt;Firefly&lt;/a&gt;, a lightweight 2D structure editor designed especially for the Web.&lt;/p&gt;

&lt;p&gt;Today, the first alpha release of Firefly is available for use with &lt;a href="http://inchimatic.com"&gt;InChIMatic&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Despite its small size of only 103K, the Firefly applet offers a number of advanced features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A clean interface with major functionality in plain sight.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Antialiased rendering.&lt;/strong&gt; Pressing the "+" and "-" keys will zoom in and out to reveal rendering detail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User-overridable bond length and angle constraints.&lt;/strong&gt; When dragging a bond, use &lt;em&gt;Shift&lt;/em&gt; to relax both angle and length constraints, or &lt;em&gt;Ctrl&lt;/em&gt; to relax only angle constraints.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automatic inside-outside double bond rendering.&lt;/strong&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Built-in molfile import/export.&lt;/strong&gt; Use the File-&gt;Import Molfile and File-&gt;Export Molfile options to copy/paste a molfile from your system clipboard.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automatic implicit hydrogen detection.&lt;/strong&gt; The quadrant for hydrogen placement is chosen based on the bonds surrounding the atom.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Twenty levels of undo/redo.&lt;/strong&gt; The commands can either be issued from the menu, or &lt;em&gt;Ctrl-Z&lt;/em&gt;/&lt;em&gt;Ctrl-Y&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Persistent molecule.&lt;/strong&gt; When you visit another page and come back, Firefly remembers the molecule you were working on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No digital certificate authorization.&lt;/strong&gt; Just start using it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Firefly also incorporates a number of keyboard shortcuts to speed up structure drawing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;1&lt;/u&gt;-&lt;u&gt;9&lt;/u&gt; keys&lt;/strong&gt; Builds a chain with the indicated number of carbons.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;a&lt;/u&gt; key&lt;/strong&gt; Phenyl (&lt;u&gt;a&lt;/u&gt;romatic) ring. When hovering over a bond, fuses the ring to the bond. When hovering over an atom, fuses the ring to that atom, if possible, or sprouts the ring.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;f&lt;/u&gt;, &lt;u&gt;l&lt;/u&gt;, &lt;u&gt;r&lt;/u&gt;, &lt;u&gt;i&lt;/u&gt; keys&lt;/strong&gt; The elements &lt;u&gt;F&lt;/u&gt;, C&lt;u&gt;l&lt;/u&gt;, B&lt;u&gt;r&lt;/u&gt;, and &lt;u&gt;I&lt;/u&gt;, respectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;z&lt;/u&gt; and &lt;u&gt;t&lt;/u&gt; keys&lt;/strong&gt; The elements Si and Sn, respectively&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;b&lt;/u&gt;, &lt;u&gt;c&lt;/u&gt;, &lt;u&gt;n&lt;/u&gt;, &lt;u&gt;o&lt;/u&gt;, &lt;u&gt;s&lt;/u&gt;, and &lt;u&gt;p&lt;/u&gt; keys&lt;/strong&gt; The elements B, C, N, O, S, and P, respectively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;[delete] and [backspace] keys&lt;/strong&gt; deletes whatever is underneath the cursor.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To use these shortcuts, simply hover the cursor over an atom and press the key on your keyboard.&lt;/p&gt;

&lt;p&gt;Being an alpha release, this version of Firefly still has room for improvement. Your feedback is important. Please send questions, comments, and suggestions to the email address found under Firefly's "Help" menu.&lt;/p&gt;</description>
      <pubDate>Wed, 15 Aug 2007 09:16:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c2afff29-47c5-4b35-acfa-72a812e66203</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/08/15/googling-for-molecules-with-inchimatic-and-firefly</link>
      <category>Tools</category>
      <category>firefly</category>
      <category>editor</category>
      <category>2d</category>
      <category>editordoc</category>
      <category>inchimatic</category>
    </item>
    <item>
      <title>Never Draw the Same Molecule Twice: Viewing Image Metadata</title>
      <description>&lt;p&gt;&lt;img src="http://depth-first.com/demo/20070801/rosiglitazone.png" align="right"&gt;&lt;/img&gt;Chemists are accustomed to embedding live molecular objects in their documents with Microsoft Word/ChemDraw. These objects can then be reprocessed and embedded into other documents, such as PowerPoint presentations, saving enormous amounts of time. What if the same feature were available with Web documents?&lt;/p&gt;

&lt;p&gt;A &lt;a href="http://depth-first.com/articles/2007/08/01/never-draw-the-same-molecule-twice-image-metadata-for-cheminformatics"&gt;recent D-F article&lt;/a&gt; proposed a method to encode molecular structure data within commonly-used Web image formats such as PNG. That article contained an embedded image of GlaxoSmithKline's diabetes treatment rosiglitazone (Avandia) encoded by a rendering toolkit built with &lt;a href="http://depth-first.com/articles/tag/firefly"&gt;Firefly&lt;/a&gt;. I claimed that this image contained the complete connection table and atom coordinates as embedded metadata. In this article, I'll show a simple method to read this metadata.&lt;/p&gt;

&lt;p&gt;Metadata is a standard part of the PNG specification; to read it requires nothing more than software capable of recognizing it. I recently found a Web-based, cross-platform method for doing so. The &lt;a href="http://www.fileformat.info/convert/image/metadata.htm"&gt;Image Metadata Viewer&lt;/a&gt; by &lt;a href="http://www.fileformat.info/index.htm"&gt;FileFormat.info&lt;/a&gt; accepts an uploaded image file and returns that image's metadata. Let's try it with the image of rosiglitazone.&lt;/p&gt;

&lt;p&gt;After saving the image to my hard drive, uploading it to FileFormat.info and pressing start, I can see that the image contains metadata:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070808-2/screenshot.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;The metadata can be viewed either as XML or as plain text. Choosing plain text (second option) gives me the complete molfile, stored as a key/value hash (molfile=[molfile]).&lt;/p&gt;

&lt;p&gt;Clearly, reading metadata is not a problem given the right software. But this leaves the question of how metadata is encoded in the first place - especially in a programming language such as Java. Like everything else, it's not difficult when you know how. Stay tuned for the answer.&lt;/p&gt;</description>
      <pubDate>Wed, 08 Aug 2007 07:40:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:980141bf-863c-4bec-be42-9e5445b88f42</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/08/08/never-draw-the-same-molecule-twice-viewing-image-metadata</link>
      <category>Tools</category>
      <category>firefly</category>
      <category>2d</category>
      <category>metadata</category>
      <category>molfile</category>
      <category>png</category>
      <category>rosiglitazone</category>
      <category>chemdraw</category>
    </item>
    <item>
      <title>Never Draw the Same Molecule Twice: Image Metadata for Cheminformatics</title>
      <description>&lt;p&gt;&lt;img src="http://depth-first.com/demo/20070801/rosiglitazone.png" align="right" border="0"&gt;&lt;/img&gt;The graphical language of 2D structures has served chemistry well for the last 100 years. Ironically, this language which is so useful for human communication is extraordinarily difficult for machines to understand. Heroic efforts at digital raster image recognition such as &lt;a href="http://cactus.nci.nih.gov/osra/"&gt;OSRA&lt;/a&gt; and those &lt;a href="http://chem-bla-ics.blogspot.com/2007/07/optical-chemical-structure-recognition.html"&gt;recently summarized by Egon Willighagen&lt;/a&gt;, in addition to a &lt;a href="http://depth-first.com/articles/2006/08/25/computational-perception-and-recognition-of-digitized-molecular-structures"&gt;handful of others&lt;/a&gt;, have tried to tackle this problem with varying degrees of success.&lt;/p&gt;

&lt;p&gt;The problem remains unsolved, and continues to be one of the most difficult technical challenges in cheminformatics. But the pace at which non-machine readable images are generated has accelerated dramatically in the last two years with the emergence of &lt;a href="http://depth-first.com/articles/2007/01/24/thirty-two-free-chemistry-databases"&gt;numerous free chemical databases&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What if 2D structure images simply contained all of the information needed for machine processing in the first place?&lt;/p&gt;

&lt;p&gt;This idea isn't as far-fetched as it may sound initially. As discussed in a &lt;a href="http://depth-first.com/articles/2007/07/30/editable-and-searchable-2d-molecular-images"&gt;recent D-F article&lt;/a&gt;, both &lt;a href="http://www.nongnu.org/gchempaint/"&gt;GChemPaint&lt;/a&gt; and &lt;a href="http://www.acdlabs.com/download/chemsk.html"&gt;ACD ChemSketch&lt;/a&gt; have been claimed to be capable of encoding machine-readable structure information.&lt;/p&gt;

&lt;p&gt;Previous D-F articles have described &lt;a href="http://depth-first.com/articles/tag/firefly"&gt;"Firefly"&lt;/a&gt;, the codename for a new lightweight 2D structure editor designed specifically for the Web. With major work on the editor's user interface complete, more recent efforts have focused on implementing a 2D rendering toolkit, and with it a mechanism to encode structural information within 2D molecular images.&lt;/p&gt;

&lt;p&gt;As a demonstration of what is now possible, consider the structure of GlaxoSmithKline's diabetes treatment rosiglitazone (Avandia), depicted as a PNG image at the beginning of this article. At first glance, the image appears to be just like any other image of a 2D molecular structure. But it is not, for embedded within it are the connection table and 2D atom coordinates of rosiglitazone encoded as an industry-standard molfile.&lt;/p&gt;

&lt;p&gt;Given the right software, a computer can interpret the structural information encoded in the rosiglitazone image and precisely re-create the original molecular representation. A graphical diagnostic tool bundled with Firefly was equipped with code for precisely this purpose.&lt;/p&gt;

&lt;p&gt;This tool can work with molfile-encoded PNG images just as easily as it can with molfiles; they can be opened and the resulting molecule can be further edited, saved in another format, or re-written as a embedded-molfile PNG image.&lt;/p&gt;

&lt;p&gt;The first step is to select the PNG image from a local hard drive:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070801/file_open2.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Opening this image produces a fully-editable version of the original molecule:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070801/firefly.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Obviously, nothing limits this technique to molfiles. InChI, SMILES, CML, or any other molecular encoding scheme would work just as well.&lt;/p&gt;

&lt;p&gt;Using molecular-encoded PNG images as a Web-ready replacement for the &lt;a href="http://depth-first.com/articles/2007/07/30/editable-and-searchable-2d-molecular-images"&gt;Word/Chemdraw OLE&lt;/a&gt; technology may be one application of this approach. With a large corpus of these images, chemical Web spidering and data mining would be possible on a scale unimaginable today. As always, these possibilities reinforce the desperate need for high quality tools that chemists actually want to use, and which simultaneously yield machine-readable output.&lt;/p&gt;</description>
      <pubDate>Wed, 01 Aug 2007 06:17:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:bc2292ae-4f21-47ec-b8e5-41a17a52e8c9</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/08/01/never-draw-the-same-molecule-twice-image-metadata-for-cheminformatics</link>
      <category>Tools</category>
      <category>firefly</category>
      <category>2d</category>
      <category>molfile</category>
      <category>encoded</category>
      <category>png</category>
      <category>rosiglitazone</category>
      <category>metadata</category>
    </item>
    <item>
      <title>Editable and Searchable 2D Molecular Images</title>
      <description>&lt;p&gt;&lt;a href="http://depth-first.com/articles/tag/firefly"&gt;&lt;img src="http://depth-first.com/demo/20070730/fluoxetine.png" align="right" border="0"&gt;&lt;/img&gt;&lt;/a&gt;Word processing replaced the typewriter for the simple reason that documents could be prepared and edited so much more quickly. If Web authoring replaces conventional word processors, it will be for the simple reason that Web documents can be found, distributed, reprocessed, and combined with other content so much more effectively. The peculiar nature of chemical structure information complicates chemistry's transition to Web authoring. This article, the first in a series, discusses some of the challenges that lie ahead.&lt;/p&gt;

&lt;h4&gt;State of the Art: Word/ChemDraw&lt;/h4&gt;

&lt;p&gt;Microsoft Word allows 2D molecular graphics, typically created with ChemDraw, to be embedded in documents and later edited. Those images can then be copied into Power Point presentations and reused in a variety of other Windows-specific products. This practice has become so widespread throughout industry and academics, that few chemists even think about the technology that many of them rely on several times a week.&lt;/p&gt;

&lt;h4&gt;Chemical Structures are Peculiar&lt;/h4&gt;

&lt;p&gt;A 2D molecular image, like the one depicting fluoxetine at the top of this article, is a peculiar beast. On one level, it's a picture that anybody can look at. But on another level, it's a type of object for which manipulation by humans and computers is extremely useful. The combination of Microsoft Word and ChemDraw lets chemists conveniently manage the dual nature of chemical structures.&lt;/p&gt;

&lt;h4&gt;Live Molecular Images&lt;/h4&gt;

&lt;p&gt;Why would anybody want to create editable and searchable 2D molecular graphics such as JPGs, PNGs, and SVGs? Alas, technology has a way of moving on just when we're getting comfortable with it (an especially difficult concept for typewriter manufacturers who went bust during the 1980s, and the dedicated word processor manufacturers who followed).&lt;/p&gt;

&lt;p&gt;Consider the number of Word and PowerPoint documents you read last week compared to the number of Web pages. Chances are the ratio is at least 1:10. The trend shows no signs of reversing itself.&lt;/p&gt;

&lt;p&gt;Although Web authoring tools have been very slow to reach the average user, the blogging explosion has led to rapid evolution in the field. As tools like &lt;a href="http://wordpress.com"&gt;WordPress&lt;/a&gt;, &lt;a href="http://movabletype.com"&gt;Movable Type&lt;/a&gt;, and even &lt;a href="http://wikipedia.org"&gt;Wikipedia&lt;/a&gt; race to satisfy the needs of power authors, the average user will rather unexpectedly discover that they have access to perfectly capable tools that let them abandon their over-engineered (and expensive) word processors to experiment with Web publishing.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://en.wikipedia.org/wiki/Wikipedia_talk:WikiProject_Chemistry/Structure_drawing_workgroup/Archive_Jun_2007#63303826060"&gt;Wikipedia Chemisty/Structure Drawing Workgroup&lt;/a&gt; hints at what lies ahead for chemistry. Two tools, &lt;a href="http://www.nongnu.org/gchempaint/"&gt;GChemPaint&lt;/a&gt; and &lt;a href="http://www.acdlabs.com/download/chemsk.html"&gt;ACD ChemSketch&lt;/a&gt;, now enable molecular structure information to be embedded in images.&lt;/p&gt;

&lt;p&gt;As chemistry turns to the Web as its primary publication medium, chemists will need the same ability to deal with chemical structures offered by their current tools of choice. In articles to follow, I'll discuss some ways this could happen.&lt;/p&gt;</description>
      <pubDate>Mon, 30 Jul 2007 08:01:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ff926bd1-3a51-4b3e-afe2-7b165b5bbb67</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/07/30/editable-and-searchable-2d-molecular-images</link>
      <category>Meta</category>
      <category>2d</category>
      <category>firefly</category>
      <category>image</category>
      <category>png</category>
      <category>chemicalstructure</category>
      <category>publication</category>
    </item>
    <item>
      <title>Top Ten Best-Selling Drugs Worldwide (2006)</title>
      <description>&lt;p&gt;&lt;a href="http://depth-first.com/demo/20070725/ten-best-selling-drugs-worldwide-with-structures.html"&gt;&lt;img src="http://depth-first.com/demo/20070725/images/atorvastatin.png" align="right" border="0"&gt;&lt;/img&gt;&lt;/a&gt;If you haven't had a chance to do so yet, &lt;a href="http://imshealth.com"&gt;IMS Health's&lt;/a&gt; recent &lt;a href="http://www.imshealth.com/ims/portal/front/articleC/0,2777,6599_40183881_81567488,00.html"&gt;Intelligence.360&lt;/a&gt; on the global pharmaceutical industry is worth reading. One noteworthy set of data contained in the report is a list of the top ten best-selling drugs worldwide for 2006.&lt;/p&gt;

&lt;p&gt;A list of chemical names and numbers by itself is not that useful. However, adding chemical structures has a way of prompting better questions and generating many more ideas. In that spirit, I've created an online table of the ten best-selling drugs worldwide for 2006. This table contains the 2D chemical structure, generic name, trade name, global sales in US$, company, and indication for each drug.&lt;/p&gt;

&lt;p&gt;A new software package codenamed "Firefly" was used to generate the chemical structures in the table. Firefly is a lightweight 2D editor and rendering library written in Java. A &lt;a href="http://depth-first.com/articles/tag/firefly"&gt;series of articles on Firefly&lt;/a&gt; can be found on Depth-First.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://depth-first.com/demo/20070725/ten-best-selling-drugs-worldwide-with-structures.html"&gt;This link&lt;/a&gt; takes you to the table.&lt;/p&gt;</description>
      <pubDate>Wed, 25 Jul 2007 06:40:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:129e40cc-70eb-4d9d-b04e-695cbad730a5</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/07/25/top-ten-best-selling-drugs-worldwide-2006</link>
      <category>Meta</category>
      <category>pharmasales</category>
      <category>firefly</category>
      <category>2d</category>
    </item>
    <item>
      <title>Building a Molecule Preview with Firefly: The Joy of Swing</title>
      <description>&lt;p&gt;Previous articles have discussed &lt;a href="http://depth-first.com/articles/tag/firefly"&gt;Firefly&lt;/a&gt;, the codename for a new 2D structure editor for the Web. Although it can be deployed as a self-contained applet on Web pages, Firefly is composed of modules that are readily re-used. By taking advantage of this design and Java's native UI toolkit Swing, new UI elements can be built with relatively little effort. This article outlines one such use - the creation of a file dialog that contains a molecule preview.&lt;/p&gt;

&lt;p&gt;Many image processing applications such as Photoshop or GIMP provide an image preview that appears in file browser dialogs. Wouldn't it be nice if applications that process molecular structure files came with a similar feature? The screenshot below shows a file chooser with an embedded molecule preview based of Firefly's Painter component:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070718/dialog1.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;When a new molfile is highlighted, a new preview is automatically generated:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070718/dialog2.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;The molecule preview is capable of all of the customizations available in Firefly including background, bond, and atom colors, borders, and atom label fonts. No matter how large or small the molecule, and regardless of its starting coordinates, it will always be exactly scaled to fit the available space and precisely centered.&lt;/p&gt;

&lt;p&gt;This dialog was rapidly implemented using the accessory capability provided by Swing's &lt;tt&gt;JFileChooser&lt;/tt&gt;:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;JFileChooser chooser = new JFileChooser();
PreviewAccessory accessory = new PreviewAccessory(chooser);

accessory.setPreferredSize(new Dimension(150, 150));

chooser.setAccessory(accessory);
chooser.addPropertyChangeListener(accessory);

// ...&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Defining a JComponent implmenting the &lt;tt&gt;PropertyChangeListener&lt;/tt&gt; interface is all that's needed to get a working molecule preview:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_java "&gt;class PreviewAccessory extends DefaultPainter implements PropertyChangeListener
{
  // implementation
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Swing has come a long way since the dark days of JDK 1.2. What started out as the dog-slow ugly duckling of user interface toolkits has developed into one of the best platforms for building desktop applications out there. Advanced tools such as the WYSIWYG interface builder &lt;a href="http://www.netbeans.org/kb/articles/matisse.html"&gt;Matisse&lt;/a&gt; and the polished components offered by &lt;a href="http://www.jidesoft.com/"&gt;JIDE&lt;/a&gt; make Swing an even more attractive option. The example described here is just one instance of how Swing's well-conceived design simplifies the job of building rich user interfaces.&lt;/p&gt;</description>
      <pubDate>Wed, 18 Jul 2007 06:52:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:33a3bc07-253a-4221-a8ae-46a77a47076a</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/07/18/building-a-molecule-preview-with-firefly-the-joy-of-swing</link>
      <category>Tools</category>
      <category>firefly</category>
      <category>filechooser</category>
      <category>swing</category>
      <category>painter</category>
      <category>preview</category>
    </item>
    <item>
      <title>Making Your 2D Structures Look Good: Firefly, Styles and Stylesheets</title>
      <description>&lt;p&gt;Chemists can be &lt;a href="http://depth-first.com/articles/2007/07/11/waldorf-salad"&gt;very discerning&lt;/a&gt; when it comes to chemical structure aesthetics. This is not surprising, given the &lt;a href="http://depth-first.com/articles/2007/03/30/the-aesthetics-of-chemical-structure-diagrams"&gt;central role&lt;/a&gt; played by 2D chemical structures in the day-to-day work of many chemists. For example, consider the &lt;a href="http://en.wikipedia.org/wiki/Wikipedia_talk:WikiProject_Chemistry/Structure_drawing_workgroup/Archive_Apr_2007"&gt;Wikipedia Chemistry/Structure drawing workgroup's ongoing discussion&lt;/a&gt; about achieving a consistent look for chemical structures on the online encyclopedia.&lt;/p&gt;

&lt;p&gt;Several articles have discussed &lt;a href="http://depth-first.com/articles/tag/firefly"&gt;Firefly&lt;/a&gt;, a 2D chemical structure editor specifically designed for the Web. With major work on the rendering engine and structure manipulation interface complete, recent efforts have turned toward exposing drawing settings through a graphical user interface. Here I'll provide some screenshots of an interface prototype along with sample structures. I'll also briefly discuss the larger question of making 2D structure drawing styles portable.&lt;/p&gt;

&lt;p&gt;Drawing styles are edited through a tabbed dialog containing a live preview window that uses the current structure or a default structure if none is available. The dialog is resizable, enabling users to immediately see the effects of changes on structures of varying sizes. Although this dialog could be bundled and deployed with the editor, its large footprint makes it more appropriate for use as an optional feature or as a standalone configuration tool in a Web application.&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070713/dialog.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Changes can be rolled back entirely ("Reset"), canceled ("Cancel"), or accepted ("OK").&lt;/p&gt;

&lt;p&gt;Let's say we'd like to apply a black background with white bonds, as used in some Power Point presentations:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070713/default.png"&gt;&lt;/img&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://depth-first.com/demo/20070713/black_background.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;After applying this change, we decide that we'd rather not use atom coloring:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070713/black_background.png"&gt;&lt;/img&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://depth-first.com/demo/20070713/no_colors.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;After looking at this structure for a few seconds, we decide that narrower stereo bonds are needed:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070713/no_colors.png"&gt;&lt;/img&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://depth-first.com/demo/20070713/thin_stereo.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;After some experimentation, we find a more appropriate non-stereo bond width and double bond offset:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070713/thin_stereo.png"&gt;&lt;/img&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://depth-first.com/demo/20070713/thin_lines.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;What about a Serif font? No, I don't think so:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070713/thin_lines.png"&gt;&lt;/img&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://depth-first.com/demo/20070713/serif_font.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;But we could certainly reduce the size of the atom labels:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070713/thin_lines.png"&gt;&lt;/img&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://depth-first.com/demo/20070713/small_labels.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;On second thought, the original atom sizes were fine, although changing font may require us to reconsider the atom label heights:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070713/default.png"&gt;&lt;/img&gt;&amp;nbsp;&amp;nbsp;&lt;img src="http://depth-first.com/demo/20070713/thin_lines.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the possibilities for customization are nearly endless. In practice, however, most chemists will adopt only two structure drawing styles that they re-use as needed: one for reports and manuscripts; and one for presentations. It will be interesting to see whether a third style makes it's way into the standard repertoire: Web.&lt;/p&gt;

&lt;p&gt;Each chemist will want a way to save their styles, possibly share them, and easily apply them. Although a few systems for doing so are feasible, the most practical approach would be a &lt;a href="http://en.wikipedia.org/wiki/Stylesheet_language"&gt;stylesheet&lt;/a&gt;. Applying a stylesheet to any structure diagram would change its appearance, offering a simple mechanism to achieve a consistent look across documents.&lt;/p&gt;

&lt;p&gt;Developing a universal (cross-editor) stylesheet system would be no easy task, given the wildly divergent capabilities of 2D structure rendering software. Despite the technical difficulty, the payoff for users is obvious.&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jul 2007 11:19:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:7146dc3e-d044-4776-ac04-c5f87c8eeed5</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/07/13/making-your-2d-structures-look-good-firefly-styles-and-stylesheets</link>
      <category>Graphics</category>
      <category>firefly</category>
      <category>editor</category>
      <category>2d</category>
      <category>screenshots</category>
      <category>stylesheets</category>
    </item>
    <item>
      <title>Open Notebook Science Using InChIMatic</title>
      <description>&lt;p&gt;Have you ever wanted to find a molecule on the Web using your favorite search engine in combination with a 2-D structure editor? &lt;a href="http://inchimatic.com"&gt;InChIMatic&lt;/a&gt; is a service that lets you do just that. In this article, I'll show how InChIMatic can be used to look up molecules in the &lt;a href="http://usefulchem-molecules.blogspot.com/"&gt;UsefulChem-Molecules&lt;/a&gt; blog.&lt;/p&gt;

&lt;p&gt;For those who aren't familiar with it, &lt;a href="http://usefulchem-molecules.blogspot.com/"&gt;UsefulChem-Molecules&lt;/a&gt; is a blog operated by &lt;a href="http://usefulchem.blogspot.com/"&gt;Jean-Claude Bradly's&lt;/a&gt; research group at Drexel University that publicly archives molecules of interest. Each entry is a single molecule that may be linked to other Web resources.&lt;/p&gt;

&lt;p&gt;Let's say you wanted to look up &lt;a href="http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=2202"&gt;dithranol&lt;/a&gt;. This can be done by simply pointing your browser to &lt;a href="http://inchimatic.com"&gt;inchimatic.com&lt;/a&gt; and drawing the structure:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070621/screenshot.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;When you're finished, select your search engine of choice (we'll use Google here) and press "Search". You'll be taken to the familiar results page. The second result links to the UsefulChem-Molecules &lt;a href="http://usefulchem-molecules.blogspot.com/2007/04/uc0234.html"&gt;entry for dithranol&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070621/screenshot2.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;In performing this simple workflow, I noticed areas for improvement in both UsefulChem and InChIMatic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;UsefulChem&lt;/strong&gt; If you look at the &lt;a href="http://usefulchem-molecules.blogspot.com/2007/04/uc0234.html"&gt;entry for dithranol&lt;/a&gt;, you'll notice there are no linkouts. In essence, the entry is a bookmark without context. Although it's useful to know that the Bradly group is interested in this molecule, it would be even more interesting to know in what context. Each entry should contain at least one link giving the molecule a context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;InChIMatic&lt;/strong&gt; Using the back button on the Google results page takes you back to InChIMatic, but your molecule is gone. If you wanted to look for a series of related molecules, you couldn't edit your existing structure. As &lt;a href="http://depth-first.com/articles/2007/05/02/a-chemical-structure-editor-for-the-web-four-screenshots-of-a-firefly-prototype"&gt;Firefly 1.0&lt;/a&gt; nears completion, a top priority will be to incorporate it into InChIMatic and fix the back-button problem.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can see, between InChIMatic and UsefulChem-Molecules, we have the makings of a crude laboratory information management system. The problem is we're trying to use existing tools (search engines and blogs) for purposes they are ill-suited for. It can work, but it could also work much better.&lt;/p&gt;

&lt;p&gt;What chemistry really needs is open, user-friendly systems specifically designed to archive and search chemical information of the type maintained by the Bradly group. But that's a story for another time.&lt;/p&gt;</description>
      <pubDate>Thu, 21 Jun 2007 10:27:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3f9763cb-1e08-460d-b3fa-06e74cf235f6</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/06/21/open-notebook-science-using-inchimatic</link>
      <category>Meta</category>
      <category>inchimatic</category>
      <category>usefulchem</category>
      <category>blogs</category>
      <category>firefly</category>
    </item>
    <item>
      <title>A Chemical Structure Editor for the Web: Four Screenshots of a Firefly Prototype</title>
      <description>&lt;p&gt;The &lt;a href="http://depth-first.com/articles/2007/04/23/a-chemical-structure-editor-for-the-web-fireflys-two-audiences"&gt;previous article&lt;/a&gt; in this series discussed the requirements of Firefly, a new 2D chemical structure editor for the Web. Another article discussed &lt;a href="http://depth-first.com/articles/2007/04/18/a-2d-chemical-structure-editor-for-the-web-embracing-constraints-in-firefly"&gt;Firefly's design constraints&lt;/a&gt; and the importance of embracing them. Why so much focus on a structure editor? Simply put, the structure editor is the &lt;a href="http://depth-first.com/articles/2007/04/16/the-structure-editor-forgotten-link-between-chemistry-and-cheminformatics"&gt;key link between chemistry and cheminformatics&lt;/a&gt;. Without the structure editor, there would be no audience for cheminformatics software.&lt;/p&gt;

&lt;p&gt;So far the discussion has been rather abstract. To make it less so, the following four screenshots illustrate the user interface and rendering capabilities of a Firefly prototype. All molecules were drawn with the Firefly interface running on Linux. Screenshots were directly captured from the running application.&lt;/p&gt;

&lt;h4&gt;Cholesterol&lt;/h4&gt;

&lt;p&gt;The image below illustrates fused rings and stereo atoms. Also notice that the atom label for oxygen has one implicit hydrogen atom that is properly placed to the left.&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070502/cholesterol.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;h4&gt;Doxorubicin&lt;/h4&gt;

&lt;p&gt;This image illustrates both atom labels and aromatic bonding. Notice the improperly-placed quinone double bond. Refining Firefly's aromaticity perception is currently a top priority.&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070502/doxorubicen.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;h4&gt;Flunoxaprofen&lt;/h4&gt;

&lt;p&gt;Firefly comes complete with a developer-overridable atom coloring scheme. Also notice the correct length of the internal carbon-nitrogen double bond line.&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070502/flunoxaprofen.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;h4&gt;Uric Acid&lt;/h4&gt;

&lt;p&gt;One of the more difficult aspects of rendering molecules with implicit hydrogens is placing them in the correct quandrant. In this screenshot of uric acid, notice how the hydrogens occupy three different quadrants relative to their hosting nitrogen atoms. &lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20070502/uric_acid.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 02 May 2007 10:13:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6852141f-ebdf-4dbb-bade-d203929a31b9</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/05/02/a-chemical-structure-editor-for-the-web-four-screenshots-of-a-firefly-prototype</link>
      <category>Tools</category>
      <category>firefly</category>
      <category>editor</category>
      <category>2d</category>
      <category>screenshots</category>
    </item>
    <item>
      <title>A Chemical Structure Editor for the Web: Firefly's Two Audiences</title>
      <description>&lt;p&gt;&lt;a href="http://flickr.com/photos/elbisreverri/51049270/"&gt;&lt;img src="http://depth-first.com/demo/20070423/towers.jpg" align="right" border="0"&gt;&lt;/img&gt;&lt;/a&gt;The &lt;a href="http://depth-first.com/articles/2007/04/18/a-2d-chemical-structure-editor-for-the-web-embracing-constraints-in-firefly"&gt;previous article&lt;/a&gt; in this series outlined the main technical constraints in the design of Firefly, a new chemical structure editor for the Web. Knowing the technical barriers you're up against is important in any software project, but understanding what the software needs to do is also important. This article offers a high-level approach to answering this important question.&lt;/p&gt;

&lt;h4&gt;Why Use an Editor at All?&lt;/h4&gt;

&lt;p&gt;The purpose of Firefly will be to conveniently convert the language of chemistry (structure diagrams) into the language of cheminformatics (&lt;a href="http://depth-first.com/articles/2007/03/14/eleven-qualities-of-the-perfect-line-notation-for-the-web"&gt;line notations&lt;/a&gt; and file formats). There are certainly alternatives to using a graphical editor. For example, SMILES strings could be directly entered. Molfiles could be pasted into a window. But as a real-world solution, a graphical editor embedded in the host application is the only approach that makes sense.&lt;/p&gt;

&lt;h4&gt;Two Audiences&lt;/h4&gt;

&lt;p&gt;As &lt;a href="http://depth-first.com/articles/2007/04/16/the-structure-editor-forgotten-link-between-chemistry-and-cheminformatics"&gt;discussed previously&lt;/a&gt;, the structure editor plays the pivotal role of linking consumers of cheminformatics software (i.e., chemists) with producers of cheminformatics software. As a result, the structure editor is one of those few pieces of software that is simultaneously "seen" and "felt" by chemists, and used as a building block by cheminformatics developers. For an editor to be successful, the needs of &lt;em&gt;both&lt;/em&gt; of these audiences must be satisfied.&lt;/p&gt;

&lt;h4&gt;The Chemist Experience&lt;/h4&gt;

&lt;p&gt;To understand how to build a good structure editor, it's important to understand what's happening in the thirty seconds just before the editor is run. Typically, a chemist is in the middle of doing something important like answering a burning question, preparing a presentation, or setting up an experiment. Firing up a structure editor is actually a major distraction from that work-flow; it interrupts the scientific thought process with a mundane data-entry task far more complex than any text box.&lt;/p&gt;

&lt;p&gt;Understandably, using a structure editor is not something that most chemists are enthusiastic about. And using a new structure editor, with its own quirky way of doing things, is potentially even worse. This makes it especially important that any new editor behave intuitively. But what exactly does "intuitive" mean?&lt;/p&gt;

&lt;p&gt;ChemDraw and IsisDraw are the 500-pound gorillas of structure editors. They're everywhere - in universities (often bootlegged), at home, and in industry. Important portions of the ChemDraw/IsisDraw user interfaces make appearances in all major structure editors (e.g., ChemSketch). The two things that can be assumed about any prospective user of a new structure editor are that: (1) they have used ChemDraw/IsisDraw; and (2) their current editor is either ChemDraw/IsisDraw or something very similar.&lt;/p&gt;

&lt;p&gt;For better or worse, ChemDraw/IsisDraw define the meaning of the word "intuitive" when it comes to 2D structure editors. When faced with any new editor, the first thing Joe the Chemist is likely to try is what works in ChemDraw/IsisDraw. Any attempt to innovate the user interface therefore needs to be very carefully considered. Developers who violate this &lt;a href="http://en.wikipedia.org/wiki/Principle_of_least_astonishment"&gt;"principle of least surprise"&lt;/a&gt; are likely to meet with &lt;a href="http://www.joelonsoftware.com/uibook/fog0000000249.html"&gt;well-founded resistance&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To summarize: Firefly should minimize the number of "innovations" it introduces into the user interface.&lt;/p&gt;

&lt;h4&gt;The Developer Experience&lt;/h4&gt;

&lt;p&gt;In contrast to chemists, developers are likely to be much more tolerant of innovations in Firefly. The reason is simple: there is no standard structure editor for Web applications. This leaves just a few basic requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Molfile input/output.&lt;/strong&gt; Many tools exist, such as &lt;a href="http://depth-first.com/articles/2007/04/09/painless-installation-of-ruby-open-babel"&gt;Ruby Open Babel&lt;/a&gt;, that can be deployed on a server and which will convert a Molfile into virtually any desired format. To fully satisfy developer expectations, it will be sufficient that Firefly can export and import Molfiles. Additional formats are unnecessary, at least for the 1.0 release.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Designed with JavaScript in mind.&lt;/strong&gt; All applet settings will be addressable though get/set methods. Using Java primitives as arguments to these methods will maximize developer productivity in languages such as JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extensibility.&lt;/strong&gt; A mechanism to &lt;a href="http://depth-first.com/articles/2006/12/18/anatomy-of-a-cheminformatics-web-application-structure-cleanup-in-java-molecular-editor"&gt;conveniently extend&lt;/a&gt; the functionality of Firefly through JavaScript must exist.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adaptability.&lt;/strong&gt; It must be possible to use Firefly as a 2D &lt;a href="http://depth-first.com/articles/2006/12/04/anatomy-of-a-cheminformatics-web-application-ajaxifying-depict"&gt;molecular rendering framework&lt;/a&gt;, independent of its user interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comprehensible Design.&lt;/strong&gt; Firefly's design will be made more understandable through the use and documentation of Design Patterns. Monolithic classes and methods are to be avoided.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Summary&lt;/h4&gt;

&lt;p&gt;To be successful, Firefly must satisfy two very different groups of users: chemists who will interact with its graphical interface; and developers who will plug it into other software frameworks. These two groups have very different expectations and needs. Understanding, and embracing, these expectations will go a long way toward making Firefly the best editor it can be.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Image Credit: &lt;a href="http://flickr.com/photos/elbisreverri/"&gt;elbisreverri&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 23 Apr 2007 11:22:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6fccdc8c-c4b8-4d8c-983b-6514e5af671d</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/04/23/a-chemical-structure-editor-for-the-web-fireflys-two-audiences</link>
      <category>Meta</category>
      <category>2d</category>
      <category>editor</category>
      <category>firefly</category>
    </item>
  </channel>
</rss>
