⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 analyzerpanel.java

📁 著名的神经网络工具箱
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  public void newLine(){
    lIndex++;
    lIndex %= points.length;
    points[ lIndex ].removeAllPoints();
  }

  void lockLogPanel(){
    snns.pLog.enableOnly(this);
  }

  void releaseLogPanel(){
    snns.pLog.release(this);
  }


  public int print( Graphics g, PageFormat pf, int pi ){
    return dArea.print( g, pf, pi );
  }

  /**
   * method returns the currently selected unit for the x-values
   *
   * @return the selected x-unit
   */
  Unit getXUnit() throws Exception{
    int no = -1;
    try{ no = Integer.parseInt( tfXUnitNo.getText() ); }
    catch( Exception e ){
      throw new Exception("The unit number on x-axis has to be an integer value");
    }
    Unit unit = snns.network.getUnitNumber( no );
    if( unit == null )
      throw new Exception("Wrong unit number on x-axis");
    return unit;
  }


  /**
   * method returns the currently selected unit for the y-values
   *
   * @return the selected y-unit
   */
  Unit getYUnit() throws Exception{
    int no = -1;
    try{ no = Integer.parseInt( tfYUnitNo.getText() ); }
    catch( Exception e ){
      throw new Exception("The unit number on y-axis has to be an integer value");
    }
    Unit unit = snns.network.getUnitNumber( no );
    if( unit == null )
      throw new Exception("Wrong unit number on y-axis");
    return unit;
  }

  /**
   * method returns the number of steps choosen by the steps text field
   *
   * @return the number of selected steps
   */
  int getSteps() throws Exception{
    int no = -1;
    try{ no = Integer.parseInt( tfSteps.getText() ); }
    catch( Exception e ){
      throw new Exception("The number of steps has to be an integer value");
    }
    return no;
  }

  /**
   * method returns the number of training steps selected in the training steps
   * text field
   *
   * @return the number of training steps
   */
  int getTrainingSteps() throws Exception{
    int no = -1;
    try{ no = Integer.parseInt( tfTrainingSteps.getText() ); }
    catch( Exception e ){
      throw new Exception("The number of training steps has to be an integer value");
    }
    return no;
  }

  String getXFormPattern(){
    if( cbXScaleDefault.isSelected() ) return null;
    return tfXScale.getText();
  }

  String getYFormPattern(){
    if( cbYScaleDefault.isSelected() ) return null;
    return tfYScale.getText();
  }


  /*
  the following methods initialize the different panels of the ananlyzer
   */

  private JPanel getMain(){
    Color[] cLines = { Color.black, Color.blue, Color.red, Color.green,
                       Color.blue.darker(), Color.red.darker(), Color.green.darker(),
                       Color.orange, Color.cyan, Color.magenta };

    // left panel:
    Icon icon = snns.icons.getIcon("decreaseYAxis.gif", "Zoom in");
    bDecreaseY = new FlatButton( icon );
    bDecreaseY.setToolTipText("Decrease y-axis");
    bDecreaseY.addActionListener( this );
    icon = snns.icons.getIcon("increaseYAxis.gif", "Zoom out");
    bIncreaseY = new FlatButton( icon );
    bIncreaseY.setToolTipText("Increase y-axis");
    bIncreaseY.addActionListener( this );

    icon = snns.icons.getIcon("leftArrow-12.gif", "Move left");
    bLeft = new FlatButton( icon );
    bLeft.setToolTipText("Move left");
    bLeft.addActionListener( this );

    iGridOn = snns.icons.getIcon("graphGrid.gif", "Grid on" );
    iGridOff = snns.icons.getIcon("graphNoGrid.gif", "Grid off" );
    Icon iNewGraph = snns.icons.getIcon("newGraph.gif", "Clear graph" );
    bGrid = new FlatButton( iGridOn );
    bGrid.setToolTipText("Turn grid on");
    bGrid.addActionListener( this );
    bClear = new FlatButton( iNewGraph );
    bClear.setToolTipText( "Clear graph" );
    bClear.addActionListener( this );

    JPanel pLeft = new JPanel();
    pLeft.setLayout(new BoxLayout(pLeft, BoxLayout.Y_AXIS) );
    pLeft.add(bIncreaseY);
    pLeft.add(bDecreaseY);
    pLeft.add( Box.createVerticalGlue() );
    pLeft.add(bLeft);
    pLeft.add( Box.createVerticalGlue() );
    pLeft.add(bGrid);
    pLeft.add(bClear);

    // top panel:
    icon = snns.icons.getIcon("upArrow-12.gif", "Move up");
    bUp = new FlatButton( icon );
    bUp.setToolTipText("Move up");
    bUp.addActionListener( this );

    JPanel pTop = new JPanel();
    pTop.setLayout(new BoxLayout(pTop, BoxLayout.X_AXIS) );
    pTop.add( Box.createHorizontalGlue() );
    pTop.add(bUp);
    pTop.add( Box.createHorizontalGlue() );

    // center panel:
    dArea = new DArea();
    dArea.setMinRectangle( new DRectangle( -2, -2, 4, 4 ) );
    dArea.setAutoGrid( true );
    dArea.setGridVisible( false );
    dArea.setGridColor( Color.lightGray );
    dArea.setBackground( Color.white );
    dArea.setPreferredSize( new Dimension( 400, 300 ) );
    sbArea = new ScaledBorder();
    sbArea.foreground = Color.gray;
    dArea.setBorder( sbArea );
    new DMouseZoom( dArea );
    points = new DPointSet[ cLines.length ];
    for( int i=0; i<cLines.length; i++ ){
      points[i] = new DPointSet( 5 );
      points[i].setColor( cLines[i] );
      points[i].setConnected( true );
      dArea.addDElement( points[i] );
    }

    // bottom panel:
    icon = snns.icons.getIcon("decreaseXAxis.gif", "Zoom in");
    bDecreaseX = new FlatButton( icon );
    bDecreaseX.setToolTipText("Decrease x-axis");
    bDecreaseX.addActionListener( this );
    icon = snns.icons.getIcon("increaseXAxis.gif", "Zoom out");
    bIncreaseX = new FlatButton( icon );
    bIncreaseX.setToolTipText("Increase x-axis");
    bIncreaseX.addActionListener( this );

    icon = snns.icons.getIcon("downArrow-12.gif", "Move down");
    bDown = new FlatButton( icon );
    bDown.setToolTipText("Move down");
    bDown.addActionListener( this );

    icon = snns.icons.getIcon("errorGraph.gif", "New line");
    bNewLine = new FlatButton( icon );
    bNewLine.setToolTipText("New line");
    bNewLine.addActionListener( this );

    icon = snns.icons.getIcon("Zoom16.gif", "Autofocus");
    bAutoFocus = new FlatButton( icon );
    bAutoFocus.setToolTipText("Autofocus");
    bAutoFocus.addActionListener( this );

    JPanel pBottom = new JPanel();
    pBottom.setLayout(new BoxLayout(pBottom, BoxLayout.X_AXIS) );
    pBottom.add( bNewLine );
    pBottom.add( bAutoFocus );
    pBottom.add( Box.createHorizontalGlue() );
    pBottom.add(bDown);
    pBottom.add( Box.createHorizontalGlue() );
    pBottom.add( bDecreaseX );
    pBottom.add( bIncreaseX );

    // right panel:
    icon = snns.icons.getIcon("rightArrow-12.gif", "Move right");
    bRight = new FlatButton(icon);
    bRight.setToolTipText("Move right");
    bRight.addActionListener(this);

    JPanel pRight = new JPanel();
    pRight.setLayout(new BoxLayout(pRight, BoxLayout.Y_AXIS) );
    pRight.add( Box.createVerticalGlue() );
    pRight.add(bRight);
    pRight.add( Box.createVerticalGlue() );

    // put all together:
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel panel = new JPanel();
    panel.setLayout(gbl);

    gbc.fill = gbc.BOTH;
    gbc.gridheight = 3;
    gbl.setConstraints(pLeft, gbc);
    panel.add(pLeft);

    gbc.gridx = 1;
    gbc.gridheight = 1;
    gbl.setConstraints(pTop, gbc);
    panel.add(pTop);

    gbc.gridy = gbc.RELATIVE;
    gbc.weightx = gbc.weighty = 1;
    gbl.setConstraints(dArea, gbc);
    panel.add(dArea);

    gbc.weightx = gbc.weighty = 0;
    gbc.gridwidth = 2;
    gbl.setConstraints(pBottom, gbc);
    panel.add(pBottom);
    gbc.gridwidth = 1;

    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.gridheight = 2;
    gbc.weightx = gbc.weighty = 0;
    gbl.setConstraints(pRight, gbc);
    panel.add(pRight);

    return panel;
  }


  private JPanel getSetup(){
    JLabel lXaxis = new JLabel("x-axis: "),
           lYaxis = new JLabel("y-axis: ");

    jcbXValues = new JComboBox();
    jcbXValues.addItem( "Unit" );
    jcbXValues.addItem( "Time");
    jcbXValues.addItem( "Pattern no." );
    jcbXValues.setToolTipText("Values displayed on x-axis");
    jcbXValues.addActionListener( this );

    jcbYValues = new JComboBox();
    jcbYValues.addItem( "Unit" );
    jcbYValues.addItem( "Error" );
    jcbYValues.setPreferredSize( jcbXValues.getPreferredSize() );
    jcbYValues.setToolTipText("Values displayed on y-axis");
    jcbYValues.addActionListener( this );

    tfXUnitNo = new JTextField( 4 );
    tfXUnitNo.setToolTipText("Number of the unit on x-axis");
    tfYUnitNo = new JTextField( 4 );
    tfYUnitNo.setToolTipText("Number of the unit on y-axis");


    rbXAct = new JRadioButton( "Activation", true );
    rbYAct = new JRadioButton( "Activation", true );
    cbAVE = new JCheckBox( "AVE", true );
    cbAVE.setToolTipText("Error/|Output Units|");

    jcbErrors = new JComboBox();
    jcbErrors.addItem( "\u03a3|t-o|" );
    jcbErrors.addItem( "\u03a3|t-o|

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -