Skip to content

Commit

Permalink
Cleanup banner and perspective button to enable dark mode gephi#2584
Browse files Browse the repository at this point in the history
  • Loading branch information
mbastian committed Sep 23, 2022
1 parent 45b4816 commit c9690e6
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,40 +39,7 @@

<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
<Component class="javax.swing.JButton" name="logoButton">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/gephi/desktop/banner/resources/logo_std.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/desktop/banner/Bundle.properties" key="BannerComponent.logoButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="borderPainted" type="boolean" value="false"/>
<Property name="contentAreaFilled" type="boolean" value="false"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/>
</Property>
<Property name="focusPainted" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="pressedIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/gephi/desktop/banner/resources/logo_glow.png"/>
</Property>
<Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/gephi/desktop/banner/resources/logo_glow.png"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Container class="javax.swing.JPanel" name="groupsPanel">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/>
Expand All @@ -83,9 +50,6 @@
<SubComponents>
<Container class="javax.swing.JPanel" name="buttonsPanel">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Default Cursor"/>
</Property>
Expand All @@ -106,18 +70,6 @@
<Property name="verticalGap" type="int" value="3"/>
</Layout>
</Container>
<Component class="javax.swing.JLabel" name="bannerBackground">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/gephi/desktop/banner/resources/bannerback.png"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="23" weightX="1.0" weightY="1.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,12 @@ public class BannerComponent extends javax.swing.JPanel {
private final transient PerspectiveController perspectiveController;
private transient JToggleButton[] buttons;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel bannerBackground;
private javax.swing.JPanel buttonsPanel;
private javax.swing.JPanel groupsPanel;
// End of variables declaration//GEN-END:variables

//Not working
/*public void reset() {
refreshSelectedPerspective();
for (final Perspective group : Lookup.getDefault().lookupAll(Perspective.class).toArray(new Perspective[0])) {
TopComponentGroup tpg = WindowManager.getDefault().findTopComponentGroup(group.getName());
if (group.getName().equals(selectedPerspective)) {
tpg.open();
} else {
tpg.close();
}
}
}*/
private javax.swing.JButton logoButton;
private javax.swing.JPanel mainPanel;
private javax.swing.ButtonGroup perspectivesButtonGroup;
private javax.swing.JPanel workspacePanel;
// End of variables declaration//GEN-END:variables

public BannerComponent() {
initComponents();
Expand All @@ -93,43 +78,22 @@ public BannerComponent() {

addGroupTabs();

logoButton.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();

if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) {
try {
java.net.URI uri = new java.net.URI("https://gephi.org");
desktop.browse(uri);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}

}
});

//This defines the height of the banner bar
setPreferredSize(new Dimension(100, 65));
}

private void addGroupTabs() {
buttons = new JPerspectiveButton[perspectiveController.getPerspectives().length];
buttons = new JToggleButton[perspectiveController.getPerspectives().length];
int i = 0;

//Add tabs
for (final Perspective perspective : perspectiveController.getPerspectives()) {
JPerspectiveButton toggleButton =
new JPerspectiveButton(perspective.getDisplayName(), perspective.getIcon());
toggleButton.addActionListener(new ActionListener() {
JToggleButton toggleButton =
new JToggleButton(perspective.getDisplayName(), perspective.getIcon());
toggleButton.setFocusPainted(false);
toggleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

@Override
public void actionPerformed(ActionEvent e) {
perspectiveController.selectPerspective(perspective);
}
});
toggleButton.addActionListener(e -> perspectiveController.selectPerspective(perspective));
perspectivesButtonGroup.add(toggleButton);
buttonsPanel.add(toggleButton);
buttons[i++] = toggleButton;
Expand Down Expand Up @@ -162,10 +126,8 @@ private void initComponents() {

perspectivesButtonGroup = new javax.swing.ButtonGroup();
mainPanel = new javax.swing.JPanel();
logoButton = new javax.swing.JButton();
groupsPanel = new javax.swing.JPanel();
buttonsPanel = new javax.swing.JPanel();
bannerBackground = new javax.swing.JLabel();
workspacePanel = new org.gephi.desktop.banner.workspace.WorkspacePanel();

setBackground(new java.awt.Color(255, 255, 255));
Expand All @@ -174,28 +136,8 @@ private void initComponents() {
mainPanel.setBackground(new java.awt.Color(255, 255, 255));
mainPanel.setLayout(new java.awt.GridBagLayout());

logoButton.setIcon(new javax.swing.ImageIcon(
getClass().getResource("/org/gephi/desktop/banner/resources/logo_std.png"))); // NOI18N
logoButton.setToolTipText(org.openide.util.NbBundle
.getMessage(BannerComponent.class, "BannerComponent.logoButton.toolTipText")); // NOI18N
logoButton.setBorderPainted(false);
logoButton.setContentAreaFilled(false);
logoButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
logoButton.setFocusPainted(false);
logoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
logoButton.setPressedIcon(new javax.swing.ImageIcon(
getClass().getResource("/org/gephi/desktop/banner/resources/logo_glow.png"))); // NOI18N
logoButton.setRolloverIcon(new javax.swing.ImageIcon(
getClass().getResource("/org/gephi/desktop/banner/resources/logo_glow.png"))); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
mainPanel.add(logoButton, gridBagConstraints);

groupsPanel.setBackground(new java.awt.Color(255, 255, 255));
groupsPanel.setLayout(new java.awt.GridBagLayout());

buttonsPanel.setBackground(new java.awt.Color(255, 255, 255));
buttonsPanel.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
buttonsPanel.setOpaque(false);
buttonsPanel.setPreferredSize(new java.awt.Dimension(10, 50));
Expand All @@ -209,17 +151,6 @@ private void initComponents() {
gridBagConstraints.weighty = 1.0;
groupsPanel.add(buttonsPanel, gridBagConstraints);

bannerBackground.setIcon(new javax.swing.ImageIcon(
getClass().getResource("/org/gephi/desktop/banner/resources/bannerback.png"))); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
groupsPanel.add(bannerBackground, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
Expand All @@ -232,27 +163,4 @@ private void initComponents() {
add(mainPanel, java.awt.BorderLayout.CENTER);
add(workspacePanel, java.awt.BorderLayout.SOUTH);
}// </editor-fold>//GEN-END:initComponents

private static class JPerspectiveButton extends JToggleButton {

public JPerspectiveButton(String text, Icon icon) {
setText(text);
setBorder(null);
setBorderPainted(false);
setContentAreaFilled(false);
setFocusPainted(false);
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

setIcon(ImageUtilities.image2Icon(ImageUtilities.mergeImages(
ImageUtilities.loadImage("org/gephi/desktop/banner/perspective/resources/aqua-enabled.png"),
ImageUtilities.icon2Image(icon), 6, 3)));
setRolloverIcon(ImageUtilities.image2Icon(ImageUtilities.mergeImages(
ImageUtilities.loadImage("org/gephi/desktop/banner/perspective/resources/aqua-mouseover.png"),
ImageUtilities.icon2Image(icon), 6, 3)));
setSelectedIcon(ImageUtilities.image2Icon(ImageUtilities.mergeImages(
ImageUtilities.loadImage("org/gephi/desktop/banner/perspective/resources/aqua-selected.png"),
ImageUtilities.icon2Image(icon), 6, 3)));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
OpenIDE-Module-Long-Description=Implementations of default perspectives and banner panel
OpenIDE-Module-Short-Description=Implementations of default perspectives and banner panel
BannerComponent.logoButton.toolTipText=Go on Gephi website www.gephi.org
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c9690e6

Please sign in to comment.