- }
-
- 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);
+ ViewStyle vs = (ViewStyle) other;
+
+ boolean match = (getAbovePIDThreshold() == vs.getAbovePIDThreshold()
+ && isCentreColumnLabels() == vs.isCentreColumnLabels()
+ && getCharHeight() == vs.getCharHeight()
+ && getCharWidth() == vs.getCharWidth()
+ && getColourAppliesToAllGroups() == vs
+ .getColourAppliesToAllGroups()
+ && isColourByReferenceSeq() == vs.isColourByReferenceSeq()
+ && getColourText() == vs.getColourText()
+ && isConservationColourSelected() == vs
+ .isConservationColourSelected()
+ && getConservationSelected() == vs.getConservationSelected()
+ && isDisplayReferenceSeq() == vs.isDisplayReferenceSeq()
+ && getFontSize() == vs.getFontSize()
+ && getFontStyle() == vs.getFontStyle()
+ && getIdWidth() == vs.getIdWidth()
+ && getIncrement() == vs.getIncrement()
+ && isRenderGaps() == vs.isRenderGaps()
+ && isRightAlignIds() == vs.isRightAlignIds()
+ && getScaleAboveWrapped() == vs.getScaleAboveWrapped()
+ && getScaleLeftWrapped() == vs.getScaleLeftWrapped()
+ && isScaleProteinAsCdna() == vs.isScaleProteinAsCdna()
+ && isProteinFontAsCdna() == vs.isProteinFontAsCdna()
+ && getScaleRightWrapped() == vs.getScaleRightWrapped()
+ && isSeqNameItalics() == vs.isSeqNameItalics()
+ && isShowAnnotation() == vs.isShowAnnotation()
+ && getShowBoxes() == vs.getShowBoxes()
+ && isShowColourText() == vs.isShowColourText()
+ && isShowDBRefs() == vs.isShowDBRefs()
+ && getShowHiddenMarkers() == vs.getShowHiddenMarkers()
+ && getShowJVSuffix() == vs.getShowJVSuffix()
+ && isShowNPFeats() == vs.isShowNPFeats()
+ && isShowSequenceFeaturesHeight() == vs
+ .isShowSequenceFeaturesHeight()
+ && isShowSequenceFeatures() == vs.isShowSequenceFeatures()
+ && getShowText() == vs.getShowText()
+ && getShowUnconserved() == vs.getShowUnconserved()
+ && getThreshold() == vs.getThreshold()
+ && getThresholdTextColour() == vs.getThresholdTextColour()
+ && isUpperCasebold() == vs.isUpperCasebold()
+ && getWrapAlignment() == vs.getWrapAlignment()
+ && getWrappedWidth() == vs.getWrappedWidth());
+ /*
+ * and compare non-primitive types; syntax below will match null with null
+ * values
+ */
+ match = match && String.valueOf(getFontName())
+ .equals(String.valueOf(vs.getFontName()));
+ match = match && String.valueOf(getTextColour())
+ .equals(String.valueOf(vs.getTextColour()));
+ match = match && String.valueOf(getTextColour2())
+ .equals(String.valueOf(vs.getTextColour2()));
+ return match;
+ // return equivalent(this, (ViewStyle) other);
+ }
+
+ /**
+ * Overridden to ensure that whenever vs1.equals(vs2) then vs1.hashCode() ==
+ * vs2.hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ /*
+ * No need to include all properties, just a selection...
+ */
+ int hash = 0;
+ int m = 1;
+ // Boolean.hashCode returns 1231 or 1237
+ hash += m++ * Boolean.valueOf(this.abovePIDThreshold).hashCode();
+ hash += m++ * Boolean.valueOf(this.centreColumnLabels).hashCode();
+ hash += m++ * Boolean.valueOf(this.colourAppliesToAllGroups).hashCode();
+ hash += m++ * Boolean.valueOf(this.displayReferenceSeq).hashCode();
+ hash += m++ * Boolean.valueOf(this.renderGaps).hashCode();
+ hash += m++ * Boolean.valueOf(this.rightAlignIds).hashCode();
+ hash += m++ * Boolean.valueOf(this.scaleProteinAsCdna).hashCode();
+ hash += m++ * Boolean.valueOf(this.scaleRightWrapped).hashCode();
+ hash += m++ * Boolean.valueOf(this.seqNameItalics).hashCode();
+ hash += m++ * Boolean.valueOf(this.showAnnotation).hashCode();
+ hash += m++ * Boolean.valueOf(this.showBoxes).hashCode();
+ hash += m++ * Boolean.valueOf(this.showdbrefs).hashCode();
+ hash += m++ * Boolean.valueOf(this.showJVSuffix).hashCode();
+ hash += m++ * Boolean.valueOf(this.showSequenceFeatures).hashCode();
+ hash += m++ * Boolean.valueOf(this.showUnconserved).hashCode();
+ hash += m++ * Boolean.valueOf(this.wrapAlignment).hashCode();
+ hash += m++ * this.charHeight;
+ hash += m++ * this.charWidth;
+ hash += m++ * fontSize;
+ hash += m++ * fontStyle;
+ hash += m++ * idWidth;
+ hash += String.valueOf(this.fontName).hashCode();
+ return hash;