use of javax.swing.JWindow in project webanno by webanno.
the class WebAnno method main.
public static void main(String[] args) throws Exception {
Optional<JWindow> splash = LoadingSplashScreen.setupScreen(WebAnno.class.getResource("splash.png"));
SpringApplicationBuilder builder = new SpringApplicationBuilder();
// Signal that we may need the shutdown dialog
builder.properties("running.from.commandline=true");
init(builder);
builder.sources(WebAnno.class);
builder.listeners(event -> {
if (event instanceof ApplicationReadyEvent || event instanceof ShutdownDialogAvailableEvent) {
splash.ifPresent(it -> it.dispose());
}
});
builder.run(args);
}
use of javax.swing.JWindow in project jsql-injection by ron190.
the class ShadowPopup method reset.
/**
* Reinitializes this ShadowPopup using the given parameters.
*
* @param owner component mouse coordinates are relative to, may be null
* @param contents the contents of the popup
* @param x the desired x location of the popup
* @param y the desired y location of the popup
* @param popup the popup to wrap
*/
private void reset(Component owner, Component contents, int x, int y, Popup popup) {
this.owner = owner;
this.contents = contents;
this.popup = popup;
this.x = x;
this.y = y;
// Do not install the shadow border when the contents
// has a preferred size less than or equal to 0.
// We can't use the size, because it is(0, 0) for new popups.
Dimension contentsPrefSize = new Dimension();
// Implementation by javax.swing.plaf.metal.MetalToolTipUI.getPreferredSize()
try {
contentsPrefSize = contents.getPreferredSize();
} catch (NullPointerException e) {
LOGGER.error(e.getMessage(), e);
}
if (contentsPrefSize.width <= 0 || contentsPrefSize.height <= 0) {
return;
}
for (Container p = contents.getParent(); p != null; p = p.getParent()) {
if (p instanceof JWindow || p instanceof Panel) {
// Workaround for the gray rect problem.
p.setBackground(contents.getBackground());
this.heavyWeightContainer = p;
break;
}
}
JComponent parent = (JComponent) contents.getParent();
this.oldOpaque = parent.isOpaque();
this.oldBorder = parent.getBorder();
parent.setOpaque(false);
parent.setBorder(SHADOW_BORDER);
// Pack it because we have changed the border.
if (this.heavyWeightContainer != null) {
this.heavyWeightContainer.setSize(this.heavyWeightContainer.getPreferredSize());
} else {
parent.setSize(parent.getPreferredSize());
}
}
use of javax.swing.JWindow in project chatty by chatty.
the class AutoCompletion method createInfoWindow.
/**
* Creates the window for the info popup. This should only be run once and
* then reused, only changing the text and size.
*/
private void createInfoWindow() {
infoWindow = new JWindow(SwingUtilities.getWindowAncestor(textField));
infoLabel = new JLabel();
infoWindow.add(infoLabel);
JPanel contentPane = (JPanel) infoWindow.getContentPane();
Border border = BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.GRAY), BorderFactory.createEmptyBorder(2, 4, 2, 4));
contentPane.setBorder(border);
contentPane.setBackground(HtmlColors.decode("#EEEEEE"));
infoLabel.setFont(textField.getFont());
/**
* Hide the info popup if the textfield or containing window is changed
* in any way.
*/
containingWindow = SwingUtilities.getWindowAncestor(textField);
if (containingWindow != null) {
containingWindow.addComponentListener(componentListener);
}
textField.addComponentListener(componentListener);
}
use of javax.swing.JWindow in project jmulticard by ctt-gob-es.
the class CustomDialogSmartcard method createAccessibilityButtonsPanel.
/**
* Se crea el panel de botones de accesibilidad.
*/
private void createAccessibilityButtonsPanel() {
this.accessibilityButtonsPanel = new JPanel(new GridBagLayout());
// Para el tooltip
final JWindow tip = new JWindow();
final JLabel tipText = new JLabel();
// Panel que va a contener los botones de accesibilidad
final JPanel panel = new JPanel(new GridBagLayout());
// Restricciones para los botones
final GridBagConstraints consButtons = new GridBagConstraints();
consButtons.fill = GridBagConstraints.BOTH;
consButtons.gridx = 0;
consButtons.gridy = 0;
consButtons.weightx = 1.0;
consButtons.weighty = 1.0;
// right padding
consButtons.insets = new Insets(0, 0, 0, 0);
// Restore button
final JPanel restorePanel = new JPanel();
// $NON-NLS-1$
final ImageIcon imageIconRestore = new ImageIcon(CustomDialogSmartcard.class.getResource("/images/restore.png"));
this.restoreButton = new JButton(imageIconRestore);
this.restoreButton.setMnemonic(KeyEvent.VK_R);
// $NON-NLS-1$
this.restoreButton.setToolTipText(Messages.getString("Wizard.restaurar.description"));
this.restoreButton.getAccessibleContext().setAccessibleName(this.restoreButton.getToolTipText());
this.restoreButton.addFocusListener(new FocusListener() {
/**
* Evento que se produce cuando el componente pierde el foco.
*/
@Override
public void focusLost(final FocusEvent e) {
Utils.showToolTip(false, tip, CustomDialogSmartcard.this.getRestoreButton(), tipText);
}
/**
* Evento que se produce cuando el componente tiene el foco.
*/
@Override
public void focusGained(final FocusEvent e) {
Utils.showToolTip(true, tip, CustomDialogSmartcard.this.getRestoreButton(), tipText);
}
});
final Dimension dimension = new Dimension(20, 20);
this.restoreButton.setPreferredSize(dimension);
this.restoreButton.addKeyListener(new KeyListener() {
@Override
public void keyTyped(final KeyEvent arg0) {
/* No necesario */
}
@Override
public void keyReleased(final KeyEvent arg0) {
/* No necesario */
}
@Override
public void keyPressed(final KeyEvent ke) {
if (10 == ke.getKeyCode()) {
getRestoreButton().doClick();
}
}
});
// $NON-NLS-1$
this.restoreButton.setName("restaurar");
restorePanel.add(this.restoreButton);
this.restoreButton.addActionListener(new ActionListener() {
/**
* Accion del boton.
*/
@Override
public void actionPerformed(final ActionEvent e) {
restaurarActionPerformed();
}
});
Utils.remarcar(this.restoreButton);
panel.add(restorePanel, consButtons);
consButtons.gridx = 1;
// right padding
consButtons.insets = new Insets(0, 0, 0, 0);
// Maximize button
final JPanel maximizePanel = new JPanel();
// $NON-NLS-1$
final ImageIcon imageIconMaximize = new ImageIcon(CustomDialogSmartcard.class.getResource("/images/maximize.png"));
this.maximizeButton = new JButton(imageIconMaximize);
this.maximizeButton.setMnemonic(KeyEvent.VK_M);
// $NON-NLS-1$
this.maximizeButton.setToolTipText(Messages.getString("Wizard.maximizar.description"));
this.maximizeButton.getAccessibleContext().setAccessibleName(this.maximizeButton.getToolTipText());
this.maximizeButton.addKeyListener(new KeyListener() {
@Override
public void keyTyped(final KeyEvent arg0) {
/* No necesario */
}
@Override
public void keyReleased(final KeyEvent arg0) {
/* No necesario */
}
@Override
public void keyPressed(final KeyEvent ke) {
if (10 == ke.getKeyCode()) {
getMaximizeButton().doClick();
}
}
});
// $NON-NLS-1$
this.maximizeButton.setName("maximizar");
// Se asigna una dimension por defecto
this.maximizeButton.setPreferredSize(dimension);
Utils.remarcar(this.maximizeButton);
maximizePanel.add(this.maximizeButton);
this.maximizeButton.addFocusListener(new FocusListener() {
/**
* Evento que se produce cuando el componente pierde el foco.
*/
@Override
public void focusLost(final FocusEvent e) {
Utils.showToolTip(false, tip, CustomDialogSmartcard.this.getMaximizeButton(), tipText);
}
/**
* Evento que se produce cuando el componente tiene el foco.
*/
@Override
public void focusGained(final FocusEvent e) {
Utils.showToolTip(true, tip, CustomDialogSmartcard.this.getMaximizeButton(), tipText);
}
});
this.maximizeButton.addActionListener(new ActionListener() {
/**
* Accion del boton.
*/
@Override
public void actionPerformed(final ActionEvent e) {
maximizarActionPerformed();
}
});
panel.add(maximizePanel, consButtons);
// Se anade al panel general
// Restricciones para el panel de botones
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.NONE;
c.gridx = 0;
c.gridy = 0;
c.weightx = 1.0;
c.weighty = 1.0;
c.insets = new Insets(0, 0, 0, 0);
c.anchor = GridBagConstraints.SOUTH;
this.accessibilityButtonsPanel.add(panel, c);
// Habilitado/Deshabilitado de botones restaurar/maximizar
if (GeneralConfig.isMaximized()) {
// Se deshabilita el boton de maximizado
this.maximizeButton.setEnabled(false);
// Se habilita el boton de restaurar
this.restoreButton.setEnabled(true);
} else {
// Se habilita el boton de maximizado
this.maximizeButton.setEnabled(true);
// Se deshabilita el boton de restaurar
this.restoreButton.setEnabled(false);
}
}
use of javax.swing.JWindow in project clusterMaker2 by RBVI.
the class RankingPanel method createClusterImage.
/**
* Convert a network to an image. This is used by the MCODEResultsPanel.
*
* @param cluster Input network to convert to an image
* @param height Height that the resulting image should be
* @param width Width that the resulting image should be
* @param layouter Reference to the layout algorithm
* @param layoutNecessary Determinant of cluster size growth or shrinkage, the former requires layout
* @return The resulting image
*/
public Image createClusterImage(final NodeCluster cluster, final int height, final int width, SpringEmbeddedLayouter layouter, boolean layoutNecessary) {
// System.out.println("CCI: inside method");
final CyRootNetwork root = clusterManager.getService(CyRootNetworkManager.class).getRootNetwork(network);
// need to create a method get the subnetwork for a cluster
final CyNetwork net = cluster.getSubNetwork(network, root, SavePolicy.DO_NOT_SAVE);
// System.out.println("CCI: after getting root and network ");
// Progress reporters.
// There are three basic tasks, the progress of each is calculated and then combined
// using the respective weighting to get an overall progress global progress
// setting up the nodes and edges is deemed as 25% of the whole task
int weightSetupNodes = 20;
int weightSetupEdges = 5;
// layout it is 70%
double weightLayout = 75.0;
double goalTotal = weightSetupNodes + weightSetupEdges;
if (layoutNecessary) {
goalTotal += weightLayout;
}
// keeps track of progress as a percent of the totalGoal
double progress = 0;
final VisualStyle vs = getClusterStyle();
// System.out.println("CCI: after getClusterStyle");
final CyNetworkView clusterView = createNetworkView(net, vs);
// System.out.println("CCI: after createNetworkView");
clusterView.setVisualProperty(NETWORK_WIDTH, new Double(width));
clusterView.setVisualProperty(NETWORK_HEIGHT, new Double(height));
for (View<CyNode> nv : clusterView.getNodeViews()) {
if (interrupted) {
// problems the next time around
if (layouter != null)
layouter.resetDoLayout();
resetLoading();
return null;
}
// Node position
final double x;
final double y;
// first prevents the program from throwing a null pointer exception in the second condition)
if (cluster.getView() != null && cluster.getView().getNodeView(nv.getModel()) != null) {
// If it does, then we take the layout position that was already generated for it
x = cluster.getView().getNodeView(nv.getModel()).getVisualProperty(NODE_X_LOCATION);
y = cluster.getView().getNodeView(nv.getModel()).getVisualProperty(NODE_Y_LOCATION);
} else {
// Otherwise, randomize node positions before layout so that they don't all layout in a line
// (so they don't fall into a local minimum for the SpringEmbedder)
// If the SpringEmbedder implementation changes, this code may need to be removed
// size is small for many default drawn graphs, thus +100
x = (clusterView.getVisualProperty(NETWORK_WIDTH) + 100) * Math.random();
y = (clusterView.getVisualProperty(NETWORK_HEIGHT) + 100) * Math.random();
if (!layoutNecessary) {
goalTotal += weightLayout;
progress /= (goalTotal / (goalTotal - weightLayout));
layoutNecessary = true;
}
}
nv.setVisualProperty(NODE_X_LOCATION, x);
nv.setVisualProperty(NODE_Y_LOCATION, y);
// Might be specific to MCODE
/*
// Node shape
if (cluster.getSeedNode() == nv.getModel().getSUID()) {
nv.setLockedValue(NODE_SHAPE, NodeShapeVisualProperty.RECTANGLE);
} else {
nv.setLockedValue(NODE_SHAPE, NodeShapeVisualProperty.ELLIPSE);
}
*/
/*
// Update loader
if (loader != null) {
progress += 100.0 * (1.0 / (double) clusterView.getNodeViews().size()) *
((double) weightSetupNodes / (double) goalTotal);
loader.setProgress((int) progress, "Setup: nodes");
}
*/
}
if (clusterView.getEdgeViews() != null) {
for (int i = 0; i < clusterView.getEdgeViews().size(); i++) {
if (interrupted) {
// logger.error("Interrupted: Edge Setup");
if (layouter != null)
layouter.resetDoLayout();
resetLoading();
return null;
}
/*
if (loader != null) {
progress += 100.0 * (1.0 / (double) clusterView.getEdgeViews().size()) *
((double) weightSetupEdges / (double) goalTotal);
loader.setProgress((int) progress, "Setup: edges");
}
*/
}
}
if (layoutNecessary) {
if (layouter == null) {
layouter = new SpringEmbeddedLayouter();
}
layouter.setGraphView(clusterView);
// The doLayout method should return true if the process completes without interruption
if (!layouter.doLayout(weightLayout, goalTotal, progress)) {
// Otherwise, if layout is not completed, set the interruption to false, and return null, not an image
resetLoading();
return null;
}
}
final Image image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final Graphics2D g = (Graphics2D) image.getGraphics();
SwingUtilities.invokeLater(new Runnable() {
// @Override
public void run() {
try {
final Dimension size = new Dimension(width, height);
JPanel panel = new JPanel();
panel.setPreferredSize(size);
panel.setSize(size);
panel.setMinimumSize(size);
panel.setMaximumSize(size);
panel.setBackground((Color) vs.getDefaultValue(NETWORK_BACKGROUND_PAINT));
JWindow window = new JWindow();
window.getContentPane().add(panel, BorderLayout.CENTER);
RenderingEngine<CyNetwork> re = renderingEngineFactory.createRenderingEngine(panel, clusterView);
vs.apply(clusterView);
clusterView.fitContent();
clusterView.updateView();
window.pack();
window.repaint();
re.createImage(width, height);
re.printCanvas(g);
g.dispose();
if (clusterView.getNodeViews().size() > 0) {
cluster.setView(clusterView);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
});
layouter.resetDoLayout();
resetLoading();
return image;
}
Aggregations