X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjalview%2Fappletgui%2FAnnotationPanel.js;h=6234bd358f1b26a0d471e7002e3a998e5352140c;hp=33f7259cdb99b0e7151e36221cf36cb9c05a6dcc;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6 diff --git a/site/j2s/jalview/appletgui/AnnotationPanel.js b/site/j2s/jalview/appletgui/AnnotationPanel.js index 33f7259..6234bd3 100644 --- a/site/j2s/jalview/appletgui/AnnotationPanel.js +++ b/site/j2s/jalview/appletgui/AnnotationPanel.js @@ -1,364 +1,364 @@ -Clazz.declarePackage ("jalview.appletgui"); -Clazz.load (["awt2swing.Panel", "jalview.renderer.AwtRenderPanelI", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.MouseListener", "$.MouseMotionListener", "java.awt.Color"], "jalview.appletgui.AnnotationPanel", ["awt2swing.MenuItem", "$.PopupMenu", "jalview.appletgui.EditNameDialog", "$.UserDefinedColours", "jalview.datamodel.Annotation", "jalview.renderer.AnnotationRenderer", "jalview.util.MessageManager", "$.Platform", "java.awt.Dimension", "java.lang.StringBuffer"], function () { -c$ = Clazz.decorateAsClass (function () { -this.av = null; -this.ap = null; -this.activeRow = -1; -this.HELIX = "Helix"; -this.SHEET = "Sheet"; -this.STEM = "RNA Helix"; -this.LABEL = "Label"; -this.REMOVE = "Remove Annotation"; -this.COLOUR = "Colour"; -this.HELIX_COLOUR = null; -this.SHEET_COLOUR = null; -this.image = null; -this.gg = null; -this.fm = null; -this.imgWidth = 0; -this.$fastPaint = false; -this.graphStretch = -1; -this.graphStretchY = -1; -this.mouseDragging = false; -this.MAC = false; -this.renderer = null; -this.needValidating = false; -this.scrollOffset = 0; -this.$bounds = null; -Clazz.instantialize (this, arguments); -}, jalview.appletgui, "AnnotationPanel", awt2swing.Panel, [jalview.renderer.AwtRenderPanelI, java.awt.event.AdjustmentListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); -Clazz.prepareFields (c$, function () { -this.HELIX_COLOUR = java.awt.Color.red.darker (); -this.SHEET_COLOUR = java.awt.Color.green.darker ().darker (); -this.$bounds = Clazz.newIntArray (2, 0); -}); -Clazz.makeConstructor (c$, -function (ap) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationPanel, []); -this.MAC = jalview.util.Platform.isAMac (); -this.ap = ap; -this.av = ap.av; -this.setLayout (null); -var height = this.adjustPanelHeight (); -ap.apvscroll.setValues (0, this.getSize ().height, 0, height); -this.addMouseMotionListener (this); -this.addMouseListener (this); -this.renderer = new jalview.renderer.AnnotationRenderer (); -}, "jalview.appletgui.AlignmentPanel"); -Clazz.makeConstructor (c$, -function (av) { -Clazz.superConstructor (this, jalview.appletgui.AnnotationPanel, []); -this.av = av; -this.renderer = new jalview.renderer.AnnotationRenderer (); -}, "jalview.appletgui.AlignViewport"); -Clazz.overrideMethod (c$, "adjustmentValueChanged", -function (evt) { -}, "java.awt.event.AdjustmentEvent"); -Clazz.overrideMethod (c$, "actionPerformed", -function (evt) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return; -}var anot = aa[this.activeRow].annotations; -if (anot.length < this.av.getColumnSelection ().getMax ()) { -var temp = new Array (this.av.getColumnSelection ().getMax () + 2); -System.arraycopy (anot, 0, temp, 0, anot.length); -anot = temp; -aa[this.activeRow].annotations = anot; -}var label = ""; -if (this.av.getColumnSelection () != null && this.av.getColumnSelection ().size () > 0 && anot[this.av.getColumnSelection ().getMin ()] != null) { -label = anot[this.av.getColumnSelection ().getMin ()].displayCharacter; -}if (evt.getActionCommand ().equals ("Remove Annotation")) { -for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { -anot[this.av.getColumnSelection ().columnAt (i)] = null; -} -} else if (evt.getActionCommand ().equals ("Label")) { -label = this.enterLabel (label, "Enter Label"); -if (label == null) { -return; -}if ((label.length > 0) && !aa[this.activeRow].hasText) { -aa[this.activeRow].hasText = true; -}for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { -var index = this.av.getColumnSelection ().columnAt (i); -if (!this.av.getColumnSelection ().isVisible (index)) { -continue; -}if (anot[index] == null) { -anot[index] = new jalview.datamodel.Annotation (label, "", ' ', 0); -}anot[index].displayCharacter = label; -} -} else if (evt.getActionCommand ().equals ("Colour")) { -var udc = new jalview.appletgui.UserDefinedColours (this, java.awt.Color.black, this.ap.alignFrame); -var col = udc.getColor (); -for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { -var index = this.av.getColumnSelection ().columnAt (i); -if (!this.av.getColumnSelection ().isVisible (index)) { -continue; -}if (anot[index] == null) { -anot[index] = new jalview.datamodel.Annotation ("", "", ' ', 0); -}anot[index].colour = col; -} -} else { -var type = String.fromCharCode (0); -var symbol = "\u03B1"; -if (evt.getActionCommand ().equals ("Helix")) { -type = 'H'; -} else if (evt.getActionCommand ().equals ("Sheet")) { -type = 'E'; -symbol = "\u03B2"; -} else if (evt.getActionCommand ().equals ("RNA Helix")) { -type = 'S'; -symbol = "\u03C3"; -}if (!aa[this.activeRow].hasIcons) { -aa[this.activeRow].hasIcons = true; -}label = this.enterLabel (symbol, "Enter Label"); -if (label == null) { -return; -}if ((label.length > 0) && !aa[this.activeRow].hasText) { -aa[this.activeRow].hasText = true; -if (evt.getActionCommand ().equals ("RNA Helix")) { -aa[this.activeRow].showAllColLabels = true; -}}for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { -var index = this.av.getColumnSelection ().columnAt (i); -if (!this.av.getColumnSelection ().isVisible (index)) { -continue; -}if (anot[index] == null) { -anot[index] = new jalview.datamodel.Annotation (label, "", type, 0); -}anot[index].secondaryStructure = type != 'S' ? type : label.length == 0 ? ' ' : label.charAt (0); -anot[index].displayCharacter = label; -} -}this.av.getAlignment ().validateAnnotation (aa[this.activeRow]); -this.ap.alignmentChanged (); -this.adjustPanelHeight (); -this.repaint (); -return; -}, "java.awt.event.ActionEvent"); -Clazz.defineMethod (c$, "enterLabel", -function (text, label) { -var dialog = new jalview.appletgui.EditNameDialog (text, null, label, null, this.ap.alignFrame, "Enter Label", 400, 200, true); -if (dialog.accept) { -return dialog.getName (); -} else { -return null; -}}, "~S,~S"); -Clazz.overrideMethod (c$, "mousePressed", -function (evt) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return; -}var height = -this.scrollOffset; -this.activeRow = -1; -for (var i = 0; i < aa.length; i++) { -if (aa[i].visible) { -height += aa[i].height; -}if (evt.getY () < height) { -if (aa[i].editable) { -this.activeRow = i; -} else if (aa[i].graph > 0) { -this.graphStretch = i; -this.graphStretchY = evt.getY (); -}break; -}} -if ((evt.getModifiers () & 4) == 4 && this.activeRow != -1) { -if (this.av.getColumnSelection () == null) { -return; -}var pop = new awt2swing.PopupMenu (jalview.util.MessageManager.getString ("label.structure_type")); -var item; -if (this.av.getAlignment ().isNucleotide () == true) { -item = new awt2swing.MenuItem ("RNA Helix"); -item.addActionListener (this); -pop.add (item); -} else { -item = new awt2swing.MenuItem ("Helix"); -item.addActionListener (this); -pop.add (item); -item = new awt2swing.MenuItem ("Sheet"); -item.addActionListener (this); -pop.add (item); -}item = new awt2swing.MenuItem ("Label"); -item.addActionListener (this); -pop.add (item); -item = new awt2swing.MenuItem ("Colour"); -item.addActionListener (this); -pop.add (item); -item = new awt2swing.MenuItem ("Remove Annotation"); -item.addActionListener (this); -pop.add (item); -this.ap.alignFrame.add (pop); -pop.show (this, evt.getX (), evt.getY ()); -return; -}this.ap.scalePanel.mousePressed (evt); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseReleased", -function (evt) { -this.graphStretch = -1; -this.graphStretchY = -1; -this.mouseDragging = false; -if (this.needValidating) { -this.ap.validate (); -this.needValidating = false; -}this.ap.scalePanel.mouseReleased (evt); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseClicked", -function (evt) { -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseDragged", -function (evt) { -if (this.graphStretch > -1) { -this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight += this.graphStretchY - evt.getY (); -if (this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight < 0) { -this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight = 0; -}this.graphStretchY = evt.getY (); -this.av.calcPanelHeight (); -this.needValidating = true; -this.ap.paintAlignment (true); -} else { -this.ap.scalePanel.mouseDragged (evt); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseMoved", -function (evt) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return; -}var row = -1; -var height = -this.scrollOffset; -for (var i = 0; i < aa.length; i++) { -if (aa[i].visible) { -height += aa[i].height; -}if (evt.getY () < height) { -row = i; -break; -}} -var res = Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ()) + this.av.getStartRes (); -if (this.av.hasHiddenColumns ()) { -res = this.av.getColumnSelection ().adjustForHiddenColumns (res); -}if (row > -1 && res < aa[row].annotations.length && aa[row].annotations[res] != null) { -var text = new StringBuffer ("Sequence position " + (res + 1)); -if (aa[row].annotations[res].description != null) { -text.append (" " + aa[row].annotations[res].description); -}this.ap.alignFrame.setStatus (text.toString ()); -}}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseEntered", -function (evt) { -this.ap.scalePanel.mouseEntered (evt); -}, "java.awt.event.MouseEvent"); -Clazz.overrideMethod (c$, "mouseExited", -function (evt) { -this.ap.scalePanel.mouseExited (evt); -}, "java.awt.event.MouseEvent"); -Clazz.defineMethod (c$, "adjustPanelHeight", -function () { -return this.adjustPanelHeight (true); -}); -Clazz.defineMethod (c$, "adjustPanelHeight", -function (repaint) { -var height = this.av.calcPanelHeight (); -this.setSize ( new java.awt.Dimension (this.getSize ().width, height)); -if (repaint) { -this.repaint (); -}return height; -}, "~B"); -Clazz.defineMethod (c$, "addEditableColumn", -function (i) { -if (this.activeRow == -1) { -var aa = this.av.getAlignment ().getAlignmentAnnotation (); -if (aa == null) { -return; -}for (var j = 0; j < aa.length; j++) { -if (aa[j].editable) { -this.activeRow = j; -break; -}} -}}, "~N"); -Clazz.overrideMethod (c$, "paintComponent", -function (g) { -if (this.av.getWrapAlignment () || !this.av.isShowAnnotation ()) return; -var d = this.getSize (); -this.imgWidth = d.width; -if (this.imgWidth < 1 || d.height < 1) { -return; -}if (this.image == null || this.imgWidth != this.image.getWidth (this) || d.height != this.image.getHeight (this)) { -this.image = this.createImage (this.imgWidth, d.height); -this.gg = this.image.getGraphics (); -this.gg.setFont (this.av.getFont ()); -this.fm = this.gg.getFontMetrics (); -this.$fastPaint = false; -}if (this.$fastPaint) { -g.drawImage (this.image, 0, 0, this); -this.$fastPaint = false; -return; -}this.gg.setColor (java.awt.Color.white); -this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -this.drawComponent (this.gg, this.av.startRes, this.av.endRes + 1); -g.drawImage (this.image, 0, 0, this); -}, "java.awt.Graphics"); -Clazz.defineMethod (c$, "fastPaint", -function (horizontal) { -if (horizontal == 0 || this.av.getAlignment ().getAlignmentAnnotation () == null || this.av.getAlignment ().getAlignmentAnnotation ().length < 1) { -this.repaint (); -return; -}this.gg.copyArea (0, 0, this.imgWidth, this.getSize ().height, -horizontal * this.av.getCharWidth (), 0); -var sr = this.av.startRes; -var er = this.av.endRes + 1; -var transX = 0; -if (horizontal > 0) { -transX = (er - sr - horizontal) * this.av.getCharWidth (); -sr = er - horizontal; -} else if (horizontal < 0) { -er = sr - horizontal; -}this.gg.translate (transX, 0); -this.drawComponent (this.gg, sr, er); -this.gg.translate (-transX, 0); -this.$fastPaint = true; -this.repaint (); -}, "~N"); -Clazz.defineMethod (c$, "drawComponent", -function (g, startRes, endRes) { -var ofont = this.av.getFont (); -g.setFont (ofont); -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, (endRes - startRes) * this.av.getCharWidth (), this.getSize ().height); -if (this.fm == null) { -this.fm = g.getFontMetrics (); -}if ((this.av.getAlignment ().getAlignmentAnnotation () == null) || (this.av.getAlignment ().getAlignmentAnnotation ().length < 1)) { -g.setColor (java.awt.Color.white); -g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); -g.setColor (java.awt.Color.black); -if (this.av.validCharWidth) { -g.drawString (jalview.util.MessageManager.getString ("label.alignment_has_no_annotations"), 20, 15); -}return; -}g.translate (0, -this.scrollOffset); -this.renderer.drawComponent (this, this.av, g, this.activeRow, startRes, endRes); -g.translate (0, +this.scrollOffset); -}, "java.awt.Graphics,~N,~N"); -Clazz.defineMethod (c$, "setScrollOffset", -function (value, repaint) { -this.scrollOffset = value; -if (repaint) { -this.repaint (); -}}, "~N,~B"); -Clazz.defineMethod (c$, "getFontMetrics", -function () { -return this.fm; -}); -Clazz.overrideMethod (c$, "getFadedImage", -function () { -return this.image; -}); -Clazz.overrideMethod (c$, "getFadedImageWidth", -function () { -return this.imgWidth; -}); -Clazz.overrideMethod (c$, "getVisibleVRange", -function () { -if (this.ap != null && this.ap.alabels != null) { -var sOffset = -this.ap.alabels.scrollOffset; -var visHeight = sOffset + this.ap.annotationPanelHolder.getHeight (); -this.$bounds[0] = sOffset; -this.$bounds[1] = visHeight; -return this.$bounds; -} else { -return null; -}}); -Clazz.defineStatics (c$, -"GRAPH_HEIGHT", 40); -}); +Clazz.declarePackage ("jalview.appletgui"); +Clazz.load (["awt2swing.Panel", "jalview.renderer.AwtRenderPanelI", "java.awt.event.ActionListener", "$.AdjustmentListener", "$.MouseListener", "$.MouseMotionListener", "java.awt.Color"], "jalview.appletgui.AnnotationPanel", ["awt2swing.MenuItem", "$.PopupMenu", "jalview.appletgui.EditNameDialog", "$.UserDefinedColours", "jalview.datamodel.Annotation", "jalview.renderer.AnnotationRenderer", "jalview.util.MessageManager", "$.Platform", "java.awt.Dimension", "java.lang.StringBuffer"], function () { +c$ = Clazz.decorateAsClass (function () { +this.av = null; +this.ap = null; +this.activeRow = -1; +this.HELIX = "Helix"; +this.SHEET = "Sheet"; +this.STEM = "RNA Helix"; +this.LABEL = "Label"; +this.REMOVE = "Remove Annotation"; +this.COLOUR = "Colour"; +this.HELIX_COLOUR = null; +this.SHEET_COLOUR = null; +this.image = null; +this.gg = null; +this.fm = null; +this.imgWidth = 0; +this.$fastPaint = false; +this.graphStretch = -1; +this.graphStretchY = -1; +this.mouseDragging = false; +this.MAC = false; +this.renderer = null; +this.needValidating = false; +this.scrollOffset = 0; +this.$bounds = null; +Clazz.instantialize (this, arguments); +}, jalview.appletgui, "AnnotationPanel", awt2swing.Panel, [jalview.renderer.AwtRenderPanelI, java.awt.event.AdjustmentListener, java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener]); +Clazz.prepareFields (c$, function () { +this.HELIX_COLOUR = java.awt.Color.red.darker (); +this.SHEET_COLOUR = java.awt.Color.green.darker ().darker (); +this.$bounds = Clazz.newIntArray (2, 0); +}); +Clazz.makeConstructor (c$, +function (ap) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationPanel, []); +this.MAC = jalview.util.Platform.isAMac (); +this.ap = ap; +this.av = ap.av; +this.setLayout (null); +var height = this.adjustPanelHeight (); +ap.apvscroll.setValues (0, this.getSize ().height, 0, height); +this.addMouseMotionListener (this); +this.addMouseListener (this); +this.renderer = new jalview.renderer.AnnotationRenderer (); +}, "jalview.appletgui.AlignmentPanel"); +Clazz.makeConstructor (c$, +function (av) { +Clazz.superConstructor (this, jalview.appletgui.AnnotationPanel, []); +this.av = av; +this.renderer = new jalview.renderer.AnnotationRenderer (); +}, "jalview.appletgui.AlignViewport"); +Clazz.overrideMethod (c$, "adjustmentValueChanged", +function (evt) { +}, "java.awt.event.AdjustmentEvent"); +Clazz.overrideMethod (c$, "actionPerformed", +function (evt) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return; +}var anot = aa[this.activeRow].annotations; +if (anot.length < this.av.getColumnSelection ().getMax ()) { +var temp = new Array (this.av.getColumnSelection ().getMax () + 2); +System.arraycopy (anot, 0, temp, 0, anot.length); +anot = temp; +aa[this.activeRow].annotations = anot; +}var label = ""; +if (this.av.getColumnSelection () != null && this.av.getColumnSelection ().size () > 0 && anot[this.av.getColumnSelection ().getMin ()] != null) { +label = anot[this.av.getColumnSelection ().getMin ()].displayCharacter; +}if (evt.getActionCommand ().equals ("Remove Annotation")) { +for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { +anot[this.av.getColumnSelection ().columnAt (i)] = null; +} +} else if (evt.getActionCommand ().equals ("Label")) { +label = this.enterLabel (label, "Enter Label"); +if (label == null) { +return; +}if ((label.length > 0) && !aa[this.activeRow].hasText) { +aa[this.activeRow].hasText = true; +}for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { +var index = this.av.getColumnSelection ().columnAt (i); +if (!this.av.getColumnSelection ().isVisible (index)) { +continue; +}if (anot[index] == null) { +anot[index] = new jalview.datamodel.Annotation (label, "", ' ', 0); +}anot[index].displayCharacter = label; +} +} else if (evt.getActionCommand ().equals ("Colour")) { +var udc = new jalview.appletgui.UserDefinedColours (this, java.awt.Color.black, this.ap.alignFrame); +var col = udc.getColor (); +for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { +var index = this.av.getColumnSelection ().columnAt (i); +if (!this.av.getColumnSelection ().isVisible (index)) { +continue; +}if (anot[index] == null) { +anot[index] = new jalview.datamodel.Annotation ("", "", ' ', 0); +}anot[index].colour = col; +} +} else { +var type = String.fromCharCode (0); +var symbol = "\u03B1"; +if (evt.getActionCommand ().equals ("Helix")) { +type = 'H'; +} else if (evt.getActionCommand ().equals ("Sheet")) { +type = 'E'; +symbol = "\u03B2"; +} else if (evt.getActionCommand ().equals ("RNA Helix")) { +type = 'S'; +symbol = "\u03C3"; +}if (!aa[this.activeRow].hasIcons) { +aa[this.activeRow].hasIcons = true; +}label = this.enterLabel (symbol, "Enter Label"); +if (label == null) { +return; +}if ((label.length > 0) && !aa[this.activeRow].hasText) { +aa[this.activeRow].hasText = true; +if (evt.getActionCommand ().equals ("RNA Helix")) { +aa[this.activeRow].showAllColLabels = true; +}}for (var i = 0; i < this.av.getColumnSelection ().size (); i++) { +var index = this.av.getColumnSelection ().columnAt (i); +if (!this.av.getColumnSelection ().isVisible (index)) { +continue; +}if (anot[index] == null) { +anot[index] = new jalview.datamodel.Annotation (label, "", type, 0); +}anot[index].secondaryStructure = type != 'S' ? type : label.length == 0 ? ' ' : label.charAt (0); +anot[index].displayCharacter = label; +} +}this.av.getAlignment ().validateAnnotation (aa[this.activeRow]); +this.ap.alignmentChanged (); +this.adjustPanelHeight (); +this.repaint (); +return; +}, "java.awt.event.ActionEvent"); +Clazz.defineMethod (c$, "enterLabel", +function (text, label) { +var dialog = new jalview.appletgui.EditNameDialog (text, null, label, null, this.ap.alignFrame, "Enter Label", 400, 200, true); +if (dialog.accept) { +return dialog.getName (); +} else { +return null; +}}, "~S,~S"); +Clazz.overrideMethod (c$, "mousePressed", +function (evt) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return; +}var height = -this.scrollOffset; +this.activeRow = -1; +for (var i = 0; i < aa.length; i++) { +if (aa[i].visible) { +height += aa[i].height; +}if (evt.getY () < height) { +if (aa[i].editable) { +this.activeRow = i; +} else if (aa[i].graph > 0) { +this.graphStretch = i; +this.graphStretchY = evt.getY (); +}break; +}} +if ((evt.getModifiers () & 4) == 4 && this.activeRow != -1) { +if (this.av.getColumnSelection () == null) { +return; +}var pop = new awt2swing.PopupMenu (jalview.util.MessageManager.getString ("label.structure_type")); +var item; +if (this.av.getAlignment ().isNucleotide () == true) { +item = new awt2swing.MenuItem ("RNA Helix"); +item.addActionListener (this); +pop.add (item); +} else { +item = new awt2swing.MenuItem ("Helix"); +item.addActionListener (this); +pop.add (item); +item = new awt2swing.MenuItem ("Sheet"); +item.addActionListener (this); +pop.add (item); +}item = new awt2swing.MenuItem ("Label"); +item.addActionListener (this); +pop.add (item); +item = new awt2swing.MenuItem ("Colour"); +item.addActionListener (this); +pop.add (item); +item = new awt2swing.MenuItem ("Remove Annotation"); +item.addActionListener (this); +pop.add (item); +this.ap.alignFrame.add (pop); +pop.show (this, evt.getX (), evt.getY ()); +return; +}this.ap.scalePanel.mousePressed (evt); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseReleased", +function (evt) { +this.graphStretch = -1; +this.graphStretchY = -1; +this.mouseDragging = false; +if (this.needValidating) { +this.ap.validate (); +this.needValidating = false; +}this.ap.scalePanel.mouseReleased (evt); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseClicked", +function (evt) { +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseDragged", +function (evt) { +if (this.graphStretch > -1) { +this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight += this.graphStretchY - evt.getY (); +if (this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight < 0) { +this.av.getAlignment ().getAlignmentAnnotation ()[this.graphStretch].graphHeight = 0; +}this.graphStretchY = evt.getY (); +this.av.calcPanelHeight (); +this.needValidating = true; +this.ap.paintAlignment (true); +} else { +this.ap.scalePanel.mouseDragged (evt); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseMoved", +function (evt) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return; +}var row = -1; +var height = -this.scrollOffset; +for (var i = 0; i < aa.length; i++) { +if (aa[i].visible) { +height += aa[i].height; +}if (evt.getY () < height) { +row = i; +break; +}} +var res = Clazz.doubleToInt (evt.getX () / this.av.getCharWidth ()) + this.av.getStartRes (); +if (this.av.hasHiddenColumns ()) { +res = this.av.getColumnSelection ().adjustForHiddenColumns (res); +}if (row > -1 && res < aa[row].annotations.length && aa[row].annotations[res] != null) { +var text = new StringBuffer ("Sequence position " + (res + 1)); +if (aa[row].annotations[res].description != null) { +text.append (" " + aa[row].annotations[res].description); +}this.ap.alignFrame.setStatus (text.toString ()); +}}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseEntered", +function (evt) { +this.ap.scalePanel.mouseEntered (evt); +}, "java.awt.event.MouseEvent"); +Clazz.overrideMethod (c$, "mouseExited", +function (evt) { +this.ap.scalePanel.mouseExited (evt); +}, "java.awt.event.MouseEvent"); +Clazz.defineMethod (c$, "adjustPanelHeight", +function () { +return this.adjustPanelHeight (true); +}); +Clazz.defineMethod (c$, "adjustPanelHeight", +function (repaint) { +var height = this.av.calcPanelHeight (); +this.setSize ( new java.awt.Dimension (this.getSize ().width, height)); +if (repaint) { +this.repaint (); +}return height; +}, "~B"); +Clazz.defineMethod (c$, "addEditableColumn", +function (i) { +if (this.activeRow == -1) { +var aa = this.av.getAlignment ().getAlignmentAnnotation (); +if (aa == null) { +return; +}for (var j = 0; j < aa.length; j++) { +if (aa[j].editable) { +this.activeRow = j; +break; +}} +}}, "~N"); +Clazz.overrideMethod (c$, "paintComponent", +function (g) { +if (this.av.getWrapAlignment () || !this.av.isShowAnnotation ()) return; +var d = this.getSize (); +this.imgWidth = d.width; +if (this.imgWidth < 1 || d.height < 1) { +return; +}if (this.image == null || this.imgWidth != this.image.getWidth (this) || d.height != this.image.getHeight (this)) { +this.image = this.createImage (this.imgWidth, d.height); +this.gg = this.image.getGraphics (); +this.gg.setFont (this.av.getFont ()); +this.fm = this.gg.getFontMetrics (); +this.$fastPaint = false; +}if (this.$fastPaint) { +g.drawImage (this.image, 0, 0, this); +this.$fastPaint = false; +return; +}this.gg.setColor (java.awt.Color.white); +this.gg.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +this.drawComponent (this.gg, this.av.startRes, this.av.endRes + 1); +g.drawImage (this.image, 0, 0, this); +}, "java.awt.Graphics"); +Clazz.defineMethod (c$, "fastPaint", +function (horizontal) { +if (horizontal == 0 || this.av.getAlignment ().getAlignmentAnnotation () == null || this.av.getAlignment ().getAlignmentAnnotation ().length < 1) { +this.repaint (); +return; +}this.gg.copyArea (0, 0, this.imgWidth, this.getSize ().height, -horizontal * this.av.getCharWidth (), 0); +var sr = this.av.startRes; +var er = this.av.endRes + 1; +var transX = 0; +if (horizontal > 0) { +transX = (er - sr - horizontal) * this.av.getCharWidth (); +sr = er - horizontal; +} else if (horizontal < 0) { +er = sr - horizontal; +}this.gg.translate (transX, 0); +this.drawComponent (this.gg, sr, er); +this.gg.translate (-transX, 0); +this.$fastPaint = true; +this.repaint (); +}, "~N"); +Clazz.defineMethod (c$, "drawComponent", +function (g, startRes, endRes) { +var ofont = this.av.getFont (); +g.setFont (ofont); +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, (endRes - startRes) * this.av.getCharWidth (), this.getSize ().height); +if (this.fm == null) { +this.fm = g.getFontMetrics (); +}if ((this.av.getAlignment ().getAlignmentAnnotation () == null) || (this.av.getAlignment ().getAlignmentAnnotation ().length < 1)) { +g.setColor (java.awt.Color.white); +g.fillRect (0, 0, this.getSize ().width, this.getSize ().height); +g.setColor (java.awt.Color.black); +if (this.av.validCharWidth) { +g.drawString (jalview.util.MessageManager.getString ("label.alignment_has_no_annotations"), 20, 15); +}return; +}g.translate (0, -this.scrollOffset); +this.renderer.drawComponent (this, this.av, g, this.activeRow, startRes, endRes); +g.translate (0, +this.scrollOffset); +}, "java.awt.Graphics,~N,~N"); +Clazz.defineMethod (c$, "setScrollOffset", +function (value, repaint) { +this.scrollOffset = value; +if (repaint) { +this.repaint (); +}}, "~N,~B"); +Clazz.defineMethod (c$, "getFontMetrics", +function () { +return this.fm; +}); +Clazz.overrideMethod (c$, "getFadedImage", +function () { +return this.image; +}); +Clazz.overrideMethod (c$, "getFadedImageWidth", +function () { +return this.imgWidth; +}); +Clazz.overrideMethod (c$, "getVisibleVRange", +function () { +if (this.ap != null && this.ap.alabels != null) { +var sOffset = -this.ap.alabels.scrollOffset; +var visHeight = sOffset + this.ap.annotationPanelHolder.getHeight (); +this.$bounds[0] = sOffset; +this.$bounds[1] = visHeight; +return this.$bounds; +} else { +return null; +}}); +Clazz.defineStatics (c$, +"GRAPH_HEIGHT", 40); +});