Package javax.swing

Examples of javax.swing.Spring$ScaleSpring


                    .println("The first argument to makeCompactGrid must use SpringLayout.");
            return;
        }

        // Align all cells in each column and make them the same width.
        Spring x = Spring.constant(initialX);
        for (int c = 0; c < cols; c++) {
            Spring width = Spring.constant(0);
            for (int r = 0; r < rows; r++) {
                width = Spring.max(width,
                        getConstraintsForCell(r, c, parent, cols).getWidth());
            }
            for (int r = 0; r < rows; r++) {
                SpringLayout.Constraints constraints = getConstraintsForCell(r,
                        c, parent, cols);
                constraints.setX(x);
                constraints.setWidth(width);
            }
            x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
        }

        // Align all cells in each row and make them the same height.
        Spring y = Spring.constant(initialY);
        for (int r = 0; r < rows; r++) {
            Spring height = Spring.constant(0);
            for (int c = 0; c < cols; c++) {
                height = Spring.max(height,
                        getConstraintsForCell(r, c, parent, cols).getHeight());
            }
            for (int c = 0; c < cols; c++) {
View Full Code Here


     */
    public static void makeSpringGrid( Container parent, int rows, int cols,
                     int initialX, int initialY, int xPad, int yPad )
  {
        SpringLayout        layout;
    Spring            xPadSpring, yPadSpring, initialXSpring, initialYSpring;
    Spring            maxWidthSpring, maxHeightSpring;
    SpringLayout.Constraints  cons;
        SpringLayout.Constraints  lastCons    = null;
        SpringLayout.Constraints  lastRowCons    = null;
    int              max        = rows * cols;
   
 
View Full Code Here

     */
    public static void makeCompactSpringGrid( Container parent, int rows, int cols,
                        int initialX, int initialY, int xPad, int yPad )
  {
    SpringLayout        layout;
    Spring            x, y, width, height;
    SpringLayout.Constraints  constraints;
    Component          comp;
    boolean            anyVisible;

    try {
View Full Code Here

   @todo  this method is not yet fully working
   */
  public void makeGrid( boolean elastic )
  {
    final List          realOnes    = new ArrayList( getComponentCount() );
    final Spring        xPadSpring, yPadSpring, initialXSpring, initialYSpring;
    final int[]          colCnt;
    final int[]          rowCnt;
    final int          effCols, effRows;
//    final SpringLayout      layout      = new SpringLayout();

    Spring            maxWidthSpring, maxHeightSpring, spX, spY, spW, spH;
    SpringLayout.Constraints  cons;
//    SpringLayout.Constraints  lastCons    = null;
//    SpringLayout.Constraints  lastRowCons    = null;
    Rectangle          r;
    Component          comp;
    JComponent          jc;
    int              rows      = 0;
    int              cols      = 0;

//    setLayout( layout );

    xPadSpring    = Spring.constant( xPad );
    yPadSpring    = Spring.constant( yPad );
    initialXSpring  = Spring.constant( initialX );
    initialYSpring  = Spring.constant( initialY );

    for( int i = 0; i < getComponentCount(); i++ ) {
      comp      = getComponent( i );
      layout.removeLayoutComponent( comp );
      if( !(comp instanceof JComponent) || !comp.isVisible() ) continue;
      jc        = (JComponent) comp;
      r        = (Rectangle) jc.getClientProperty( GRID );
      if( r == null ) continue;
      realOnes.add( jc );
      cols      = Math.max( cols, r.x + r.width );
      rows      = Math.max( rows, r.y + r.height );
    }
   
    if( (cols == 0) || (rows == 0) ) return;
   
    colCnt = new int[ cols ];
    rowCnt = new int[ rows ];
   
    for( int i = 0; i < realOnes.size(); i++ ) {
      jc        = (JComponent) realOnes.get( i );
      r        = (Rectangle) jc.getClientProperty( GRID );
      for( int col = r.x; col < r.x + r.width; col++ ) {
        colCnt[ col ]++;
      }
      for( int row = r.y; row < r.y + r.height; row++ ) {
        rowCnt[ row ]++;
      }
    }
   
    for( int col = 0, colOff = 0; col < cols; col++ ) {
      if( colCnt[ col ] > 0 ) {
        colCnt[ col ] = colOff++;
      }
    }
    for( int row = 0, rowOff = 0; row < rows; row++ ) {
      if( rowCnt[ row ] > 0 ) {
        rowCnt[ row ] = rowOff++;
      }
    }

    effCols = colCnt[ cols - 1 ] + 1;
    effRows = rowCnt[ rows - 1 ] + 1;

    if( elastic ) {
//      maxWidthSpring  = Spring.constant( 64 );
//      maxHeightSpring = Spring.constant( 32 );
      maxWidthSpring  = new ComponentWidthRatioSpring( this, 1, effCols );
      maxHeightSpring = new ComponentHeightRatioSpring( this, 1, effRows );
    } else {
      // Calculate Springs that are the max of the width/height so that all
      // cells have the same size.
      maxWidthSpring  = Spring.constant( 0 );
      maxHeightSpring = Spring.constant( 0 );
    }
    for( int i = 0; i < realOnes.size(); i++ ) {
      jc        = (JComponent) realOnes.get( i );
      r        = (Rectangle) jc.getClientProperty( GRID );
      cons      = layout.getConstraints( jc );
      spW        = new RatioSpring( cons.getWidth(), 1, r.width );
      spH        = new RatioSpring( cons.getHeight(), 1, r.height );
      maxWidthSpring  = Spring.max( maxWidthSpring, spW );
      maxHeightSpring = Spring.max( maxHeightSpring, spH );
    }
   
    System.err.println( "cols "+cols+"; rows "+rows+"; maxWidthSpring "+maxWidthSpring.getValue()+
      "; maxHeightSpring "+maxHeightSpring.getValue() );

    // Apply the new width/height Spring. This forces all the
    // components to have the same size.
    // Adjust the x/y constraints of all the cells so that they
View Full Code Here

   @todo  the elastic flags should be set to true for now
   */
    public void makeCompactGrid( boolean hElastic, boolean vElastic )
  {
    final List          realOnes    = new ArrayList( getComponentCount() );
    final Spring        xPadSpring, yPadSpring; // , initialXSpring, initialYSpring;
    final int[]          colCnt;
    final int[]          rowCnt;
    final Spring[]        spXs, spYs, spWs, spHs;
//    final SpringLayout      layout      = new SpringLayout();

    Spring            spX, spY, spW, spH;
    SpringLayout.Constraints  cons;
//    SpringLayout.Constraints  lastCons    = null;
//    SpringLayout.Constraints  lastRowCons    = null;
    Rectangle          r;
    Component          comp;
View Full Code Here

            throw new IllegalArgumentException("The first argument to makeCompactGrid must use SpringLayout.");
        }
        SpringLayout layout = (SpringLayout) parent.getLayout();

        // Align all cells in each column and make them the same width.
        Spring x = Spring.constant(initialX);
        for (int c = 0; c < columns; c++)
        {
            Spring width = Spring.constant(0);
            for (int r = 0; r < rows; r++)
            {
                width = Spring.max(width,
                                   getConstraintsForCell(r, c, parent, columns).getWidth());
            }
            for (int r = 0; r < rows; r++)
            {
                SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, columns);
                constraints.setX(x);
                constraints.setWidth(width);
            }
            x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
        }

        // Align all cells in each row and make them the same height.
        Spring y = Spring.constant(initialY);
        for (int r = 0; r < rows; r++)
        {
            Spring height = Spring.constant(0);
            for (int c = 0; c < columns; c++)
            {
                height = Spring.max(height,
                                    getConstraintsForCell(r, c, parent, columns).getHeight());
            }
View Full Code Here

        } catch (ClassCastException exc) {
            System.err.println("The first argument to makeGrid must use SpringLayout.");
            return;
        }

        Spring xPadSpring = Spring.constant(xPad);
        Spring yPadSpring = Spring.constant(yPad);
        Spring initialXSpring = Spring.constant(initialX);
        Spring initialYSpring = Spring.constant(initialY);
        int max = rows * cols;

        //Calculate Springs that are the max of the width/height so that all
        //cells have the same size.
        Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).
                                    getWidth();
        Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).
                                    getWidth();
        for (int i = 1; i < max; i++) {
            SpringLayout.Constraints cons = layout.getConstraints(
                                            parent.getComponent(i));

View Full Code Here

            System.err
                    .println("The first argument to makeGrid must use SpringLayout.");
            return;
        }

        Spring xPadSpring = Spring.constant(xPad);
        Spring yPadSpring = Spring.constant(yPad);
        Spring initialXSpring = Spring.constant(initialX);
        Spring initialYSpring = Spring.constant(initialY);
        int max = rows * cols;

        //Calculate Springs that are the max of the width/height so that all
        //cells have the same size.
        Spring maxWidthSpring =
                layout.getConstraints(parent.getComponent(0)).getWidth();
        Spring maxHeightSpring =
                layout.getConstraints(parent.getComponent(0)).getWidth();
        for (int i = 1; i < max; i++) {
            SpringLayout.Constraints cons =
                    layout.getConstraints(parent.getComponent(i));

View Full Code Here

                    .println("The first argument to makeCompactGrid must use SpringLayout.");
            return;
        }

        //Align all cells in each column and make them the same width.
        Spring x = Spring.constant(initialX);
        for (int c = 0; c < cols; c++) {
            Spring width = Spring.constant(0);
            for (int r = 0; r < rows; r++) {
                width =
                        Spring.max(width, getConstraintsForCell(r,
                                                                c,
                                                                parent,
                                                                cols)
                                .getWidth());
            }
            for (int r = 0; r < rows; r++) {
                SpringLayout.Constraints constraints =
                        getConstraintsForCell(r, c, parent, cols);
                constraints.setX(x);
                constraints.setWidth(width);
            }
            x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));
        }

        //Align all cells in each row and make them the same height.
        Spring y = Spring.constant(initialY);
        for (int r = 0; r < rows; r++) {
            Spring height = Spring.constant(0);
            for (int c = 0; c < cols; c++) {
                height =
                        Spring.max(height, getConstraintsForCell(r,
                                                                 c,
                                                                 parent,
View Full Code Here

        } catch (final ClassCastException exc) {
            System.err.println("The first argument to makeGrid must use SpringLayout.");
            return;
        }

        final Spring xPadSpring = Spring.constant(xPad);
        final Spring yPadSpring = Spring.constant(yPad);
        final Spring initialXSpring = Spring.constant(initialX);
        final Spring initialYSpring = Spring.constant(initialY);
        final int max = rows * cols;

        //Calculate Springs that are the max of the width/height so that all
        //cells have the same size.
        Spring maxWidthSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
        Spring maxHeightSpring = layout.getConstraints(parent.getComponent(0)).getWidth();
        for (int i = 1; i < max; i++) {
            final SpringLayout.Constraints cons = layout.getConstraints(parent.getComponent(i));

            maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
            maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
View Full Code Here

TOP

Related Classes of javax.swing.Spring$ScaleSpring

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.