From 65a73bdab9f97cadab54162fbbe53ba9f1d3f3be Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 13 Dec 2016 10:57:13 +0000 Subject: [PATCH] JAL-2360 code formatting only and if-else changed to switch --- src/jalview/schemes/BuriedColourScheme.java | 1 + src/jalview/schemes/ClustalxColourScheme.java | 1 + src/jalview/schemes/ColourSchemeI.java | 25 +++--- src/jalview/schemes/ColourSchemeProperty.java | 82 ++++++++++---------- src/jalview/schemes/CovariationColourScheme.java | 1 + src/jalview/schemes/HelixColourScheme.java | 1 + src/jalview/schemes/HydrophobicColourScheme.java | 1 + .../schemes/PurinePyrimidineColourScheme.java | 1 + .../schemes/RNAInteractionColourScheme.java | 21 +---- src/jalview/schemes/ResidueColourScheme.java | 5 +- src/jalview/schemes/StrandColourScheme.java | 1 + src/jalview/schemes/TurnColourScheme.java | 1 + 12 files changed, 65 insertions(+), 76 deletions(-) diff --git a/src/jalview/schemes/BuriedColourScheme.java b/src/jalview/schemes/BuriedColourScheme.java index 3c68da0..4a850f0 100755 --- a/src/jalview/schemes/BuriedColourScheme.java +++ b/src/jalview/schemes/BuriedColourScheme.java @@ -47,6 +47,7 @@ public class BuriedColourScheme extends ScoreColourScheme * * @return DOCUMENT ME! */ + @Override public Color makeColour(float c) { return new Color(0, (float) (1.0 - c), c); diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index ca4316f..33bd0d9 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -74,6 +74,7 @@ public class ClustalxColourScheme extends ResidueColourScheme alignmentChanged(alignment, hiddenReps); } + @Override public void alignmentChanged(AnnotatedCollectionI alignment, Map hiddenReps) { diff --git a/src/jalview/schemes/ColourSchemeI.java b/src/jalview/schemes/ColourSchemeI.java index da99a4a..fb86888 100755 --- a/src/jalview/schemes/ColourSchemeI.java +++ b/src/jalview/schemes/ColourSchemeI.java @@ -35,7 +35,7 @@ public interface ColourSchemeI * @param c * @return the colour for the given character */ - public Color findColour(char c); + Color findColour(char c); /** * @@ -48,51 +48,51 @@ public interface ColourSchemeI * @return context dependent colour for the given symbol at the position in * the given sequence */ - public Color findColour(char c, int j, SequenceI seq); + Color findColour(char c, int j, SequenceI seq); /** * assign the given consensus profile for the colourscheme */ - public void setConsensus(ProfilesI hconsensus); + void setConsensus(ProfilesI hconsensus); /** * assign the given conservation to the colourscheme * * @param c */ - public void setConservation(jalview.analysis.Conservation c); + void setConservation(jalview.analysis.Conservation c); /** * enable or disable conservation shading for this colourscheme * * @param conservationApplied */ - public void setConservationApplied(boolean conservationApplied); + void setConservationApplied(boolean conservationApplied); /** * * @return true if conservation shading is enabled for this colourscheme */ - public boolean conservationApplied(); + boolean conservationApplied(); /** * set scale factor for bleaching of colour in unconserved regions * * @param i */ - public void setConservationInc(int i); + void setConservationInc(int i); /** * * @return scale factor for bleaching colour in unconserved regions */ - public int getConservationInc(); + int getConservationInc(); /** * * @return percentage identity threshold for applying colourscheme */ - public int getThreshold(); + int getThreshold(); /** * set percentage identity threshold and type of %age identity calculation for @@ -103,7 +103,7 @@ public interface ColourSchemeI * @param ignoreGaps * when true, calculate PID without including gapped positions */ - public void setThreshold(int ct, boolean ignoreGaps); + void setThreshold(int ct, boolean ignoreGaps); /** * recalculate dependent data using the given sequence collection, taking @@ -112,7 +112,7 @@ public interface ColourSchemeI * @param alignment * @param hiddenReps */ - public void alignmentChanged(AnnotatedCollectionI alignment, + void alignmentChanged(AnnotatedCollectionI alignment, Map hiddenReps); /** @@ -123,7 +123,6 @@ public interface ColourSchemeI * @param hiddenRepSequences * @return copy of current scheme with any inherited settings transfered */ - public ColourSchemeI applyTo(AnnotatedCollectionI sg, + ColourSchemeI applyTo(AnnotatedCollectionI sg, Map hiddenRepSequences); - } diff --git a/src/jalview/schemes/ColourSchemeProperty.java b/src/jalview/schemes/ColourSchemeProperty.java index 0d9c39d..fc703ba 100755 --- a/src/jalview/schemes/ColourSchemeProperty.java +++ b/src/jalview/schemes/ColourSchemeProperty.java @@ -415,8 +415,7 @@ public class ColourSchemeProperty try { // fix the launchApp user defined coloursheme transfer bug - jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme( - "white"); + UserColourScheme ucs = new UserColourScheme("white"); ucs.parseAppletParameter(name); } catch (Exception e) @@ -425,7 +424,7 @@ public class ColourSchemeProperty } } } - return getColour(alignment, getColourIndexFromName(name)); + return getColour(alignment, colindex); } /** @@ -538,61 +537,64 @@ public class ColourSchemeProperty return cs; } + /** + * Returns the Color constant for a given colour name e.g. "pink", or null if + * the name is not recognised + * + * @param name + * @return + */ public static Color getAWTColorFromName(String name) { + if (name == null) + { + return null; + } Color col = null; name = name.toLowerCase(); - if (name.equals("black")) + + // or make a static map; or use reflection on the field name + switch (name) { + case "black": col = Color.black; - } - else if (name.equals("blue")) - { + break; + case "blue": col = Color.blue; - } - else if (name.equals("cyan")) - { + break; + case "cyan": col = Color.cyan; - } - else if (name.equals("darkGray")) - { + break; + case "darkGray": col = Color.darkGray; - } - else if (name.equals("gray")) - { + break; + case "gray": col = Color.gray; - } - else if (name.equals("green")) - { + break; + case "green": col = Color.green; - } - else if (name.equals("lightGray")) - { + break; + case "lightGray": col = Color.lightGray; - } - else if (name.equals("magenta")) - { + break; + case "magenta": col = Color.magenta; - } - else if (name.equals("orange")) - { + break; + case "orange": col = Color.orange; - } - else if (name.equals("pink")) - { + break; + case "pink": col = Color.pink; - } - else if (name.equals("red")) - { + break; + case "red": col = Color.red; - } - else if (name.equals("white")) - { + break; + case "white": col = Color.white; - } - else if (name.equals("yellow")) - { + break; + case "yellow": col = Color.yellow; + break; } return col; diff --git a/src/jalview/schemes/CovariationColourScheme.java b/src/jalview/schemes/CovariationColourScheme.java index 49d5dee..4701e0b 100644 --- a/src/jalview/schemes/CovariationColourScheme.java +++ b/src/jalview/schemes/CovariationColourScheme.java @@ -85,6 +85,7 @@ public class CovariationColourScheme extends ResidueColourScheme * * @return DOCUMENT ME! */ + @Override public Color findColour(char c) { // System.out.println("called"); log.debug diff --git a/src/jalview/schemes/HelixColourScheme.java b/src/jalview/schemes/HelixColourScheme.java index 1242cd3..c6ac7a5 100755 --- a/src/jalview/schemes/HelixColourScheme.java +++ b/src/jalview/schemes/HelixColourScheme.java @@ -30,6 +30,7 @@ public class HelixColourScheme extends ScoreColourScheme ResidueProperties.helixmin, ResidueProperties.helixmax); } + @Override public Color makeColour(float c) { return new Color(c, (float) 1.0 - c, c); diff --git a/src/jalview/schemes/HydrophobicColourScheme.java b/src/jalview/schemes/HydrophobicColourScheme.java index 055000f..954471f 100755 --- a/src/jalview/schemes/HydrophobicColourScheme.java +++ b/src/jalview/schemes/HydrophobicColourScheme.java @@ -47,6 +47,7 @@ public class HydrophobicColourScheme extends ScoreColourScheme * * @return DOCUMENT ME! */ + @Override public Color makeColour(float c) { return new Color(c, (float) 0.0, (float) 1.0 - c); diff --git a/src/jalview/schemes/PurinePyrimidineColourScheme.java b/src/jalview/schemes/PurinePyrimidineColourScheme.java index d2b878d..8bbbd15 100644 --- a/src/jalview/schemes/PurinePyrimidineColourScheme.java +++ b/src/jalview/schemes/PurinePyrimidineColourScheme.java @@ -47,6 +47,7 @@ public class PurinePyrimidineColourScheme extends ResidueColourScheme * @return Color from purinepyrimidineIndex in * jalview.schemes.ResidueProperties */ + @Override public Color findColour(char c) { return colors[ResidueProperties.purinepyrimidineIndex[c]]; diff --git a/src/jalview/schemes/RNAInteractionColourScheme.java b/src/jalview/schemes/RNAInteractionColourScheme.java index 794195a..db1401a 100644 --- a/src/jalview/schemes/RNAInteractionColourScheme.java +++ b/src/jalview/schemes/RNAInteractionColourScheme.java @@ -31,34 +31,17 @@ public class RNAInteractionColourScheme extends ResidueColourScheme super(); } - /** - * DOCUMENT ME! - * - * @param n - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ @Override public Color findColour(char c) { - // System.out.println("called"); log.debug + // FIXME this is just a copy of NucleotideColourScheme return colors[ResidueProperties.nucleotideIndex[c]]; } - /** - * DOCUMENT ME! - * - * @param n - * DOCUMENT ME! - * @param j - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ @Override public Color findColour(char c, int j, SequenceI seq) { + // FIXME this is just a copy of NucleotideColourScheme Color currentColour; if ((threshold == 0) || aboveThreshold(c, j)) { diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index f6b7c5e..e675a27 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -34,10 +34,7 @@ import java.awt.Color; import java.util.Map; /** - * DOCUMENT ME! - * - * @author $author$ - * @version $Revision$ + * Base class for residue-based colour schemes */ public class ResidueColourScheme implements ColourSchemeI { diff --git a/src/jalview/schemes/StrandColourScheme.java b/src/jalview/schemes/StrandColourScheme.java index 1340de3..56a2d90 100755 --- a/src/jalview/schemes/StrandColourScheme.java +++ b/src/jalview/schemes/StrandColourScheme.java @@ -47,6 +47,7 @@ public class StrandColourScheme extends ScoreColourScheme * * @return DOCUMENT ME! */ + @Override public Color makeColour(float c) { return new Color(c, c, (float) 1.0 - c); diff --git a/src/jalview/schemes/TurnColourScheme.java b/src/jalview/schemes/TurnColourScheme.java index 22422ff..2c95755 100755 --- a/src/jalview/schemes/TurnColourScheme.java +++ b/src/jalview/schemes/TurnColourScheme.java @@ -47,6 +47,7 @@ public class TurnColourScheme extends ScoreColourScheme * * @return DOCUMENT ME! */ + @Override public Color makeColour(float c) { return new Color(c, 1 - c, 1 - c); -- 1.7.10.2