📄 outputpanel.java,v
字号:
* returns the width on the output canvas *d211 1a211 1 * method: getHeighta212 1 * @@param nonea213 3 * * returns the height on the output canvas *d224 1a224 6 * method: getXRatio * * @@param none * @@return height of the output plot * * get the X direction Ratiod226 1d239 1a239 6 * method: getYRatio * * @@param none * @@return height of the output plot * * get the Y direction Ratiod241 1d254 1a254 6 * method: clear() * * @@param none * @@return none * * redraw the input panel screend265 1a265 7 * method: refresh() * * @@param none * @@return none * * redraw the input panel screen *d274 1a274 6 * method: copy() * * @@param none * @@return OutputPanel * * duplicates the OutputPanel Objectd276 1@1.2log@drawing lines instead of points. Played around with thethickness of the line and then got to know the draw line stuff.@text@d1 4a4 2// file: OutputPanel.java//d17 9a25 7// class: OutputPanel//// OutputPanel acts as the top level container that encompasses the output// plot that displays the input classes as well as the decision regions//// heirarchy: JPanel->SubPanel->OutputPanel//d29 1a29 63 // ********************************************************************* // // declare global variables and components // // ********************************************************************* // static members // public static double Xmax = 2.0; // maximum range of the x axis public static double Xmin = -2.0; // minimum range of the x axis public static double Ymax = 2.0; // maximum range of the y axis public static double Ymin = -2.0; // minimum range of the y axis public static double Rx = 0.0; // time per pixel ration of the x axis public static double Ry = 0.0; // time per pixel ration of the y axis // declare components // String title; // title for the input panel Font currentFont = getFont(); // fonts for the buttons Font newFont = new Font(currentFont.getName(), currentFont.getStyle(), 12); DisplayArea disp_area_d; // declare a panel for plotting static final int GRID_DIV = 20; // division size for the grid 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 int currObject = 0; // current object that is in focus String newline; // newline statement for text area String text; // string for process description int algorithm = 0; // index to indicate algorithm to be used // ********************************************************************* // // declare class constructors // // ********************************************************************* // method: OutputPanel // // arguments: // Data d: data samples form the input plot // InputPanel in: panel that encompasses the input plot // ProcessBox p: process description box // // returns : none // // constructor initializes the samples to be plotted in the signal panel // OutputPanel() { super(); // initialize the panel used for plottingd31 1a31 3 disp_area_d = new DisplayArea(); // set the border for the paneld33 1a33 27 title = new String("Output Display:"); Border titleBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.black), title, TitledBorder.LEFT, TitledBorder.ABOVE_TOP, newFont, Color.black); setBorder(titleBorder); } // method: OutputPanel // // arguments: // Data d: data samples form the input plot // InputPanel in: panel that encompasses the input plot // ProcessBox p: process description box // // returns : none // // constructor initializes the samples to be plotted in the signal panel // OutputPanel(OutputPanel toCopy) { super();d35 1a35 1 // initialize the panel used for plottingd37 6a42 1 disp_area_d = toCopy.disp_area_d;d44 1a44 1 // set the border for the paneld46 1a46 11 title = new String("Output Display:"); Border titleBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.black), title, TitledBorder.LEFT, TitledBorder.ABOVE_TOP, newFont, Color.black); setBorder(titleBorder); }d48 1a48 15 // ********************************************************************* // // declare class methods // // ********************************************************************* // method: add_components // // arguments: none // return : none // // add components to the input panel // public void add_components() {d50 1a50 16 constrain( this, disp_area_d, 0, 0, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, 1, 1, 2, 2, 2, 2); }d52 1a52 18 // method: paintComponent // // arguments: // Graphics g: graphics object // // return : none // // paing the current data points and if needed the decision regions // public void paintComponent(Graphics g) { super.paintComponent(g); // g.drawLine(10, 15, 410, 50); draws a line but always // near the Text Output Display:. // the line is drawn in the background. // idea is to draw a line - refer the AlgorithmLP.java code. }d54 1a54 11 // method: addOutput // // arguments: // Graphics g: graphics object // // return : none // // paing the current data points and if needed the decision regions // public boolean addOutput(Vector points_a, int type_a, Color color_a) {d56 2a57 3 disp_area_d.output_points_d.add(points_a); disp_area_d.type_d.add(new Integer(type_a)); disp_area_d.color_d.add(color_a);d59 2a60 4 // init the algorithm // return true; }d62 1a62 9 // method: getDisplayWidth // // arguments: none // return : width of the output plot // // returns the width on the output canvas // public int getDisplayWidth() {d64 2a65 4 // return the width // return disp_area_d.getWidth(); }d67 1a67 9 // method: getHeight // // arguments: none // return : height of the output plot // // returns the height on the output canvas // public int getDisplayHeight() {d69 1a69 1 // return the width d71 3a73 12 return disp_area_d.getHeight(); } // method: getXRatio // // arguments: none // return : height of the output plot // // get the X direction Ratio // public double getXRatio() {d75 69a143 1 Rx = (Xmax - Xmin) / getDisplayWidth();d145 1a145 1 // return the width d147 1a147 17 return Rx; } // method: getYRatio // // arguments: none // return : height of the output plot // // get the Y direction Ratio // public double getYRatio() { Ry = (Ymax - Ymin) / getDisplayWidth(); // return the width d149 1a149 2 return Ry; }d151 10a160 8 // method: clear() // // arguments: none // return : none // // redraw the input panel screen // public void clear()a161 29 super.repaint(); disp_area_d.clear(); disp_area_d.repaint(); } // method: refresh() // // arguments: none // return : none // // redraw the input panel screen // public void refresh() { super.repaint(); disp_area_d.repaint(); } public OutputPanel copy() { try { return (OutputPanel)clone(); } catch (CloneNotSupportedException e) {} return null; }d163 180d344 2a346 3//// end of file@1.1log@Initial revision@text@d172 1a172 1 // method: paintComponentd181 9a189 4 public void paintComponent(Graphics g) { super.paintComponent(g); }@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -