コード例 #1
0
ファイル: Themes.java プロジェクト: Ruruzahari/cabra
 /**
  * Sets the current theme.
  *
  * @param theme the new theme
  */
 public static void setTheme(Themes theme) {
   currentTheme = theme;
   System.out.println(theme.getName());
   // activate current theme
   GUI.resetLookAndFeel(); // wipes the slate clean
   theme.doColoring();
   GUI.setNimbusLookAndFeel(); // puts nimbus back on
 }
コード例 #2
0
ファイル: Themes.java プロジェクト: Ruruzahari/cabra
  /**
   * Finds all the themes available and returns them.
   *
   * @return all the themes available to the user, in an arraylist
   */
  public static ArrayList<Themes> getAvailableThemes() {
    ArrayList<Themes> themes = new ArrayList<Themes>();

    for (Themes theme : Themes.values()) {
      if (theme.isUnlocked()) themes.add(theme);
    }

    return themes;
  }
コード例 #3
0
ファイル: Utils.java プロジェクト: hathix/cabra-desktop
  /**
   * Draws an emblem (based on current theme) in the bottom left of the given component. Call this
   * in paintComponent() of the component.
   *
   * @param component the component to draw on
   * @param g the Graphics object from paintComponent()
   */
  public static void drawEmblem(JComponent component, Graphics g) {
    Themes currentTheme = Themes.getCurrentTheme();
    ImageIcon image = GUI.createImageIcon("translucent/" + currentTheme.getImageIconPath());

    /*if(Themes.getCurrentTheme() == Themes.SNOW){
        image = GUI.createImageIcon("translucent/snow.png");
    }*/

    int imageWidth = image.getIconWidth();
    int imageHeight = image.getIconHeight();
    // top left corner of where to start drawing
    int topLeftX = component.getWidth() - imageWidth; // x (horizontal) coordinate
    int topLeftY = component.getHeight() - imageHeight; // y (vertical) coordinate

    // draw in bottom right corner
    g.drawImage(image.getImage(), topLeftX, topLeftY, (java.awt.image.ImageObserver) null);
    // g.drawImage(image.getImage(), 0,0, (java.awt.image.ImageObserver)null);
  }
コード例 #4
0
ファイル: Themes.java プロジェクト: Ruruzahari/cabra
 /**
  * Turns the given string into the corresponding Themes.
  *
  * @param theName the name of the theme you want to get
  * @return the Themes that was created
  */
 public static Themes getThemeByName(String theName) {
   // returns the Themes value based on its name
   try {
     theName =
         theName.replace(
             ' ',
             '_'); // replaces the spaces with underscores so that stuff like Evil Goat won't break
     return Themes.valueOf(
         theName
             .toUpperCase()); // if theName's "Cherry", it turns it to "CHERRY" and returns
                              // Themes.CHERRY
   } catch (IllegalArgumentException e) {
     // no idea what the theme is, so return the default one
     return Themes.SPONGEBOB;
   }
 }
コード例 #5
0
ファイル: Themes.java プロジェクト: Ruruzahari/cabra
    @Override
    public void doColoring() {
      Calendar now = Calendar.getInstance();
      final int year = now.get(Calendar.YEAR);

      // compare to now to determine theme
      Calendar spring = Calendar.getInstance();
      spring.set(year, 3 - 1, 1); // March 1

      Calendar summerSolstice = Calendar.getInstance();
      summerSolstice.set(year, 6 - 1, 21); // June 21

      Calendar fall = Calendar.getInstance();
      fall.set(year, 9 - 1, 1); // September 1

      Calendar halloween = Calendar.getInstance();
      halloween.set(year, 10 - 1, 31); // October 31

      // today's relation to a certain event
      // on or before counts as yes; so:
      // >0 to see if you're after
      // <= 0 to see if you're before

      // think about it
      // Nov to Feb - Snow (4 months)
      // Mar to May - Spring (3 months)
      // Jun to Aug - Beach (3 months)
      // Sep to Oct - Halloween (2 months)

      Themes theme = Themes.DEFAULT;
      if (now.compareTo(halloween) > 0 || now.compareTo(spring) <= 0) {
        // after halloween, before spring solstice
        theme = Themes.SNOW;
      } else if (now.compareTo(fall) > 0) {
        // before halloween (necessarily), after fall solstice
        theme = Themes.HALLOWEEN;
      } else if (now.compareTo(summerSolstice) > 0) {
        // before fall and halloween (necessarily), after summer solstice
        theme = Themes.BEACH;
      } else if (now.compareTo(spring) > 0) {
        // before fall, summer, and halloween (necessarily), after spring solstice
        theme = Themes.SPRING;
      }

      Themes.setTheme(theme);
    }
コード例 #6
0
ファイル: Themes.java プロジェクト: Ruruzahari/cabra
 public static ArrayList<Themes> getAllThemes() {
   ArrayList<Themes> themes = new ArrayList<Themes>();
   themes.addAll(Arrays.asList(Themes.values()));
   return themes;
 }
コード例 #7
0
ファイル: Themes.java プロジェクト: Ruruzahari/cabra
 @Override
 public void doColoring() {
   resetDefaults();
   Themes theme = randomTheme();
   Themes.setTheme(theme);
 }