Skip to content

Commit

Permalink
Closes #507
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhorridge committed Aug 8, 2016
1 parent 8db7df9 commit a644765
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.protege.editor.owl.ui.util;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.Rectangle2D;

/**
* Matthew Horridge
* Stanford Center for Biomedical Informatics Research
* 8 Aug 16
*/
public class NothingSelectedPanel extends JPanel {

public static final String NOTHING_SELECTED = "Nothing Selected";

private static final Color BORDER_COLOR = new Color(220, 220, 220);

private static final Color TEXT_COLOR = new Color(200, 200, 200);

private static final int BORDER_MARGIN = 20;

private static final int BORDER_THICKNESS = 8;

private static final Font FONT = new Font("Sans-serif", Font.PLAIN, 40);

public NothingSelectedPanel() {
}

@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
Stroke currentStroke = g2.getStroke();
g2.setStroke(new BasicStroke(BORDER_THICKNESS));
g2.setColor(BORDER_COLOR);
int borderWidth = getWidth() - 2 * BORDER_MARGIN;
int borderHeight = getHeight() - 2 * BORDER_MARGIN;
g2.drawRoundRect(BORDER_MARGIN, BORDER_MARGIN, borderWidth, borderHeight, BORDER_MARGIN, BORDER_MARGIN);
g2.setStroke(currentStroke);
g2.setColor(TEXT_COLOR);
g2.setFont(FONT);
Rectangle2D rectangle = g2.getFontMetrics().getStringBounds(NOTHING_SELECTED, g2);
int stringX = (int) (getWidth() - rectangle.getWidth()) / 2;
int stringY = (int) (getHeight() - rectangle.getHeight()) / 2;
g2.drawString(NOTHING_SELECTED, stringX, stringY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.protege.editor.core.ui.view.ViewsPane;
import org.protege.editor.core.ui.view.ViewsPaneMemento;
import org.protege.editor.owl.model.selection.OWLSelectionModelListener;
import org.protege.editor.owl.ui.util.NothingSelectedPanel;
import org.semanticweb.owlapi.model.*;

import javax.swing.*;
Expand All @@ -21,16 +22,11 @@
*/
public class SelectedEntityCardView extends AbstractOWLViewComponent implements Resettable {

/**
*
*/
private static final long serialVersionUID = -287697571704681093L;

public static final String ID = "org.protege.editor.owl.SelectedEntityView";

private CardLayout cardLayout = new CardLayout();
private final CardLayout cardLayout = new CardLayout();

private JPanel cardPanel;
private final JPanel cardPanel = new JPanel();

private List<ViewsPane> viewsPanes = new ArrayList<>();

Expand All @@ -52,14 +48,11 @@ public class SelectedEntityCardView extends AbstractOWLViewComponent implements

protected void initialiseOWLView() throws Exception {
setLayout(new BorderLayout());
cardPanel = new JPanel();
add(cardPanel);
cardPanel.setLayout(cardLayout);
cardPanel.add(new JPanel(), BLANK_PANEL);
cardPanel.add(new NothingSelectedPanel(), BLANK_PANEL);
createViewPanes(false);
getOWLWorkspace().getOWLSelectionModel().addListener(() -> {
processSelection();
});
getOWLWorkspace().getOWLSelectionModel().addListener(this::processSelection);
getView().setShowViewBar(false);
processSelection();
}
Expand Down

0 comments on commit a644765

Please sign in to comment.