From: <sh...@us...> - 2006-11-03 14:15:51
|
Revision: 7233 http://svn.sourceforge.net/cdk/?rev=7233&view=rev Author: shk3 Date: 2006-11-03 06:15:22 -0800 (Fri, 03 Nov 2006) Log Message: ----------- this avoids the odd loyout if a branch is added to a ring + input of groups is not case-sensitive Modified Paths: -------------- trunk/cdk/src/org/openscience/cdk/applications/jchempaint/JChemPaintEditorPanel.java trunk/cdk/src/org/openscience/cdk/controller/AbstractController2D.java trunk/cdk/src/org/openscience/cdk/layout/AtomPlacer.java Modified: trunk/cdk/src/org/openscience/cdk/applications/jchempaint/JChemPaintEditorPanel.java =================================================================== --- trunk/cdk/src/org/openscience/cdk/applications/jchempaint/JChemPaintEditorPanel.java 2006-11-03 11:41:37 UTC (rev 7232) +++ trunk/cdk/src/org/openscience/cdk/applications/jchempaint/JChemPaintEditorPanel.java 2006-11-03 14:15:22 UTC (rev 7233) @@ -290,7 +290,10 @@ }else if(((char)i)=='\n' || ((char)i)=='\r'){ if(!sb.toString().equals("")){ StringTokenizer st=new StringTokenizer(sb.toString()); - funcgroups.put(st.nextElement(), sp.parseSmiles((String)st.nextElement())); + String key=(String)st.nextElement(); + String value=(String)st.nextElement(); + funcgroups.put(key, sp.parseSmiles(value)); + funcgroups.put(key.toUpperCase(), sp.parseSmiles(value)); sb=new StringBuffer(); } }else{ @@ -299,7 +302,10 @@ } if(!sb.toString().equals("")){ StringTokenizer st=new StringTokenizer(sb.toString()); - funcgroups.put(st.nextElement(), sp.parseSmiles((String)st.nextElement())); + String key=(String)st.nextElement(); + String value=(String)st.nextElement(); + funcgroups.put(key, sp.parseSmiles(value)); + funcgroups.put(key.toUpperCase(), sp.parseSmiles(value)); } }catch(Exception ex){ ex.printStackTrace(); Modified: trunk/cdk/src/org/openscience/cdk/controller/AbstractController2D.java =================================================================== --- trunk/cdk/src/org/openscience/cdk/controller/AbstractController2D.java 2006-11-03 11:41:37 UTC (rev 7232) +++ trunk/cdk/src/org/openscience/cdk/controller/AbstractController2D.java 2006-11-03 14:15:22 UTC (rev 7233) @@ -99,7 +99,7 @@ * @cdk.require java1.4+ * @cdk.module control */ - abstract class AbstractController2D implements MouseMotionListener, MouseListener, KeyListener +abstract class AbstractController2D implements MouseMotionListener, MouseListener, KeyListener { private final static int DRAG_UNSET = 0; @@ -1303,7 +1303,6 @@ String x=JOptionPane.showInputDialog(null,"Enter new element symbol"); try{ IAtomContainer ac=(IAtomContainer)funcgroupsmap.get(x); - String formerSymbol=""; //this means a functional group was entered //TODO undo-redo if(ac!=null){ @@ -1347,7 +1346,8 @@ if(r2dm.getRenderingCoordinate(atom)==null) r2dm.setRenderingCoordinate(atom, atom.getPoint2d()); } - }else{ + }else if(x!=null && x.length()>0){ + String formerSymbol=""; if(Character.isLowerCase(x.toCharArray()[0])) x=Character.toUpperCase(x.charAt(0))+x.substring(1); IsotopeFactory ifa=IsotopeFactory.getInstance(r2dm.getHighlightedAtom().getBuilder()); @@ -1358,23 +1358,22 @@ // update atom IAtomContainer container = ChemModelManipulator.getRelevantAtomContainer(chemModel, atomInRange); updateAtom(container, atomInRange); + /* + * PRESERVE THIS. This notifies the + * the listener responsible for + * undo and redo storage that it + * should store this change of an atom symbol + */ + isUndoableChange = true; + /* + * --- + */ + // undoredo support + UndoableEdit edit = new ChangeAtomSymbolEdit(atomInRange, formerSymbol, x); + undoRedoHandler.postEdit(edit); + r2dm.fireChange(); + fireChange(); } - - /* - * PRESERVE THIS. This notifies the - * the listener responsible for - * undo and redo storage that it - * should store this change of an atom symbol - */ - isUndoableChange = true; - /* - * --- - */ - // undoredo support - UndoableEdit edit = new ChangeAtomSymbolEdit(atomInRange, formerSymbol, x); - undoRedoHandler.postEdit(edit); - r2dm.fireChange(); - fireChange(); }catch(Exception ex){ ex.printStackTrace(); logger.debug(ex.getMessage()+" in SELECTELEMENT"); Modified: trunk/cdk/src/org/openscience/cdk/layout/AtomPlacer.java =================================================================== --- trunk/cdk/src/org/openscience/cdk/layout/AtomPlacer.java 2006-11-03 11:41:37 UTC (rev 7232) +++ trunk/cdk/src/org/openscience/cdk/layout/AtomPlacer.java 2006-11-03 14:15:22 UTC (rev 7233) @@ -191,7 +191,7 @@ * one placed neigbor, the chain placement methods * should be used. */ - if (placedNeighbours.getAtomCount() >= 1) + if (placedNeighbours.getAtomCount() == 1) { logger.debug("Only one neighbour..."); for (int f = 0; f < unplacedNeighbours.getAtomCount(); f++) @@ -594,6 +594,7 @@ { connectAtom = (IAtom) atomsToDraw.elementAt(i); renderingCoordinates.put(connectAtom, points.elementAt(i)); + connectAtom.setPoint2d((Point2d)points.elementAt(i)); connectAtom.setFlag(CDKConstants.ISPLACED, true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |