This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/src/main/java/envoy/client/ui/Theme.java

182 lines
4.9 KiB
Java

package envoy.client.ui;
import java.awt.Color;
import java.io.Serializable;
/**
* Project: <strong>envoy-client</strong><br>
* File: <strong>Theme.java</strong><br>
* Created: <strong>23 Nov 2019</strong><br>
*
* @author Maximilian K&auml;fer
* @since Envoy v0.2-alpha
*/
public class Theme implements Serializable {
private static final long serialVersionUID = 141727847527060352L;
private String themeName;
private Color backgroundColor;
private Color cellColor;
private Color interactableBackgroundColor;
private Color userNameColor;
private Color interactableForegroundColor;
private Color messageColorChat;
private Color dateColorChat;
private Color selectionColor;
private Color typingMessageColor;
public Theme(String themeName, Color backgroundColor, Color cellColor, Color interactableForegroundColor,
Color interactableBackgroundColor, Color messageColorChat, Color dateColorChat, Color selectionColor,
Color typingMessageColor, Color userNameColor) {
this.themeName = themeName;
this.backgroundColor = backgroundColor;
this.cellColor = cellColor;
this.interactableForegroundColor = interactableForegroundColor;
this.interactableBackgroundColor = interactableBackgroundColor;
this.messageColorChat = messageColorChat;
this.dateColorChat = dateColorChat;
this.selectionColor = selectionColor;
this.typingMessageColor = typingMessageColor;
this.userNameColor = userNameColor;
}
public Theme(String name, Theme other) {
this(name, other.backgroundColor, other.cellColor, other.interactableBackgroundColor,
other.interactableForegroundColor, other.messageColorChat, other.dateColorChat, other.selectionColor,
other.typingMessageColor, other.userNameColor);
}
/**
* @return name of the theme
* @since Envoy v0.2-alpha
*/
public String getThemeName() { return themeName; }
/**
* @return interactableForegroundColor
* @since Envoy v0.2-alpha
*/
public Color getInteractableForegroundColor() { return interactableForegroundColor; }
/**
* @return messageColorChat
* @since Envoy v0.2-alpha
*/
public Color getMessageColorChat() { return messageColorChat; }
/**
* @return dateColorChat
* @since Envoy v0.2-alpha
*/
public Color getDateColorChat() { return dateColorChat; }
/**
* @return selectionColor
* @since Envoy v0.2-alpha
*/
public Color getSelectionColor() { return selectionColor; }
/**
* @return typingMessageColor
* @since Envoy v0.2-alpha
*/
public Color getTypingMessageColor() { return typingMessageColor; }
/**
* @return backgroundColor
* @since Envoy v0.2-alpha
*/
public Color getBackgroundColor() { return backgroundColor; }
/**
* @return cellColor
* @since Envoy v0.2-alpha
*/
public Color getCellColor() { return cellColor; }
/**
* @return interactableBackgroundColor
* @since Envoy v0.2-alpha
*/
public Color getInteractableBackgroundColor() { return interactableBackgroundColor; }
/**
* @return userNameColor
* @since Envoy v0.2-alpha
*/
public Color getUserNameColor() { return userNameColor; }
/**
* @return a color array containing all colors of this theme
* @since Envoy v0.2-alpha
*/
public Color[] getAllColors() {
Color[] c = new Color[9];
c[0] = backgroundColor;
c[1] = cellColor;
c[2] = interactableForegroundColor;
c[3] = interactableBackgroundColor;
c[4] = messageColorChat;
c[5] = dateColorChat;
c[6] = selectionColor;
c[7] = typingMessageColor;
c[8] = userNameColor;
return c;
}
/**
* Sets the a specific {@link Color} in this theme to a new {@link Color}
*
* @param index - index of the color </br>
* 0 = backgroundColor </br>
* 1 = cellColor </br>
* 2 = interactableForegroundColor </br>
* 3 = interactableBackgroundColor </br>
* 4 = messageColorChat </br>
* 5 = dateColorChat </br>
* 6 = selectionColor </br>
* 7 = typingMessageColor </br>
* 8 = userNameColor </br>
* </br>
*
* @param newColor - new {@link Color} to be set
* @since Envoy 0.2-alpha
*/
public void setColor(int index, Color newColor) {
switch (index) {
case 0:
this.backgroundColor = newColor;
break;
case 1:
this.cellColor = newColor;
break;
case 2:
this.interactableForegroundColor = newColor;
break;
case 3:
this.interactableBackgroundColor = newColor;
break;
case 4:
this.messageColorChat = newColor;
break;
case 5:
this.dateColorChat = newColor;
break;
case 6:
this.selectionColor = newColor;
break;
case 7:
this.typingMessageColor = newColor;
break;
case 8:
this.userNameColor = newColor;
break;
}
}
}