X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fappletgui%2FRotatableCanvas.js;fp=site%2Fj2s%2Fjalview%2Fappletgui%2FRotatableCanvas.js;h=5e61deac01c718ec8b2a41b783244704d96b13b4;hp=0bb0b4a47f2e7045c69adcf324a5ccf218b28479;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jalview/appletgui/RotatableCanvas.js b/site/j2s/jalview/appletgui/RotatableCanvas.js index 0bb0b4a..5e61dea 100644 --- a/site/j2s/jalview/appletgui/RotatableCanvas.js +++ b/site/j2s/jalview/appletgui/RotatableCanvas.js @@ -1,371 +1,371 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "jalview.api.RotatableCanvasI", "java.awt.event.KeyListener", "$.MouseListener", "$.MouseMotionListener", "jalview.math.RotatableMatrix"], "jalview.appletgui.RotatableCanvas", ["jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "jalview.util.Format", "$.MessageManager", "java.awt.Color", "$.Dimension", "$.Font"], function () { -c$ = Clazz.decorateAsClass (function () { -this.idmat = null; -this.objmat = null; -this.rotmat = null; -this.tooltip = null; -this.toolx = 0; -this.tooly = 0; -this.$drawAxes = true; -this.omx = 0; -this.mx = 0; -this.omy = 0; -this.my = 0; -this.img = null; -this.ig = null; -this.prefsize = null; -this.centre = null; -this.$width = null; -this.max = null; -this.min = null; -this.maxwidth = 0; -this.scale = 0; -this.npoint = 0; -this.points = null; -this.orig = null; -this.axes = null; -this.startx = 0; -this.starty = 0; -this.lastx = 0; -this.lasty = 0; -this.rectx1 = 0; -this.recty1 = 0; -this.rectx2 = 0; -this.recty2 = 0; -this.scalefactor = 1; -this.av = null; -this.$showLabels = false; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "RotatableCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, jalview.api.RotatableCanvasI]); -Clazz.prepareFields (c$, function () { -this.idmat = new jalview.math.RotatableMatrix (3, 3); -this.objmat = new jalview.math.RotatableMatrix (3, 3); -this.rotmat = new jalview.math.RotatableMatrix (3, 3); -this.centre = Clazz.newFloatArray (3, 0); -this.$width = Clazz.newFloatArray (3, 0); -this.max = Clazz.newFloatArray (3, 0); -this.min = Clazz.newFloatArray (3, 0); -}); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.RotatableCanvas, []); -this.av = av; -}, "jalview.viewmodel.AlignmentViewport"); -Clazz.defineMethod (c$, "showLabels", -function (b) { -this.$showLabels = b; -this.repaint (); -}, "~B"); -Clazz.overrideMethod (c$, "setPoints", -function (points, npoint) { -this.points = points; -this.npoint = npoint; -jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ()); -this.prefsize = this.getPreferredSize (); -this.orig = Clazz.newFloatArray (npoint, 3, 0); -for (var i = 0; i < npoint; i++) { -var sp = points.elementAt (i); -for (var j = 0; j < 3; j++) { -this.orig[i][j] = sp.coord[j]; -} -} -for (var i = 0; i < 3; i++) { -for (var j = 0; j < 3; j++) { -if (i != j) { -this.idmat.addElement (i, j, 0); -this.objmat.addElement (i, j, 0); -this.rotmat.addElement (i, j, 0); -} else { -this.idmat.addElement (i, j, 0); -this.objmat.addElement (i, j, 0); -this.rotmat.addElement (i, j, 0); -}} -} -this.axes = Clazz.newFloatArray (3, 3, 0); -this.initAxes (); -this.findCentre (); -this.findWidth (); -this.scale = this.findScale (); -this.addMouseListener (this); -this.addKeyListener (this); -this.addMouseMotionListener (this); -}, "java.util.Vector,~N"); -Clazz.defineMethod (c$, "initAxes", -function () { -for (var i = 0; i < 3; i++) { -for (var j = 0; j < 3; j++) { -if (i != j) { -this.axes[i][j] = 0; -} else { -this.axes[i][j] = 1; -}} -} -}); -Clazz.defineMethod (c$, "findWidth", -function () { -this.max = Clazz.newFloatArray (3, 0); -this.min = Clazz.newFloatArray (3, 0); -this.max[0] = -1.0E30; -this.max[1] = -1.0E30; -this.max[2] = -1.0E30; -this.min[0] = 1e30; -this.min[1] = 1e30; -this.min[2] = 1e30; -for (var i = 0; i < 3; i++) { -for (var j = 0; j < this.npoint; j++) { -var sp = this.points.elementAt (j); -if (sp.coord[i] >= this.max[i]) { -this.max[i] = sp.coord[i]; -}if (sp.coord[i] <= this.min[i]) { -this.min[i] = sp.coord[i]; -}} -} -this.$width[0] = Math.abs (this.max[0] - this.min[0]); -this.$width[1] = Math.abs (this.max[1] - this.min[1]); -this.$width[2] = Math.abs (this.max[2] - this.min[2]); -this.maxwidth = this.$width[0]; -if (this.$width[1] > this.$width[0]) { -this.maxwidth = this.$width[1]; -}if (this.$width[2] > this.$width[1]) { -this.maxwidth = this.$width[2]; -}}); -Clazz.defineMethod (c$, "findScale", -function () { -var dim; -var width; -var height; -if (this.getSize ().width != 0) { -width = this.getSize ().width; -height = this.getSize ().height; -} else { -width = this.prefsize.width; -height = this.prefsize.height; -}if (width < height) { -dim = width; -} else { -dim = height; -}return dim * this.scalefactor / (2 * this.maxwidth); -}); -Clazz.defineMethod (c$, "findCentre", -function () { -this.findWidth (); -this.centre[0] = (this.max[0] + this.min[0]) / 2; -this.centre[1] = (this.max[1] + this.min[1]) / 2; -this.centre[2] = (this.max[2] + this.min[2]) / 2; -}); -Clazz.overrideMethod (c$, "getPreferredSize", -function () { -if (this.prefsize != null) { -return this.prefsize; -} else { -return new java.awt.Dimension (400, 400); -}}); -Clazz.overrideMethod (c$, "getMinimumSize", -function () { -return this.getPreferredSize (); -}); -Clazz.overrideMethod (c$, "update", -function (g) { -this.paint (g); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "PaintComponent", -function (g) { -if (this.points == null) { -g.setFont ( new java.awt.Font ("Verdana", 0, 18)); -g.drawString (jalview.util.MessageManager.getString ("label.calculating_pca") + "....", 20, Clazz.doubleToInt (this.getSize ().height / 2)); -} else { -if ((this.img == null) || (this.prefsize.width != this.getSize ().width) || (this.prefsize.height != this.getSize ().height)) { -this.prefsize.width = this.getSize ().width; -this.prefsize.height = this.getSize ().height; -this.scale = this.findScale (); -this.img = this.createImage (this.getSize ().width, this.getSize ().height); -this.ig = this.img.getGraphics (); -}this.drawBackground (this.ig, java.awt.Color.black); -this.drawScene (this.ig); -if (this.$drawAxes == true) { -this.drawAxes (this.ig); -}if (this.tooltip != null) { -this.ig.setColor (java.awt.Color.red); -this.ig.drawString (this.tooltip, this.toolx, this.tooly); -}g.drawImage (this.img, 0, 0, this); -}}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "drawAxes", -function (g) { -g.setColor (java.awt.Color.yellow); -for (var i = 0; i < 3; i++) { -g.drawLine (Clazz.doubleToInt (this.getSize ().width / 2), Clazz.doubleToInt (this.getSize ().height / 2), Clazz.floatToInt (this.axes[i][0] * this.scale * this.max[0] + Clazz.doubleToInt (this.getSize ().width / 2)), Clazz.floatToInt (this.axes[i][1] * this.scale * this.max[1] + Clazz.doubleToInt (this.getSize ().height / 2))); -} -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "drawBackground", -function (g, col) { -g.setColor (col); -g.fillRect (0, 0, this.prefsize.width, this.prefsize.height); -}, "java.awt.Graphics,java.awt.Color"); -Clazz.defineMethod (c$, "drawScene", -function (g) { -var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2); -var halfheight = Clazz.doubleToInt (this.getSize ().height / 2); -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -var x = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth; -var y = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight; -var z = sp.coord[1] - this.centre[2]; -if (this.av.getSequenceColour (sp.sequence) === java.awt.Color.black) { -g.setColor (java.awt.Color.white); -} else { -g.setColor (this.av.getSequenceColour (sp.sequence)); -}if (this.av.getSelectionGroup () != null) { -if (this.av.getSelectionGroup ().getSequences (null).contains ((this.points.elementAt (i)).sequence)) { -g.setColor (java.awt.Color.gray); -}}if (z < 0) { -g.setColor (g.getColor ().darker ()); -}g.fillRect (x - 3, y - 3, 6, 6); -if (this.$showLabels) { -g.setColor (java.awt.Color.red); -g.drawString ((this.points.elementAt (i)).sequence.getName (), x - 3, y - 4); -}} -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "minimumsize", -function () { -return this.prefsize; -}); -Clazz.defineMethod (c$, "preferredsize", -function () { -return this.prefsize; -}); -Clazz.overrideMethod (c$, "keyTyped", -function (evt) { -}, "java.awt.event.KeyEvent"); -Clazz.overrideMethod (c$, "keyReleased", -function (evt) { -}, "java.awt.event.KeyEvent"); -Clazz.overrideMethod (c$, "keyPressed", -function (evt) { -if (evt.getKeyCode () == 38) { -this.scalefactor = (this.scalefactor * 1.1); -this.scale = this.findScale (); -} else if (evt.getKeyCode () == 40) { -this.scalefactor = (this.scalefactor * 0.9); -this.scale = this.findScale (); -} else if (evt.getKeyChar () == 's') { -System.err.println ("DEBUG: Rectangle selection"); -if (this.rectx2 != -1 && this.recty2 != -1) { -this.rectSelect (this.rectx1, this.recty1, this.rectx2, this.recty2); -}}this.repaint (); -}, "java.awt.event.KeyEvent"); -Clazz.defineMethod (c$, "printPoints", -function () { -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -jalview.util.Format.printLong (System.out, "%5d ", i); -for (var j = 0; j < 3; j++) { -jalview.util.Format.printDouble (System.out, "%13.3f ", sp.coord[j]); -} -System.out.println (); -} -}); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -var x = evt.getX (); -var y = evt.getY (); -this.mx = x; -this.my = y; -this.omx = this.mx; -this.omy = this.my; -this.startx = x; -this.starty = y; -this.rectx1 = x; -this.recty1 = y; -this.rectx2 = -1; -this.recty2 = -1; -var found = this.findPoint (x, y); -if (found != null) { -if (this.av.getSelectionGroup () != null) { -this.av.getSelectionGroup ().addOrRemove (found, true); -this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); -} else { -this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ()); -this.av.getSelectionGroup ().addOrRemove (found, true); -this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); -}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); -this.av.sendSelection (); -}this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -var found = this.findPoint (evt.getX (), evt.getY ()); -if (found == null) { -this.tooltip = null; -} else { -this.tooltip = found.getName (); -this.toolx = evt.getX (); -this.tooly = evt.getY (); -}this.repaint (); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -this.mx = evt.getX (); -this.my = evt.getY (); -this.rotmat.setIdentity (); -this.rotmat.rotate (this.my - this.omy, 'x'); -this.rotmat.rotate (this.mx - this.omx, 'y'); -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -sp.coord[0] -= this.centre[0]; -sp.coord[1] -= this.centre[1]; -sp.coord[2] -= this.centre[2]; -sp.coord = this.rotmat.vectorMultiply (sp.coord); -sp.coord[0] += this.centre[0]; -sp.coord[1] += this.centre[1]; -sp.coord[2] += this.centre[2]; -} -for (var i = 0; i < 3; i++) { -this.axes[i] = this.rotmat.vectorMultiply (this.axes[i]); -} -this.omx = this.mx; -this.omy = this.my; -this.paint (this.getGraphics ()); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "rectSelect", -function (x1, y1, x2, y2) { -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -var tmp1 = Clazz.doubleToInt ((sp.coord[0] - this.centre[0]) * this.scale + this.getSize ().width / 2.0); -var tmp2 = Clazz.doubleToInt ((sp.coord[1] - this.centre[1]) * this.scale + this.getSize ().height / 2.0); -if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) { -if (this.av != null) { -if (!this.av.getSelectionGroup ().getSequences (null).contains (sp.sequence)) { -this.av.getSelectionGroup ().addSequence (sp.sequence, true); -}}}} -}, "~N,~N,~N,~N"); -Clazz.defineMethod (c$, "findPoint", -function (x, y) { -var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2); -var halfheight = Clazz.doubleToInt (this.getSize ().height / 2); -var found = -1; -for (var i = 0; i < this.npoint; i++) { -var sp = this.points.elementAt (i); -var px = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth; -var py = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight; -if (Math.abs (px - x) < 3 && Math.abs (py - y) < 3) { -found = i; -}} -if (found != -1) { -return (this.points.elementAt (found)).sequence; -} else { -return null; -}}, "~N,~N"); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "jalview.api.RotatableCanvasI", "java.awt.event.KeyListener", "$.MouseListener", "$.MouseMotionListener", "jalview.math.RotatableMatrix"], "jalview.appletgui.RotatableCanvas", ["jalview.appletgui.PaintRefresher", "jalview.datamodel.SequenceGroup", "jalview.util.Format", "$.MessageManager", "java.awt.Color", "$.Dimension", "$.Font"], function () { +c$ = Clazz.decorateAsClass (function () { +this.idmat = null; +this.objmat = null; +this.rotmat = null; +this.tooltip = null; +this.toolx = 0; +this.tooly = 0; +this.$drawAxes = true; +this.omx = 0; +this.mx = 0; +this.omy = 0; +this.my = 0; +this.img = null; +this.ig = null; +this.prefsize = null; +this.centre = null; +this.$width = null; +this.max = null; +this.min = null; +this.maxwidth = 0; +this.scale = 0; +this.npoint = 0; +this.points = null; +this.orig = null; +this.axes = null; +this.startx = 0; +this.starty = 0; +this.lastx = 0; +this.lasty = 0; +this.rectx1 = 0; +this.recty1 = 0; +this.rectx2 = 0; +this.recty2 = 0; +this.scalefactor = 1; +this.av = null; +this.$showLabels = false; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "RotatableCanvas", awt2swing.Panel, [java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, jalview.api.RotatableCanvasI]); +Clazz.prepareFields (c$, function () { +this.idmat = new jalview.math.RotatableMatrix (3, 3); +this.objmat = new jalview.math.RotatableMatrix (3, 3); +this.rotmat = new jalview.math.RotatableMatrix (3, 3); +this.centre = Clazz.newFloatArray (3, 0); +this.$width = Clazz.newFloatArray (3, 0); +this.max = Clazz.newFloatArray (3, 0); +this.min = Clazz.newFloatArray (3, 0); +}); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.RotatableCanvas, []); +this.av = av; +}, "jalview.viewmodel.AlignmentViewport"); +Clazz.defineMethod (c$, "showLabels", +function (b) { +this.$showLabels = b; +this.repaint (); +}, "~B"); +Clazz.overrideMethod (c$, "setPoints", +function (points, npoint) { +this.points = points; +this.npoint = npoint; +jalview.appletgui.PaintRefresher.Register (this, this.av.getSequenceSetId ()); +this.prefsize = this.getPreferredSize (); +this.orig = Clazz.newFloatArray (npoint, 3, 0); +for (var i = 0; i < npoint; i++) { +var sp = points.elementAt (i); +for (var j = 0; j < 3; j++) { +this.orig[i][j] = sp.coord[j]; +} +} +for (var i = 0; i < 3; i++) { +for (var j = 0; j < 3; j++) { +if (i != j) { +this.idmat.addElement (i, j, 0); +this.objmat.addElement (i, j, 0); +this.rotmat.addElement (i, j, 0); +} else { +this.idmat.addElement (i, j, 0); +this.objmat.addElement (i, j, 0); +this.rotmat.addElement (i, j, 0); +}} +} +this.axes = Clazz.newFloatArray (3, 3, 0); +this.initAxes (); +this.findCentre (); +this.findWidth (); +this.scale = this.findScale (); +this.addMouseListener (this); +this.addKeyListener (this); +this.addMouseMotionListener (this); +}, "java.util.Vector,~N"); +Clazz.defineMethod (c$, "initAxes", +function () { +for (var i = 0; i < 3; i++) { +for (var j = 0; j < 3; j++) { +if (i != j) { +this.axes[i][j] = 0; +} else { +this.axes[i][j] = 1; +}} +} +}); +Clazz.defineMethod (c$, "findWidth", +function () { +this.max = Clazz.newFloatArray (3, 0); +this.min = Clazz.newFloatArray (3, 0); +this.max[0] = -1.0E30; +this.max[1] = -1.0E30; +this.max[2] = -1.0E30; +this.min[0] = 1e30; +this.min[1] = 1e30; +this.min[2] = 1e30; +for (var i = 0; i < 3; i++) { +for (var j = 0; j < this.npoint; j++) { +var sp = this.points.elementAt (j); +if (sp.coord[i] >= this.max[i]) { +this.max[i] = sp.coord[i]; +}if (sp.coord[i] <= this.min[i]) { +this.min[i] = sp.coord[i]; +}} +} +this.$width[0] = Math.abs (this.max[0] - this.min[0]); +this.$width[1] = Math.abs (this.max[1] - this.min[1]); +this.$width[2] = Math.abs (this.max[2] - this.min[2]); +this.maxwidth = this.$width[0]; +if (this.$width[1] > this.$width[0]) { +this.maxwidth = this.$width[1]; +}if (this.$width[2] > this.$width[1]) { +this.maxwidth = this.$width[2]; +}}); +Clazz.defineMethod (c$, "findScale", +function () { +var dim; +var width; +var height; +if (this.getSize ().width != 0) { +width = this.getSize ().width; +height = this.getSize ().height; +} else { +width = this.prefsize.width; +height = this.prefsize.height; +}if (width < height) { +dim = width; +} else { +dim = height; +}return dim * this.scalefactor / (2 * this.maxwidth); +}); +Clazz.defineMethod (c$, "findCentre", +function () { +this.findWidth (); +this.centre[0] = (this.max[0] + this.min[0]) / 2; +this.centre[1] = (this.max[1] + this.min[1]) / 2; +this.centre[2] = (this.max[2] + this.min[2]) / 2; +}); +Clazz.overrideMethod (c$, "getPreferredSize", +function () { +if (this.prefsize != null) { +return this.prefsize; +} else { +return new java.awt.Dimension (400, 400); +}}); +Clazz.overrideMethod (c$, "getMinimumSize", +function () { +return this.getPreferredSize (); +}); +Clazz.overrideMethod (c$, "update", +function (g) { +this.paint (g); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "PaintComponent", +function (g) { +if (this.points == null) { +g.setFont ( new java.awt.Font ("Verdana", 0, 18)); +g.drawString (jalview.util.MessageManager.getString ("label.calculating_pca") + "....", 20, Clazz.doubleToInt (this.getSize ().height / 2)); +} else { +if ((this.img == null) || (this.prefsize.width != this.getSize ().width) || (this.prefsize.height != this.getSize ().height)) { +this.prefsize.width = this.getSize ().width; +this.prefsize.height = this.getSize ().height; +this.scale = this.findScale (); +this.img = this.createImage (this.getSize ().width, this.getSize ().height); +this.ig = this.img.getGraphics (); +}this.drawBackground (this.ig, java.awt.Color.black); +this.drawScene (this.ig); +if (this.$drawAxes == true) { +this.drawAxes (this.ig); +}if (this.tooltip != null) { +this.ig.setColor (java.awt.Color.red); +this.ig.drawString (this.tooltip, this.toolx, this.tooly); +}g.drawImage (this.img, 0, 0, this); +}}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "drawAxes", +function (g) { +g.setColor (java.awt.Color.yellow); +for (var i = 0; i < 3; i++) { +g.drawLine (Clazz.doubleToInt (this.getSize ().width / 2), Clazz.doubleToInt (this.getSize ().height / 2), Clazz.floatToInt (this.axes[i][0] * this.scale * this.max[0] + Clazz.doubleToInt (this.getSize ().width / 2)), Clazz.floatToInt (this.axes[i][1] * this.scale * this.max[1] + Clazz.doubleToInt (this.getSize ().height / 2))); +} +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "drawBackground", +function (g, col) { +g.setColor (col); +g.fillRect (0, 0, this.prefsize.width, this.prefsize.height); +}, "java.awt.Graphics,java.awt.Color"); +Clazz.defineMethod (c$, "drawScene", +function (g) { +var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2); +var halfheight = Clazz.doubleToInt (this.getSize ().height / 2); +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +var x = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth; +var y = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight; +var z = sp.coord[1] - this.centre[2]; +if (this.av.getSequenceColour (sp.sequence) === java.awt.Color.black) { +g.setColor (java.awt.Color.white); +} else { +g.setColor (this.av.getSequenceColour (sp.sequence)); +}if (this.av.getSelectionGroup () != null) { +if (this.av.getSelectionGroup ().getSequences (null).contains ((this.points.elementAt (i)).sequence)) { +g.setColor (java.awt.Color.gray); +}}if (z < 0) { +g.setColor (g.getColor ().darker ()); +}g.fillRect (x - 3, y - 3, 6, 6); +if (this.$showLabels) { +g.setColor (java.awt.Color.red); +g.drawString ((this.points.elementAt (i)).sequence.getName (), x - 3, y - 4); +}} +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "minimumsize", +function () { +return this.prefsize; +}); +Clazz.defineMethod (c$, "preferredsize", +function () { +return this.prefsize; +}); +Clazz.overrideMethod (c$, "keyTyped", +function (evt) { +}, "java.awt.event.KeyEvent"); +Clazz.overrideMethod (c$, "keyReleased", +function (evt) { +}, "java.awt.event.KeyEvent"); +Clazz.overrideMethod (c$, "keyPressed", +function (evt) { +if (evt.getKeyCode () == 38) { +this.scalefactor = (this.scalefactor * 1.1); +this.scale = this.findScale (); +} else if (evt.getKeyCode () == 40) { +this.scalefactor = (this.scalefactor * 0.9); +this.scale = this.findScale (); +} else if (evt.getKeyChar () == 's') { +System.err.println ("DEBUG: Rectangle selection"); +if (this.rectx2 != -1 && this.recty2 != -1) { +this.rectSelect (this.rectx1, this.recty1, this.rectx2, this.recty2); +}}this.repaint (); +}, "java.awt.event.KeyEvent"); +Clazz.defineMethod (c$, "printPoints", +function () { +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +jalview.util.Format.printLong (System.out, "%5d ", i); +for (var j = 0; j < 3; j++) { +jalview.util.Format.printDouble (System.out, "%13.3f ", sp.coord[j]); +} +System.out.println (); +} +}); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +var x = evt.getX (); +var y = evt.getY (); +this.mx = x; +this.my = y; +this.omx = this.mx; +this.omy = this.my; +this.startx = x; +this.starty = y; +this.rectx1 = x; +this.recty1 = y; +this.rectx2 = -1; +this.recty2 = -1; +var found = this.findPoint (x, y); +if (found != null) { +if (this.av.getSelectionGroup () != null) { +this.av.getSelectionGroup ().addOrRemove (found, true); +this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); +} else { +this.av.setSelectionGroup ( new jalview.datamodel.SequenceGroup ()); +this.av.getSelectionGroup ().addOrRemove (found, true); +this.av.getSelectionGroup ().setEndRes (this.av.getAlignment ().getWidth () - 1); +}jalview.appletgui.PaintRefresher.Refresh (this, this.av.getSequenceSetId ()); +this.av.sendSelection (); +}this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +var found = this.findPoint (evt.getX (), evt.getY ()); +if (found == null) { +this.tooltip = null; +} else { +this.tooltip = found.getName (); +this.toolx = evt.getX (); +this.tooly = evt.getY (); +}this.repaint (); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +this.mx = evt.getX (); +this.my = evt.getY (); +this.rotmat.setIdentity (); +this.rotmat.rotate (this.my - this.omy, 'x'); +this.rotmat.rotate (this.mx - this.omx, 'y'); +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +sp.coord[0] -= this.centre[0]; +sp.coord[1] -= this.centre[1]; +sp.coord[2] -= this.centre[2]; +sp.coord = this.rotmat.vectorMultiply (sp.coord); +sp.coord[0] += this.centre[0]; +sp.coord[1] += this.centre[1]; +sp.coord[2] += this.centre[2]; +} +for (var i = 0; i < 3; i++) { +this.axes[i] = this.rotmat.vectorMultiply (this.axes[i]); +} +this.omx = this.mx; +this.omy = this.my; +this.paint (this.getGraphics ()); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "rectSelect", +function (x1, y1, x2, y2) { +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +var tmp1 = Clazz.doubleToInt ((sp.coord[0] - this.centre[0]) * this.scale + this.getSize ().width / 2.0); +var tmp2 = Clazz.doubleToInt ((sp.coord[1] - this.centre[1]) * this.scale + this.getSize ().height / 2.0); +if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) { +if (this.av != null) { +if (!this.av.getSelectionGroup ().getSequences (null).contains (sp.sequence)) { +this.av.getSelectionGroup ().addSequence (sp.sequence, true); +}}}} +}, "~N,~N,~N,~N"); +Clazz.defineMethod (c$, "findPoint", +function (x, y) { +var halfwidth = Clazz.doubleToInt (this.getSize ().width / 2); +var halfheight = Clazz.doubleToInt (this.getSize ().height / 2); +var found = -1; +for (var i = 0; i < this.npoint; i++) { +var sp = this.points.elementAt (i); +var px = Clazz.floatToInt ((sp.coord[0] - this.centre[0]) * this.scale) + halfwidth; +var py = Clazz.floatToInt ((sp.coord[1] - this.centre[1]) * this.scale) + halfheight; +if (Math.abs (px - x) < 3 && Math.abs (py - y) < 3) { +found = i; +}} +if (found != -1) { +return (this.points.elementAt (found)).sequence; +} else { +return null; +}}, "~N,~N"); +});