Added Javadoc requested by @delvh
This commit is contained in:
parent
69153005cd
commit
500555c8db
@ -8,7 +8,7 @@ import javax.swing.JButton;
|
|||||||
* Project: <strong>envoy-client</strong><br>
|
* Project: <strong>envoy-client</strong><br>
|
||||||
* File: <strong>PrimaryButton.javaEvent.java</strong><br>
|
* File: <strong>PrimaryButton.javaEvent.java</strong><br>
|
||||||
* Created: <strong>07.12.2019</strong><br>
|
* Created: <strong>07.12.2019</strong><br>
|
||||||
*
|
*
|
||||||
* @author Kai S. K. Engelbart
|
* @author Kai S. K. Engelbart
|
||||||
* @author Maximilian Käfer
|
* @author Maximilian Käfer
|
||||||
* @since Envoy v0.2-alpha
|
* @since Envoy v0.2-alpha
|
||||||
@ -21,7 +21,7 @@ public class PrimaryButton extends JButton {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a primary button
|
* Creates a primary button
|
||||||
*
|
*
|
||||||
* @param title the title of the button
|
* @param title the title of the button
|
||||||
* @since Envoy 0.2-alpha
|
* @since Envoy 0.2-alpha
|
||||||
*/
|
*/
|
||||||
@ -29,9 +29,9 @@ public class PrimaryButton extends JButton {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a primary button
|
* Creates a primary button
|
||||||
*
|
*
|
||||||
* @param title the title of the button
|
* @param title the title of the button
|
||||||
* @param the size of the arc used to draw the round button edges
|
* @param arcSize the size of the arc used to draw the round button edges
|
||||||
* @since Envoy 0.2-alpha
|
* @since Envoy 0.2-alpha
|
||||||
*/
|
*/
|
||||||
public PrimaryButton(String title, int arcSize) {
|
public PrimaryButton(String title, int arcSize) {
|
||||||
|
@ -1,95 +1,115 @@
|
|||||||
package envoy.client.ui;
|
package envoy.client.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JScrollBar;
|
import javax.swing.JScrollBar;
|
||||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
import javax.swing.plaf.basic.BasicScrollBarUI;
|
||||||
|
|
||||||
import envoy.client.Settings;
|
import envoy.client.Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>envoy-client</strong><br>
|
* Project: <strong>envoy-client</strong><br>
|
||||||
* File: <strong>PrimaryScrollBar.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 final int arcSize;
|
private final int arcSize;
|
||||||
private final Color scrollBarColor;
|
private final Color scrollBarColor;
|
||||||
private final Color hoverColor;
|
private final Color hoverColor;
|
||||||
private final Color draggingColor;
|
private final Color draggingColor;
|
||||||
private final boolean isVertical;
|
private final boolean isVertical;
|
||||||
|
|
||||||
public PrimaryScrollBar(int arcSize, Color scrollBarColor, Color hoverColor, Color draggingColor, boolean isVertical) {
|
/**
|
||||||
this.arcSize = arcSize;
|
* Initializes a {@link PrimaryScrollBar} with a color scheme.
|
||||||
this.scrollBarColor = scrollBarColor;
|
*
|
||||||
this.hoverColor = hoverColor;
|
* @param arcSize the size of the arc used to draw the round scroll bar
|
||||||
this.draggingColor = draggingColor;
|
* edges
|
||||||
this.isVertical = isVertical;
|
* @param scrollBarColor the default color
|
||||||
}
|
* @param hoverColor the color while hovering
|
||||||
|
* @param draggingColor the color while dragging
|
||||||
public PrimaryScrollBar(Theme theme, boolean isVertical) {
|
* @param isVertical indicates whether this is a vertical
|
||||||
this(5, theme.getInteractableBackgroundColor(), new Color(theme.getInteractableBackgroundColor().getRGB() - 50),
|
* {@link PrimaryScrollBar}
|
||||||
new Color(theme.getInteractableBackgroundColor().getRGB() + 170), isVertical);
|
*/
|
||||||
}
|
public PrimaryScrollBar(int arcSize, Color scrollBarColor, Color hoverColor, Color draggingColor, boolean isVertical) {
|
||||||
|
this.arcSize = arcSize;
|
||||||
@Override
|
this.scrollBarColor = scrollBarColor;
|
||||||
protected JButton createDecreaseButton(int orientation) {
|
this.hoverColor = hoverColor;
|
||||||
JButton button = new JButton();
|
this.draggingColor = draggingColor;
|
||||||
button.setPreferredSize(d);
|
this.isVertical = isVertical;
|
||||||
return button;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
@Override
|
* Initializes a {@link PrimaryScrollBar} using a color scheme specified in a
|
||||||
protected JButton createIncreaseButton(int orientation) {
|
* {@link Theme}
|
||||||
JButton button = new JButton();
|
*
|
||||||
button.setPreferredSize(d);
|
* @param theme the {@link Theme} to be applied to this
|
||||||
return button;
|
* {@link PrimaryScrollBar}
|
||||||
}
|
* @param isVertical indicates whether this is a vertical
|
||||||
|
* {@link PrimaryScrollBar}
|
||||||
@Override
|
*/
|
||||||
protected void paintTrack(Graphics g, JComponent c, Rectangle r) {}
|
public PrimaryScrollBar(Theme theme, boolean isVertical) {
|
||||||
|
this(5, theme.getInteractableBackgroundColor(), new Color(theme.getInteractableBackgroundColor().getRGB() - 50),
|
||||||
@Override
|
new Color(theme.getInteractableBackgroundColor().getRGB() + 170), isVertical);
|
||||||
protected void paintThumb(Graphics g, JComponent c, Rectangle r) {
|
}
|
||||||
Graphics2D g2 = (Graphics2D) g.create();
|
|
||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
@Override
|
||||||
Color color;
|
protected JButton createDecreaseButton(int orientation) {
|
||||||
JScrollBar sb = (JScrollBar) c;
|
JButton button = new JButton();
|
||||||
|
button.setPreferredSize(d);
|
||||||
if (!sb.isEnabled()) return;
|
return button;
|
||||||
|
}
|
||||||
if (isDragging) color = draggingColor;
|
|
||||||
else if (isThumbRollover()) color = hoverColor;
|
@Override
|
||||||
else color = scrollBarColor;
|
protected JButton createIncreaseButton(int orientation) {
|
||||||
|
JButton button = new JButton();
|
||||||
g2.setPaint(color);
|
button.setPreferredSize(d);
|
||||||
if (isVertical) {
|
return button;
|
||||||
g2.fillRoundRect(r.x - 9, r.y, r.width, r.height, arcSize, arcSize);
|
}
|
||||||
g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
|
||||||
g2.drawRoundRect(r.x - 9, r.y, r.width, r.height, arcSize, arcSize);
|
@Override
|
||||||
} else {
|
protected void paintTrack(Graphics g, JComponent c, Rectangle r) {}
|
||||||
g2.fillRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
|
||||||
g2.setPaint(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
@Override
|
||||||
g2.drawRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
protected void paintThumb(Graphics g, JComponent c, Rectangle r) {
|
||||||
}
|
Graphics2D g2 = (Graphics2D) g.create();
|
||||||
g2.dispose();
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
}
|
Color color;
|
||||||
|
JScrollBar sb = (JScrollBar) c;
|
||||||
@Override
|
|
||||||
protected void setThumbBounds(int x, int y, int width, int height) {
|
if (!sb.isEnabled()) return;
|
||||||
super.setThumbBounds(x, y, width, height);
|
|
||||||
scrollbar.repaint();
|
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().getThemes().get(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().getThemes().get(Settings.getInstance().getCurrentTheme()).getCellColor());
|
||||||
|
g2.drawRoundRect(r.x, r.y + 9, r.width, r.height - 10, arcSize, arcSize);
|
||||||
|
}
|
||||||
|
g2.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setThumbBounds(int x, int y, int width, int height) {
|
||||||
|
super.setThumbBounds(x, y, width, height);
|
||||||
|
scrollbar.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,6 +17,11 @@ public class PrimaryScrollPane extends JScrollPane {
|
|||||||
private int verticalScrollBarMaximum = getVerticalScrollBar().getMaximum();
|
private int verticalScrollBarMaximum = getVerticalScrollBar().getMaximum();
|
||||||
private boolean chatOpened = false;
|
private boolean chatOpened = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a {@link JScrollPane} with the primary Envoy design scheme
|
||||||
|
*
|
||||||
|
* @since Envoy v0.2-alpha
|
||||||
|
*/
|
||||||
public PrimaryScrollPane() { setBorder(null); }
|
public PrimaryScrollPane() { setBorder(null); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,5 +72,12 @@ public class PrimaryScrollPane extends JScrollPane {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 v0.2-alpha
|
||||||
|
*/
|
||||||
public void setChatOpened(boolean chatOpened) { this.chatOpened = chatOpened; }
|
public void setChatOpened(boolean chatOpened) { this.chatOpened = chatOpened; }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user