import jalview.api.ViewStyleI;
import java.awt.Color;
+import java.lang.reflect.Method;
+import java.util.HashMap;
/**
* A container for holding alignment view properties. View properties are
int charWidth;
+ int idWidth = -1;
+
/**
* gui state - changes to colour scheme propagated to all groups
*/
private boolean colourAppliesToAllGroups;
/**
+ * centre columnar annotation labels in displayed alignment annotation
+ */
+ boolean centreColumnLabels = false;
+
+ private boolean showdbrefs;
+
+ private boolean shownpfeats;
+
+ // --------END Structure Conservation
+
+ /**
* colour according to the reference sequence defined on the alignment
*/
private boolean colourByReferenceSeq = false;
boolean upperCasebold = false;
/**
+ * name of base font for view
+ */
+ private String fontName;
+ /**
+ * size for base font
+ */
+ private int fontSize;
+
+ public ViewStyle(ViewStyleI viewStyle)
+ {
+ ViewStyle.configureFrom(this, viewStyle);
+ }
+
+ public ViewStyle()
+ {
+ }
+
+ private static HashMap<String, Method> getters, isErs, setters;
+ static
+ {
+ getters = new HashMap<String, Method>();
+ isErs = new HashMap<String, Method>();
+ setters = new HashMap<String, Method>();
+ // Match Getters and Setters
+ for (Method m : ViewStyleI.class.getMethods())
+ {
+ if (m.getDeclaringClass() == ViewStyleI.class)
+ {
+ if (m.getName().startsWith("get"))
+ {
+ getters.put(m.getName().substring(3), m);
+ }
+ if (m.getName().startsWith("is"))
+ {
+ isErs.put(m.getName().substring(2), m);
+ }
+ if (m.getName().startsWith("set"))
+ {
+ setters.put(m.getName().substring(3), m);
+ }
+ }
+ }
+ }
+
+ private static void configureFrom(ViewStyle us, ViewStyleI viewStyle)
+ {
+ // try and do the set thing
+ for (String prop : setters.keySet())
+ {
+ Method getter = getters.get(prop);
+ Method setter = setters.get(prop);
+ if (getter == null)
+ {
+ getter = isErs.get(prop);
+ }
+ if (getter != null && setter != null)
+ {
+ try
+ {
+ setter.invoke(us, getter.invoke(viewStyle));
+ } catch (Exception q)
+ {
+ System.err.println("Unexpected exception setting view property "
+ + prop + " by reflection");
+ q.printStackTrace();
+ }
+
+ }
+ }
+ }
+
+ private static boolean equivalent(ViewStyle us, ViewStyleI them)
+ {
+ // look for properties we can set
+ for (String prop : setters.keySet())
+ {
+ Method getter = getters.get(prop);
+ if (getter == null)
+ {
+ getter = isErs.get(prop);
+ }
+ if (getter != null)
+ {
+ try
+ {
+ if (!getter.invoke(them).equals(getter.invoke(us)))
+ {
+ return false;
+ }
+ } catch (Exception q)
+ {
+ System.err.println("Unexpected exception testing equivalence of property "
+ + prop + " by reflection");
+ q.printStackTrace();
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public boolean equals(ViewStyleI other)
+ {
+ return other == null ? false : equivalent(this, other);
+ }
+
+ /**
* @return the upperCasebold
*/
@Override
*/
int wrappedWidth;
+ private int fontStyle;
+
/**
* GUI state
*
abovePIDThreshold = b;
}
+
/**
* DOCUMENT ME!
*
{
this.wrappedWidth = w;
}
+
+ @Override
+ public boolean sameStyle(ViewStyleI them)
+ {
+ return equivalent(this, them);
+ }
+
+ @Override
+ public String getFontName()
+ {
+ return fontName;
+ }
+
+ @Override
+ public int getFontSize()
+ {
+ return fontSize;
+ }
+
+ @Override
+ public int getFontStyle()
+ {
+ return fontStyle;
+ }
+
+ @Override
+ public void setFontName(String name)
+ {
+ fontName = name;
+ }
+
+ @Override
+ public void setFontSize(int size)
+ {
+ fontSize = size;
+
+ }
+
+ @Override
+ public void setFontStyle(int style)
+ {
+ fontStyle = style;
+ }
+
+ @Override
+ public int getIdWidth()
+ {
+ return idWidth;
+ }
+
+ /**
+ * @param idWidth
+ * the idWidth to set
+ */
+ @Override
+ public void setIdWidth(int idWidth)
+ {
+ this.idWidth = idWidth;
+ }
+
+ /**
+ * @return the centreColumnLabels
+ */
+ @Override
+ public boolean isCentreColumnLabels()
+ {
+ return centreColumnLabels;
+ }
+
+ /**
+ * @param centreColumnLabels
+ * the centreColumnLabels to set
+ */
+ @Override
+ public void setCentreColumnLabels(boolean centreColumnLabels)
+ {
+ this.centreColumnLabels = centreColumnLabels;
+ }
+
+ /**
+ * @return the showdbrefs
+ */
+ @Override
+ public boolean isShowDBRefs()
+ {
+ return showdbrefs;
+ }
+
+ /**
+ * @param showdbrefs
+ * the showdbrefs to set
+ */
+ @Override
+ public void setShowDBRefs(boolean showdbrefs)
+ {
+ this.showdbrefs = showdbrefs;
+ }
+
+ /**
+ * @return the shownpfeats
+ */
+ @Override
+ public boolean isShowNPFeats()
+ {
+ return shownpfeats;
+ }
+
+ /**
+ * @param shownpfeats
+ * the shownpfeats to set
+ */
+ @Override
+ public void setShowNPFeats(boolean shownpfeats)
+ {
+ this.shownpfeats = shownpfeats;
+ }
}