-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d2b914
commit bbadb77
Showing
3 changed files
with
184 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/ai/nets/samj/gui/components/ImageDrawerPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package ai.nets.samj.gui.components; | ||
|
||
import java.awt.BorderLayout; | ||
import java.awt.Color; | ||
import java.awt.Dimension; | ||
import java.awt.GridBagConstraints; | ||
import java.awt.GridBagLayout; | ||
import java.awt.Insets; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.JButton; | ||
import javax.swing.JLabel; | ||
import javax.swing.JPanel; | ||
import javax.swing.border.LineBorder; | ||
|
||
import ai.nets.samj.gui.HTMLPane; | ||
|
||
public class ImageDrawerPanel extends JPanel { | ||
|
||
private JLabel drawerTitle = new JLabel(); | ||
private JButton install = new JButton("Install"); | ||
private JButton uninstall = new JButton("Uninstall"); | ||
|
||
private int hSize; | ||
|
||
private static final String MODEL_TITLE = "<html><div style='text-align: center; font-size: 15px;'>%s</html>"; | ||
|
||
|
||
private ImageDrawerPanel(int hSize) { | ||
this.hSize = hSize; | ||
createDrawerPanel(); | ||
} | ||
|
||
public static ImageDrawerPanel create(int hSize) { | ||
return new ImageDrawerPanel(hSize); | ||
} | ||
|
||
private void createDrawerPanel() { | ||
this.setLayout(new BorderLayout()); | ||
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); | ||
drawerTitle.setText(String.format(MODEL_TITLE, " ")); | ||
this.add(drawerTitle, BorderLayout.NORTH); | ||
this.add(createInstallModelComponent(), BorderLayout.SOUTH); | ||
HTMLPane html = new HTMLPane("Arial", "#000", "#CCCCCC", 200, 200); | ||
html.append("Model description"); | ||
html.append("Model description"); | ||
html.append("Model description"); | ||
html.append(""); | ||
html.append("i", "Other information"); | ||
html.append("i", "References"); | ||
this.add(html, BorderLayout.CENTER); | ||
this.setPreferredSize(new Dimension(hSize, 0)); // Set preferred width | ||
} | ||
|
||
// Method to create the install model component | ||
private JPanel createInstallModelComponent() { | ||
JPanel thirdComponent = new JPanel(); | ||
thirdComponent.setLayout(new GridBagLayout()); | ||
thirdComponent.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2)); | ||
thirdComponent.setBorder(new LineBorder(Color.BLACK)); | ||
|
||
GridBagConstraints gbc = new GridBagConstraints(); | ||
gbc.insets = new Insets(0, 0, 0, 0); | ||
gbc.gridy = 0; | ||
gbc.fill = GridBagConstraints.BOTH; | ||
gbc.weightx = 1.0; | ||
|
||
// Install button | ||
gbc.gridx = 0; | ||
thirdComponent.add(this.install, gbc); | ||
|
||
// Uninstall button | ||
gbc.gridx = 1; | ||
thirdComponent.add(this.uninstall, gbc); | ||
|
||
return thirdComponent; | ||
} | ||
|
||
public void setTitle(String title) { | ||
drawerTitle.setText(String.format(MODEL_TITLE, title)); | ||
} | ||
|
||
@Override | ||
public void setVisible(boolean visible) { | ||
this.isOpen = visible; | ||
super.setVisible(visible); | ||
} | ||
|
||
} |
90 changes: 90 additions & 0 deletions
90
src/main/java/ai/nets/samj/gui/components/ModelDrawerPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package ai.nets.samj.gui.components; | ||
|
||
import java.awt.BorderLayout; | ||
import java.awt.Color; | ||
import java.awt.Dimension; | ||
import java.awt.GridBagConstraints; | ||
import java.awt.GridBagLayout; | ||
import java.awt.Insets; | ||
|
||
import javax.swing.BorderFactory; | ||
import javax.swing.JButton; | ||
import javax.swing.JLabel; | ||
import javax.swing.JPanel; | ||
import javax.swing.border.LineBorder; | ||
|
||
import ai.nets.samj.gui.HTMLPane; | ||
|
||
public class ModelDrawerPanel extends JPanel { | ||
|
||
private JLabel drawerTitle = new JLabel(); | ||
private JButton install = new JButton("Install"); | ||
private JButton uninstall = new JButton("Uninstall"); | ||
|
||
|
||
private int hSize; | ||
|
||
private static final String MODEL_TITLE = "<html><div style='text-align: center; font-size: 15px;'>%s</html>"; | ||
|
||
|
||
private ModelDrawerPanel(int hSize) { | ||
this.hSize = hSize; | ||
createDrawerPanel(); | ||
} | ||
|
||
public static ModelDrawerPanel create(int hSize) { | ||
return new ModelDrawerPanel(hSize); | ||
} | ||
|
||
private void createDrawerPanel() { | ||
this.setLayout(new BorderLayout()); | ||
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); | ||
drawerTitle.setText(String.format(MODEL_TITLE, " ")); | ||
this.add(drawerTitle, BorderLayout.NORTH); | ||
this.add(createInstallModelComponent(), BorderLayout.SOUTH); | ||
HTMLPane html = new HTMLPane("Arial", "#000", "#CCCCCC", 200, 200); | ||
html.append("Model description"); | ||
html.append("Model description"); | ||
html.append("Model description"); | ||
html.append(""); | ||
html.append("i", "Other information"); | ||
html.append("i", "References"); | ||
this.add(html, BorderLayout.CENTER); | ||
this.setPreferredSize(new Dimension(hSize, 0)); // Set preferred width | ||
} | ||
|
||
// Method to create the install model component | ||
private JPanel createInstallModelComponent() { | ||
JPanel thirdComponent = new JPanel(); | ||
thirdComponent.setLayout(new GridBagLayout()); | ||
thirdComponent.setBorder(BorderFactory.createEmptyBorder(5, 2, 5, 2)); | ||
thirdComponent.setBorder(new LineBorder(Color.BLACK)); | ||
|
||
GridBagConstraints gbc = new GridBagConstraints(); | ||
gbc.insets = new Insets(0, 0, 0, 0); | ||
gbc.gridy = 0; | ||
gbc.fill = GridBagConstraints.BOTH; | ||
gbc.weightx = 1.0; | ||
|
||
// Install button | ||
gbc.gridx = 0; | ||
thirdComponent.add(this.install, gbc); | ||
|
||
// Uninstall button | ||
gbc.gridx = 1; | ||
thirdComponent.add(this.uninstall, gbc); | ||
|
||
return thirdComponent; | ||
} | ||
|
||
public void setTitle(String title) { | ||
drawerTitle.setText(String.format(MODEL_TITLE, title)); | ||
} | ||
|
||
@Override | ||
public void setVisible(boolean visible) { | ||
this.isOpen = visible; | ||
super.setVisible(visible); | ||
} | ||
|
||
} |