Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alt input mode (ring sprout, bond sprout, kekule/tautomer shifting) #199

Open
wants to merge 103 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
4834e4b
upgrade to cdk-2.9 and modification IRGroup
RvdPloeg Dec 13, 2024
5151894
remove core/target directory
RvdPloeg Jan 13, 2025
54bda34
removed all target directories
RvdPloeg Jan 13, 2025
a440f15
add gitignore and *.class
RvdPloeg Jan 13, 2025
408152f
Update .gitignore and remove ignored files from tracking
RvdPloeg Jan 14, 2025
225ed44
Update JNIInChIHandler.java
RvdPloeg Jan 16, 2025
52f6af5
Merge pull request #197 from RvdPloeg/update
johnmay Jan 21, 2025
8867acc
Move to CDK-2.10 cdk-annotation is now gone.
johnmay Jan 21, 2025
0f33139
Merge branch 'cdk-2.10-wip' of github.com:JChemPaint/jchempaint into …
johnmay Jan 21, 2025
887b861
Disable FitToScreen but default - not a nice option IMO
johnmay Jan 21, 2025
c97a5f0
Make sure atoms get added before bonds.
johnmay Jan 21, 2025
a1a77ec
Move to CDK 2.11-SNAPSHOT we need some changes to the CDK to fix things.
johnmay Jan 21, 2025
02845b0
Fix zoom behaviour, rotation can be 0 (on OS X trackpad) and the clam…
johnmay Jan 21, 2025
a2a9aa7
Allow modifiers to passed through when scrolling the mouse wheel. Mak…
johnmay Jan 21, 2025
057678d
Avoid reference/pointer comparision and use atom.equals() and bond.eq…
johnmay Jan 21, 2025
55d5081
Silence image missing warnings when we don't really need them (e.g. i…
johnmay Jan 22, 2025
f9b6a7c
Large overhaul to get things working reasonably well. The major chang…
johnmay Jan 22, 2025
2bdec8c
Fix and issue with adding Phenyl
johnmay Jan 22, 2025
a8d4af2
Get highlighting working correctly, there was lots of misuse of IChem…
johnmay Jan 22, 2025
e5b30f0
deleteFragment needs to use the Atom/Bond set
johnmay Jan 22, 2025
f444ec2
Document what pbg/pag are!
johnmay Jan 22, 2025
1dd04b6
More fixes around using the AtomBondSet
johnmay Jan 22, 2025
8e24669
Add in Snapshots repository
johnmay Jan 22, 2025
eefefd9
Fix selection ChemModel for logical selection.
johnmay Jan 22, 2025
b102057
Change zoom behaviour to be relative to the top corner, this is much …
johnmay Jan 22, 2025
9c6ba1b
Structure insertion needs some tweaks to make sure they are inserted …
johnmay Jan 22, 2025
054c714
Fix the chain tool.
johnmay Jan 23, 2025
9c449c1
Add atom module with phantom bond also needs the atoms.
johnmay Jan 23, 2025
782857d
Draw "atom in hand" when the add atom tool is selected.
johnmay Jan 23, 2025
599f79e
Centralise the bond length calculations on Renderer
johnmay Jan 23, 2025
c2ad315
Add an alt-input mode which allows sprouting rings on atoms easier, s…
johnmay Jan 23, 2025
584d4cb
Improved atom symbol quick-change key presses. We can get different s…
johnmay Jan 23, 2025
9c4eaed
Add bond short cuts to quickly set the bond order and wedge from a si…
johnmay Jan 23, 2025
55a688b
Advanced bond semantics, clicking a single bond can act as increment.…
johnmay Jan 23, 2025
7789586
Correct semantics for cycling the bond order.
johnmay Jan 23, 2025
8f12c3e
Fix comment.
johnmay Jan 23, 2025
b54cf82
Watch out for meta+Z for undo/redo etc
johnmay Jan 23, 2025
b35098a
Create correct ringSize
johnmay Jan 23, 2025
8392129
Show a phantom bond sprouting when placing a terminal atom (and selec…
johnmay Jan 23, 2025
74fbac9
clear phantoms whenever something is deleted
johnmay Jan 23, 2025
502d62d
Don'y cycle if bond is wedged
johnmay Jan 23, 2025
36c576a
Move the shortcuts to key pressed rather than released. This avoids f…
johnmay Jan 23, 2025
52f0466
Enforce a zig-zag chain no matter which way we are moving.
johnmay Jan 23, 2025
26558f4
Advanced chain placing semantics, a lesser known feature of Symyx Dra…
johnmay Jan 23, 2025
8dcd8fd
Disable the combo box listener as it causes a double insert more ofte…
johnmay Jan 23, 2025
b1830d3
We can reuse the existing cycleBondValence here.
johnmay Jan 23, 2025
8f91286
Cleaner if we redirect the "1" shortcut to cycle bond valence.
johnmay Jan 23, 2025
e65c21f
Add the option to cycle Kekulé form of a conjugated system.
johnmay Jan 23, 2025
0c01702
Need a temporary container to make sure atom placer works correctly.
johnmay Jan 24, 2025
20c0f8f
Make sure the bond display is also set.
johnmay Jan 24, 2025
73facfd
Allow both atoms of a bond to be updated at once.
johnmay Jan 24, 2025
c760d32
Slight tweek to phantom atoms... if Visit is set it is also in the ma…
johnmay Jan 24, 2025
07d8651
Major cleanup of the undo/redo stack, rather than use inheritance and…
johnmay Jan 24, 2025
02d45cd
Cleanup AdjustBondOrdersEdit to use entrySet iterator and to only upd…
johnmay Jan 24, 2025
d220193
Add a compound edit which allows us to combined multiple edits into a…
johnmay Jan 24, 2025
1605da1
When deleting something, the selection should take priority of any at…
johnmay Jan 24, 2025
ecdcd8c
Allow tautomers to be shifted like the conjugated rings.
johnmay Jan 24, 2025
6ff6697
Improve behaviour on miss-clicks, if a structure is highlighted and y…
johnmay Jan 24, 2025
ac61036
Fix RemoveAtomEdit... there was sometimes a double delete happening w…
johnmay Jan 24, 2025
ecd21a0
Update atoms once all bonds are added.
johnmay Jan 24, 2025
81c462c
Ensure the hydrogen counts are consisted across undo/redo - since by …
johnmay Jan 24, 2025
7b134d4
Improved OS X shortcuts
johnmay Jan 26, 2025
c4dbb09
It doesn't make sense to disable the atom/bond menus since this stops…
johnmay Jan 26, 2025
adca167
minor typo
johnmay Jan 26, 2025
3bd7dcc
Allow charge to be set on highlighted atom at the press of a key.
johnmay Jan 26, 2025
f006410
Improve the setting of symbols and undo/redo should not change the ma…
johnmay Jan 26, 2025
6ac68af
Expand the atom/bond hot keys and note that we need to move these to …
johnmay Jan 26, 2025
f27781a
Improved 2D rotation by snapping to 30 degree, alt can be held for fi…
johnmay Jan 28, 2025
ec106be
Similar to rotate if we flip around a bond, ignore the horizontal/ver…
johnmay Jan 28, 2025
46c8b24
Minor tweak don't continually set the cursor.
johnmay Jan 28, 2025
2262f75
Actually show which button/tool is active - we not to make the but op…
johnmay Jan 30, 2025
97c0e93
Allow modifiers on drag
johnmay Jan 30, 2025
d547407
Add the option to have not atom shape on selection and also allow the…
johnmay Jan 30, 2025
5e5957b
Minor tweak to logical selection to give it more utility.
johnmay Jan 30, 2025
5d888e0
Highlight bond shape
johnmay Jan 30, 2025
ad57dd3
Add some utilities to the JCP Renderer Model that will help is in hav…
johnmay Jan 30, 2025
67994aa
Add in a selection controls generator which will allow us to move/rot…
johnmay Jan 30, 2025
dc0ac66
Mouse relay drag modifiers
johnmay Jan 30, 2025
39403a1
Cleanup the IChemModelRelay and add some new type Scale/CursorType an…
johnmay Jan 30, 2025
5da0330
Use Set in Shape selection and a method which will allow a shape sele…
johnmay Jan 30, 2025
b22b9f6
Fix the selection semantics so we can properly do logical selections …
johnmay Jan 30, 2025
e64ada0
Optimize imports
johnmay Jan 30, 2025
37a717d
We should pull in the updated CDK AwtDrawVisitor but for now we shoul…
johnmay Jan 30, 2025
cec6012
Improved rotation module so we can reuse parts in the Move module
johnmay Jan 30, 2025
e0c7099
Some left over bits and pieces from modifying the control module. Set…
johnmay Jan 30, 2025
420a0df
Allow the MoveModule to do rotations/scaling when we using the contro…
johnmay Jan 30, 2025
af68cfb
Fix a minor bug when merging atoms - we need to check for multi-edges…
johnmay Jan 30, 2025
9964690
rotate cursor image
johnmay Jan 30, 2025
975a56b
Make sure updates are correct when adding/removing bonds and also whe…
johnmay Jan 30, 2025
18557bb
Simplify the AddRingModule/Action by moving the phantom handling logi…
johnmay Jan 30, 2025
f774ed5
Logic to allow the highlighted atom/bond to be moved with arrow key p…
johnmay Jan 30, 2025
ffa69f2
Improved chain placement semantics and some utilities to add differen…
johnmay Jan 30, 2025
01f84ad
Add more hot-keys (including moving the selection) and the option to …
johnmay Jan 30, 2025
3cc42df
Add an init option to use the old split generator or the new Standard…
johnmay Jan 30, 2025
af0f596
Improve the anchor bond choice when flipping
johnmay Jan 30, 2025
fd2a121
Use the bounds of a rendered atom to set the bounding box, make sure …
johnmay Jan 31, 2025
a381653
Simplify ShapeSelection
johnmay Jan 31, 2025
c88184e
Do not show the controls if a single atom is selected.
johnmay Jan 31, 2025
82317e9
Snap rotations to 10 degrees
johnmay Jan 31, 2025
0391286
Allow fragment selection with space.
johnmay Jan 31, 2025
cd36493
Rename the highlighted atom/bond variables.
johnmay Jan 31, 2025
2ae389a
If a highlighted atom is being erased we should set a new one.
johnmay Jan 31, 2025
7c1dac4
Applets are dead... make the default size of the Desktop application …
johnmay Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ dist/
*~
lib-licenses.txt
MANIFEST.MF
.gitignore
.classpath
.project
build.xml
**/*.class
**/target/
maven/jchempaint-nodeps/target/
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
10 changes: 0 additions & 10 deletions META-INF/MANIFEST.MF

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ new=meta N
open=meta O
saveAs=meta shift S
export=meta E
zoomin=typed +
zoomout=typed -
zoomin=meta EQUALS
zoomout=meta MINUS
plus=EQUALS
minus=MINUS
renderOptions=alt E
print=meta P
close=alt C
close=alt W
cut=meta X
copy=meta C
eraser=pressed DELETE
Expand Down
798 changes: 0 additions & 798 deletions build.xml

This file was deleted.

9 changes: 5 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.openscience.cdk</groupId>
<artifactId>cdk-annotation</artifactId>
</dependency>
<dependency>
<groupId>org.openscience.cdk</groupId>
<artifactId>cdk-atomtype</artifactId>
Expand Down Expand Up @@ -172,6 +168,11 @@
<artifactId>gettext-commons</artifactId>
<version>0.9.8</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
</dependency>
</dependencies>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public abstract class AbstractJChemPaintPanel extends JPanel{
private JComponent lastActionButton;
protected JMenuItem undoMenu;
protected JMenuItem redoMenu;
protected JMenu atomMenu;
protected JMenu bondMenu;
protected JMenu rgroupMenu;
protected boolean debug=false;
protected boolean modified = false;
Expand Down
84 changes: 84 additions & 0 deletions core/src/main/java/org/openscience/jchempaint/AtomBondSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package org.openscience.jchempaint;

import org.openscience.cdk.AtomRef;
import org.openscience.cdk.BondRef;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;

import java.util.ArrayList;
import java.util.List;

/**
* CDK 2.10 onwards enforces an invariant on AtomContainer's that a bond
* can not be stored unless it's atoms are also stored (a dangling bond).
* You must also add atoms before bonds in AtomContainer now.
* <br/>
* This class allows arbitrary sets of atoms and bonds to be stored without
* the no dangling bonds constraint. This is required because sometimes we merge
* /delete/update bonds.
*/
public class AtomBondSet {

private final List<IAtom> atoms = new ArrayList<>();
private final List<IBond> bonds = new ArrayList<>();

public AtomBondSet() {
}

public AtomBondSet(IAtomContainer mol) {
for (IAtom atom : mol.atoms())
atoms.add(AtomRef.deref(atom));
for (IBond bond : mol.bonds())
bonds.add(BondRef.deref(bond));
}

public Iterable<IAtom> atoms() {
return atoms;
}

public Iterable<IBond> bonds() {
return bonds;
}

public int getAtomCount() {
return atoms.size();
}

public int getBondCount() {
return bonds.size();
}

public void add(IAtom atom) {
atoms.add(atom);
}

public void add(IBond bond) {
bonds.add(bond);
}

public void remove(IBond bond) {
bonds.remove(bond);
}

public void remove(IAtom atom) {
atoms.remove(atom);
}

public boolean contains(IAtom atom) {
return atoms.contains(atom);
}

public boolean contains(IBond bond) {
return bonds.contains(bond);
}

public boolean isEmpty() {
return atoms.isEmpty() && bonds.isEmpty();
}

public IAtom getSingleAtom() {
if (atoms.size() != 1) throw new IllegalArgumentException();
return atoms.get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public InsertTextPanel(AbstractJChemPaintPanel jChemPaintPanel, JFrame closeafte
textCombo = new JComboBox<String>(oldText.toArray(new String[]{}));
textCombo.setEditable(true);
textCombo.setToolTipText(GT.get("Enter a CAS, SMILES or InChI string"));

textCombo.addActionListener(this);
// textCombo.addActionListener(this); // this can cause double inserts
editor = (JTextComponent) textCombo.getEditor().getEditorComponent();

button.addActionListener(this);
Expand Down Expand Up @@ -116,7 +115,7 @@ public void actionPerformed(ActionEvent actionEvent) {
if (molecule == null)
return;
try {
JChemPaint.generateModel(jChemPaintPanel, molecule, true, false);
JChemPaint.generateModel(jChemPaintPanel, molecule, true, true);
} catch (CDKException e) {
e.printStackTrace();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ public ResourceBundle getResources()


/**
* Returns an URL build from the path of this object and another part that is
* searched in the properties file. Used to find the images for the buttons.
* Returns an URL build from the path of this object and another part that is
* searched in the properties file. Used to find the images for the buttons.
*
*@param key String The String that says which image is searched
*@return URL The URL where the image is located
* @param key String The String that says which image is searched
* @return URL The URL where the image is located
*/
public URL getResource(String key)
{
Expand All @@ -307,13 +307,29 @@ public URL getResource(String key)
return null;
}

/**
* Returns the resource URL from the properties file that follows the given
* String, if the resource is not found, no log message is emitted.
*
* @param key String The String to be looked after
* @return URL The URL where the image is located
*/
public URL getOptionalResource(String key)
{
try {
return getClass().getResource(getResources().getString(key));
} catch (MissingResourceException ignore) {
return null;
}
}


/**
* Returns the ResourceString from the properties file that follows the given
* String.
* Returns the ResourceString from the properties file that follows the given
* String.
*
*@param key String The String to be looked after
*@return String The String that follows the key in the properties file
* @param key String The String to be looked after
* @return String The String that follows the key in the properties file
*/
public String getResourceString(String key)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class JCPToolBar
private static ILoggingTool logger =
LoggingToolFactory.createLoggingTool(JCPToolBar.class);
public static Color BUTTON_INACTIVE_COLOR=Color.WHITE;//new Color(230,230,230);
public static Color BUTON_ACTIVE_COLOR=new Color(98, 182, 207, 111);
/**
* Gets the toolbar attribute of the MainContainerPanel object
*
Expand Down Expand Up @@ -173,7 +174,7 @@ public float getAlignmentY()
logger.warn("Could not find Tooltip resource for: ", key);
logger.debug(e);
}
URL disabledurl = jcpph.getResource(key + JCPAction.disabled_imageSuffix);
URL disabledurl = jcpph.getOptionalResource(key + JCPAction.disabled_imageSuffix);
logger.debug("Trying to find resource: ", url);
if (disabledurl != null){
ImageIcon disabledimage = new ImageIcon(disabledurl);
Expand Down Expand Up @@ -247,13 +248,15 @@ public static Component createToolbar(int orientation, String kind, AbstractJChe
if (toolKeys[i].equals("bondTool")) {
//button.setBackground(Color.GRAY);
button.setBackground(new Color(238, 238, 238));
button.setOpaque(true);
chemPaintPanel.setLastActionButton(button);
AddBondDragModule activeModule = new AddBondDragModule(chemPaintPanel.get2DHub(), IBond.Stereo.NONE, true);
activeModule.setID(toolKeys[i]);
chemPaintPanel.get2DHub().setActiveDrawModule(activeModule);
} else if (toolKeys[i].equals("C")) {
button.setBackground(Color.GRAY);
chemPaintPanel.setLastSecondaryButton(button);
button.setOpaque(true);
} else {
button.setBackground(BUTTON_INACTIVE_COLOR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.swing.event.MenuListener;

import org.openscience.cdk.config.XMLIsotopeFactory;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IIsotope;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;
Expand Down Expand Up @@ -132,14 +133,6 @@ else if (itemKeys[i].startsWith("@")) {
}
}
}
if(key.equals("atomMenu")){
jcpPanel.atomMenu=(JMenu)menu;
jcpPanel.enOrDisableMenus((JMenu)menu, false);
}
if(key.equals("bondMenu")){
jcpPanel.bondMenu=(JMenu)menu;
jcpPanel.enOrDisableMenus((JMenu)menu, false);
}

if(key.equals("isotopeChange")){
((JMenu)menu).addMenuListener(new MenuListener(){
Expand All @@ -155,11 +148,11 @@ public void menuSelected(MenuEvent arg0) {
//is empty, various commands return null
if((SwingPopupModule.lastAtomPopupedFor!=null && SwingPopupModule.lastAtomPopupedFor.getSymbol()!=null)
|| (jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection()!=null &&
jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().getConnectedAtomContainer()!=null &&
jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().getConnectedAtomContainer().getAtomCount()>0)){
!jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().elements(IAtom.class).isEmpty())){
try {
String symbol;
if(jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().getConnectedAtomContainer()!=null && jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().getConnectedAtomContainer().getAtomCount()>0)
if(jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().getConnectedAtomContainer()!=null &&
!jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().elements(IAtom.class).isEmpty())
symbol = jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().getConnectedAtomContainer().getAtom(0).getSymbol();
else
symbol = SwingPopupModule.lastAtomPopupedFor.getSymbol();
Expand Down Expand Up @@ -259,14 +252,14 @@ protected JMenuItem createMenuItem(AbstractJChemPaintPanel jcpPanel, String cmd,
mi = new JMenuItem(translation);
}
JCPPropertyHandler jcpph = JCPPropertyHandler.getInstance(true);
URL url = jcpph.getResource(cmd + JCPAction.imageSuffix);
URL url = jcpph.getOptionalResource(cmd + JCPAction.imageSuffix);
if (url != null)
{
ImageIcon image = new ImageIcon(url);
Image img = image.getImage();
Image newimg = img.getScaledInstance(16, 16, java.awt.Image.SCALE_SMOOTH);
mi.setIcon(new ImageIcon(newimg));
URL disabledurl = jcpph.getResource(cmd + JCPAction.disabled_imageSuffix);
URL disabledurl = jcpph.getOptionalResource(cmd + JCPAction.disabled_imageSuffix);
if (disabledurl != null){
ImageIcon disabledimage = new ImageIcon(disabledurl);
if (image != null){
Expand Down Expand Up @@ -317,7 +310,7 @@ protected JMenuItem createMenuItem(AbstractJChemPaintPanel jcpPanel, String cmd,
* for zooming is problematic.<br>
* More here: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4262044
*
* @param cmd String The Strin to identify the MenuItem.
* @param cmd String The String to identify the MenuItem.
* @param mi the regarding MenuItem.
* @param jcp The JChemPaintPanel this menu is used for.
*/
Expand Down
Loading
Loading