Package DisplayProject

Examples of DisplayProject.GridCell


   * In Forte, the minimum size of a button is a fraction bigger than the ones
   * in Java, so we'll adjust this here.
   */
  @Override
  public Dimension getMinimumSize() {
    GridCell cell = GridField.getConstraints(this);
    Dimension d = new Dimension();

    // If we're natural or to_parent then the minimum size is
    // the UI minimum size
    // TF:8/11/07: The above rule applies only to explicit size, not parent
    // size
    // as we can actually shrink the widget if we need to.
    if (cell.getWidthPolicy() == Constants.SP_NATURAL /*
                               * ||
                               * cell.getWidthPolicy() ==
                               * Constants.SP_TO_PARENT
                               */) {
      d.width = this.getIcon().getIconWidth();
    } else if (cell.getWidthPolicy() == Constants.SP_EXPLICIT) {
      // Must be the same as the current size
      d.width = getWidth();
    } else {
      d.width = 0;
    }
    if (cell.getHeightPolicy() == Constants.SP_NATURAL /*
                               * ||
                               * cell.getHeightPolicy() ==
                               * Constants.SP_TO_PARENT
                               */) {
      d.height = this.getIcon().getIconHeight();
    } else if (cell.getHeightPolicy() == Constants.SP_EXPLICIT) {
      // Must be the same as the current size
      d.height = getHeight();
    } else {
      d.height = 0;
    }
View Full Code Here


   * must be called PRIOR to setting the size of the image.
   *
   * @param pWidthPolicy
   */
  public void setWidthPolicy(int pWidthPolicy) {
    GridCell gbc = GridField.getConstraints(this);
    gbc.setWidthPolicy(pWidthPolicy);
    if (getParent() != null) {
      getParent().invalidate();
      getParent().validate();
    }
  }
View Full Code Here

  /**
   * Get the height policy of this control
   */
  public int getWidthPolicy() {
    GridCell gbc = GridField.getConstraints(this);
    return gbc.getWidthPolicy();
  }
View Full Code Here

   * must be called PRIOR to setting the size of the image.
   *
   * @param pHeightPolicy
   */
  public void setHeightPolicy(int pHeightPolicy) {
    GridCell gbc = GridField.getConstraints(this);
    gbc.setHeightPolicy(pHeightPolicy);
    if (getParent() != null) {
      getParent().invalidate();
      getParent().validate();
    }
  }
View Full Code Here

  /**
   * Get the height policy of this control
   */
  public int getHeightPolicy() {
    GridCell gbc = GridField.getConstraints(this);
    return gbc.getHeightPolicy();
  }
View Full Code Here

                comp.setForeground(this.fgColor);
            }
        }
        this.gbc.fill = ArrayFieldCellHelper.getGBCFill(comp);
        // TF:21/10/2008:Changed this to use grid cells to obey the width and height policies
        GridCell cell = new GridCell(this.gbc);
        if (comp instanceof JComponent) {
          GridCell oldCell = GridCell.get((JComponent)comp);
          cell.setWidthPolicy(oldCell.getWidthPolicy());
          cell.setHeightPolicy(oldCell.getHeightPolicy());
        }
        // this.panelWrapper.add(comp, this.gbc);
        this.panelWrapper.add(comp, cell);

      // CraigM:16/10/2008 - Check the array column is wide enough to fit us
View Full Code Here

        d.width = width + 1;
        d.height = (fm.getHeight() + fm.getDescent()) * Math.max(1, getLineCount());

        // Now apply the margins onto the size if needed
        Insets i = getInsets();
        GridCell cell = GridCell.get(this);
        switch (cell.getWidthPolicy()) {
            case Constants.SP_TO_PARENT:
                d.width += i.left + i.right;
                d.width = Math.max(d.width, getWidth());
                break;
            case Constants.SP_EXPLICIT:
                d.width = getWidth();
                break;
            case Constants.SP_NATURAL:
            case Constants.SP_TO_PARTNER:
            default:
                d.width += i.left + i.right;
                break;
        }
        switch (cell.getHeightPolicy()) {
            case Constants.SP_TO_PARENT:
                d.height += i.top + i.bottom;
                d.height = Math.max(d.height, getHeight());
                break;
            case Constants.SP_EXPLICIT:
                d.height = getHeight();
                break;
            case Constants.SP_NATURAL:
            case Constants.SP_TO_PARTNER:
            default:
                d.height += i.top + i.bottom;
                break;
        }

        // Cater for a frame.  CraigM 03/01/2008.
        if (FrameWeight.get(this) > 0) {
          // TF:06/08/2008:If we're explicitly set then we don't adjust the size.
          int size = FrameWeight.get(this);
          if (cell.getWidthPolicy() != Constants.SP_EXPLICIT) {
            d.height += size;
          }
          if (cell.getHeightPolicy() != Constants.SP_EXPLICIT) {
            d.width += size;
          }
        }
        return d;
    }
View Full Code Here

    }

    public Component getTableCellRendererComponent(JTable table, Object data, boolean arg2, boolean arg3, int arg4, int arg5) {
        if ((data != null)&&(data instanceof ImageData)) {
            // TF:08/03/2009:Added the following code to make the renderer clone all the properties properly.
            GridCell origCell = GridCell.get(originalPic);
            GridCell clonedCell = GridCell.get(clonedPic);
            clonedCell.setBottomMargin(origCell.getBottomMargin());
            clonedCell.setTopMargin(origCell.getTopMargin());
            clonedCell.setLeftMargin(origCell.getLeftMargin());
            clonedCell.setRightMargin(origCell.getRightMargin());
            clonedCell.setCellGravity(origCell.getCellGravity());
            clonedCell.setHeightPolicy(origCell.getHeightPolicy());
            clonedCell.setWidthPolicy(origCell.getWidthPolicy());

//            clonedPic.setSize(originalPic.getSize());
//          clonedPic.setMinimumSize(originalPic.getMinimumSize());
//          clonedPic.setPreferredSize(originalPic.getPreferredSize());
//          clonedPic.setFrameColor(originalPic.getFrameColor());
View Full Code Here

                stdProperties.add(new TableData("  minimumSize", c.isMinimumSizeSet() ? showDimension(c.getMinimumSize()): "<html><i>Not set</i></html>"));
                stdProperties.add(new TableData("  maximumSize", c.isMaximumSizeSet() ? showDimension(c.getMaximumSize()): "<html><i>Not set</i></html>"));
                stdProperties.add(new TableData("  preferredSize", c.isPreferredSizeSet() ? showDimension(c.getPreferredSize()): "<html><i>Not set</i></html>"));
                if (c instanceof JComponent) {
                    JComponent comp = (JComponent)c;
                    GridCell cell = GridCell.get(comp);
                    stdProperties.add(new TableData("<html><b>Layout Info</b></html>", ""));
                    stdProperties.add(new TableData("  cell", "[row="+ cell.getRow()+",column="+cell.getColumn()+"]"));
                    stdProperties.add(new TableData("  widthPolicy", cell.sizePolicyToString(cell.getWidthPolicy())));
                    if (cell.getWidthPolicy() == Constants.SP_TO_PARTNER) {
                      JComponent comp1 = LayoutManagerHelper.getWidthPartner(comp);
                      for (int i = 1; comp1 != null && comp1 != comp; i++) {
                            stdProperties.add(new TableData("      ["+i+"]", "  " + comp1.toString()));
                            comp1 = LayoutManagerHelper.getWidthPartner(comp1);
                      }
                    }
                    else if (cell.getWidthPolicy() == Constants.SP_TO_MATRIX_PARTNER && comp instanceof GridField) {
                      GridField partner = ((GridField)comp).getWidthMatrixPartner();
                      for (int i = 1; partner != null && partner != comp; i++) {
                            stdProperties.add(new TableData("      ["+i+"]", "  " + partner.toString()));
                            partner = partner.getWidthMatrixPartner();
                      }
                    }
                    stdProperties.add(new TableData("  heightPolicy", cell.sizePolicyToString(cell.getHeightPolicy())));
                    if (cell.getHeightPolicy() == Constants.SP_TO_PARTNER) {
                      JComponent comp1 = LayoutManagerHelper.getHeightPartner(comp);
                      for (int i = 1; comp1 != null && comp1 != comp; i++) {
                            stdProperties.add(new TableData("      ["+i+"]", "  " + comp1.toString()));
                            comp1 = LayoutManagerHelper.getHeightPartner(comp1);
                      }
                    }
                    else if (cell.getHeightPolicy() == Constants.SP_TO_MATRIX_PARTNER && comp instanceof GridField) {
                      GridField partner = ((GridField)comp).getHeightMatrixPartner();
                      for (int i = 1; partner != null && partner != comp; i++) {
                            stdProperties.add(new TableData("      ["+i+"]", "  " + partner.toString()));
                            partner = partner.getHeightMatrixPartner();
                      }
                    }
                    stdProperties.add(new TableData("  gravity", cell.gravityAsString()));
                    stdProperties.add(new TableData("  margins", "[t="+cell.getTopMargin()+
                                                                ",l="+cell.getLeftMargin()+
                                                                ",b="+cell.getBottomMargin()+
                                                                ",r="+cell.getRightMargin()+"]"))
                    if (comp.getParent() instanceof GridField) {
                        GridField gf = (GridField)comp.getParent();
                        stdProperties.add(new TableData("  rowWeight", ""+gf.getRowJustifyWeight(cell.getRow())));
                        stdProperties.add(new TableData("  columnWeight", ""+gf.getColumnJustifyWeight(cell.getColumn())));
                    }
                    if (comp instanceof GridField) {
                        StringBuilder buffer = new StringBuilder(50);
                        GridField gf = (GridField)comp;
                        int[] rowWeights = gf.getRowJustifyWeight();
View Full Code Here

            // CraigM:16/10/2008 - Size ourselves to our parent (the array column) so the component will be centered
            this.setHeightPolicy(Constants.SP_TO_PARENT);
            this.setWidthPolicy(Constants.SP_TO_PARENT);
            // TF:21/10/2008:Changed this to use grid cells to obey the width and height policies
            GridCell cell = new GridCell(gbc);
            if (comp instanceof JComponent) {
              GridCell oldCell = GridCell.get((JComponent)comp);
              cell.setWidthPolicy(oldCell.getWidthPolicy());
              cell.setHeightPolicy(oldCell.getHeightPolicy());
            }
            // this.add(comp, gbc);
            this.add(comp, cell);
        }
View Full Code Here

TOP

Related Classes of DisplayProject.GridCell

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.