Skip to content

Commit 8b55f4a

Browse files
committed
keed adding javadoc
1 parent 6ca918b commit 8b55f4a

File tree

3 files changed

+13
-59
lines changed

3 files changed

+13
-59
lines changed

src/main/java/ai/nets/samj/gui/ResizableButton.java

Lines changed: 11 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@
1919
*/
2020
package ai.nets.samj.gui;
2121

22-
import java.awt.Font;
23-
import java.awt.FontMetrics;
2422
import java.awt.Insets;
2523
import java.awt.event.ComponentAdapter;
2624
import java.awt.event.ComponentEvent;
2725

2826
import javax.swing.JButton;
29-
import javax.swing.JLabel;
30-
import javax.swing.SwingConstants;
3127
/**
3228
* TODO make it resizable
3329
* This class is a normal button whose font is resized when the component is resized
@@ -38,14 +34,6 @@ public class ResizableButton extends JButton {
3834
* Serial version unique identifier
3935
*/
4036
private static final long serialVersionUID = -958367053852506146L;
41-
/**
42-
* Label containing the text that the button displays when it is not pressed
43-
*/
44-
private JLabel textLabel;
45-
/**
46-
* Label containing the loading animation to be displayed while the button is pressed
47-
*/
48-
private int fontSize;
4937

5038
private int horizontalInset;
5139
private int verticalInset;
@@ -54,12 +42,12 @@ public class ResizableButton extends JButton {
5442
* Constructor. Creates a button that has an icon inside. The icon changes when pressed.
5543
* @param text
5644
* the text inside the button
57-
* @param filePath
58-
* the path to the file that contains the image that is going to be used
59-
* @param filename
60-
* the name of the file that is going to be used
61-
* @param animationSize
62-
* size of the side of the squared animation inside the button
45+
* @param fontSize
46+
* the size of the font that we want in the button
47+
* @param horizontalInset
48+
* horizontal distance from the letter to the sides
49+
* @param verticalInset
50+
* vertical distance from the buttons to the sizes
6351
*/
6452
public ResizableButton(String text, int fontSize, int horizontalInset, int verticalInset) {
6553
super(text);
@@ -77,6 +65,11 @@ public void componentResized(ComponentEvent e) {
7765
//adjustButtonFont();
7866
}
7967

68+
/**
69+
*
70+
* @param fontSize
71+
* the font size of the button
72+
*/
8073
public void setFontSize(int fontSize) {
8174
setFont(getFont().deriveFont((float) fontSize));
8275
}
@@ -90,43 +83,4 @@ public Insets getInsets() {
9083
public Insets getInsets(Insets insets) {
9184
return new Insets(verticalInset, horizontalInset, verticalInset, horizontalInset);
9285
}
93-
94-
// Method to adjust the font size based on button size
95-
private void adjustButtonFont() {
96-
int btnHeight = this.getHeight();
97-
int btnWidth = this.getWidth();
98-
99-
if (btnHeight <= 0 || btnWidth <= 0) {
100-
return; // Cannot calculate font size with non-positive dimensions
101-
}
102-
103-
// Get the button's insets
104-
Insets insets = this.getInsets();
105-
int availableWidth = btnWidth - insets.left - insets.right;
106-
107-
// Start with a font size based on button height
108-
int fontSize = btnHeight - insets.top - insets.bottom;
109-
110-
// Get the current font
111-
Font originalFont = this.getFont();
112-
Font font = originalFont.deriveFont((float) fontSize);
113-
114-
FontMetrics fm = this.getFontMetrics(font);
115-
int textWidth = fm.stringWidth(this.getText());
116-
117-
// Reduce font size until text fits
118-
while (textWidth > availableWidth && fontSize > 0) {
119-
fontSize--;
120-
font = originalFont.deriveFont((float) fontSize);
121-
fm = this.getFontMetrics(font);
122-
textWidth = fm.stringWidth(this.getText());
123-
}
124-
125-
// Apply the new font
126-
this.setFont(font);
127-
128-
// Center the text
129-
this.setHorizontalAlignment(JButton.CENTER);
130-
this.setVerticalAlignment(JButton.CENTER);
131-
}
13286
}

src/main/java/ai/nets/samj/gui/components/ComboBoxItem.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public abstract class ComboBoxItem {
4040
/**
4141
* An object that associates a unique identifier with an Object.
4242
* The unique identifier cannot be -1, as it is reserved for empty objects
43-
* @param uniqueID
44-
* the unique identifier
4543
* @param seq
4644
* the object
4745
*/

src/main/java/ai/nets/samj/gui/tools/Tools.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public class Tools {
3535

3636
/**
3737
* Opens user's default desktop web browser on the given 'url'.
38+
* @param url
39+
* the url of interest as a String
3840
*/
3941
public static void openUrlInWebBrowser(final String url) {
4042
final String myOS = System.getProperty("os.name").toLowerCase();

0 commit comments

Comments
 (0)