📄 functionview.java
字号:
gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( deleteButton, gbc ); functionButtonPanel.add( deleteButton ); // Button: clear JButton clearButton = new FunctionButton( FunctionDocument.Command.CLEAR_FUNCTIONS ); clearButton.setMnemonic( KeyEvent.VK_L ); gbc.gridx = gridX++; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( clearButton, gbc ); functionButtonPanel.add( clearButton ); // Button: redo if ( App.getInstance( ).isApplet( ) ) { JComponent filler = GuiUtilities.createFiller( 8, 1 ); gbc.gridx = gridX++; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( filler, gbc ); functionButtonPanel.add( filler ); JButton redoButton = new FunctionButton( FunctionDocument.Command.REDO ); redoButton.setMnemonic( KeyEvent.VK_R ); gbc.gridx = gridX++; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( redoButton, gbc ); functionButtonPanel.add( redoButton ); } // Update buttons FunctionButton.updateWidth( ); updateButtons( ); //---- Function panel JPanel functionPanel = new JPanel( gridBag ); GuiUtilities.setPaddedLineBorder( functionPanel, 4 ); functionPanel.setBackground( backgroundColour ); int gridY = 0; gbc.gridx = 0; gbc.gridy = gridY++; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets( 0, 0, 4, 0 ); gridBag.setConstraints( functionListScrollPane, gbc ); functionPanel.add( functionListScrollPane ); gbc.gridx = 0; gbc.gridy = gridY++; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets( 0, 0, 0, 0 ); gridBag.setConstraints( functionButtonPanel, gbc ); functionPanel.add( functionButtonPanel ); //---- Coordinates panel JPanel coordPanel = new JPanel( gridBag ); GuiUtilities.setPaddedLineBorder( coordPanel ); coordPanel.setBackground( backgroundColour ); gridX = 0; // Label: cursor JLabel cursorLabel = new FLabel( CURSOR_STR ); gbc.gridheight = 1; gbc.gridx = gridX++; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_END; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( cursorLabel, gbc ); coordPanel.add( cursorLabel ); // Field: coordinates coordinatesField = new CoordinatesField( ); gbc.gridx = gridX++; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( coordinatesField, gbc ); coordPanel.add( coordinatesField ); //---- Interval panel JPanel intervalPanel = new JPanel( gridBag ); GuiUtilities.setPaddedLineBorder( intervalPanel ); intervalPanel.setBackground( backgroundColour ); gridX = 0; // Label: x interval JLabel xIntervalLabel = new FLabel( X_INTERVAL_STR ); gbc.gridx = gridX++; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_END; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( xIntervalLabel, gbc ); intervalPanel.add( xIntervalLabel ); // Field: x lower endpoint xLowerEndpointField = new EndpointField( INTERVAL_EP_NUM_COLUMNS ); xLowerEndpointField.setActionCommand( Command.SET_X_INTERVAL ); xLowerEndpointField.addActionListener( this ); gbc.gridx = gridX++; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( xLowerEndpointField, gbc ); intervalPanel.add( xLowerEndpointField ); // Label: to, x JLabel xToLabel = new FLabel( TO_STR ); gbc.gridx = gridX++; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_END; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets( 2, 1, 2, 1 ); gridBag.setConstraints( xToLabel, gbc ); intervalPanel.add( xToLabel ); // Field: x upper endpoint xUpperEndpointField = new EndpointField( INTERVAL_EP_NUM_COLUMNS ); xUpperEndpointField.setActionCommand( Command.SET_X_INTERVAL ); xUpperEndpointField.addActionListener( this ); gbc.gridx = gridX++; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( xUpperEndpointField, gbc ); intervalPanel.add( xUpperEndpointField ); gridX = 0; // Label: y interval JLabel yIntervalLabel = new FLabel( Y_INTERVAL_STR ); gbc.gridx = gridX++; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_END; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( yIntervalLabel, gbc ); intervalPanel.add( yIntervalLabel ); // Field: y lower endpoint yLowerEndpointField = new EndpointField( INTERVAL_EP_NUM_COLUMNS ); yLowerEndpointField.setActionCommand( Command.SET_Y_INTERVAL ); yLowerEndpointField.addActionListener( this ); gbc.gridx = gridX++; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( yLowerEndpointField, gbc ); intervalPanel.add( yLowerEndpointField ); // Label: to, y JLabel yToLabel = new FLabel( TO_STR ); gbc.gridx = gridX++; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_END; gbc.fill = GridBagConstraints.NONE; gbc.insets = new Insets( 2, 1, 2, 1 ); gridBag.setConstraints( yToLabel, gbc ); intervalPanel.add( yToLabel ); // Field: y upper endpoint yUpperEndpointField = new EndpointField( INTERVAL_EP_NUM_COLUMNS ); yUpperEndpointField.setActionCommand( Command.SET_Y_INTERVAL ); yUpperEndpointField.addActionListener( this ); gbc.gridx = gridX++; gbc.gridy = 1; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( yUpperEndpointField, gbc ); intervalPanel.add( yUpperEndpointField ); // Update interval fields updateIntervalFields( ); //---- Scroll panel JPanel scrollPanel = new JPanel( new GridLayout( 0, 3, 1, 1 ) ); GuiUtilities.setPaddedLineBorder( scrollPanel, 4 ); Color scrollZoomBackgroundColour = GuiUtilities.scaleColourBrightness( backgroundColour, 0.9375f ); scrollPanel.setBackground( scrollZoomBackgroundColour ); scrollPanel.add( GuiUtilities.createFiller( ) ); // Button: scroll up scrollPanel.add( new ScrollButton( FunctionDocument.Command.SCROLL_UP ) ); scrollPanel.add( GuiUtilities.createFiller( ) ); // Button: scroll left scrollPanel.add( new ScrollButton( FunctionDocument.Command.SCROLL_LEFT ) ); // Button: centre on origin scrollPanel.add( new ScrollButton( FunctionDocument.Command.CENTRE_ON_ORIGIN ) ); // Button: scroll right scrollPanel.add( new ScrollButton( FunctionDocument.Command.SCROLL_RIGHT ) ); scrollPanel.add( GuiUtilities.createFiller( ) ); // Button: scroll down scrollPanel.add( new ScrollButton( FunctionDocument.Command.SCROLL_DOWN ) ); //---- X zoom panel JPanel xZoomPanel = new JPanel( gridBag ); xZoomPanel.setBackground( backgroundColour ); gridX = 0; // Label: x zoom JLabel xZoomLabel = new FLabel( X_ZOOM_STR ); gbc.gridx = gridX++; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_END; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( xZoomLabel, gbc ); xZoomPanel.add( xZoomLabel ); // Panel: x zoom buttons JPanel xZoomButtonPanel = new JPanel( new GridLayout( 1, 0, 4, 0 ) ); GuiUtilities.setPaddedLineBorder( xZoomButtonPanel, 4 ); xZoomButtonPanel.setBackground( scrollZoomBackgroundColour ); xZoomButtonPanel.add( new ZoomButton( FunctionDocument.Command.X_ZOOM_IN ) ); xZoomButtonPanel.add( new ZoomButton( FunctionDocument.Command.X_ZOOM_OUT ) ); gbc.gridx = gridX++; gbc.gridy = 0; gbc.gridwidth = 1; gbc.gridheight = 1; gbc.weightx = 0.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.LINE_START; gbc.fill = GridBagConstraints.NONE; gbc.insets = AppConstants.COMPONENT_INSETS; gridBag.setConstraints( xZoomButtonPanel, gbc ); xZoomPanel.add( xZoomButtonPanel ); // Combo box: x zoom factor xZoomFactorComboBox = new FComboBox( ZOOM_FACTOR_STRS ); xZoomFactorComboBox.setSelectedItem( xZoomFactorStr ); xZoomFactorComboBox.setActionCommand( Command.SELECT_X_ZOOM_FACTOR ); xZoomFactorComboBox.addActionListener( this );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -