Skip to content

Commit b0a97a6

Browse files
egonwrajarshi
authored andcommitted
Extend the new QueryChemObject
Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
1 parent b98f650 commit b0a97a6

File tree

1 file changed

+5
-322
lines changed

1 file changed

+5
-322
lines changed

src/main/org/openscience/cdk/isomorphism/matchers/QueryAtom.java

Lines changed: 5 additions & 322 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,18 @@
1919
*/
2020
package org.openscience.cdk.isomorphism.matchers;
2121

22-
import java.util.ArrayList;
23-
import java.util.HashMap;
24-
import java.util.Iterator;
25-
import java.util.List;
26-
import java.util.Map;
27-
2822
import javax.vecmath.Point2d;
2923
import javax.vecmath.Point3d;
3024

3125
import org.openscience.cdk.CDKConstants;
32-
import org.openscience.cdk.event.ChemObjectChangeEvent;
33-
import org.openscience.cdk.interfaces.IAtom;
3426
import org.openscience.cdk.interfaces.IAtomType;
3527
import org.openscience.cdk.interfaces.IBond;
36-
import org.openscience.cdk.interfaces.IChemObjectBuilder;
37-
import org.openscience.cdk.interfaces.IChemObjectChangeEvent;
38-
import org.openscience.cdk.interfaces.IChemObjectListener;
3928

40-
public abstract class QueryAtom implements IQueryAtom {
29+
/**
30+
* @cdk.module isomorphism
31+
* @cdk.githash
32+
*/
33+
public abstract class QueryAtom extends QueryChemObject implements IQueryAtom {
4134

4235
/**
4336
* The partial charge of the atom.
@@ -134,26 +127,6 @@ public abstract class QueryAtom implements IQueryAtom {
134127
/** The atomic number for this element giving their position in the periodic table. */
135128
protected Integer atomicNumber = (Integer) CDKConstants.UNSET;
136129

137-
/**
138-
* List for listener administration.
139-
*/
140-
private List<IChemObjectListener> chemObjectListeners;
141-
142-
/**
143-
* A hashtable for the storage of any kind of properties of this IChemObject.
144-
*/
145-
private Map<Object, Object> properties;
146-
147-
/**
148-
* You will frequently have to use some flags on a IChemObject. For example, if
149-
* you want to draw a molecule and see if you've already drawn an atom, or in
150-
* a ring search to check whether a vertex has been visited in a graph
151-
* traversal. Use these flags while addressing particular positions in the
152-
* flag array with self-defined constants (flags[VISITED] = true). 100 flags
153-
* per object should be more than enough.
154-
*/
155-
private boolean[] flags;
156-
157130
public QueryAtom(String symbol) {
158131
this.symbol = symbol;
159132
}
@@ -661,294 +634,4 @@ public Integer getValency()
661634
return this.electronValency;
662635
}
663636

664-
/**
665-
* Lazy creation of chemObjectListeners List.
666-
*
667-
*@return List with the ChemObjects associated.
668-
*/
669-
private List<IChemObjectListener> lazyChemObjectListeners()
670-
{
671-
if (chemObjectListeners == null) {
672-
chemObjectListeners = new ArrayList<IChemObjectListener>();
673-
}
674-
return chemObjectListeners;
675-
}
676-
677-
678-
/**
679-
* Use this to add yourself to this IChemObject as a listener. In order to do
680-
* so, you must implement the ChemObjectListener Interface.
681-
*
682-
*@param col the ChemObjectListener
683-
*@see #removeListener
684-
*/
685-
public void addListener(IChemObjectListener col)
686-
{
687-
List<IChemObjectListener> listeners = lazyChemObjectListeners();
688-
689-
if (!listeners.contains(col))
690-
{
691-
listeners.add(col);
692-
}
693-
// Should we throw an exception if col is already in here or
694-
// just silently ignore it?
695-
}
696-
697-
698-
/**
699-
* Returns the number of ChemObjectListeners registered with this object.
700-
*
701-
*@return the number of registered listeners.
702-
*/
703-
public int getListenerCount() {
704-
if (chemObjectListeners == null) {
705-
return 0;
706-
}
707-
return lazyChemObjectListeners().size();
708-
}
709-
710-
711-
/**
712-
* Use this to remove a ChemObjectListener from the ListenerList of this
713-
* IChemObject. It will then not be notified of change in this object anymore.
714-
*
715-
*@param col The ChemObjectListener to be removed
716-
*@see #addListener
717-
*/
718-
public void removeListener(IChemObjectListener col) {
719-
if (chemObjectListeners == null) {
720-
return;
721-
}
722-
723-
List<IChemObjectListener> listeners = lazyChemObjectListeners();
724-
if (listeners.contains(col)) {
725-
listeners.remove(col);
726-
}
727-
}
728-
729-
730-
/**
731-
* This should be triggered by an method that changes the content of an object
732-
* to that the registered listeners can react to it.
733-
*/
734-
public void notifyChanged() {
735-
if (getNotification() && getListenerCount() > 0) {
736-
List<IChemObjectListener> listeners = lazyChemObjectListeners();
737-
for (Object listener : listeners) {
738-
((IChemObjectListener) listener).stateChanged(
739-
new ChemObjectChangeEvent(this)
740-
);
741-
}
742-
}
743-
}
744-
745-
746-
/**
747-
* This should be triggered by an method that changes the content of an object
748-
* to that the registered listeners can react to it. This is a version of
749-
* notifyChanged() which allows to propagate a change event while preserving
750-
* the original origin.
751-
*
752-
*@param evt A ChemObjectChangeEvent pointing to the source of where
753-
* the change happend
754-
*/
755-
public void notifyChanged(IChemObjectChangeEvent evt) {
756-
if (getNotification() && getListenerCount() > 0) {
757-
List<IChemObjectListener> listeners = lazyChemObjectListeners();
758-
for (Object listener : listeners) {
759-
((IChemObjectListener) listener).stateChanged(evt);
760-
}
761-
}
762-
}
763-
764-
765-
/**
766-
* Lazy creation of properties hash.
767-
*
768-
* @return Returns in instance of the properties
769-
*/
770-
private Map<Object, Object> lazyProperties()
771-
{
772-
if (properties == null)
773-
{
774-
properties = new HashMap<Object, Object>();
775-
}
776-
return properties;
777-
}
778-
779-
780-
/**
781-
* Sets a property for a IChemObject.
782-
*
783-
*@param description An object description of the property (most likely a
784-
* unique string)
785-
*@param property An object with the property itself
786-
*@see #getProperty
787-
*@see #removeProperty
788-
*/
789-
public void setProperty(Object description, Object property)
790-
{
791-
lazyProperties().put(description, property);
792-
notifyChanged();
793-
}
794-
795-
796-
/**
797-
* Removes a property for a IChemObject.
798-
*
799-
*@param description The object description of the property (most likely a
800-
* unique string)
801-
*@see #setProperty
802-
*@see #getProperty
803-
*/
804-
public void removeProperty(Object description)
805-
{
806-
if (properties == null) {
807-
return;
808-
}
809-
if (lazyProperties().remove(description) != null)
810-
notifyChanged();
811-
}
812-
813-
/**
814-
* Returns a property for the IChemObject.
815-
*
816-
*@param description An object description of the property (most likely a
817-
* unique string)
818-
*@return The object containing the property. Returns null if
819-
* propert is not set.
820-
*@see #setProperty
821-
*@see #removeProperty
822-
*/
823-
public Object getProperty(Object description)
824-
{
825-
if (properties != null) {
826-
return lazyProperties().get(description);
827-
}
828-
return null;
829-
}
830-
831-
/**
832-
* Returns a Map with the IChemObject's properties.
833-
*
834-
*@return The object's properties as an Hashtable
835-
*@see #setProperties
836-
*/
837-
public Map<Object,Object> getProperties()
838-
{
839-
return lazyProperties();
840-
}
841-
842-
/**
843-
* Returns the identifier (ID) of this object.
844-
*
845-
*@return a String representing the ID value
846-
*@see #setID
847-
*/
848-
public String getID()
849-
{
850-
return this.identifier;
851-
}
852-
853-
/**
854-
* Sets the identifier (ID) of this object.
855-
*
856-
*@param identifier a String representing the ID value
857-
*@see #getID
858-
*/
859-
public void setID(String identifier)
860-
{
861-
this.identifier = identifier;
862-
notifyChanged();
863-
}
864-
865-
/**
866-
* Sets the value of some flag.
867-
*
868-
*@param flag_type Flag to set
869-
*@param flag_value Value to assign to flag
870-
*@see #getFlag
871-
*/
872-
public void setFlag(int flag_type, boolean flag_value)
873-
{
874-
flags[flag_type] = flag_value;
875-
notifyChanged();
876-
}
877-
878-
/**
879-
* Returns the value of some flag.
880-
*
881-
*@param flag_type Flag to retrieve the value of
882-
*@return true if the flag <code>flag_type</code> is set
883-
*@see #setFlag
884-
*/
885-
public boolean getFlag(int flag_type)
886-
{
887-
return flags[flag_type];
888-
}
889-
890-
/**
891-
* Sets the properties of this object.
892-
*
893-
*@param properties a Hashtable specifying the property values
894-
*@see #getProperties
895-
*/
896-
public void setProperties(Map<Object,Object> properties)
897-
{
898-
Iterator<Object> keys = properties.keySet().iterator();
899-
while (keys.hasNext())
900-
{
901-
Object key = keys.next();
902-
lazyProperties().put(key, properties.get(key));
903-
}
904-
notifyChanged();
905-
}
906-
907-
private boolean doNotification = true;
908-
909-
/**
910-
* Sets the whole set of flags.
911-
*
912-
* @param flagsNew the new flags.
913-
* @see #getFlags
914-
*/
915-
public void setFlags(boolean[] flagsNew){
916-
flags=flagsNew;
917-
}
918-
919-
/**
920-
* Returns the whole set of flags.
921-
*
922-
*@return the flags.
923-
*@see #setFlags
924-
*/
925-
public boolean[] getFlags(){
926-
return(flags);
927-
}
928-
929-
public void setNotification(boolean bool) {
930-
this.doNotification = bool;
931-
}
932-
933-
public boolean getNotification() {
934-
return this.doNotification;
935-
}
936-
937-
@Override
938-
public IChemObjectBuilder getBuilder() {
939-
// TODO Auto-generated method stub
940-
return null;
941-
}
942-
943-
@Override
944-
public boolean matches(IAtom atom) {
945-
// TODO Auto-generated method stub
946-
return false;
947-
}
948-
949-
@Override
950-
public Object clone() throws CloneNotSupportedException {
951-
// TODO Auto-generated method stub
952-
return super.clone();
953-
}
954637
}

0 commit comments

Comments
 (0)