Skip to content

Commit

Permalink
increase reaction margin slightly to keep everything on the canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
novakps committed Apr 20, 2011
1 parent 2e6549c commit 43a202a
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 16 deletions.
219 changes: 219 additions & 0 deletions kemia/io/testdata.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions kemia/view/reaction_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ kemia.view.ReactionRenderer.prototype.render = function(reaction) {
if(!this.transform){
if (molecules.length>0){
var box = this.boundingBox(molecules);
var m = this.config.get("margin");
var m = this.config.get("reaction_margin");
box.expand(m, m, m, m);
this.setTransform(this.buildTransform(box));
} else {
Expand Down Expand Up @@ -109,5 +109,5 @@ kemia.view.ReactionRenderer.prototype.setScaleFactor = function(scale){
* A default configuration for renderer
*/
kemia.view.ReactionRenderer.defaultConfig = {
'margin' : 4
'reaction_margin' : 5
};
26 changes: 14 additions & 12 deletions kemia/view/reaction_renderer_demo.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>kemia.view.ReactionRenderer</title>
<script src="http://localhost:9810/compile?id=reaction_renderer_demo"></script>

</head>

<body >
<div id="reactionContainer" style="width: 1000px; height: 400px"></div>

</body>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
kemia.view.ReactionRenderer
</title>
<script src="http://localhost:9810/compile?id=reaction_renderer_demo" type="text/javascript">
</script>
</head>
<body>
<div id="reactionContainer" style="width: 1000px; height: 400px"></div>
<div id="reactionContainerNoReactants" style="width: 1000px; height: 400px"></div>
</body>
</html>
10 changes: 8 additions & 2 deletions kemia/view/reaction_renderer_demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@
function initPage(){
var c = new goog.debug.Console();
c.setCapturing(true);

var reaction = kemia.io.json.readReaction(kemia.io.Testdata.reactionDrawing);
var element = goog.dom.getElement('reactionContainer')
var graphics = goog.graphics.createGraphics(element.clientWidth,
element.clientHeight);
graphics.render(element);

var rr = new kemia.view.ReactionRenderer( graphics);

rr.render(reaction);
rr.moleculeRenderer.highlightOn(
reaction.getReactants()[0], 'blue');

var reactionNoReactants = kemia.io.json.readReaction(kemia.io.Testdata.reactionDrawingNoReactants);
var elementNoReactants = goog.dom.getElement('reactionContainerNoReactants');
var graphics2 = goog.graphics.createGraphics(elementNoReactants.clientWidth, element.clientHeight);
graphics2.render(elementNoReactants);
var rr2 = new kemia.view.ReactionRenderer( graphics2);
rr2.render(reactionNoReactants);
};

goog.events.listen(window, goog.events.EventType.LOAD, initPage);

0 comments on commit 43a202a

Please sign in to comment.