// all properties of same type like Color or Font must have different hashCodes!
  private int getStyleKey(Map<String, Object> style, BandElement bandElement) {
    final int prime = 31;
    int hashCode = getFontKey(style);
    if (style.containsKey(StyleFormatConstants.BACKGROUND_COLOR)) {
      Color val = (Color) style.get(StyleFormatConstants.BACKGROUND_COLOR);
      hashCode = prime * hashCode + val.hashCode() * 3;
    }
    if (style.containsKey(StyleFormatConstants.HORIZONTAL_ALIGN_KEY)) {
      String val = (String) style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY);
      hashCode = prime * hashCode + +val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.VERTICAL_ALIGN_KEY)) {
      String val = (String) style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY);
      hashCode = prime * hashCode + val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.BORDER_LEFT)) {
      Float val = (Float) style.get(StyleFormatConstants.BORDER_LEFT) * 23;
      hashCode = prime * hashCode + val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.BORDER_RIGHT)) {
      Float val = (Float) style.get(StyleFormatConstants.BORDER_RIGHT) * 29;
      hashCode = prime * hashCode + val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.BORDER_TOP)) {
      Float val = (Float) style.get(StyleFormatConstants.BORDER_TOP) * 31;
      hashCode = prime * hashCode + val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM)) {
      Float val = (Float) style.get(StyleFormatConstants.BORDER_BOTTOM) * 37;
      hashCode = prime * hashCode + val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.BORDER_LEFT_COLOR)) {
      Color val = (Color) style.get(StyleFormatConstants.BORDER_LEFT_COLOR);
      hashCode = prime * hashCode + val.hashCode() * 5;
    }
    if (style.containsKey(StyleFormatConstants.BORDER_RIGHT_COLOR)) {
      Color val = (Color) style.get(StyleFormatConstants.BORDER_RIGHT_COLOR);
      hashCode = prime * hashCode + val.hashCode() * 7;
    }
    if (style.containsKey(StyleFormatConstants.BORDER_TOP_COLOR)) {
      Color val = (Color) style.get(StyleFormatConstants.BORDER_TOP_COLOR);
      hashCode = prime * hashCode + val.hashCode() * 11;
    }
    if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM_COLOR)) {
      Color val = (Color) style.get(StyleFormatConstants.BORDER_BOTTOM_COLOR);
      hashCode = prime * hashCode + val.hashCode() * 13;
    }
    if (style.containsKey(StyleFormatConstants.PATTERN)) {
      String val = (String) style.get(StyleFormatConstants.PATTERN);
      hashCode = prime * hashCode + val.hashCode() * 17;
    }

    if (bandElement != null) {
      hashCode = prime * hashCode + (bandElement.isWrapText() ? 19 : 41);
    }
    return hashCode;
  }
 @Override
 public int hashCode() {
   int result = myForeground != null ? myForeground.hashCode() : 0;
   result = 31 * result + (myBackground != null ? myBackground.hashCode() : 0);
   result = 31 * result + myFontType;
   result = 31 * result + (myEffectColor != null ? myEffectColor.hashCode() : 0);
   result = 31 * result + (myEffectType != null ? myEffectType.hashCode() : 0);
   result = 31 * result + (myErrorStripeColor != null ? myErrorStripeColor.hashCode() : 0);
   return result;
 }
 public int hashCode() {
   int result;
   result = (textColor != null ? textColor.hashCode() : 0);
   result = 31 * result + (borderColor != null ? borderColor.hashCode() : 0);
   result = 31 * result + (backgroundColor != null ? backgroundColor.hashCode() : 0);
   result = 31 * result + (menusEnabled ? 1 : 0);
   result = 31 * result + (toolbarButtonsEnabled ? 1 : 0);
   result = 31 * result + (toolWindowButtonsEnabled ? 1 : 0);
   result = 31 * result + (allButtonsEnabled ? 1 : 0);
   result = 31 * result + (int) (displayTime ^ (displayTime >>> 32));
   result = 31 * result + (int) (flashAnimationDelay ^ (flashAnimationDelay >>> 32));
   result = 31 * result + proposeToCreateShortcutCount;
   result = 31 * result + (fixedTipPosistion ? 1 : 0);
   result = 31 * result + (popupTemplate != null ? popupTemplate.hashCode() : 0);
   return result;
 }
Example #4
0
 @Override
 public int hashCode() {
   int result = name.hashCode();
   result = 31 * result + (color != null ? color.hashCode() : 0);
   result = 31 * result + (tasks != null ? tasks.hashCode() : 0);
   return result;
 }
 @Override
 public int hashCode() {
   int result = (myIsStandard ? 1 : 0);
   result = 31 * result + (myName != null ? myName.hashCode() : 0);
   result = 31 * result + (myValue != null ? myValue.hashCode() : 0);
   result = 31 * result + (myColor != null ? myColor.hashCode() : 0);
   return result;
 }
Example #6
0
 /** {@inheritDoc} */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((c == null) ? 0 : c.hashCode());
   result = prime * result + nextMoveCol;
   return result;
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((color == null) ? 0 : color.hashCode());
   result = prime * result + side;
   return result;
 }
 /**
  * Computes a hashcode for the LightDefinition object.
  *
  * @return the hashcode.
  */
 public int hashCode() {
   int result = 0;
   if (color != null) {
     result += color.hashCode();
   }
   if (limit != null) {
     result = 31 * result + limit.hashCode();
   } else {
     result = 31 * result;
   }
   return result;
 }
Example #9
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   // result = prime * result + ((baggle == null) ? 0 : baggle.hashCode());
   result = prime * result + ((color == null) ? 0 : color.hashCode());
   result = prime * result + ((content == null) ? 0 : content.hashCode());
   result = prime * result + (leftWall ? 1231 : 1237);
   result = prime * result + (topWall ? 1231 : 1237);
   result = prime * result + ((world == null) ? 0 : world.hashCode());
   result = prime * result + x;
   result = prime * result + y;
   return result;
 }
  private int getFontKey(Map<String, Object> style) {
    final int prime = 31;
    int hashCode = 1;

    if (style.containsKey(StyleFormatConstants.FONT_FAMILY_KEY)) {

      String val = (String) style.get(StyleFormatConstants.FONT_FAMILY_KEY);
      hashCode = prime * hashCode + val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.FONT_SIZE)) {
      Float val = (Float) style.get(StyleFormatConstants.FONT_SIZE);
      hashCode = prime * hashCode + val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.FONT_COLOR)) {
      Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR);
      hashCode = prime * hashCode + val.hashCode();
    }
    if (style.containsKey(StyleFormatConstants.FONT_STYLE_KEY)) {
      String val = (String) style.get(StyleFormatConstants.FONT_STYLE_KEY);
      hashCode = prime * hashCode + val.hashCode();
    }
    return hashCode;
  }
 public int hashCode() {
   return c.hashCode() * (horizontal ? 1 : 2) * size;
 }
  @Override
  public void produceVisibleOutput(QContent qc, boolean bInit, boolean bPlain) throws OmException {
    // Get actual current value of string
    String sCurrent = getQuestion().applyPlaceholders(sEquation);

    if (bPlain) {
      // Put text equivalent
      Element eDiv =
          qc.createElement("div"); // Can't use span because they aren't allowed to contain things
      eDiv.setAttribute("style", "display:inline");
      qc.addInlineXHTML(eDiv);
      XML.createText(eDiv, (bSpaceBefore ? " " : "") + getString("alt") + (bSpaceAfter ? " " : ""));
      qc.addTextEquivalent(getString("alt"));

      // Put each placeholder
      for (int i = 0; i < apPlaces.length; i++) {
        // Check content is not hidden
        Place p = apPlaces[i];
        if ((!p.bImplicit && !p.qc.isDisplayed()) || (p.bImplicit && !p.qc.isChildDisplayed()))
          continue;

        // Label followed by content of placeholder
        Element ePlace = XML.createChild(eDiv, "div");
        if (p.sLabel != null) {
          Element eLabel = XML.createChild(ePlace, p.sLabelFor == null ? "span" : "label");
          XML.createText(eLabel, p.sLabel + " ");
          qc.addTextEquivalent(p.sLabel);
          if (p.sLabelFor != null)
            eLabel.setAttribute(
                "for", LabelComponent.getLabel(getQDocument(), bPlain, p.sLabelFor));
        }
        qc.setParent(ePlace);
        p.qc.produceOutput(qc, bInit, bPlain);
        qc.unsetParent();
      }
    } else {
      // Check background colour, foreground, and zoom
      Color cBackground = getBackground();
      if (cBackground == null) cBackground = Color.white;
      Color cForeground =
          getQuestion().isFixedColour()
              ? convertRGB(getQuestion().getFixedColourFG())
              : Color.black;
      double dZoom = getQuestion().getZoom();

      // Hash to filename/identifier
      String sFilename =
          "eq"
              + (sCurrent.hashCode()
                  + cBackground.hashCode() * 3
                  + cForeground.hashCode() * 7
                  + (new Double(dZoom)).hashCode() * 11)
              + (getBoolean(PROPERTY_TEXTFONT) ? "t" : "e")
              + ".png";

      // Make actual image if needed, also get placeholder positions
      if (!sFilename.equals(sSent)) {
        e = Equation.create(sCurrent, (float) dZoom);
        if (getBoolean(PROPERTY_TEXTFONT)) e.setFont("Verdana", new int[] {13, 11, 9});
        BufferedImage bi = e.render(cForeground, cBackground, true);
        qc.addResource(sFilename, "image/png", QContent.convertPNG(bi));
        for (int i = 0; i < apPlaces.length; i++) {
          Point p = e.getPlaceholder(apPlaces[i].sID);
          apPlaces[i].iActualX = p.x;
          apPlaces[i].iActualY = p.y;
        }
        sSent = sFilename;
      }

      Element eEnsureSpaces = qc.createElement("div");
      eEnsureSpaces.setAttribute("class", "equation");
      qc.addInlineXHTML(eEnsureSpaces);

      // If there's a space before, add one here too (otherwise IE eats it)
      if (bSpaceBefore) XML.createText(eEnsureSpaces, " ");

      String sImageID = QDocument.ID_PREFIX + getID() + "_img";
      Element eImg = XML.createChild(eEnsureSpaces, "img");
      eImg.setAttribute("id", sImageID);
      eImg.setAttribute("onmousedown", "return false;"); // Prevent Firefox drag/drop
      eImg.setAttribute("src", "%%RESOURCES%%/" + sFilename);
      eImg.setAttribute("alt", getString("alt"));
      eImg.setAttribute("style", "vertical-align:-" + (e.getHeight() - e.getBaseline()) + "px;");

      if (bSpaceAfter) XML.createText(eEnsureSpaces, " ");

      qc.addTextEquivalent(getString("alt"));

      String sJavascript = "addOnLoad(function() { inlinePositionFix('" + sImageID + "'";

      for (int i = 0; i < apPlaces.length; i++) {
        Place p = apPlaces[i];

        // Must get the label even though not using it, just to indicate that
        // it's been used
        if (p.sLabelFor != null) LabelComponent.getLabel(getQDocument(), bPlain, p.sLabelFor);

        int iEffectiveWidth = (int) Math.round(dZoom * p.iWidth),
            iEffectiveHeight = (int) Math.round(dZoom * p.iHeight);

        String sPlaceholderID = QDocument.ID_PREFIX + getID() + "_" + p.sID;
        Element ePlace = XML.createChild(eEnsureSpaces, "div");
        ePlace.setAttribute("class", "placeholder");
        ePlace.setAttribute("id", sPlaceholderID);
        ePlace.setAttribute(
            "style",
            "width:"
                + iEffectiveWidth
                + "px; "
                + "height:"
                + iEffectiveHeight
                + "px; "
                + "visibility:hidden;");

        QComponent qcPlaceComponent = p.qc;

        if (qcPlaceComponent.isPropertyDefined(PROPERTY_FORCEWIDTH)
            && qcPlaceComponent.isPropertyDefined(PROPERTY_FORCEHEIGHT)) {
          qcPlaceComponent.setInteger(PROPERTY_FORCEWIDTH, iEffectiveWidth);
          qcPlaceComponent.setInteger(PROPERTY_FORCEHEIGHT, iEffectiveHeight);
        }

        if (p.sLabel != null) qc.addTextEquivalent(p.sLabel);
        qc.setParent(ePlace);
        qcPlaceComponent.produceOutput(qc, bInit, bPlain);
        qc.unsetParent();

        sJavascript += ",['" + sPlaceholderID + "'," + p.iActualX + "," + p.iActualY + "]";
      }
      sJavascript += "); });";

      if (apPlaces.length > 0) // No JS needed if there weren't any placeholders
      {
        Element eScript = XML.createChild(eEnsureSpaces, "script");
        eScript.setAttribute("type", "text/javascript");
        XML.createText(eScript, sJavascript);
      }
    }
  }
Example #13
0
 public int hashCode() {
   return (c.hashCode());
 }