use of java.awt.event.ComponentEvent in project android by JetBrains.
the class NetworkCaptureSegment method createCaptureTable.
@NotNull
private JTable createCaptureTable() {
JBTable table = new JBTable(new NetworkCaptureTableModel());
table.setDefaultRenderer(StateChart.class, (t, value, isSelected, hasFocus, row, column) -> myCharts.get(row));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().addListSelectionListener(e -> {
if (table.getSelectedRow() < myDataList.size()) {
myDetailedViewListener.showDetailedConnection(myDataList.get(table.getSelectedRow()));
}
});
table.setFont(AdtUiUtils.DEFAULT_FONT);
table.setRowHeight(myRowHeight);
table.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
table.getColumnModel().getColumn(Column.TIMELINE.ordinal()).setPreferredWidth(myCaptureTable.getWidth() / 2);
}
});
return table;
}
use of java.awt.event.ComponentEvent in project JWildfire by thargor6.
the class Buffer method addImageBuffer.
private void addImageBuffer(JDesktopPane pDesktop) {
final int TRANSFORMERS_WIDTH = 300;
// left + right border
final int X_BORDER = 5 + 5 + TRANSFORMERS_WIDTH;
// top + bottom border
final int Y_BORDER = 30 + 5;
int imageWidth = img.getImageWidth();
int imageHeight = img.getImageHeight();
int maxWidth, maxHeight;
if (pDesktop != null) {
maxWidth = pDesktop.getWidth() - X_BORDER;
maxHeight = pDesktop.getHeight() - Y_BORDER;
} else {
maxWidth = imageWidth;
maxHeight = imageHeight;
}
int panelWidth;
if ((imageWidth <= maxWidth) && (imageHeight <= maxHeight))
panelWidth = imageWidth;
else if ((imageWidth > maxWidth) && (imageHeight <= maxHeight))
panelWidth = maxWidth;
else if ((imageWidth <= maxWidth) && (imageHeight > maxHeight))
panelWidth = (int) (((double) maxHeight / (double) imageHeight) * (double) imageWidth + 0.5);
else {
double sclWidth = (double) maxWidth / (double) imageWidth;
double sclHeight = (double) maxHeight / (double) imageHeight;
double scl = (sclWidth < sclHeight) ? sclWidth : sclHeight;
panelWidth = (int) (scl * (double) imageWidth + 0.5);
}
if (pDesktop != null) {
pnl = new ImagePanel(img, 0, 0, panelWidth);
pnl.setLayout(null);
internalFrame = new JInternalFrame();
internalFrame.setTitle(getTitle(panelWidth));
internalFrame.setClosable(true);
internalFrame.setMaximizable(true);
internalFrame.setIconifiable(true);
internalFrame.setResizable(true);
internalFrame.setVisible(true);
internalFrame.setContentPane(pnl);
internalFrame.pack();
pDesktop.add(internalFrame, null);
internalFrame.addComponentListener(new ComponentListener() {
@Override
public void componentHidden(ComponentEvent arg0) {
// empty
}
@Override
public void componentMoved(ComponentEvent arg0) {
// empty
}
@Override
public void componentResized(ComponentEvent evt) {
Component c = (Component) evt.getSource();
Dimension newSize = c.getSize();
int imgWidth = img.getImageWidth();
int windowWidth = newSize.width;
int newWidth;
if (Math.abs(windowWidth - imgWidth) < imgWidth * 0.03)
newWidth = imgWidth;
else
newWidth = windowWidth;
pnl.setImage(img, 0, 0, newWidth);
internalFrame.setTitle(getTitle(newWidth));
}
@Override
public void componentShown(ComponentEvent arg0) {
// empty
}
});
internalFrame.toFront();
pDesktop.repaint();
}
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class NetworkViewComparisonPanel method init.
private void init() {
final Set<CyNetworkView> views = new LinkedHashSet<>();
for (ViewPanel vp : viewPanels.values()) {
vp.getNetworkViewContainer().setComparing(true);
views.add(vp.getNetworkView());
}
setName(createUniqueKey(views));
setLayout(new BorderLayout());
add(getGridPanel(), BorderLayout.CENTER);
add(getComparisonToolBar(), BorderLayout.SOUTH);
addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
requestFocusInWindow();
for (ViewPanel vp : viewPanels.values()) {
if (vp.isCurrent()) {
vp.getNetworkViewContainer().getContentPane().requestFocusInWindow();
break;
}
}
arrangePanels();
update();
}
@Override
public void componentResized(ComponentEvent e) {
arrangePanels();
}
});
setKeyBindings(this);
arrangePanels();
update();
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class VisualPropertySheetItem method getShowMappingBtn.
protected ExpandCollapseButton getShowMappingBtn() {
if (expandCollapseBtn == null) {
expandCollapseBtn = new ExpandCollapseButton(false, evt -> {
if (getMappingPnl().isShowing())
collapse();
else
expand();
});
final Dimension d = new Dimension(VALUE_ICON_WIDTH, VALUE_ICON_HEIGHT);
expandCollapseBtn.setMinimumSize(d);
expandCollapseBtn.setPreferredSize(d);
expandCollapseBtn.setMaximumSize(d);
expandCollapseBtn.setBorder(BorderFactory.createEmptyBorder(BUTTON_V_PAD, BUTTON_H_PAD, BUTTON_V_PAD, BUTTON_H_PAD));
getMappingPnl().addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(final ComponentEvent ce) {
if (expandCollapseBtn != null && !expandCollapseBtn.isSelected())
expandCollapseBtn.setSelected(true);
}
@Override
public void componentHidden(final ComponentEvent ce) {
if (expandCollapseBtn != null && expandCollapseBtn.isSelected())
expandCollapseBtn.setSelected(false);
}
});
}
return expandCollapseBtn;
}
use of java.awt.event.ComponentEvent in project cytoscape-impl by cytoscape.
the class VisualPropertySheet method setItems.
public void setItems(final Set<VisualPropertySheetItem<?>> newItems) {
// Remove current items
vpItemMap.clear();
depItemMap.clear();
items.clear();
if (newItems != null) {
items.addAll(newItems);
// Create the internal panel that contains the visual property editors
final JPanel p = new JPanel(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.FIRST_LINE_START;
c.gridx = 0;
c.weightx = 1;
// Add the visual property editors to the internal panel
int y = 0;
int minWidth = 120;
for (final VisualPropertySheetItem<?> i : items) {
c.gridy = y++;
p.add(i, c);
// Save it for future use
if (i.getModel().getVisualPropertyDependency() == null)
vpItemMap.put(i.getModel().getVisualProperty(), i);
else
depItemMap.put(i.getModel().getVisualPropertyDependency().getIdString(), i);
// Add listeners
i.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
onMousePressedItem(e, i);
}
});
if (i.getModel().isVisualMappingAllowed()) {
i.addComponentListener(new ComponentAdapter() {
@Override
public void componentShown(final ComponentEvent e) {
updateCollapseExpandButtons();
}
@Override
public void componentHidden(final ComponentEvent e) {
if (selectionHead == i)
selectionHead = null;
if (selectionTail == i)
selectionTail = null;
updateCollapseExpandButtons();
}
});
i.addPropertyChangeListener("enabled", evt -> {
updateCollapseExpandButtons();
});
i.addPropertyChangeListener("expanded", evt -> {
updateCollapseExpandButtons();
});
i.getPropSheetPnl().getTable().addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
onMousePressedItem(e, i);
}
});
}
minWidth = Math.max(minWidth, i.getPreferredSize().width);
}
// Add an empty panel to fill the vertical gap
final JPanel fillPnl = new JPanel();
fillPnl.setBackground(VisualPropertySheetItem.getBackgroundColor());
c.fill = GridBagConstraints.BOTH;
c.weighty = 1;
p.add(fillPnl, c);
fillPnl.addMouseListener(new MouseAdapter() {
@Override
@SuppressWarnings("unchecked")
public void mouseClicked(final MouseEvent e) {
if (// Deselect all items
!e.isShiftDown() || e.isControlDown())
setSelectedItems(Collections.EMPTY_SET);
}
});
getVpListScr().setViewportView(p);
minWidth = Math.min((minWidth += 10), 400);
getVpListScr().setMinimumSize(new Dimension(minWidth, 140));
if (getParent() != null) {
minWidth = Math.max(minWidth + 8, getParent().getMinimumSize().width);
getParent().setMinimumSize(new Dimension(minWidth, getParent().getMinimumSize().height));
}
}
updateCollapseExpandButtons();
createMenuItems();
}
Aggregations