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

147 lines
4.7 KiB
Java
Executable File

package envoy.client.ui;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* 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 Client v0.2-alpha
*/
public class Theme implements Serializable {
private static final long serialVersionUID = 0L;
private String themeName;
private Map<String, Color> colors = new HashMap<>();
/**
* Initializes a {@link Theme} with all colors relevant to the application GUI.
*
* @param themeName the name of the {@link Theme}
* @param backgroundColor the background color
* @param cellColor the cell color
* @param interactableForegroundColor the color of interactable foreground UI
* elements
* @param interactableBackgroundColor the color of interactable background UI
* elements
* @param textColor the color normal text should be displayed
* in
* @param dateColorChat the color of chat message metadata
* @param selectionColor the section color
* @param typingMessageColor the color of currently typed messages
* @param userNameColor the color of user names
* @since Envoy Client v0.2-alpha
*/
public Theme(String themeName, Color backgroundColor, Color cellColor, Color interactableForegroundColor, Color interactableBackgroundColor,
Color textColor, Color dateColorChat, Color selectionColor, Color typingMessageColor, Color userNameColor) {
this.themeName = themeName;
colors.put("backgroundColor", backgroundColor);
colors.put("cellColor", cellColor);
colors.put("interactableForegroundColor", interactableForegroundColor);
colors.put("interactableBackgroundColor", interactableBackgroundColor);
colors.put("textColor", textColor);
colors.put("dateColorChat", dateColorChat);
colors.put("selectionColor", selectionColor);
colors.put("typingMessageColor", typingMessageColor);
colors.put("userNameColor", userNameColor);
}
/**
* Initializes a {@link Theme} by copying all parameters except for the name
* from another {@link Theme} instance.
*
* @param name the name of the {@link Theme}
* @param other the {@link Theme} to copy
* @since Envoy Client v0.2-alpha
*/
public Theme(String name, Theme other) {
themeName = name;
colors.putAll(other.colors);
}
/**
* @return a {@code Map<String, Color>} of all colors defined for this theme
* with their names as keys
* @since Envoy Client v0.2-alpha
*/
public Map<String, Color> getColors() { return colors; }
/**
* @return name of the theme
* @since Envoy Client v0.2-alpha
*/
public String getThemeName() { return themeName; }
/**
* @return interactableForegroundColor
* @since Envoy Client v0.2-alpha
*/
public Color getInteractableForegroundColor() { return colors.get("interactableForegroundColor"); }
/**
* @return the {@link Color} in which the text content of a message should be
* displayed
* @since Envoy Client v0.2-alpha
*/
public Color getTextColor() { return colors.get("textColor"); }
/**
* @return the {@link Color} in which the creation date of a message should be
* displayed
* @since Envoy Client v0.2-alpha
*/
public Color getDateColor() { return colors.get("dateColorChat"); }
/**
* @return selectionColor
* @since Envoy Client v0.2-alpha
*/
public Color getSelectionColor() { return colors.get("selectionColor"); }
/**
* @return typingMessageColor
* @since Envoy Client v0.2-alpha
*/
public Color getTypingMessageColor() { return colors.get("typingMessageColor"); }
/**
* @return backgroundColor
* @since Envoy Client v0.2-alpha
*/
public Color getBackgroundColor() { return colors.get("backgroundColor"); }
/**
* @return cellColor
* @since Envoy Client v0.2-alpha
*/
public Color getCellColor() { return colors.get("cellColor"); }
/**
* @return interactableBackgroundColor
* @since Envoy Client v0.2-alpha
*/
public Color getInteractableBackgroundColor() { return colors.get("interactableBackgroundColor"); }
/**
* @return userNameColor
* @since Envoy Client v0.2-alpha
*/
public Color getUserNameColor() { return colors.get("userNameColor"); }
/**
* Sets the a specific {@link Color} in this theme to a new {@link Color}
*
* @param colorName the name of the {@link Color} to set
* @param newColor the new {@link Color} to be set
* @since Envoy 0.2-alpha
*/
public void setColor(String colorName, Color newColor) { colors.put(colorName, newColor); }
}