📄 rowadjustments.java
字号:
int row_count = tree_view.getRowCount(); slider_VIS_ROW_COUNT.setMaxLabel( row_count ); fld_VIS_ROW_COUNT.fireActionPerformed(); } // else if ( resize_mode.equals( ROW_HEIGHT_RESIZE ) ) { // } fitall_btn.doClick(); }/* private class YLabelExpansionListener implements TreeExpansionListener { public void treeCollapsed( TreeExpansionEvent evt ) { if ( debug.isActive() ) debug.println( "YLabelExpansionListener.treeCollapsed()" ); updateSlidersAfterTreeExpansion(); } public void treeExpanded( TreeExpansionEvent evt ) { if ( debug.isActive() ) debug.println( "YLabelExpansionListener.treeExpanded()" ); updateSlidersAfterTreeExpansion(); } }*/ private class SliderComponentListener extends ComponentAdapter { public void componentResized( ComponentEvent evt ) { if ( debug.isActive() ) { debug.println( "SliderComponentListener: START" ); debug.println( "HEIGHT: canvas_vport.height = " + canvas_vport.getHeight() ); } slider_VIS_ROW_HEIGHT.setMaxLabel( canvas_vport.getHeight() ); String resize_mode = (String) combo_ROW_RESIZE.getSelectedItem(); if ( resize_mode.equals( ROW_COUNT_RESIZE ) ) { double vis_row_count, row_height; vis_row_count = fld_VIS_ROW_COUNT.getDouble(); row_height = (double) canvas_vport.getHeight() / vis_row_count; // slider_VIS_ROW_HEIGHT.setValLabel( row_height ); tree_view.setRowHeight( (int) Math.round( row_height ) ); canvas_vport.fireComponentResized(); if ( debug.isActive() ) debug.println( "ROW: row_height = " + row_height ); } else if ( resize_mode.equals( ROW_HEIGHT_RESIZE ) ) { double row_height; row_height = fld_VIS_ROW_HEIGHT.getDouble(); slider_VIS_ROW_HEIGHT.setValLabel( row_height ); } if ( debug.isActive() ) debug.println( "SliderComponentListener: END" ); } } private class RowHeightSliderListener implements ChangeListener { public void stateChanged( ChangeEvent evt ) { if ( debug.isActive() ) debug.println( "RowHeightSliderListener: START" ); double tree_row_count, vport_height; double min_row_height, max_row_height; double vis_row_count, row_height; vis_row_count = -1.0d; row_height = slider_VIS_ROW_HEIGHT.getValLabel(); fld_VIS_ROW_HEIGHT.setDouble( row_height ); if ( ! slider_VIS_ROW_HEIGHT.getValueIsAdjusting() ) { vport_height = (double) canvas_vport.getHeight(); tree_row_count = (double) tree_view.getRowCount(); min_row_height = vport_height / tree_row_count; max_row_height = vport_height; // Constraint: row_height * vis_row_count = tree_view_count // Process the invalid values first if ( row_height > max_row_height ) { // Slider's range should have avoided this case already row_height = max_row_height; vis_row_count = 1.0d; fld_VIS_ROW_HEIGHT.setDouble( row_height ); slider_VIS_ROW_HEIGHT.setValLabelFully( row_height ); } else { if ( row_height < min_row_height ) { row_height = min_row_height; vis_row_count = tree_row_count; fld_VIS_ROW_HEIGHT.setDouble( row_height ); slider_VIS_ROW_HEIGHT.setValLabelFully( row_height ); } else // The valid range: min_ < vis_row_count < max_ vis_row_count = vport_height / row_height; } slider_VIS_ROW_COUNT.setValLabel( vis_row_count ); tree_view.setRowHeight( (int) Math.round( row_height ) ); canvas_vport.fireComponentResized(); if ( debug.isActive() ) debug.println( "RowHeightSliderListener: " + "h=" + row_height + ",N=" + vis_row_count ); } if ( debug.isActive() ) debug.println( "RowHeightSliderListener: END" ); } } private class RowHeightTextListener implements ActionListener { public void actionPerformed( ActionEvent evt ) { if ( debug.isActive() ) debug.println( "RowHeightTextListener: START" ); double tree_row_count, vport_height; double min_row_height, max_row_height; double vis_row_count, row_height; vport_height = (double) canvas_vport.getHeight(); tree_row_count = (double) tree_view.getRowCount(); min_row_height = vport_height / tree_row_count; max_row_height = vport_height; vis_row_count = -1.0d; row_height = fld_VIS_ROW_HEIGHT.getDouble(); // Constraint: row_height * vis_row_count = tree_view_count // Process the invalid values first if ( row_height > max_row_height ) { row_height = max_row_height; vis_row_count = 1.0d; fld_VIS_ROW_HEIGHT.setDouble( row_height ); } else { if ( row_height < min_row_height ) { row_height = min_row_height; vis_row_count = tree_row_count; fld_VIS_ROW_HEIGHT.setDouble( row_height ); } else // The valid range: min_ < vis_row_count < max_ vis_row_count = vport_height / row_height; } slider_VIS_ROW_HEIGHT.setValLabel( row_height ); slider_VIS_ROW_COUNT.setValLabel( vis_row_count ); tree_view.setRowHeight( (int) Math.round( row_height ) ); canvas_vport.fireComponentResized(); if ( debug.isActive() ) { debug.println( "RowHeightTextListener: " + "h=" + row_height + ",N=" + vis_row_count ); debug.println( "RowHeightTextListener: END" ); } } } private class RowCountSliderListener implements ChangeListener { public void stateChanged( ChangeEvent evt ) { if ( debug.isActive() ) debug.println( "RowCountSliderListener: START" ); double min_vis_row_count, max_vis_row_count; double vis_row_count, row_height; row_height = -1.0d; vis_row_count = slider_VIS_ROW_COUNT.getValLabel(); fld_VIS_ROW_COUNT.setDouble( vis_row_count ); if ( ! slider_VIS_ROW_COUNT.getValueIsAdjusting() ) { min_vis_row_count = slider_VIS_ROW_COUNT.getMinLabel(); max_vis_row_count = slider_VIS_ROW_COUNT.getMaxLabel(); // Constraint: row_height * vis_row_count = tree_view_count // Process the invalid values first if ( vis_row_count > max_vis_row_count ) { // Slider's range should have avoided this case already vis_row_count = max_vis_row_count; fld_VIS_ROW_COUNT.setDouble( vis_row_count ); slider_VIS_ROW_COUNT.setValLabelFully( vis_row_count ); } else { // if ( vis_row_count <= max_vis_row_count ) if ( vis_row_count < min_vis_row_count ) { vis_row_count = min_vis_row_count; fld_VIS_ROW_COUNT.setDouble( vis_row_count ); slider_VIS_ROW_COUNT.setValLabelFully( vis_row_count ); } } // tree_view.setVisibleRowCount( vis_row_count ); row_height = (double) canvas_vport.getHeight() / vis_row_count; slider_VIS_ROW_HEIGHT.setValLabel( row_height ); if ( debug.isActive() ) debug.println( "RowCountSliderListener: " + "h=" + row_height + ",N=" + vis_row_count ); } if ( debug.isActive() ) debug.println( "RowCountSliderListener: END" ); } } private class RowCountTextListener implements ActionListener { public void actionPerformed( ActionEvent evt ) { if ( debug.isActive() ) debug.println( "RowCountTextListener: START" ); double min_vis_row_count, max_vis_row_count; double vis_row_count, row_height; min_vis_row_count = slider_VIS_ROW_COUNT.getMinLabel(); max_vis_row_count = slider_VIS_ROW_COUNT.getMaxLabel(); row_height = -1; vis_row_count = fld_VIS_ROW_COUNT.getDouble(); // Constraint: row_height * vis_row_count = tree_view_count // Process the invalid values first if ( vis_row_count > max_vis_row_count ) { vis_row_count = max_vis_row_count; fld_VIS_ROW_COUNT.setDouble( vis_row_count ); } else { // if ( vis_row_count <= max_vis_row_count ) if ( vis_row_count < min_vis_row_count ) { vis_row_count = min_vis_row_count; fld_VIS_ROW_COUNT.setDouble( vis_row_count ); } } slider_VIS_ROW_COUNT.setValLabel( vis_row_count ); // tree_view.setVisibleRowCount( vis_row_count ); row_height = (double) canvas_vport.getHeight() / vis_row_count; slider_VIS_ROW_HEIGHT.setValLabel( row_height ); if ( debug.isActive() ) { debug.println( "RowCountTextListener: " + "h=" + row_height + ",N=" + vis_row_count ); debug.println( "RowCountTextListener: END" ); } } } private class ButtonActionListener implements ActionListener { public void actionPerformed( ActionEvent evt ) { double row_height; row_height = (double) canvas_vport.getHeight() / tree_view.getRowCount(); slider_VIS_ROW_HEIGHT.setValLabel( row_height ); fld_VIS_ROW_HEIGHT.setDouble( row_height ); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -