ChemWriter v1.3.0

com.metamolecular.chemwriter.applet
Class BaseApplet

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by com.metamolecular.chemwriter.applet.BaseApplet
All Implemented Interfaces:
PaintStyler, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer
Direct Known Subclasses:
EditorApplet, PainterApplet

public abstract class BaseApplet
extends javax.swing.JApplet
implements PaintStyler

The base class for ChemWriter™ applets.

Author:
Richard L. Apodaca
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 void clearAtomColors()
          Clears all atom coloring, making all atoms appear in the bond color.
 void copyStyle(PaintStyler styler)
          Copies all settings from styler to this PaintStyler.
 void flash(java.lang.String message)
          Display message as a JOptionPane.
 java.lang.String getAppletInfo()
          Returns version number, copyright notice, and license status.
 java.awt.Color getAtomColor(java.lang.String atomSymbol)
          Returns the color for atoms of atomic symbol atomSymbol.
 java.lang.String getAtomLabelFont()
          Returns the name of the font being used to render atom labels.
 java.lang.String[] getAtomLabelFonts()
          Returns an array containing the names of the fonts that can be used for Atom labels.
 double getAtomLabelHeight()
          Returns the atom label height, as a ratio of the median bond length.
 java.awt.Color getBackgroundColor()
          Returns the background color.
 java.awt.Color getBondColor()
          Returns the bond color.
 java.lang.String getCapStyle()
          Returns the line cap style.
 java.lang.String[] getColoredAtoms()
          Returns an array of atom labels that this PaintStyler will color.
 double getLineEndPadding()
          Returns the end line padding.
 double getLineOffset()
          Returns the multiple bond line offset as a ratio of the median bond length.
 double getLineWidth()
          Returns the line width, as a ratio of the median bond length.
abstract  java.lang.String getMolfile()
          Returns the molfile representation of the molecule contained in this applet.
 java.lang.String[][] getParameterInfo()
           
 double getStereoWidth()
          Returns the maximum width of a stereo bond, as a ratio of the bond length.
 void init()
           
 boolean isAntialiasing()
          Returns true if antialiasing is activated or false otherwise.
 boolean isAtomColoringEnabled()
          Returns true if atom coloring is enabled, or false otherwise.
abstract  boolean isBlank()
          Returns true if this applet's canvas contains no molecule, or false otherwise.
 boolean isCarbonVisible()
          Returns true if carbon atoms and their associated virutal hydrogens are rendered or false otherwise.
 boolean isRenderVirtualHydrogens()
          Returns true if heteroatom virtual hydrogens are rendered or false otherwise.
 boolean isVirtualizeHydrogens()
          Returns true if this applet virtualized hydrogen atoms from molfile input, or false otherwise.
 void setAntialiasing(boolean antialiasing)
          Determines whether antialiasing is used.
 void setAtomColor(java.lang.String atomSymbol, java.awt.Color color)
          Sets the color for atoms of atomic symbol atomicSymbol to color
 void setAtomColor(java.lang.String atomSymbol, int red, int green, int blue)
          Sets the color for atoms of atomic symbol atomicSymbol to the color represented by the values red, green, and blue.
 void setAtomColoringEnabled(boolean enabled)
          Turns atom coloring on and off.
 void setAtomLabelFont(java.lang.String font)
          Sets the name of the font being used to render atom labels.
 void setAtomLabelHeight(double height)
          Sets the atom label height, as a ratio of the median bond length.
 void setBackgroundColor(java.awt.Color color)
          Sets the background color to color.
 void setBackgroundColor(int red, int green, int blue)
          Sets the background color to that represented by the red green, and blue values.
 void setBondColor(java.awt.Color color)
          Sets the bond color to color.
 void setBondColor(int red, int green, int blue)
          Sets the bond color to that represented by the red, green, and blue values.
 void setCapStyle(java.lang.String endCap)
          Sets the line cap style: "square", "round", or "none".
 void setCarbonVisible(boolean visible)
          Determines whether carbon atoms and their associated virtual hydrogens will be rendered.
 void setLineEndPadding(double padding)
          Sets line end padding to padding.
 void setLineOffset(double offset)
          Sets the multiple bond line offset, as a ratio of the bond length.
 void setLineWidth(double width)
          Sets the line width, as a ratio of the median bond length.
abstract  void setMolfile(java.lang.String molfile)
          Replaces the current molecule with one defined by molfile.
 void setRenderVirtualHydrogens(boolean visible)
          Determines whether heteroatom virtual hydrogens will be rendered.
 void setStereoWidth(double width)
          Sets the maximum width of a stereo bond, as a ratio of the bond length.
 void setVirtualizeHydrogens(boolean virtualizeHydrogens)
          Removes hydrogens from non-stereogenic carbons and non-metallic heteroatoms for all molfile input.
 
Methods inherited from class javax.swing.JApplet
getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

isBlank

public abstract boolean isBlank()
Returns true if this applet's canvas contains no molecule, or false otherwise.

Returns:
true if this applet's canvas contains no molecule, or false otherwise
Since:
1.2

getLineEndPadding

public double getLineEndPadding()
Description copied from interface: PaintStyler
Returns the end line padding. Line end padding is the spacing between a single bond terminus and a visible atom label, relative to the median bond length. For example, a value of 0.05 sets the distance between the edge of a single bond and a nitrogen atom label to be 5% of the median bond length.

Specified by:
getLineEndPadding in interface PaintStyler
Returns:
the spacing between a single bond terminus and a visible atom label, relative to the median bond length

setLineEndPadding

public void setLineEndPadding(double padding)
Description copied from interface: PaintStyler
Sets line end padding to padding. Line end padding is the spacing between a single bond terminus and a visible atom label, relative to the median bond length. For example, a value of 0.05 sets the distance between the edge of a single bond and a nitrogen atom label to be 5% of the median bond length.

Specified by:
setLineEndPadding in interface PaintStyler
Parameters:
padding - the spacing between a single bond terminus and a visible atom label, relative to the median bond length

getAtomLabelFonts

public java.lang.String[] getAtomLabelFonts()
Description copied from interface: PaintStyler
Returns an array containing the names of the fonts that can be used for Atom labels. All members of this array can be used with setAtomLabelFont.

Specified by:
getAtomLabelFonts in interface PaintStyler
Returns:
an array containing the names of the fonts that can be used for Atom labels

getAppletInfo

public java.lang.String getAppletInfo()
Returns version number, copyright notice, and license status.

Overrides:
getAppletInfo in class java.applet.Applet

getParameterInfo

public java.lang.String[][] getParameterInfo()
Overrides:
getParameterInfo in class java.applet.Applet

init

public void init()
Overrides:
init in class java.applet.Applet

clearAtomColors

public void clearAtomColors()
Description copied from interface: PaintStyler
Clears all atom coloring, making all atoms appear in the bond color.

Specified by:
clearAtomColors in interface PaintStyler

copyStyle

public void copyStyle(PaintStyler styler)
Description copied from interface: PaintStyler
Copies all settings from styler to this PaintStyler.

Specified by:
copyStyle in interface PaintStyler
Parameters:
styler - the PaintStyler from which setting will be copied

getAtomColor

public java.awt.Color getAtomColor(java.lang.String atomSymbol)
Description copied from interface: PaintStyler
Returns the color for atoms of atomic symbol atomSymbol.

Specified by:
getAtomColor in interface PaintStyler
Parameters:
atomSymbol - the case-sensitive one- or two-character atomic symbol to query
Returns:
the color of atoms having the symbol atomicSymbol

getAtomLabelFont

public java.lang.String getAtomLabelFont()
Description copied from interface: PaintStyler
Returns the name of the font being used to render atom labels.

Specified by:
getAtomLabelFont in interface PaintStyler
Returns:
the name of the font being used to render atom labels

getAtomLabelHeight

public double getAtomLabelHeight()
Description copied from interface: PaintStyler
Returns the atom label height, as a ratio of the median bond length.

Specified by:
getAtomLabelHeight in interface PaintStyler
Returns:
the atom label height

getBackgroundColor

public java.awt.Color getBackgroundColor()
Description copied from interface: PaintStyler
Returns the background color.

Specified by:
getBackgroundColor in interface PaintStyler
Returns:
the background color

getBondColor

public java.awt.Color getBondColor()
Description copied from interface: PaintStyler
Returns the bond color.

Specified by:
getBondColor in interface PaintStyler
Returns:
the bond color

getCapStyle

public java.lang.String getCapStyle()
Description copied from interface: PaintStyler
Returns the line cap style.

Specified by:
getCapStyle in interface PaintStyler
Returns:
one of "square", "round", or "none"

getColoredAtoms

public java.lang.String[] getColoredAtoms()
Description copied from interface: PaintStyler
Returns an array of atom labels that this PaintStyler will color.

Specified by:
getColoredAtoms in interface PaintStyler
Returns:
an array of atom labels that this PaintStyler will color

getLineOffset

public double getLineOffset()
Description copied from interface: PaintStyler
Returns the multiple bond line offset as a ratio of the median bond length.

Specified by:
getLineOffset in interface PaintStyler
Returns:
the multiple bond line offset as a ratio of the median bond length

getLineWidth

public double getLineWidth()
Description copied from interface: PaintStyler
Returns the line width, as a ratio of the median bond length. Line widths apply to all bonds and stereo bond hashes.

Specified by:
getLineWidth in interface PaintStyler
Returns:
the line width, as a ratio of the median bond length

getStereoWidth

public double getStereoWidth()
Description copied from interface: PaintStyler
Returns the maximum width of a stereo bond, as a ratio of the bond length.

Specified by:
getStereoWidth in interface PaintStyler
Returns:
the maximum width of a stereo bond, as a ratio of the bond length

isAntialiasing

public boolean isAntialiasing()
Description copied from interface: PaintStyler
Returns true if antialiasing is activated or false otherwise.

Specified by:
isAntialiasing in interface PaintStyler
Returns:
true if antialiasing is activated or false otherwise

isAtomColoringEnabled

public boolean isAtomColoringEnabled()
Description copied from interface: PaintStyler
Returns true if atom coloring is enabled, or false otherwise.

Specified by:
isAtomColoringEnabled in interface PaintStyler
Returns:
true if atom coloring is enabled, or false otherwise

isCarbonVisible

public boolean isCarbonVisible()
Description copied from interface: PaintStyler
Returns true if carbon atoms and their associated virutal hydrogens are rendered or false otherwise.

Specified by:
isCarbonVisible in interface PaintStyler
Returns:
true if carbon atoms and their associated virutal hydrogens are rendered or false otherwise

isRenderVirtualHydrogens

public boolean isRenderVirtualHydrogens()
Description copied from interface: PaintStyler
Returns true if heteroatom virtual hydrogens are rendered or false otherwise.

Specified by:
isRenderVirtualHydrogens in interface PaintStyler
Returns:
true if heteroatom virtual hydrogens are rendered or false otherwise

setAntialiasing

public void setAntialiasing(boolean antialiasing)
Description copied from interface: PaintStyler
Determines whether antialiasing is used. Deactivating antialiasing improves performance.

Specified by:
setAntialiasing in interface PaintStyler
Parameters:
antialiasing - true if activated for false otherwise

setAtomColor

public void setAtomColor(java.lang.String atomSymbol,
                         java.awt.Color color)
Description copied from interface: PaintStyler
Sets the color for atoms of atomic symbol atomicSymbol to color

Specified by:
setAtomColor in interface PaintStyler
Parameters:
atomSymbol - the case-sensitive one- or two-character atomic symbol to color
color - the new color for atoms of atomic symbol atomSymbol

setAtomColor

public void setAtomColor(java.lang.String atomSymbol,
                         int red,
                         int green,
                         int blue)
Description copied from interface: PaintStyler
Sets the color for atoms of atomic symbol atomicSymbol to the color represented by the values red, green, and blue.

Specified by:
setAtomColor in interface PaintStyler
Parameters:
atomSymbol - the case-sensitive one- or two-character atomic symbol to color
red - the red color component (0-255)
green - the green color component (0-255)
blue - the blue color component (0-255)

setAtomColoringEnabled

public void setAtomColoringEnabled(boolean enabled)
Description copied from interface: PaintStyler
Turns atom coloring on and off. When atom coloring is disabled, all atom labels appear with the same color as bonds.

Specified by:
setAtomColoringEnabled in interface PaintStyler
Parameters:
enabled - enables atom coloring if true

setAtomLabelFont

public void setAtomLabelFont(java.lang.String font)
Description copied from interface: PaintStyler
Sets the name of the font being used to render atom labels. All system fonts are available in addition to the standard fonts "Serif", "SansSerif", and "Monospaced."

Specified by:
setAtomLabelFont in interface PaintStyler
Parameters:
font - the name of the new font to be used in rendering atom labels

setAtomLabelHeight

public void setAtomLabelHeight(double height)
Description copied from interface: PaintStyler
Sets the atom label height, as a ratio of the median bond length.

Specified by:
setAtomLabelHeight in interface PaintStyler
Parameters:
height - the new atom label height - greater than zero

setBackgroundColor

public void setBackgroundColor(java.awt.Color color)
Description copied from interface: PaintStyler
Sets the background color to color.

Specified by:
setBackgroundColor in interface PaintStyler
Parameters:
color - the new background color

setBackgroundColor

public void setBackgroundColor(int red,
                               int green,
                               int blue)
Description copied from interface: PaintStyler
Sets the background color to that represented by the red green, and blue values.

Specified by:
setBackgroundColor in interface PaintStyler
Parameters:
red - the red color component (0-255)
green - the green color component (0-255)
blue - the blue color component (0-255)

setBondColor

public void setBondColor(java.awt.Color color)
Description copied from interface: PaintStyler
Sets the bond color to color.

Specified by:
setBondColor in interface PaintStyler
Parameters:
color - the new bond color

setBondColor

public void setBondColor(int red,
                         int green,
                         int blue)
Description copied from interface: PaintStyler
Sets the bond color to that represented by the red, green, and blue values.

Specified by:
setBondColor in interface PaintStyler
Parameters:
red - the red color component (0-255)
green - the green color component (0-255)
blue - the blue color component (0-255)

setCapStyle

public void setCapStyle(java.lang.String endCap)
Description copied from interface: PaintStyler
Sets the line cap style: "square", "round", or "none".

Specified by:
setCapStyle in interface PaintStyler
Parameters:
endCap - one of "square", "round", or "none"

setCarbonVisible

public void setCarbonVisible(boolean visible)
Description copied from interface: PaintStyler
Determines whether carbon atoms and their associated virtual hydrogens will be rendered.

Specified by:
setCarbonVisible in interface PaintStyler
Parameters:
visible - when true carbons and their associated virtual hydrogens will be rendered

setLineOffset

public void setLineOffset(double offset)
Description copied from interface: PaintStyler
Sets the multiple bond line offset, as a ratio of the bond length.

Specified by:
setLineOffset in interface PaintStyler
Parameters:
offset - the new multiple bond line offset - greater than zero

setLineWidth

public void setLineWidth(double width)
Description copied from interface: PaintStyler
Sets the line width, as a ratio of the median bond length.

Specified by:
setLineWidth in interface PaintStyler
Parameters:
width - the new line width - greater than zero

setRenderVirtualHydrogens

public void setRenderVirtualHydrogens(boolean visible)
Description copied from interface: PaintStyler
Determines whether heteroatom virtual hydrogens will be rendered.

Specified by:
setRenderVirtualHydrogens in interface PaintStyler
Parameters:
visible - when true carbons and their associated virtual hydrogens will be rendered

setStereoWidth

public void setStereoWidth(double width)
Description copied from interface: PaintStyler
Sets the maximum width of a stereo bond, as a ratio of the bond length.

Specified by:
setStereoWidth in interface PaintStyler
Parameters:
width - the maximum width of a stereo bond - greater than zero

setVirtualizeHydrogens

public void setVirtualizeHydrogens(boolean virtualizeHydrogens)
Removes hydrogens from non-stereogenic carbons and non-metallic heteroatoms for all molfile input. This virtualized hydrogens are counted during invocation of an Atom's virtualHydrogenCount method. Certain publishers, for example PubChem, distribute molfiles containing virtualizable hydrogens. Removing them leads to a more compact image that is easier to interpret.

Parameters:
virtualizeHydrogens - the setting
Since:
1.2

isVirtualizeHydrogens

public boolean isVirtualizeHydrogens()
Returns true if this applet virtualized hydrogen atoms from molfile input, or false otherwise.

Returns:
true if this applet virtualized hydrogen atoms from molfile input, or false otherwise
Since:
1.2

setMolfile

public abstract void setMolfile(java.lang.String molfile)
Replaces the current molecule with one defined by molfile.

Parameters:
molfile - the molfile representation that will replace the current molecule
See Also:
MDL V2000 Molfile Specification

getMolfile

public abstract java.lang.String getMolfile()
Returns the molfile representation of the molecule contained in this applet.

Returns:
the molfile representation of the molecule contained in this applet
See Also:
MDL V2000 Molfile Specification

flash

public void flash(java.lang.String message)
Display message as a JOptionPane.

Parameters:
message - the message to be displayed

ChemWriter v1.3.0

Copyright © 2007, 2008 Metamolecular, LLC. All Rights Reserved.