📄 inputpanel.java
字号:
/** * file: InputPanel.java * * last edited: Ryan Irwin */// import necessary java libraries//import java.awt.*;import javax.swing.*;import javax.swing.border.*;//These imports are not needed - Phil T. 6-23-03//import java.awt.event.*;/** * class acts as a top level container that emcompasses the input plot * * hierarchy: JPanel->SubPanel->InputPanel * */class InputPanel extends SubPanel { // ********************************************************************* // // declare global variables and components // // ********************************************************************* // declare components // DataPoints data_points_d; // selection area for input display // SelectionArea selection_area_d; Font curr_font_d = getFont(); // fonts for the buttons Font new_font_d = new Font(curr_font_d.getName(), curr_font_d.getStyle(), 12); int width = 0; // width of the canvas int height = 0; // height of the canvas int zeroX = 0; // zero position on x axis int zeroY = 0; // zero position on y axis // ********************************************************************* // // declare class constructors // // ********************************************************************* /** * constructor sets the border and initializes the input plot * * @param data_a input data samples * */ InputPanel(DataPoints data_a) { super(); // initialize components // data_points_d = data_a; // register a listener for the radio buttons. // selection_area_d = new SelectionArea(data_points_d); // set the border for the panel // String title = new String("Input Display:"); Border titleBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.black), title, TitledBorder.LEFT, TitledBorder.ABOVE_TOP, new_font_d, Color.black); setBorder(titleBorder); } // ********************************************************************* // // declare class methods // // ********************************************************************* /** * set the value of the draw flag for the input canvas * * @param flag input draw flag * */ public void setDrawFlag(boolean flag) { selection_area_d.drawFlag = flag; } /** * add components to the input panel * */ public void add_components() { constrain(this, selection_area_d, 0, 0, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, 1, 1, 2, 2, 2, 2); } /** * redraw the input panel screen. Calls repaint() * */ public void refresh() { super.repaint(); selection_area_d.repaint(); } /** * redraw the input panel screen. Calls repaint() * */ public void clear() { super.repaint(); selection_area_d.clear(); selection_area_d.repaint(); } /* /** * set the canvas dimensions, i.e., the input plot dimensions * */ /* public void setCanvasDimensions() { data.inputWidth = slection_area_d.getCanvasWidth(); data.inputHeight = slection_area_d.getCanvasHeight(); } */ /** * determine the dimensions of the selection area * */ public void DetermineDimensions() { Dimension dimen = this.getSize(); width = dimen.width; height = dimen.height; // set the coordinates of the axis origin // zeroX = width >> 1; zeroY = height >> 1; // store the dimensions of the output canvas // //setCanvasDimensions(); } /** * paing the current data points and if needed the decision regions * * @param g graphics object to be */ public void paintComponent(Graphics g) { super.paintComponent(g); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -