* @param width DOCUMENT ME!\r
* @param height DOCUMENT ME!\r
*/\r
- public void drawSequence(Graphics g1, SequenceI seq, SequenceGroup[] sg,\r
- int start, int end, int x1, int y1, int width, int height)\r
+ public void drawSequence(Graphics g, SequenceI seq,\r
+ int start, int end, int x1, int y1, int width, int height)\r
{\r
\r
- if(seq.getSequenceFeatures()==null)\r
- return;\r
+ if (seq.getDatasetSequence().getSequenceFeatures() == null)\r
+ return;\r
\r
- Enumeration e = null, e2;\r
- String type;\r
- if(featuresDisplayed!=null)\r
- e = featuresDisplayed.elements();\r
- else\r
- e = seq.getSequenceFeatures().elements();\r
-\r
- Graphics2D g = (Graphics2D)g1;\r
- g.setComposite(\r
- AlphaComposite.getInstance(\r
- AlphaComposite.SRC_OVER,transparency));\r
+ if (transparency != 1)\r
+ {\r
+ Graphics2D g2 = (Graphics2D) g;\r
+ g2.setComposite(\r
+ AlphaComposite.getInstance(\r
+ AlphaComposite.SRC_OVER, transparency));\r
+ }\r
\r
+ Enumeration e, e2;\r
+ String type;\r
+ SequenceFeature sf;\r
+ if (featuresDisplayed != null)\r
+ {\r
+ e = featuresDisplayed.elements();\r
+ while(e.hasMoreElements())\r
+ {\r
+ type = e.nextElement().toString();\r
+ e2 = seq.getDatasetSequence().getSequenceFeatures().elements();\r
+ while(e2.hasMoreElements())\r
+ {\r
+ sf = (SequenceFeature) e2.nextElement();\r
+ if(!type.equals(sf.getType() ) )\r
+ continue;\r
+\r
+ if (sf.getBegin() > seq.getEnd())\r
+ continue;\r
+\r
+ renderFeature(g,seq,\r
+ seq.findIndex(sf.getBegin()) - 1,\r
+ seq.findIndex(sf.getEnd()) - 1,\r
+ type,start,end,x1,y1,width,height);\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ e = seq.getDatasetSequence().getSequenceFeatures().elements();\r
while (e.hasMoreElements())\r
{\r
+ sf = (SequenceFeature) e.nextElement();\r
+ type = sf.getType();\r
+\r
+ if (sf.getBegin() > seq.getEnd())\r
+ {\r
+ continue;\r
+ }\r
+\r
+ renderFeature(g,seq,\r
+ seq.findIndex(sf.getBegin()) - 1,\r
+ seq.findIndex(sf.getEnd()) - 1,\r
+ type,start,end,x1,y1,width,height);\r
+\r
+ }\r
+ }\r
+\r
+ /* while (e.hasMoreElements())\r
+ {\r
SequenceFeature sf=null;\r
if(featuresDisplayed!=null)\r
{\r
- e2 = seq.getSequenceFeatures().elements();\r
+ e2 = seq.getDatasetSequence().getSequenceFeatures().elements();\r
type = e.nextElement().toString();\r
while(e2.hasMoreElements())\r
{\r
\r
int fstart = seq.findIndex(sf.getBegin()) - 1;\r
int fend = seq.findIndex(sf.getEnd()) - 1;\r
+*/\r
\r
- if (((fstart <= end) && (fend >= start)))\r
- {\r
- if (fstart < start)\r
- { // fix for if the feature we have starts before the sequence start,\r
- fstart = start; // but the feature end is still valid!!\r
- }\r
-\r
- if (fend >= end)\r
- {\r
- fend = end;\r
- }\r
-\r
- if (fstart == fend)\r
- {\r
- g.setColor(getColour(type));\r
- g.fillRoundRect((fstart - start) * width, y1, width,\r
- height, 4, 4);\r
- g.setColor(Color.white);\r
-\r
- char s = seq.getSequence().charAt(fstart);\r
- FontMetrics fm = g.getFontMetrics();\r
- int charOffset = (width - fm.charWidth(s)) / 2;\r
- int pady = height / 5;\r
- g.drawString(String.valueOf(s),\r
- charOffset + x1 + (width * (fstart - start)),\r
- (y1 + height) - pady);\r
- }\r
- else\r
- {\r
- for (int i = fstart; i <= fend; i++)\r
- {\r
- char s = seq.getSequence().charAt(i);\r
-\r
- if (jalview.util.Comparison.isGap(s))\r
- {\r
- continue;\r
- }\r
-\r
- g.setColor(getColour(type));\r
- g.fillRect((i - start) * width, y1, width, height);\r
-\r
- g.setColor(Color.white);\r
-\r
- FontMetrics fm = g.getFontMetrics();\r
- int charOffset = (width - fm.charWidth(s)) / 2;\r
- int pady = height / 5;\r
- g.drawString(String.valueOf(s),\r
- charOffset + x1 + (width * (i - start)),\r
- (y1 + height) - pady);\r
- }\r
- }\r
- }\r
+ if(transparency!=1.0f)\r
+ {\r
+ Graphics2D g2 = (Graphics2D) g;\r
+ g2.setComposite(\r
+ AlphaComposite.getInstance(\r
+ AlphaComposite.SRC_OVER, 1.0f));\r
}\r
- g.setComposite(\r
- AlphaComposite.getInstance(\r
- AlphaComposite.SRC_OVER,1.0f));\r
+ }\r
\r
+ void renderFeature(Graphics g, SequenceI seq,\r
+ int fstart, int fend, String type, int start, int end, int x1, int y1, int width, int height)\r
+ {\r
+ if (((fstart <= end) && (fend >= start)))\r
+ {\r
+ if (fstart < start)\r
+ { // fix for if the feature we have starts before the sequence start,\r
+ fstart = start; // but the feature end is still valid!!\r
+ }\r
+\r
+ if (fend >= end)\r
+ {\r
+ fend = end;\r
+ }\r
+\r
+ if (fstart == fend)\r
+ {\r
+ g.setColor(getColour(type));\r
+ g.fillRoundRect((fstart - start) * width, y1, width,\r
+ height, 4, 4);\r
+ g.setColor(Color.white);\r
+\r
+ char s = seq.getSequence().charAt(fstart);\r
+ FontMetrics fm = g.getFontMetrics();\r
+ int charOffset = (width - fm.charWidth(s)) / 2;\r
+ int pady = height / 5;\r
+ g.drawString(String.valueOf(s),\r
+ charOffset + x1 + (width * (fstart - start)),\r
+ (y1 + height) - pady);\r
+ }\r
+ else\r
+ {\r
+ for (int i = fstart; i <= fend; i++)\r
+ {\r
+ char s = seq.getSequence().charAt(i);\r
+\r
+ if (jalview.util.Comparison.isGap(s))\r
+ {\r
+ continue;\r
+ }\r
+\r
+ g.setColor(getColour(type));\r
+ g.fillRect((i - start) * width, y1, width, height);\r
+\r
+ g.setColor(Color.white);\r
+\r
+ FontMetrics fm = g.getFontMetrics();\r
+ int charOffset = (width - fm.charWidth(s)) / 2;\r
+ int pady = height / 5;\r
+ g.drawString(String.valueOf(s),\r
+ charOffset + x1 + (width * (i - start)),\r
+ (y1 + height) - pady);\r
+ }\r
+ }\r
+ }\r
}\r
\r
public Color getColour(String featureType)\r
import javax.swing.BorderFactory;\r
import java.awt.event.*;\r
import javax.swing.table.*;\r
-import java.io.*;\r
\r
public class FeatureSettings extends JPanel\r
{\r
av.alignment.getSequences();\r
final JInternalFrame frame = new JInternalFrame();\r
frame.setContentPane(this);\r
- Desktop.addInternalFrame(frame, "Sequence Feature Settings", 500, 300);\r
+ Desktop.addInternalFrame(frame, "Sequence Feature Settings", 400, 300);\r
\r
\r
Vector allFeatures = new Vector();\r
Enumeration e;\r
SequenceFeature sf;\r
\r
-\r
for(int i=0; i< av.alignment.getHeight(); i++)\r
{\r
- features = av.alignment.getSequenceAt(i).getSequenceFeatures();\r
+ features = av.alignment.getSequenceAt(i).getDatasetSequence().getSequenceFeatures();\r
if(features==null)\r
continue;\r
\r
Color col = fr.getColour(type);\r
data[i][0]=type;\r
data[i][1]=col;\r
- data[i][2]= new Boolean(true);\r
+ if(fr.featuresDisplayed!=null)\r
+ data[i][2] = new Boolean(fr.featuresDisplayed.contains(type));\r
+ else\r
+ data[i][2] = new Boolean(true);\r
+\r
originalData[i][0]=type;\r
originalData[i][1]=col;\r
- originalData[i][2]= new Boolean(true);\r
+ if(fr.featuresDisplayed!=null)\r
+ originalData[i][2] = new Boolean(fr.featuresDisplayed.contains(type));\r
+ else\r
+ originalData[i][2] = new Boolean(true);\r
+\r
}\r
\r
final JSlider transparency = new JSlider(0,70,0);\r
table.setDefaultEditor(Color.class,\r
new ColorEditor());\r
\r
+ table.getColumnModel().getColumn(0).setPreferredWidth(200);\r
+\r
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
\r
table.addMouseListener(new MouseAdapter()\r