コード例 #1
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);
  }