Permalink
Browse files

move get/setCursor from Renderer/IRenderer/AtomContainerRenderer to C…

…ontrollerHub/IChemModelRelay; fixes issue JChemPaint#13
  • Loading branch information...
rwst committed May 28, 2012
1 parent 0e0128e commit c58ca2fc63ead0d8b45090dc4a7a90e88af754cb
@@ -73,6 +73,7 @@
import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator;
import org.openscience.cdk.tools.manipulator.ReactionManipulator;
import org.openscience.cdk.validate.ProblemMarker;
import org.openscience.jchempaint.RenderPanel;
import org.openscience.jchempaint.applet.JChemPaintAbstractApplet;
import org.openscience.jchempaint.controller.undoredo.IUndoRedoFactory;
import org.openscience.jchempaint.controller.undoredo.IUndoRedoable;
@@ -111,7 +112,7 @@
private IRenderer renderer;
private IViewEventRelay eventRelay;
private RenderPanel eventRelay;

This comment has been minimized.

@egonw

egonw Jun 23, 2012

In general it is better to write against interfaces than implementations. Also, the commit message suggests to me you could reuse an existing class, but then you would simply remove an interface, not?

Anyway, getCursor() should indeed not be part of the Renderer... so, I second very much fixing that.

This comment has been minimized.

@rwst

rwst Jun 23, 2012

Owner

The reason for using the implementation was it was easier to do than changing the interface. You may want to open an issue for this in the tracker.

private List<IControllerModule> generalModules;
@@ -146,7 +147,7 @@
private String phantomText = null;
public ControllerHub(IControllerModel controllerModel, IRenderer renderer,
IChemModel chemModel, IViewEventRelay eventRelay,
IChemModel chemModel, RenderPanel eventRelay,
UndoRedoHandler undoredohandler, IUndoRedoFactory undoredofactory,
boolean isViewer, JChemPaintAbstractApplet applet) {
this.controllerModel = controllerModel;
@@ -272,8 +273,8 @@ public void mouseClickedDown(int screenX, int screenY) {
if (activeModule != null)
activeModule.mouseClickedDown(modelCoord);
if (renderer.getCursor() == Cursor.HAND_CURSOR
|| renderer.getCursor() == Cursor.HAND_CURSOR) {
if (getCursor() == Cursor.HAND_CURSOR
|| getCursor() == Cursor.HAND_CURSOR) {
setCursor(Cursor.MOVE_CURSOR);
oldMouseCursor = Cursor.HAND_CURSOR;
} else {
@@ -2655,8 +2656,22 @@ public IChemModel getChemModel() {
return chemModel;
}
/**
* Sets the mouse cursor shown on the renderPanel.
*
* @param cursor One of the constants from java.awt.Cursor.
*/
public void setCursor(int cursor) {
renderer.setCursor(cursor);
eventRelay.setCursor(new Cursor(cursor));
}
/**
* Tells the mouse cursor shown on the renderPanel.
*
* @return One of the constants from java.awt.Cursor.
*/
public int getCursor() {
return eventRelay.getCursor().getType();
}
/**
Oops, something went wrong.

5 comments on commit c58ca2f

@egonw

This comment has been minimized.

egonw replied Jun 23, 2012

Ralf, this is a patch that, when cleaned up should go into CDK/CDK-JChemPaint.

Do you think you can rebase it as patch on cdk-1.4.x?

@rwst

This comment has been minimized.

Owner

rwst replied Jun 23, 2012

What patch? The last 4 lines? You cannot mean the whole commit because it undoes something that is only in JCP. Please be more specific.

@egonw

This comment has been minimized.

egonw replied Jun 25, 2012

No, the full patch (minus that .orig file): c58ca2f

I am sorry... This GitHub review website is not too intuitive...

@rwst

This comment has been minimized.

Owner

rwst replied Jun 25, 2012

As this patch 1. removes something from Renderer that is only in JCP, and 2. adds something to ControllerHub. You can only mean 2. add getCursor functionality to ControllerHub in CDK. But I still haven't agreed to backport anything to CDK controller. Remember that I first wanted to have an overview to decide which parts of controller belong to JCP vs. CDK. This principle decision hasn't been made (and probably won't for some time), so I won't know if I'll backport that patch until then.

@egonw

This comment has been minimized.

egonw replied Jun 25, 2012

OK, understood :)

Please sign in to comment.