/**
  * Computes the mean rating that a user has given to movies.
  *
  * @param ratings Map of ratings for a particular user.
  * @return Returns a double indicating the average rating.
  */
 public static double calculateMean(Map<Integer, Rating> ratings) {
   double sum = 0;
   for (Rating r : ratings.values()) {
     sum += r.getRating();
   }
   return sum / ratings.size();
 }
  /**
   * Get ratings and feedbacks
   *
   * @return list of ratings and feedbacks in Rating objects
   * @throws SQLException
   */
  public ArrayList<Rating> getRatingsAndFeedbacks() throws SQLException {
    String sql = "SELECT * FROM Rating";

    try {
      Statement statement = (Statement) connection.createStatement();
      ResultSet rs = statement.executeQuery(sql);
      ArrayList<Rating> list = new ArrayList<>();

      while (rs.next()) {
        Rating rating = new Rating();
        rating.setCID(rs.getInt("cID"));
        rating.setFeedback(rs.getString("feedback"));
        rating.setStars(rs.getInt("stars"));

        list.add(rating);
      }

      if (statement != null) {
        statement.close();
      }
      return list;
    } catch (SQLException e) {
      e.printStackTrace();
      System.out.println("Error! Cannot get ratings and feedbacks");
      return null;
    }
  }
  /**
   * Shows the PopUp
   *
   * @param e MouseEvent
   */
  protected void showPopUpMenu(MouseEvent e) {
    if (!(e.getSource() instanceof JList)) {
      return;
    }

    JList list = (JList) e.getSource();

    int i = list.locationToIndex(e.getPoint());
    list.setSelectedIndex(i);

    JPopupMenu menu = new JPopupMenu();

    Rating selRating = (Rating) list.getSelectedValue();

    JMenuItem item = new JMenuItem(mLocalizer.msg("showDetails", "Show Details"));
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            view();
          }
        });
    item.setFont(item.getFont().deriveFont(Font.BOLD));

    menu.add(item);
    menu.add(new ListAction(this, selRating.getTitle()));
    menu.add(new ShowDetailsAction(selRating.getRatingId()));

    menu.show(list, e.getX(), e.getY());
  }
Beispiel #4
0
 public Item(Integer id, String name, List<Rating> ratings) {
   this.id = id;
   this.name = name;
   // load ratings into userId -> rating map.
   ratingsByUserId = new HashMap<Integer, Rating>(ratings.size());
   for (Rating r : ratings) {
     ratingsByUserId.put(r.getUserId(), r);
   }
 }
Beispiel #5
0
 public double getAverageRating() {
   double allRatingsSum = 0.0;
   Collection<Rating> allItemRatings = ratingsByUserId.values();
   for (Rating rating : allItemRatings) {
     allRatingsSum += rating.getRating();
   }
   // use 2.5 if there are no ratings.
   return allItemRatings.size() > 0 ? allRatingsSum / allItemRatings.size() : 2.5;
 }
Beispiel #6
0
 public static Integer[] getSharedUserIds(Item x, Item y) {
   List<Integer> sharedUsers = new ArrayList<Integer>();
   for (Rating r : x.getAllRatings()) {
     // same user rated the item
     if (y.getUserRating(r.getUserId()) != null) {
       sharedUsers.add(r.getUserId());
     }
   }
   return sharedUsers.toArray(new Integer[sharedUsers.size()]);
 }
  @Test
  public void storeRating() throws Exception {
    repository.add(new BookRating(A_BOOK_RATING_ID, A_BOOK_ID, Rating.value(3)));
    repository.add(new BookRating(ANOTHER_BOOK_RATING_ID, A_BOOK_ID, Rating.value(4)));

    assertThat(
        repository.allRatings(),
        is(
            asList(
                new BookRating(A_BOOK_RATING_ID, A_BOOK_ID, Rating.value(3)),
                new BookRating(ANOTHER_BOOK_RATING_ID, A_BOOK_ID, Rating.value(4)))));
  }
Beispiel #8
0
 /*
  * Utility method to extract array of ratings based on array of user ids.
  */
 public double[] getRatingsForItemList(Integer[] userIds) {
   double[] ratings = new double[userIds.length];
   for (int i = 0, n = userIds.length; i < n; i++) {
     Rating r = getUserRating(userIds[i]);
     if (r == null) {
       throw new IllegalArgumentException(
           "Item doesn't have rating by specified user id ("
               + "userId="
               + userIds[i]
               + ", itemId="
               + getId());
     }
     ratings[i] = r.getRating();
   }
   return ratings;
 }
Beispiel #9
0
 public int hashCode() {
   int result;
   result = rating.hashCode();
   result = 29 * result + (text != null ? text.hashCode() : 0);
   result = 29 * result + created.hashCode();
   return result;
 }
  public BookRatingResponse execute(BookRatingRequest request) {
    Book book = aBookFoundWithId(request.getBookId());
    BookRating rate = book.rate(Rating.value(request.getRating()));

    bookRatingRepository.add(rate);

    return new BookRatingResponse();
  }
Beispiel #11
0
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof Comment)) return false;

    final Comment comment = (Comment) o;

    if (!(created.getTime() == comment.created.getTime())) return false;
    if (!rating.equals(comment.rating)) return false;
    if (text != null ? !text.equals(comment.text) : comment.text != null) return false;

    return true;
  }
 /**
  * Creates a new SubmissionData object based on a String returned by {@link #toString()}.
  *
  * @param s A String
  */
 public SubmissionData(String s) {
   String[] parts = s.split("&", 9);
   artist = decode(parts[0]);
   track = decode(parts[1]);
   startTime = parts[2].length() == 0 ? 0 : Long.valueOf(parts[2]);
   source = Source.valueOf(parts[3]);
   recommendationKey = parts[4].length() == 0 ? null : parts[4];
   rating = parts[5].length() == 0 ? null : Rating.valueOf(parts[5]);
   length = parts[6].length() == 0 ? -1 : Integer.valueOf(parts[6]);
   album = parts[7].length() == 0 ? null : decode(parts[7]);
   tracknumber = parts[8].length() == 0 ? -1 : Integer.valueOf(parts[8]);
 }
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((actors == null) ? 0 : actors.hashCode());
   result = prime * result + ((category == null) ? 0 : category.hashCode());
   result = prime * result + ((description == null) ? 0 : description.hashCode());
   result = prime * result + ((languages == null) ? 0 : languages.hashCode());
   result = prime * result + ((rating == null) ? 0 : rating.hashCode());
   result = prime * result + release_year;
   result = prime * result + ((title == null) ? 0 : title.hashCode());
   return result;
 }
  public static void main(String[] args) {
    // Maps that maps a user id to a subset of ratings given by that user.
    Map<Integer, User> trainRatings = new HashMap<Integer, User>();
    Map<Integer, User> testRatings = new HashMap<Integer, User>();

    // Parse training and test data into maps.
    System.out.println("1. Parsing DataSets");
    parseRatings(trainRatings, "./DataSet/TrainingRatings.txt");
    parseRatings(testRatings, "./DataSet/TestingRatings.txt");

    // Fill Map of means.
    System.out.println("2. Calculating Mean Values");
    for (Integer uid : trainRatings.keySet()) {
      trainRatings.get(uid).setMean(calculateMean(trainRatings.get(uid).getRatings()));
    }

    // Predict ratings for users.
    System.out.println("3. Predicting Ratings");
    int total = 0;
    double errorAbsSum = 0;
    double errorRootSum = 0;
    for (Integer uid : testRatings.keySet()) {
      // Predict movie ratings and determine error summation
      for (Integer mid : testRatings.get(uid).getRatings().keySet()) {
        Rating r = testRatings.get(uid).getRatings().get(mid);
        double error =
            r.getRating() - calculateWeightedSum(trainRatings, trainRatings.get(uid), mid);
        errorAbsSum += Math.abs(error);
        errorRootSum += Math.pow(error, 2);
        total++;
      }
    }

    // Compute accuracy of algorithm.
    System.out.printf("Mean Absolute Error: %.2f\n", (errorAbsSum / total));
    System.out.printf("Root Mean Squared Error: %.2f\n", (Math.sqrt(errorRootSum / total)));
  }
  /**
   * Returns a String representation of this submission with the fields separated by &. Order of the
   * fields is:<br>
   * <tt>artist&track&startTime&Source&RecommendationKey&Rating&length&album&tracknumber</tt><br>
   * Note that: - Values may possibly be <code>null</code> or empty - enum values such as Rating and
   * Source are <code>null</code> or their constant name is used (i.e. "LOVE") - all string values
   * (artist, track, album) are utf8-url-encoded
   *
   * @return a String
   */
  public String toString() {
    String b = encode(album != null ? album : "");
    String artist = encode(this.artist);
    String track = encode(this.track);
    String l = length == -1 ? "" : String.valueOf(length);
    String n = tracknumber == -1 ? "" : String.valueOf(tracknumber);

    String r = "";
    if (rating != null) r = rating.name();
    String rec = "";
    if (recommendationKey != null && source == Source.LAST_FM && recommendationKey.length() == 5)
      rec = recommendationKey;

    return String.format(
        "%s&%s&%s&%s&%s&%s&%s&%s&%s", artist, track, startTime, source.name(), rec, r, l, b, n);
  }
  String toString(String sessionId, int index) {
    String b = encode(album != null ? album : "");
    String artist = encode(this.artist);
    String track = encode(this.track);
    String l = length == -1 ? "" : String.valueOf(length);
    String n = tracknumber == -1 ? "" : String.valueOf(tracknumber);

    String r = "";
    if (rating != null) r = rating.getCode();
    String rec = "";
    if (recommendationKey != null && source == Source.LAST_FM && recommendationKey.length() == 5)
      rec = recommendationKey;

    return String.format(
        "s=%s&a[%10$d]=%s&t[%10$d]=%s&i[%10$d]=%s&o[%10$d]=%s&r[%10$d]=%s&l[%10$d]=%s&b[%10$d]=%s&n[%10$d]=%s&m[%10$d]=",
        sessionId, artist, track, startTime, source.getCode() + rec, r, l, b, n, index);
  }
 public static String alphaBeta(int depth, int beta, int alpha, String move, int player) {
   // return in the form of 1234b##########
   String list = posibleMoves();
   if (depth == 0 || list.length() == 0) {
     return move + (Rating.rating(list.length(), depth) * (1 - player * 2));
   }
   list = sortMoves(list);
   player = 1 - player; // either 1 or 0: 0 is computer 1 is human
   for (int i = 0; i < list.length(); i += 5) {
     makeMove(list.substring(i, i + 5));
     flipBoard();
     String returnString = alphaBeta(depth - 1, beta, alpha, list.substring(i, i + 5), player);
     int value = Integer.valueOf(returnString.substring(5));
     flipBoard();
     undoMove(list.substring(i, i + 5));
     if (player == 0) {
       if (value <= beta) {
         beta = value;
         if (depth == globalDepth) {
           move = returnString.substring(0, 5);
         }
       }
     } else {
       if (value > alpha) {
         alpha = value;
         if (depth == globalDepth) {
           move = returnString.substring(0, 5);
         }
       }
     }
     if (alpha >= beta) {
       if (player == 0) {
         return move + beta;
       } else {
         return move + alpha;
       }
     }
   }
   if (player == 0) {
     return move + beta;
   } else {
     return move + alpha;
   }
 }
  /**
   * Calculates the weight for two users over all items they share recorded ratings for.
   *
   * @param train User object for particular user in training data.
   * @param test User object for active user.
   * @return Returns a Double representing the computed weight.
   */
  public static double calculateWeight(User train, User test) {
    double numSum = 0;
    double denTestSum = 0;
    double denTrainSum = 0;
    Map<Integer, Rating> ratings = train.getRatings();

    for (Rating r : test.getRatings().values()) {
      if (ratings.containsKey(r.getMovieId())) {
        numSum +=
            (r.getRating() - test.getMean())
                * (ratings.get(r.getMovieId()).getRating() - train.getMean());
        denTestSum += Math.pow(r.getRating() - test.getMean(), 2);
        denTrainSum += Math.pow(ratings.get(r.getMovieId()).getRating() - train.getMean(), 2);
      }
    }
    return (denTestSum == 0 || denTrainSum == 0) ? 0 : numSum / Math.sqrt(denTestSum * denTrainSum);
  }
 public static String sortMoves(String list) {
   int[] score = new int[list.length() / 5];
   for (int i = 0; i < list.length(); i += 5) {
     makeMove(list.substring(i, i + 5));
     score[i / 5] = Rating.rating(-1, 0);
     undoMove(list.substring(i, i + 5));
   }
   String newListA = "", newListB = list;
   for (int i = 0; i < Math.min(6, list.length() / 5); i++) { // first few
     // moves only
     int max = -1000000, maxLocation = 0;
     for (int j = 0; j < list.length() / 5; j++) {
       if (score[j] > max) {
         max = score[j];
         maxLocation = j;
       }
     }
     score[maxLocation] = -1000000;
     newListA += list.substring(maxLocation * 5, maxLocation * 5 + 5);
     newListB = newListB.replace(list.substring(maxLocation * 5, maxLocation * 5 + 5), "");
   }
   return newListA + newListB;
 }
Beispiel #20
0
  public static void main(String[] args) {

    Student student = new Student();
    student.setName("Jeff");

    Address homeAddress = new Address();
    homeAddress.setAddressType(AddressType.HOME);
    homeAddress.setAddressLine1("101 Fifth St.");
    homeAddress.setAddressLine2("Suite 3a");
    homeAddress.setCity("St. Charles");
    homeAddress.setState("MO");
    homeAddress.setPostalCode("63303");

    Set addresses = new HashSet();
    addresses.add(homeAddress);

    student.setAddresses(addresses);

    Instructor instructor = new Instructor();
    instructor.setFirstName("John");
    instructor.setLastName("Smith");
    instructor.setInstructorName(instructor.getFirstName(), instructor.getLastName());

    Instructor instructor2 = new Instructor();
    instructor2.setFirstName("Ron");
    instructor2.setLastName("Regan");
    instructor2.setInstructorName(instructor.getFirstName(), instructor.getLastName());

    Course java = new Course();
    java.setCourseName("CSP 443 Advanced Java");
    java.setCreditHours(3.0f);
    java.setInstructor(instructor);

    Course cSharp = new Course();
    cSharp.setCourseName("CSP 233 Beginning C#");
    cSharp.setCreditHours(5.0f);
    java.setInstructor(instructor2);

    Course algebra = new Course();
    algebra.setCourseName("Beginners Algebra");
    algebra.setCreditHours(3.0f);
    algebra.setInstructor(instructor2);

    Course computer = new Course();
    computer.setCourseName("Intro to Computer Science");
    computer.setCreditHours(4.5f);
    computer.setInstructor(instructor);

    Rating rate = new Rating();
    rate.setCourse(java, 8.5d);

    Rating rate2 = new Rating();
    rate2.setCourse(cSharp, 9.0d);

    Rating rate3 = new Rating();
    rate3.setCourse(algebra, 7.0);

    Rating rate4 = new Rating();
    rate4.setCourse(computer, 8.0);

    Set courses = new HashSet();
    courses.add(java);
    courses.add(cSharp);
    courses.add(computer);
    courses.add(algebra);

    student.setCourses(courses);

    Set instructors = new HashSet();
    instructors.add(instructor);
    instructors.add(instructor2);

    instructor.setInstructors(instructors);

    Grade javaGrade = new Grade(student, java, 3.459f);
    Grade cSharpGrade = new Grade(student, cSharp, 3.975f);
    Grade algebraGrade = new Grade(student, algebra, 3.5f);
    Grade computerGrade = new Grade(student, computer, 3.0f);

    Session session = HibernateUtilities.getSessionFactory().openSession();
    session.beginTransaction();

    session.save(student);
    session.save(javaGrade);
    session.save(cSharpGrade);
    session.save(algebraGrade);
    session.save(computerGrade);

    session.getTransaction().commit();
    session.close();

    double result = GradebookBusinessLogic.calculateCumulativeGPA(student);

    System.out.println(student.getName() + " Cumulative Grade: " + result);
    System.out.println(instructor.getInstructorName() + ":" + rate4.getRate());
    System.out.println(instructor2.getInstructorName() + ";" + rate3.getRate());
  }
  @FXML
  private void ratingButtonClicked(ActionEvent event) throws SQLException {
    configureButtons();
    ratingButton.setGraphic(ratingSelectedIMV);

    // clear old content
    contentPane.getChildren().clear();

    // set up
    titleLabel.setText("Rating and Feedback");

    // rating box
    HBox ratingBox = new HBox();
    ratingBox.setAlignment(Pos.CENTER);
    ratingBox.setSpacing(20);
    ratingBox.setPadding(new Insets(10, 0, 10, 0));

    // Rating label
    Label ratingTitle = new Label("Average Rating: ");
    ratingTitle.setFont(new Font("System", 24));

    // 5 stars
    String yellowStarURL = "Graphics/StarYellow.png";
    String blankStarURL = "Graphics/StarBlank.png";

    ImageView starBlank1 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank2 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank3 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank4 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank5 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));

    Button star1 = new Button();
    star1.setGraphic(starBlank1);
    star1.setStyle("-fx-background-color: transparent");
    Button star2 = new Button();
    star2.setGraphic(starBlank2);
    star2.setStyle("-fx-background-color: transparent");
    Button star3 = new Button();
    star3.setGraphic(starBlank3);
    star3.setStyle("-fx-background-color: transparent");
    Button star4 = new Button();
    star4.setGraphic(starBlank4);
    star4.setStyle("-fx-background-color: transparent");
    Button star5 = new Button();
    star5.setGraphic(starBlank5);
    star5.setStyle("-fx-background-color: transparent");

    // get average rating
    double avgRating = 0;
    try {
      avgRating = operation.getAverageRating();
    } catch (SQLException e) {
      e.printStackTrace();
      ratingTitle.setText("Error! Can't get average rating");
    }

    Button[] buttonlist = new Button[5];
    buttonlist[0] = star1;
    buttonlist[1] = star2;
    buttonlist[2] = star3;
    buttonlist[3] = star4;
    buttonlist[4] = star5;

    for (int i = 0; i < Math.floor(avgRating); i++) {
      ImageView image = new ImageView(new Image(getClass().getResourceAsStream(yellowStarURL)));
      buttonlist[i].setGraphic(image);
    }

    // feedback box
    VBox feedBackBox = new VBox();
    feedBackBox.setAlignment(Pos.CENTER);
    feedBackBox.setSpacing(20);

    // Feedback title
    Label feedBackLabel = new Label("Feedback:");
    feedBackLabel.setFont(new Font("System", 24));

    // get feedback string
    String feedback = "";
    ArrayList<Rating> list = operation.getRatingsAndFeedbacks();

    for (Rating r : list) {
      feedback += r.getFeedback() + "\n\n";
    }

    Text feedbackText = new Text(feedback);
    feedbackText.setFont(new Font("System", 14));

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(feedbackText);

    // Add children nodes to appropriate boxes
    ratingBox.getChildren().addAll(ratingTitle, star1, star2, star3, star4, star5);
    feedBackBox.getChildren().addAll(feedBackLabel, scrollPane);

    // main box
    VBox mainBox = new VBox();
    mainBox.setSpacing(40);
    mainBox.getChildren().addAll(ratingBox, feedBackBox);

    contentPane.getChildren().add(mainBox);
  }
Beispiel #22
0
 /**
  * Updates existing user rating or adds a new user rating for this item.
  *
  * @param r rating to add.
  */
 public void addUserRating(Rating r) {
   ratingsByUserId.put(r.getUserId(), r);
 }
  /**
   * Accept Programs if rating fits
   *
   * @param program check this program
   * @return true, if rating fits
   */
  public boolean accept(Program program) {
    Rating rating = TVRaterPlugin.getInstance().getRating(program);

    if (rating == null) {
      return false;
    }

    if (mBest
        && rating.getOverallRating() >= mAcceptValues[TVRaterFilterAllCategories.OVERALL_INDEX]
        && rating.getActionRating() >= mAcceptValues[TVRaterFilterAllCategories.ACTION_INDEX]
        && rating.getFunRating() >= mAcceptValues[TVRaterFilterAllCategories.FUN_INDEX]
        && rating.getEroticRating() >= mAcceptValues[TVRaterFilterAllCategories.EROTIC_INDEX]
        && rating.getTensionRating() >= mAcceptValues[TVRaterFilterAllCategories.TENSION_INDEX]
        && rating.getEntitlementRating()
            >= mAcceptValues[TVRaterFilterAllCategories.ENTITLEMENT_INDEX]) {
      return true;
    } else if (!mBest
        && rating.getOverallRating() <= mAcceptValues[TVRaterFilterAllCategories.OVERALL_INDEX]
        && rating.getActionRating() <= mAcceptValues[TVRaterFilterAllCategories.ACTION_INDEX]
        && rating.getFunRating() <= mAcceptValues[TVRaterFilterAllCategories.FUN_INDEX]
        && rating.getEroticRating() <= mAcceptValues[TVRaterFilterAllCategories.EROTIC_INDEX]
        && rating.getTensionRating() <= mAcceptValues[TVRaterFilterAllCategories.TENSION_INDEX]
        && rating.getEntitlementRating()
            <= mAcceptValues[TVRaterFilterAllCategories.ENTITLEMENT_INDEX]) {
      return true;
    }
    return false;
  }
  @Override
  public JPanel getSettingsPanel() {
    JPanel panel =
        new JPanel(
            new FormLayout(
                "pref, 3dlu, pref",
                "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref"));
    CellConstraints cc = new CellConstraints();

    // better-or-worse-combobox + label
    panel.add(new JLabel(mLocalizer.msg("programsThatAre", "Programs that are")), cc.xy(1, 1));
    mBetterCombo =
        new JComboBox(
            new String[] {
              mLocalizer.msg("betterOrEqual", "better than or equal to"),
              mLocalizer.msg("worseOrEqual", "inferior or equal to")
            });
    if (mBest) {
      mBetterCombo.setSelectedIndex(0);
    } else {
      mBetterCombo.setSelectedIndex(1);
    }
    panel.add(mBetterCombo, cc.xy(3, 1));

    // the rating for the RatingComboBox
    Rating filterRating = new Rating("");
    filterRating.setOverallRating(mAcceptValues[TVRaterFilterAllCategories.OVERALL_INDEX]);
    filterRating.setActionRating(mAcceptValues[TVRaterFilterAllCategories.ACTION_INDEX]);
    filterRating.setFunRating(mAcceptValues[TVRaterFilterAllCategories.FUN_INDEX]);
    filterRating.setEroticRating(mAcceptValues[TVRaterFilterAllCategories.EROTIC_INDEX]);
    filterRating.setTensionRating(mAcceptValues[TVRaterFilterAllCategories.TENSION_INDEX]);
    filterRating.setEntitlementRating(mAcceptValues[TVRaterFilterAllCategories.ENTITLEMENT_INDEX]);

    // overall rating box + label
    panel.add(new JLabel(mLocalizer.msg("overall", "Overall") + ":"), cc.xy(1, 3));
    mOverallRatingBox = new RatingComboBox(filterRating, Rating.OVERALL_RATING_KEY);
    panel.add(mOverallRatingBox, cc.xy(3, 3));

    // action rating box + label
    panel.add(new JLabel(mLocalizer.msg("action", "Action") + ":"), cc.xy(1, 5));
    mActionRatingBox = new RatingComboBox(filterRating, Rating.ACTION_RATING_KEY);
    panel.add(mActionRatingBox, cc.xy(3, 5));

    // fun rating box + label
    panel.add(new JLabel(mLocalizer.msg("fun", "Fun") + ":"), cc.xy(1, 7));
    mFunRatingBox = new RatingComboBox(filterRating, Rating.FUN_RATING_KEY);
    panel.add(mFunRatingBox, cc.xy(3, 7));

    // erotic rating box + label
    panel.add(new JLabel(mLocalizer.msg("erotic", "Erotic") + ":"), cc.xy(1, 9));
    mEroticRatingBox = new RatingComboBox(filterRating, Rating.EROTIC_RATING_KEY);
    panel.add(mEroticRatingBox, cc.xy(3, 9));

    // tension rating box + label
    panel.add(new JLabel(mLocalizer.msg("tension", "Tension") + ":"), cc.xy(1, 11));
    mTensionRatingBox = new RatingComboBox(filterRating, Rating.TENSION_RATING_KEY);
    panel.add(mTensionRatingBox, cc.xy(3, 11));

    // entitlement rating box + label
    panel.add(new JLabel(mLocalizer.msg("entitlement", "Level") + ":"), cc.xy(1, 13));
    mEntitlementRatingBox = new RatingComboBox(filterRating, Rating.ENTITLEMENT_RATING_KEY);
    panel.add(mEntitlementRatingBox, cc.xy(3, 13));

    return panel;
  }
 @Override
 public JsonElement serialize(Rating src, Type typeOfSrc, JsonSerializationContext context) {
   return new JsonPrimitive(src.getRating());
 }