org.proteinshader.structure.visitor
Class ModifierVisitor

java.lang.Object
  extended by org.proteinshader.structure.visitor.Visitor
      extended by org.proteinshader.structure.visitor.ModifierVisitor

public class ModifierVisitor
extends Visitor

Knows how to modify multiple Drawable objects while traversing the hierarchy of objects contained in a Structure.

An AtomModifier, BondModifier, or SegmentModifier can be added to this Visitor. A newly created Visitor (or a Visitor on which clear() has been called) will have its RegionMode set to NO_REGIONS, its ResidueMode set to ALL, and its AAPortionMode set to ENTIRE_AA. Any of these modes can be changed with the setMode() method on Visitor.

Usage

The following code will set all Atoms and Bonds belonging to a Helix as invisible.

// Set up Atom and Bond modifications.
AtomModifier atomModifier = new AtomModifier();
atomModifier.setVisibility( VisibilityEnum.INVISIBLE );
BondModifier bondModifier = new BondModifier();
bondModifier.setVisibility( VisibilityEnum.INVISIBLE );

// Add the modifiers to the visitor.
ModifierVisitor visitor = new ModifierVisitor();
visitor.add( atomModifier );
visitor.add( bondModifier );
visitor.setMode( RegionMode.HELICES );

// Use the visitor to modify a Chain.
chain.accept( visitor );


Constructor Summary
ModifierVisitor()
          Constructs a ModifierVisitor.
 
Method Summary
 void add(AtomModifier modifier)
          Adds a AtomModifier.
 void add(BondModifier modifier)
          Adds a BondModifier.
 void add(SegmentModifier modifier)
          Adds a SegmentModifier.
 void clear()
          Clears all memory of previously added Modifiers.
 boolean hasAtomModifier()
          Returns true if this ModifierVisitor holds an AtomModifier object.
 boolean hasBondModifier()
          Returns true if this ModifierVisitor holds a BondModifier object.
 boolean hasSegmentModifier()
          Returns true if this ModifierVisitor holds a SegmentModifier object.
 void visit(Atom atom)
          If an AtomModifier has been added, it will be used to modify the Atom.
 void visit(Bond bond)
          If a BondModifier has been added, it will be used to modify the Bond.
 void visit(Segment segment)
          If a SegmentModifier has been added, it will be used to modify the Segment.
 
Methods inherited from class org.proteinshader.structure.visitor.Visitor
includeAAHetAndWater, setDebug, setMode, setMode, setMode, setMode, setMode, setMode, setVisitSegments, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModifierVisitor

public ModifierVisitor()
Constructs a ModifierVisitor.

Method Detail

clear

public void clear()
Clears all memory of previously added Modifiers. Also calls clear() on the Visitor superclass, which will reset it to its default start-up state of RegionMode.NO_REGIONS, ResidueMode.ALL, AAPortionMode.ENTIRE_AA, and restrictions set to null.

Overrides:
clear in class Visitor

add

public void add(AtomModifier modifier)
Adds a AtomModifier. An argument of null can be used to clear the memory of the last AtomModifier added.

Parameters:
modifier - the AtomModifier to use.

add

public void add(BondModifier modifier)
Adds a BondModifier. An argument of null can be used to clear the memory of the last BondModifier added.

Parameters:
modifier - the BondModifier to use.

add

public void add(SegmentModifier modifier)
Adds a SegmentModifier. An argument of null can be used to clear the memory of the last BondModifier added.

Parameters:
modifier - the SegmentModifier to use.

visit

public void visit(Segment segment)
           throws VisitorException
If a SegmentModifier has been added, it will be used to modify the Segment.

Overrides:
visit in class Visitor
Parameters:
segment - the Segment to modify.
Throws:
VisitorException - if an error occurs during modifications.

visit

public void visit(Atom atom)
           throws VisitorException
If an AtomModifier has been added, it will be used to modify the Atom. The traversal will only be continued to Bonds if a BondModifier has been added.

Overrides:
visit in class Visitor
Parameters:
atom - the Atom to modify.
Throws:
VisitorException - if an error occurs during modifications.

visit

public void visit(Bond bond)
           throws VisitorException
If a BondModifier has been added, it will be used to modify the Bond.

Overrides:
visit in class Visitor
Parameters:
bond - the Bond to modify.
Throws:
VisitorException - if an error occurs during modifications.

hasAtomModifier

public boolean hasAtomModifier()
Returns true if this ModifierVisitor holds an AtomModifier object. Otherwise, returns false.

Returns:
True if there is an AtomModifier. Otherwise, false.

hasBondModifier

public boolean hasBondModifier()
Returns true if this ModifierVisitor holds a BondModifier object. Otherwise, returns false.

Returns:
True if there is an BondModifier. Otherwise, false.

hasSegmentModifier

public boolean hasSegmentModifier()
Returns true if this ModifierVisitor holds a SegmentModifier object. Otherwise, returns false.

Returns:
True if there is an SegmentModifier. Otherwise, false.


Copyright © 2007-2008