From 5ea6a9eaee50c1747250717f572ed3a0e8346ac9 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Sat, 9 May 2020 09:50:41 +0200 Subject: [PATCH] Remove ui.primary package --- .../client/ui/primary/PrimaryButton.java | 63 --------- .../client/ui/primary/PrimaryScrollBar.java | 126 ------------------ .../client/ui/primary/PrimaryScrollPane.java | 85 ------------ .../client/ui/primary/PrimaryTextArea.java | 70 ---------- .../ui/primary/PrimaryToggleSwitch.java | 61 --------- .../envoy/client/ui/primary/package-info.java | 17 --- 6 files changed, 422 deletions(-) delete mode 100644 src/main/java/envoy/client/ui/primary/PrimaryButton.java delete mode 100644 src/main/java/envoy/client/ui/primary/PrimaryScrollBar.java delete mode 100644 src/main/java/envoy/client/ui/primary/PrimaryScrollPane.java delete mode 100644 src/main/java/envoy/client/ui/primary/PrimaryTextArea.java delete mode 100644 src/main/java/envoy/client/ui/primary/PrimaryToggleSwitch.java delete mode 100644 src/main/java/envoy/client/ui/primary/package-info.java diff --git a/src/main/java/envoy/client/ui/primary/PrimaryButton.java b/src/main/java/envoy/client/ui/primary/PrimaryButton.java deleted file mode 100644 index de7852c..0000000 --- a/src/main/java/envoy/client/ui/primary/PrimaryButton.java +++ /dev/null @@ -1,63 +0,0 @@ -package envoy.client.ui.primary; - -import java.awt.Graphics; - -import javax.swing.JButton; - -/** - * Project: envoy-client
- * File: PrimaryButton.javaEvent.java
- * Created: 07.12.2019
- * - * @author Kai S. K. Engelbart - * @author Maximilian Käfer - * @since Envoy Client v0.2-alpha - */ -public class PrimaryButton extends JButton { - - private static final long serialVersionUID = 0L; - - private int arcSize; - - /** - * Creates a primary button - * - * @param title the title of the button - * @since Envoy 0.2-alpha - */ - public PrimaryButton(String title) { this(title, 6); } - - /** - * Creates a primary button - * - * @param title the title of the button - * @param arcSize the size of the arc used to draw the round button edges - * @since Envoy 0.2-alpha - */ - public PrimaryButton(String title, int arcSize) { - super(title); - setBorderPainted(false); - setFocusPainted(false); - setContentAreaFilled(false); - this.arcSize = arcSize; - } - - @Override - protected void paintComponent(Graphics g) { - g.setColor(getBackground()); - g.fillRoundRect(0, 0, getWidth(), getHeight(), arcSize, arcSize); - super.paintComponent(g); - } - - /** - * @return the arcSize - * @since Envoy 0.2-alpha - */ - public int getArcSize() { return arcSize; } - - /** - * @param arcSize the arcSize to set - * @since Envoy 0.2-alpha - */ - public void setArcSize(int arcSize) { this.arcSize = arcSize; } -} diff --git a/src/main/java/envoy/client/ui/primary/PrimaryScrollBar.java b/src/main/java/envoy/client/ui/primary/PrimaryScrollBar.java deleted file mode 100644 index 371bd05..0000000 --- a/src/main/java/envoy/client/ui/primary/PrimaryScrollBar.java +++ /dev/null @@ -1,126 +0,0 @@ -package envoy.client.ui.primary; - -import java.awt.*; - -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JScrollBar; -import javax.swing.plaf.basic.BasicScrollBarUI; - -import envoy.client.data.Settings; -import envoy.client.ui.Theme; - -/** - * Project: envoy-client
- * File: PrimaryScrollBar.java
- * Created: 14.12.2019
- * - * @author Maximilian Käfer - * @since Envoy Client v0.2-alpha - */ -public class PrimaryScrollBar extends BasicScrollBarUI { - - private final Dimension d = new Dimension(); - private final int arcSize; - private final Color scrollBarColor; - private final Color hoverColor; - private final Color draggingColor; - private final boolean isVertical; - - /** - * Initializes a {@link PrimaryScrollBar} with a color scheme. - * - * @param arcSize the size of the arc used to draw the round scroll bar - * edges - * @param scrollBarColor the default color - * @param hoverColor the color while hovering - * @param draggingColor the color while dragging - * @param isVertical indicates whether this is a vertical - * {@link PrimaryScrollBar} - */ - public PrimaryScrollBar(int arcSize, Color scrollBarColor, Color hoverColor, Color draggingColor, boolean isVertical) { - this.arcSize = arcSize; - this.scrollBarColor = scrollBarColor; - this.hoverColor = hoverColor; - this.draggingColor = draggingColor; - this.isVertical = isVertical; - } - - /** - * Initializes a {@link PrimaryScrollBar} using a color scheme specified in a - * {@link Theme} - * - * @param theme the {@link Theme} to be applied to this - * {@link PrimaryScrollBar} - * @param isVertical indicates whether this is a vertical - * {@link PrimaryScrollBar} - */ - public PrimaryScrollBar(Theme theme, boolean isVertical) { - this(5, theme.getInteractableBackgroundColor(), new Color(theme.getInteractableBackgroundColor().getRGB() - 50), - new Color(theme.getInteractableBackgroundColor().getRGB() + 170), isVertical); - } - - /** - * {@inheritDoc} - */ - @Override - protected JButton createDecreaseButton(int orientation) { - JButton button = new JButton(); - button.setPreferredSize(d); - return button; - } - - /** - * {@inheritDoc} - */ - @Override - protected JButton createIncreaseButton(int orientation) { - JButton button = new JButton(); - button.setPreferredSize(d); - return button; - } - - /** - * {@inheritDoc} - */ - @Override - protected void paintTrack(Graphics g, JComponent c, Rectangle r) {} - - /** - * {@inheritDoc} - */ - @Override - protected void paintThumb(Graphics g, JComponent c, Rectangle r) { - Graphics2D g2 = (Graphics2D) g.create(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - Color color; - JScrollBar sb = (JScrollBar) c; - - if (!sb.isEnabled()) return; - - if (isDragging) color = draggingColor; - else if (isThumbRollover()) color = hoverColor; - else color = scrollBarColor; - - g2.setPaint(color); - if (isVertical) { - g2.fillRoundRect(r.x - 9, r.y, r.width, r.height, arcSize, arcSize); - g2.setPaint(Settings.getInstance().getCurrentTheme().getCellColor()); - g2.drawRoundRect(r.x - 9, r.y, r.width, r.height, arcSize, arcSize); - } else { - g2.fillRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize); - g2.setPaint(Settings.getInstance().getCurrentTheme().getCellColor()); - g2.drawRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize); - } - g2.dispose(); - } - - /** - * {@inheritDoc} - */ - @Override - protected void setThumbBounds(int x, int y, int width, int height) { - super.setThumbBounds(x, y, width, height); - scrollbar.repaint(); - } -} diff --git a/src/main/java/envoy/client/ui/primary/PrimaryScrollPane.java b/src/main/java/envoy/client/ui/primary/PrimaryScrollPane.java deleted file mode 100644 index e02502b..0000000 --- a/src/main/java/envoy/client/ui/primary/PrimaryScrollPane.java +++ /dev/null @@ -1,85 +0,0 @@ -package envoy.client.ui.primary; - -import javax.swing.JScrollPane; - -import envoy.client.ui.Theme; - -/** - * Project: envoy-client
- * File: PrimaryScrollPane.java
- * Created: 15 Dec 2019
- * - * @author Kai S. K. Engelbart - * @author Maximilian Käfer - */ -public class PrimaryScrollPane extends JScrollPane { - - private static final long serialVersionUID = 0L; - - private int verticalScrollBarMaximum = getVerticalScrollBar().getMaximum(); - private boolean chatOpened = false; - - /** - * Initializes a {@link JScrollPane} with the primary Envoy design scheme - * - * @since Envoy Client v0.2-alpha - */ - public PrimaryScrollPane() { setBorder(null); } - - /** - * Styles the vertical and horizontal scroll bars. - * - * @param theme the color set used to color the component - * @since Envoy Client v0.2-alpha - */ - public void applyTheme(Theme theme) { - setForeground(theme.getBackgroundColor()); - setBackground(theme.getCellColor()); - - getVerticalScrollBar().setBackground(theme.getCellColor()); - getVerticalScrollBar().setUI(new PrimaryScrollBar(theme, true)); - - getHorizontalScrollBar().setBackground(theme.getCellColor()); - getHorizontalScrollBar().setUI(new PrimaryScrollBar(theme, false)); - } - - /** - * Implements autoscroll functionality for the vertical scroll bar.
- *
- * Functionality to automatically scroll down when user views
- * the bottom of the chat while there are new messages added.
- *
- * When chat is opened, the vertical scroll bar starts at the bottom.
- *
- * When rereading messages, the chat doesn't scroll down if new messages
- * are added. (Besides see first point) - * - * @since Envoy Client v0.2-alpha - */ - public void autoscroll() { - // Automatic scrolling to the bottom - getVerticalScrollBar().addAdjustmentListener(e -> { - if (verticalScrollBarMaximum == e.getAdjustable().getMaximum()) return; - - if (chatOpened) { - e.getAdjustable().setValue(e.getAdjustable().getMaximum()); - verticalScrollBarMaximum = getVerticalScrollBar().getMaximum(); - chatOpened = false; - return; - } - if (getVerticalScrollBar().getValue() + getVerticalScrollBar().getVisibleAmount() + 100 >= getVerticalScrollBar().getMaximum()) { - e.getAdjustable().setValue(e.getAdjustable().getMaximum()); - verticalScrollBarMaximum = getVerticalScrollBar().getMaximum(); - } - }); - } - - /** - * Indicates a chat being opened by the user to this {@link PrimaryScrollPane} - * triggering it to automatically scroll down. - * - * @param chatOpened indicates the chat opening status - * @since Envoy Client v0.2-alpha - */ - public void setChatOpened(boolean chatOpened) { this.chatOpened = chatOpened; } -} diff --git a/src/main/java/envoy/client/ui/primary/PrimaryTextArea.java b/src/main/java/envoy/client/ui/primary/PrimaryTextArea.java deleted file mode 100644 index 37d05eb..0000000 --- a/src/main/java/envoy/client/ui/primary/PrimaryTextArea.java +++ /dev/null @@ -1,70 +0,0 @@ -package envoy.client.ui.primary; - -import java.awt.Font; -import java.awt.Graphics; - -import javax.swing.JTextArea; -import javax.swing.border.EmptyBorder; - -/** - * Project: envoy-client
- * File: PrimaryTextArea.javaEvent.java
- * Created: 07.12.2019
- * - * @author Maximilian Käfer - * @since Envoy Client v0.2-alpha - */ -public class PrimaryTextArea extends JTextArea { - - private static final long serialVersionUID = 0L; - private int arcSize; - - /** - * Creates the text area - * - * @param borderSpace the space between components - * @since Envoy 0.2-alpha - */ - public PrimaryTextArea(int borderSpace) { this(6, borderSpace); } - - /** - * Creates the text area - * - * @param arcSize is the diameter of the arc at the four corners. - * @param borderSpace is the insets of the border on all four sides. - * @since Envoy 0.2-alpha - */ - public PrimaryTextArea(int arcSize, int borderSpace) { - super(); - setWrapStyleWord(true); - setLineWrap(true); - setBorder(null); - setFont(new Font("Arial", Font.PLAIN, 17)); - setBorder(new EmptyBorder(borderSpace, borderSpace, borderSpace, borderSpace)); - setOpaque(false); - - this.arcSize = arcSize; - } - - /** - * {@inheritDoc} - */ - @Override - protected void paintComponent(Graphics g) { - g.setColor(getBackground()); - g.fillRoundRect(0, 0, getWidth(), getHeight(), arcSize, arcSize); - super.paintComponent(g); - } - - /** - * @return the arcSize - the diameter of the arc at the four corners. - * @since Envoy 0.2-alpha - */ - public int getArcSize() { return arcSize; } - - /** - * @param arcSize the arcSize to set - * @since Envoy 0.2-alpha - */ - public void setArcSize(int arcSize) { this.arcSize = arcSize; } -} diff --git a/src/main/java/envoy/client/ui/primary/PrimaryToggleSwitch.java b/src/main/java/envoy/client/ui/primary/PrimaryToggleSwitch.java deleted file mode 100644 index 87afed9..0000000 --- a/src/main/java/envoy/client/ui/primary/PrimaryToggleSwitch.java +++ /dev/null @@ -1,61 +0,0 @@ -package envoy.client.ui.primary; - -import java.awt.Dimension; -import java.awt.Graphics; - -import javax.swing.JButton; - -import envoy.client.data.Settings; -import envoy.client.data.SettingsItem; -import envoy.client.ui.Color; - -/** - * This component can be used to toggle between two options. This will change - * the state of a {@code boolean} {@link SettingsItem}.
- *
- * Project: envoy-client
- * File: PrimaryToggleSwitch.java
- * Created: 21 Dec 2019
- * - * @author Maximilian Käfer - * @author Kai S. K. Engelbart - * @since Envoy Client v0.3-alpha - */ -public class PrimaryToggleSwitch extends JButton { - - private boolean state; - - private static final long serialVersionUID = 0L; - - /** - * Initializes a {@link PrimaryToggleSwitch}. - * - * @param settingsItem the {@link SettingsItem} that is controlled by this - * {@link PrimaryToggleSwitch} - * @since Envoy Client v0.3-alpha - */ - public PrimaryToggleSwitch(SettingsItem settingsItem) { - setPreferredSize(new Dimension(50, 25)); - setMinimumSize(new Dimension(50, 25)); - setMaximumSize(new Dimension(50, 25)); - - setBorderPainted(false); - setFocusPainted(false); - setContentAreaFilled(false); - - state = settingsItem.get(); - addActionListener((evt) -> { state = !state; settingsItem.set(state); revalidate(); repaint(); }); - } - - /** - * {@inheritDoc} - */ - @Override - public void paintComponent(Graphics g) { - g.setColor(state ? Color.GREEN : Color.LIGHT_GRAY); - g.fillRoundRect(0, 0, getWidth(), getHeight(), 25, 25); - - g.setColor(Settings.getInstance().getCurrentTheme().getInteractableBackgroundColor()); - g.fillRoundRect(state ? 25 : 0, 0, 25, 25, 25, 25); - } -} diff --git a/src/main/java/envoy/client/ui/primary/package-info.java b/src/main/java/envoy/client/ui/primary/package-info.java deleted file mode 100644 index d4c54fa..0000000 --- a/src/main/java/envoy/client/ui/primary/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This package defines all "primary" components that were defined specifically - * for the visual improvement of Envoy. However, they can still be used in - * general for other projects.
- * Primary elements are supposed to provide the main functionality of a UI - * component.
- *
- * Project: envoy-client
- * File: package-info.java
- * Created: 14 Mar 2020
- * - * @author Leon Hofmeister - * @author Kai S. K. Engelbart - * @author Maximilian Käfer - * @since Envoy Client v0.1-beta - */ -package envoy.client.ui.primary;