Search in sources :

Example 1 with ScopedExpressionTableCellRenderer

use of cbit.vcell.model.gui.ScopedExpressionTableCellRenderer in project vcell by virtualcell.

the class ScrollTable method setAutoResizeMode.

@Override
public void setAutoResizeMode(int mode) {
    super.setAutoResizeMode(mode);
    if (autoResizeMode == AUTO_RESIZE_OFF) {
        setDefaultRenderer(ScopedExpression.class, new ScopedExpressionTableCellRenderer());
        setDefaultRenderer(VCUnitDefinition.class, new DefaultScrollTableCellRenderer() {

            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                if (value instanceof VCUnitDefinition) {
                    setText(((VCUnitDefinition) value).getSymbolUnicode());
                }
                return this;
            }
        });
        if (componentListener == null) {
            componentListener = new ComponentAdapter() {

                public void componentResized(ComponentEvent e) {
                    SwingUtilities.invokeLater(new Runnable() {

                        public void run() {
                            ScopedExpressionTableCellRenderer.formatTableCellSizes(ScrollTable.this);
                        }
                    });
                }
            };
        }
        enclosingScrollPane.removeComponentListener(componentListener);
        enclosingScrollPane.addComponentListener(componentListener);
    } else {
        if (componentListener != null) {
            enclosingScrollPane.removeComponentListener(componentListener);
        }
    }
}
Also used : ScopedExpressionTableCellRenderer(cbit.vcell.model.gui.ScopedExpressionTableCellRenderer) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) JTable(javax.swing.JTable) EventObject(java.util.EventObject) ComponentEvent(java.awt.event.ComponentEvent) Component(java.awt.Component) JComponent(javax.swing.JComponent) Point(java.awt.Point) ComponentAdapter(java.awt.event.ComponentAdapter)

Aggregations

ScopedExpressionTableCellRenderer (cbit.vcell.model.gui.ScopedExpressionTableCellRenderer)1 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)1 Component (java.awt.Component)1 Point (java.awt.Point)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 EventObject (java.util.EventObject)1 JComponent (javax.swing.JComponent)1 JTable (javax.swing.JTable)1