下面列出了javax.swing.JComponent#isVisible ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public Dimension minimumLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getMinimumSize();
Dimension dim2 = search.getMinimumSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getMinimumSize();
} else if (search != null) {
dim = search.getMinimumSize();
}
if ((filter != null || search != null) && hasBottomFilterFindMargin())
dim.height += 1;
return dim;
}
/** Removes popup component from textComponent root pane
* @param popup popup component to be removed from
* root pane of the text component.
*/
public void uninstall(JComponent popup) {
JComponent oldPopup = this.popup;
if (oldPopup != null) {
if (oldPopup.isVisible()) {
oldPopup.setVisible(false);
}
removeFromRootPane(oldPopup);
this.popup = null;
}
if (popup != null && popup != oldPopup) {
if (popup.isVisible()) {
popup.setVisible(false);
}
removeFromRootPane(popup);
}
}
/**
* Temporarily massage this component so it is visible, enabled, unselected,
* unfocused, etc.
*/
private void storeState(JComponent c) {
if (c instanceof AbstractButton) {
AbstractButton b = (AbstractButton) c;
b.putClientProperty(WAS_SELECTED, new Boolean(b.isSelected()));
b.putClientProperty(WAS_FOCUS_PAINTED, new Boolean(b.isSelected()));
b.setSelected(false);
b.setFocusPainted(false);
}
if (c.isEnabled() == false) {
c.putClientProperty(WAS_ENABLED, new Boolean(c.isEnabled()));
c.setEnabled(true);
}
if (c.isVisible() == false) {
c.putClientProperty(WAS_VISIBLE, new Boolean(c.isVisible()));
c.setVisible(true);
}
for (int a = 0; a < c.getComponentCount(); a++) {
if (c.getComponent(a) instanceof JComponent) {
storeState((JComponent) c.getComponent(a));
}
}
}
/**
* Binds the visibility of the specified component to the user's computer skill level. The skill level is the {@link LSettings#SKILL_LEVEL} taken from
* {@link LEnv#LAUNCHER_SETTINGS}. <strong>Also executes the listener!</strong>
*
* @param comp component whose visibility to be controlled
* @param minSkillLevel minimal skill level required for the component to be visible
*
* @param hiddenSelected if not <code>null</code>, and if the component (which must be an {@link AbstractButton} in this case) has a different selection
* state than this value case upon being hidden), the component selection will be inverted with a {@link AbstractButton#doClick()} call (which
* also fires an event)
*
* @throws IllegalArgumentException if <code>hiddenSelected</code> is not <code>null</code> and comp is not an {@link AbstractButton}
*
* @see #bindVisibilityToSkillLevel(JComponent, ISkillLevel)
*/
public static void bindVisibilityToSkillLevel( final JComponent comp, final ISkillLevel minSkillLevel, final Boolean hiddenSelected ) {
if ( hiddenSelected != null && !( comp instanceof AbstractButton ) )
throw new IllegalArgumentException( "hiddenSelected can only be specified if component is an AbstractButton!" );
final ISettingChangeListener scl = new ISettingChangeListener() {
@Override
public void valuesChanged( final ISettingChangeEvent event ) {
if ( event.affected( LSettings.SKILL_LEVEL ) ) {
comp.setVisible( minSkillLevel.isAtLeast() );
if ( hiddenSelected != null && !comp.isVisible() && hiddenSelected != ( (AbstractButton) comp ).isSelected() )
( (AbstractButton) comp ).doClick( 0 );
}
}
};
addBindExecuteScl( scl, LEnv.LAUNCHER_SETTINGS, LSettings.SKILL_LEVEL.SELF_SET, comp );
}
private int getMaximumExtraHeight(Row row, int[] columnWidths) {
int maxExtraHeight = 0;
for (int a = 0; a < row.columns.length; a++) {
if (row.columns[a] != null) {
int columnWidth = columnWidths[a];
for (int b = 0; b < row.columns[a].components.length; b++) {
JComponent jc = row.columns[a].components[b];
ComponentConstraints c = row.columns[a].constraints[b];
if (jc != null
&& jc.isVisible()
&& c.verticalPriority == profile.maxVisiblePriority) {
Dimension maxSize = getMaximumSize(jc, columnWidth);
if (maxSize == null)
maxSize = jc.getMaximumSize();
Dimension preferredSize = getPreferredSize(jc);
maxExtraHeight = Math.max(maxExtraHeight,
maxSize.height - preferredSize.height);
}
}
}
}
return maxExtraHeight;
}
public Dimension minimumLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getMinimumSize();
Dimension dim2 = search.getMinimumSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getMinimumSize();
} else if (search != null) {
dim = search.getMinimumSize();
}
if ((filter != null || search != null) /*&& hasBottomFilterFindMargin()*/)
dim.height += 1;
return dim;
}
public Dimension preferredLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getPreferredSize();
Dimension dim2 = search.getPreferredSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getPreferredSize();
} else if (search != null) {
dim = search.getPreferredSize();
}
if ((filter != null || search != null) && hasBottomFilterFindMargin())
dim.height += 1;
return dim;
}
public Dimension preferredLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getPreferredSize();
Dimension dim2 = search.getPreferredSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getPreferredSize();
} else if (search != null) {
dim = search.getPreferredSize();
}
if ((filter != null || search != null) /*&& hasBottomFilterFindMargin()*/)
dim.height += 1;
return dim;
}
public Dimension preferredLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getPreferredSize();
Dimension dim2 = search.getPreferredSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getPreferredSize();
} else if (search != null) {
dim = search.getPreferredSize();
}
if ((filter != null || search != null) /*&& hasBottomFilterFindMargin()*/)
dim.height += 1;
return dim;
}
public Dimension minimumLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getMinimumSize();
Dimension dim2 = search.getMinimumSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getMinimumSize();
} else if (search != null) {
dim = search.getMinimumSize();
}
if ((filter != null || search != null) /*&& hasBottomFilterFindMargin()*/)
dim.height += 1;
return dim;
}
public Dimension preferredLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getPreferredSize();
Dimension dim2 = search.getPreferredSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getPreferredSize();
} else if (search != null) {
dim = search.getPreferredSize();
}
if ((filter != null || search != null) /*&& hasBottomFilterFindMargin()*/)
dim.height += 1;
return dim;
}
public Dimension minimumLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getMinimumSize();
Dimension dim2 = search.getMinimumSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getMinimumSize();
} else if (search != null) {
dim = search.getMinimumSize();
}
if ((filter != null || search != null) /*&& hasBottomFilterFindMargin()*/)
dim.height += 1;
return dim;
}
public Dimension preferredLayoutSize(Container parent) {
JComponent filter = filterPanel;
if (filter != null && !filter.isVisible()) filter = null;
JComponent search = searchPanel;
if (search != null && !search.isVisible()) search = null;
Dimension dim = new Dimension();
if (filter != null && search != null) {
Dimension dim1 = filter.getPreferredSize();
Dimension dim2 = search.getPreferredSize();
dim.width = dim1.width + dim2.width + 1;
dim.height = Math.max(dim1.height, dim2.height);
} else if (filter != null) {
dim = filter.getPreferredSize();
} else if (search != null) {
dim = search.getPreferredSize();
}
if ((filter != null || search != null) /*&& hasBottomFilterFindMargin()*/)
dim.height += 1;
return dim;
}
private void checkThread(JComponent comp) throws Exception
{
if (comp.isVisible())
{
final Component root = comp.getRootPane();
if (root != null && root.isVisible())
{
if (!SwingUtilities.isEventDispatchThread())
{
// i18n[ThreadCheckingRepaintManager.workinwrongthread=GUI work done in wrong thread]
//throw new Exception(s_stringMgr.getString("ThreadCheckingRepaintManager.workinwrongthread"));
}
}
}
}
@Override
public Dimension getPreferredSize() {
Dimension size = panel.getPreferredSize();
JComponent scrollBar = getVerticalScrollBar();
if (scrollBar.isVisible()) {
/*
* Try to claim a bit more space if the user enlarges the window and
* there's not enough space sidewise.
*/
size.width += scrollBar.getWidth();
}
return size;
}
private void showObjectsView() {
JComponent c = objectsView.getComponent();
if (c.isVisible()) return;
c.setVisible(true);
component.removeAll();
component.add(c, BorderLayout.CENTER);
mergedRequest = false;
component.invalidate();
component.revalidate();
component.repaint();
}
void renderHeatFlux(float[][] t, float[][] k, JComponent c, Graphics2D g, float scale, float minSquare, boolean dotForZero) {
if (!c.isVisible())
return;
int w = c.getWidth();
int h = c.getHeight();
float dx = (float) w / (float) nx;
float dy = (float) h / (float) ny;
g.setStroke(stroke);
int x, y;
float uij, vij;
for (int i = 1; i < nx - 1; i += spacing) {
x = Math.round(i * dx);
for (int j = 1; j < ny - 1; j += spacing) {
y = Math.round(j * dy);
uij = -k[i][j] * (t[i + 1][j] - t[i - 1][j]) / (2 * dx);
vij = -k[i][j] * (t[i][j + 1] - t[i][j - 1]) / (2 * dy);
g.setColor(view.getContrastColor(x, y));
if (uij * uij + vij * vij > minSquare) {
drawVector(g, x, y, uij, vij, scale);
} else {
if (dotForZero)
g.fillOval(x, y, 4, 4);
}
}
}
}
public void savePropertyValues() {
final Set<Enum<?>> keySet = propertyToComponent.keySet();
for (final Enum<?> propertyKey : keySet) {
final JComponent component = propertyToComponent.get(propertyKey)[0];
if( !component.isVisible() ) {
setPropertyValue(propertyKey, "");
}else {
if (component instanceof JTextComponent) {
setPropertyValue(propertyKey, ((JTextComponent) component).getText());
} else if (component instanceof JCheckBox) {
setPropertyValue(propertyKey, ((JCheckBox) component).isSelected() + ""); //$NON-NLS-1$
} else if (component instanceof JComboBox) {
if (((JComboBox) component).getItemAt(0) instanceof ComboBoxItem) {
setPropertyValue(propertyKey,
((ComboBoxItem) ((JComboBox) component).getSelectedItem()).getNumberOfPoints() + ""); //$NON-NLS-1$
} else if (((JComboBox) component).getItemAt(0) instanceof String) {
setPropertyValue(propertyKey, ((String) ((JComboBox) component).getSelectedItem() ) ); //$NON-NLS-1$
} else if (((JComboBox) component).getItemAt(0) instanceof SAMPLE_SHAPE) {
setPropertyValue(propertyKey, ( (SAMPLE_SHAPE) ((JComboBox) component).getSelectedItem() ).name() );
}
} else if (component instanceof JList) {
setPropertyValue(propertyKey, ((JList) component).getSelectedValue() + ""); //$NON-NLS-1$
} else if (component instanceof JRadioButton) {
final JComponent[] jComponents = propertyToComponent.get(propertyKey);
for (final JComponent jComponent : jComponents) {
if (((JRadioButton) jComponent).isSelected()) {
setPropertyValue(propertyKey, ((JRadioButton) jComponent).getName());
}
}
} else if (component instanceof JFilePicker) {
setPropertyValue(propertyKey, ((JFilePicker) component).getSelectedFilePath());
}
}
}
}
public boolean isRowVisible(int rowIndex) {
Row row = rows.get(rowIndex);
int componentsVisible = 0;
for (JComponent jc : row.componentIterator()) {
if (jc.isVisible()) {
componentsVisible++;
} else {
return false;
}
}
return componentsVisible > 0;
}
private boolean isAvailable(JComponent c) {
return c.isVisible() && c.isEnabled();
}