Improved code style and formatting
This commit is contained in:
parent
cf56b2f7ad
commit
b051ddb831
@ -49,22 +49,22 @@ public class ChatWindow extends JFrame {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 6865098428255463649L;
|
private static final long serialVersionUID = 6865098428255463649L;
|
||||||
|
|
||||||
// user specific objects
|
// User specific objects
|
||||||
private Client client;
|
private Client client;
|
||||||
private LocalDB localDB;
|
private LocalDB localDB;
|
||||||
|
|
||||||
// GUI components
|
// GUI components
|
||||||
private JPanel contentPane = new JPanel();
|
private JPanel contentPane = new JPanel();
|
||||||
private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space);
|
private PrimaryTextArea messageEnterTextArea = new PrimaryTextArea(space);
|
||||||
private JList<User> userList = new JList<>();
|
private JList<User> userList = new JList<>();
|
||||||
private Chat currentChat;
|
private Chat currentChat;
|
||||||
private JList<Message> messageList = new JList<>();
|
private JList<Message> messageList = new JList<>();
|
||||||
private JScrollPane scrollPane = new JScrollPane();
|
private JScrollPane scrollPane = new JScrollPane();
|
||||||
private JTextPane textPane = new JTextPane();
|
|
||||||
// private JCheckBox jCbChangeMode;
|
|
||||||
private PrimaryButton postButton = new PrimaryButton("Post");
|
|
||||||
private PrimaryButton settingsButton = new PrimaryButton("Settings");
|
|
||||||
private int verticalScrollBarMaximumValue = scrollPane.getVerticalScrollBar().getMaximum();
|
private int verticalScrollBarMaximumValue = scrollPane.getVerticalScrollBar().getMaximum();
|
||||||
private boolean chatOpened = false;
|
private boolean chatOpened = false;
|
||||||
|
private JTextPane textPane = new JTextPane();
|
||||||
|
private PrimaryButton postButton = new PrimaryButton("Post");
|
||||||
|
private PrimaryButton settingsButton = new PrimaryButton("Settings");
|
||||||
|
|
||||||
private static int space = 4;
|
private static int space = 4;
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ public class ChatWindow extends JFrame {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to immediately reload the ChatWindow when settings were changed.
|
* Used to immediately reload the ChatWindow when settings were changed.
|
||||||
*
|
*
|
||||||
* @since Envoy v0.1-alpha
|
* @since Envoy v0.1-alpha
|
||||||
*/
|
*/
|
||||||
public void changeChatWindowColors(String key) {
|
public void changeChatWindowColors(String key) {
|
||||||
@ -260,8 +260,7 @@ public class ChatWindow extends JFrame {
|
|||||||
// Scroll Bar Styling
|
// Scroll Bar Styling
|
||||||
scrollPane.getVerticalScrollBar().setBackground(theme.getCellColor());
|
scrollPane.getVerticalScrollBar().setBackground(theme.getCellColor());
|
||||||
scrollPane.getVerticalScrollBar()
|
scrollPane.getVerticalScrollBar()
|
||||||
.setUI(new PrimaryScrollBar(5, theme.getInteractableBackgroundColor(),
|
.setUI(new PrimaryScrollBar(5, theme.getInteractableBackgroundColor(), new Color(theme.getInteractableBackgroundColor().getRGB() - 50),
|
||||||
new Color(theme.getInteractableBackgroundColor().getRGB() - 50),
|
|
||||||
new Color(theme.getInteractableBackgroundColor().getRGB() + 170), true));
|
new Color(theme.getInteractableBackgroundColor().getRGB() + 170), true));
|
||||||
scrollPane.getHorizontalScrollBar().setBackground(theme.getCellColor());
|
scrollPane.getHorizontalScrollBar().setBackground(theme.getCellColor());
|
||||||
scrollPane.getHorizontalScrollBar()
|
scrollPane.getHorizontalScrollBar()
|
||||||
@ -270,9 +269,7 @@ public class ChatWindow extends JFrame {
|
|||||||
|
|
||||||
// Autoscroll
|
// Autoscroll
|
||||||
scrollPane.getVerticalScrollBar().addAdjustmentListener(e -> {
|
scrollPane.getVerticalScrollBar().addAdjustmentListener(e -> {
|
||||||
if ((verticalScrollBarMaximumValue - e.getAdjustable().getMaximum()) == 0) {
|
if ((verticalScrollBarMaximumValue - e.getAdjustable().getMaximum()) == 0) { return; }
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chatOpened == true) {
|
if (chatOpened == true) {
|
||||||
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
|
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
|
||||||
@ -280,8 +277,8 @@ public class ChatWindow extends JFrame {
|
|||||||
chatOpened = false;
|
chatOpened = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (scrollPane.getVerticalScrollBar().getValue()
|
if (scrollPane.getVerticalScrollBar().getValue() + scrollPane.getVerticalScrollBar().getVisibleAmount()
|
||||||
+ scrollPane.getVerticalScrollBar().getVisibleAmount() + 100 >= scrollPane.getVerticalScrollBar().getMaximum()) {
|
+ 100 >= scrollPane.getVerticalScrollBar().getMaximum()) {
|
||||||
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
|
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
|
||||||
verticalScrollBarMaximumValue = scrollPane.getVerticalScrollBar().getMaximum();
|
verticalScrollBarMaximumValue = scrollPane.getVerticalScrollBar().getMaximum();
|
||||||
}
|
}
|
||||||
|
@ -16,23 +16,23 @@ import envoy.client.Settings;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>envoy-client</strong><br>
|
* Project: <strong>envoy-client</strong><br>
|
||||||
* File: <strong>PrimaryScrollBar.javaEvent.java</strong><br>
|
* File: <strong>PrimaryScrollBar.java</strong><br>
|
||||||
* Created: <strong>14.12.2019</strong><br>
|
* Created: <strong>14.12.2019</strong><br>
|
||||||
*
|
*
|
||||||
* @author Maximilian Käfer
|
* @author Maximilian Käfer
|
||||||
* @since Envoy v0.2-alpha
|
* @since Envoy v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public class PrimaryScrollBar extends BasicScrollBarUI{
|
public class PrimaryScrollBar extends BasicScrollBarUI {
|
||||||
|
|
||||||
private final Dimension d = new Dimension();
|
private final Dimension d = new Dimension();
|
||||||
private int arcSize;
|
private final int arcSize;
|
||||||
private Color scrollBarColor;
|
private final Color scrollBarColor;
|
||||||
private Color hoverColor;
|
private final Color hoverColor;
|
||||||
private Color draggingColor;
|
private final Color draggingColor;
|
||||||
private boolean isVertical;
|
private final boolean isVertical;
|
||||||
|
|
||||||
public PrimaryScrollBar(int arcSize, Color scrollBarColor, Color hoverColor, Color draggingColor, boolean isVertical) {
|
public PrimaryScrollBar(int arcSize, Color scrollBarColor, Color hoverColor, Color draggingColor, boolean isVertical) {
|
||||||
this.arcSize = arcSize;
|
this.arcSize = arcSize;
|
||||||
this.scrollBarColor = scrollBarColor;
|
this.scrollBarColor = scrollBarColor;
|
||||||
this.hoverColor = hoverColor;
|
this.hoverColor = hoverColor;
|
||||||
this.draggingColor = draggingColor;
|
this.draggingColor = draggingColor;
|
||||||
@ -41,62 +41,45 @@ public class PrimaryScrollBar extends BasicScrollBarUI{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JButton createDecreaseButton(int orientation) {
|
protected JButton createDecreaseButton(int orientation) {
|
||||||
return new JButton() {
|
JButton button = new JButton();
|
||||||
private static final long serialVersionUID = 1032443171070235890L;
|
button.setPreferredSize(d);
|
||||||
|
return button;
|
||||||
@Override
|
|
||||||
public Dimension getPreferredSize() {
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JButton createIncreaseButton (int orientation) {
|
protected JButton createIncreaseButton(int orientation) {
|
||||||
return new JButton() {
|
JButton button = new JButton();
|
||||||
|
button.setPreferredSize(d);
|
||||||
private static final long serialVersionUID = 7575774542623215803L;
|
return button;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dimension getPreferredSize() {
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintTrack(Graphics g, JComponent c, Rectangle r) {
|
protected void paintTrack(Graphics g, JComponent c, Rectangle r) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintThumb(Graphics g, JComponent c, Rectangle r) {
|
protected void paintThumb(Graphics g, JComponent c, Rectangle r) {
|
||||||
Graphics2D g2 = (Graphics2D) g.create();
|
Graphics2D g2 = (Graphics2D) g.create();
|
||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
Color color = null;
|
Color color;
|
||||||
JScrollBar sb = (JScrollBar) c;
|
JScrollBar sb = (JScrollBar) c;
|
||||||
if (!sb.isEnabled() || (isVertical == true && r.width > r.height) || (isVertical == false && r.width < r.height)) {
|
|
||||||
return;
|
|
||||||
} else if (isDragging) {
|
|
||||||
color = draggingColor;
|
|
||||||
} else if (isThumbRollover()) {
|
|
||||||
color = hoverColor;
|
|
||||||
} else {
|
|
||||||
color = scrollBarColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!sb.isEnabled() || (isVertical && r.width > r.height) || (!isVertical && r.width < r.height)) return;
|
||||||
|
|
||||||
|
if (isDragging) color = draggingColor;
|
||||||
|
else if (isThumbRollover()) color = hoverColor;
|
||||||
|
else color = scrollBarColor;
|
||||||
|
|
||||||
|
g2.setPaint(color);
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
g2.setPaint(color);
|
|
||||||
g2.fillRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
g2.fillRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
||||||
g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
||||||
g2.drawRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
g2.drawRoundRect(r.x + 9, r.y, r.width - 10, r.height, arcSize, arcSize);
|
||||||
g2.dispose();
|
} else {
|
||||||
}
|
|
||||||
if (!isVertical) {
|
|
||||||
g2.setPaint(color);
|
|
||||||
g2.fillRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
g2.fillRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
||||||
g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
||||||
g2.drawRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
g2.drawRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
||||||
g2.dispose();
|
|
||||||
}
|
}
|
||||||
|
g2.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user