Package DisplayProject.controls

Examples of DisplayProject.controls.Panel


     * @return
     */
    private int virtualToRealX(Component comp) {
      Container container = comp.getParent();
      if (container instanceof Panel && comp instanceof JComponent) {
        Panel panel = (Panel)container;
        Insets insets = panel.getInsets();
        Integer virtualXObj = (Integer)((JComponent)comp).getClientProperty("virtualX");
        if (virtualXObj != null) {
          int virtualX = virtualXObj.intValue() + insets.left + panel.getMargin();
          return virtualX;
        }
      }
    return comp.getX();
    }
View Full Code Here


     * @return
     */
    private int virtualToRealY(Component comp) {
      Container container = comp.getParent();
      if (container instanceof Panel && comp instanceof JComponent) {
        Panel panel = (Panel)container;
        Insets insets = panel.getInsets();
        Integer virtualYObj = (Integer)((JComponent)comp).getClientProperty("virtualY");
        if (virtualYObj != null) {
          int virtualY = virtualYObj.intValue() + insets.top + panel.getMargin();
          return virtualY;
        }
      }
    return comp.getY();
    }
View Full Code Here

     * @return
     */
    private int realToVirtualX(JComponent comp) {
      Container container = comp.getParent();
      if (container instanceof Panel) {
        Panel panel = (Panel)container;
        Insets insets = panel.getInsets();
        return comp.getX() - insets.left - panel.getMargin();
      }
    return comp.getX();
    }
View Full Code Here

     * @return
     */
    private int realToVirtualY(JComponent comp) {
      Container container = comp.getParent();
      if (container instanceof Panel) {
        Panel panel = (Panel)container;
        Insets insets = panel.getInsets();
        return comp.getY() - insets.top - panel.getMargin();
      }
    return comp.getY();
    }
View Full Code Here

     */
    private int getCaptionWidth(Container parent) {
        // calculate caption width if one exists
        int captionWidth = 0;
        if (parent instanceof Panel){
            Panel parentPanel = (Panel)parent;
            TextData tdCaption = parentPanel.getCaption();
            String caption = (tdCaption == null) ? "": tdCaption.toString();
            if ("".equals(caption)) {
                captionWidth = 0;
            }
            else {
                Font font = null;
                if (parentPanel.getCaptionFont() != null)
                    font = parentPanel.getCaptionFont();
                else
                    font = parentPanel.getFont();
                FontMetrics fm = parentPanel.getFontMetrics(font);
                // TF:21/8/07:Set the caption to be a little bigger to allow some dashes on the side.
                captionWidth = SwingUtilities.computeStringWidth(fm, caption) + 10;
            }
        }
        return captionWidth;
View Full Code Here

                naturalWidth = maxMinimumX - minX /*+ 1*/;
            }
            naturalWidth += borderInsets.left + borderInsets.right;
            // Add the border margins and panel margin twice (for both left and right margins)
            if (pParent instanceof Panel) {
                Panel aPanel = (Panel)pParent;
                naturalWidth += 2*aPanel.getMargin();

                // TF:02/03/2010:Compensate the locations by the difference between the real locations and the virtual locations
                //naturalWidth += actualLoc.x - virtualLoc.x;
            }
        }

        switch (widthPolicy) {
        case Constants.SP_NATURAL:
            minWidth = width = naturalWidth;
            break;

        case Constants.SP_TO_PARENT:
            // To parent size: our minimum is our border insets, but we can go up to the parent size
          // TF:26/07/2009:The minimum size of the panel is larger of the natural width and the borders
          // This condition about the tab panel is an issue for DET-103, but may just be eratic behaviour in Forte
            width = borderInsets.left + borderInsets.right;
            if (width < naturalWidth && !isMinSizeEnforced) {
              // TF:14/08/2009:This isn't correct in most cases, removed this change.
              //width = naturalWidth;
            }
            minWidth = width;
            if (width < pParent.getWidth()) {
                width = pParent.getWidth();
            }
            break;

        case Constants.SP_FORM:
            // We form a border around the panel the size of the minX component
            width = 2* minX + (maxCurrentX - minX);
            width += borderInsets.left + borderInsets.right;
            minWidth = width;
            if (width < pParent.getWidth()) {
                width = pParent.getWidth();
            }
            break;
           
        case Constants.SP_TO_PARTNER:
          // Our size is the size of the largest minimum size of us or our partners
            JComponent partner = LayoutManagerHelper.getWidthPartner((JComponent)pParent);
            width = minWidth = naturalWidth;
            while (partner != null && partner != pParent && partner.isVisible()) {
              // Need to perform this check to prevent infinite recursion
              if (partner.isMinimumSizeSet()) {
                  Dimension d = LayoutManagerHelper.getMinimumSizeWithoutPartners(partner);
                  if (d.width >width) {
                      width = d.width;
                  }
              }
                partner = LayoutManagerHelper.getWidthPartner(partner);
            }
          break;

        default:
            // We're using explicit, our size cannot change
            width = pParent.getWidth();
            minWidth = width;
        }
       
        // TF:29/04/2008:If we're a folder in a tab pane, we can leave our width wider than
        // normal, if it's already there. Otherwise, a grid which is sized to parent in a panel
        // which has natural size inside a tab folder will be the wrong size (too small)
        if (pParent.getParent() instanceof JTabbedPane) {
          if (pParent.getWidth() > width) {
            width = pParent.getWidth();
          }
        }
       
        // Width can also never shrink smaller than the title width
        int titleWidth = getCaptionWidth(pParent);
        // TF:2/10/07: Added a margin to make the titles look like forte
        if (minWidth < titleWidth + 8) {
            minWidth = titleWidth + 8;
        }
        if (isMinSizeEnforced) {
            // Tab folders have a size of the natural size + the offset of the child
            if (pParent.getParent() instanceof JTabbedPane) {
                naturalWidth += minX;
            }
            if (minWidth < naturalWidth) {
                minWidth = naturalWidth;
            }
        }
        // We can never shrink smaller than the min size
        if (pParent instanceof Panel) {
            int aMinWidth = ((Panel)pParent).getMinWidth();
            if (aMinWidth > width) {
                width = ((Panel)pParent).getMinWidth();
            }
            // TF:18/9/07:Separated this logic out as the width is not always the same as the minWidth
            if (aMinWidth > minWidth) {
                minWidth = aMinWidth;
            }
        }
        // Enforce the minimum width
        if (width < minWidth) {
            width = minWidth;
        }

        // Now repeat with height
        // TF:26/07/2009:Added in Constants.SP_TO_PARENT
        if (heightPolicy == Constants.SP_NATURAL || heightPolicy == Constants.SP_TO_PARTNER || heightPolicy == Constants.SP_TO_PARENT || isMinSizeEnforced) {
            // Our size is the bounding box containing all the children plus the frame size if any plus margins.
            if ((ignoreInvisibleChildren && visibleChildren > 0) || (!ignoreInvisibleChildren && pParent.getComponentCount() > 0)) {
                naturalHeight = maxMinimumY - minY /* + 1 */;
            }
            naturalHeight += borderInsets.top + borderInsets.bottom;
            // Add the border margins and panel margin twice (for both left and right margins)
            if (pParent instanceof Panel) {
                Panel aPanel = (Panel)pParent;
                naturalHeight += 2*aPanel.getMargin();

                // TF:02/03/2010:Compensate the locations by the difference between the real locations and the virtual locations
//                naturalHeight += actualLoc.y - virtualLoc.y;
            }
        }
View Full Code Here

    //PM:13/6/08 changed to return type of Panel to unsure it is a compound field
    public static Panel getForm(JFrame win) {
                try {
                Expression expr = new Expression(win, "getForm", new Object[0]);
                    expr.execute();
                    Panel form = ((Panel)expr.getValue());
                    return form;
            } catch (Exception e) {
                return null;
            }
View Full Code Here

              else {
                ((JPopupMenu)comp).setPreferredSize(new Dimension(0, 0));
              }
            }
            else if (comp instanceof Panel){
              Panel jp = ((Panel) comp);
                /*
                 * if the JPanel was or is part of a JTabbedPane
                 */
             
              _log.debug("Panel "+ jp.getCaption() + " parent: " + ((parent == null) ? "null" : parent.getClass().getName()));
                if (parent instanceof TabFolder ) {
                  if (value) {
                    ((TabFolder)parent).showTab(jp); //PM:14/01/2009:moved functionality to TabFolder
                    _log.debug("Tab: "+jp.getCaption()+" is now visible");
                  } else {
                    ((TabFolder)parent).hideTab(jp);//PM:14/01/2009:moved functionality to TabFolder
                    _log.debug("Tab: "+jp.getCaption()+" is now hidden");
                  }
                } else {
                  comp.setVisible(value);
                }
            } else if (comp instanceof JPanel) {
View Full Code Here

     */
    private int getCaptionWidth(Container parent) {
        // calculate caption width if one exists
        int captionWidth = 0;
        if (parent instanceof Panel){
            Panel parentPanel = (Panel)parent;
            TextData tdCaption = parentPanel.getCaption();
            String caption = (tdCaption == null) ? "": tdCaption.toString();
            if ("".equals(caption)) {
                captionWidth = 0;
            }
            else {
                Font font = null;
                if (parentPanel.getCaptionFont() != null)
                    font = parentPanel.getCaptionFont();
                else
                    font = parentPanel.getFont();
                FontMetrics fm = parentPanel.getFontMetrics(font);
                // TF:21/8/07:Set the caption to be a little bigger to allow some dashes on the side.
                captionWidth = SwingUtilities.computeStringWidth(fm, caption) + 10;
            }
        }
        return captionWidth;
View Full Code Here

                naturalWidth = maxMinimumX - minX /*+ 1*/;
            }
            naturalWidth += borderInsets.left + borderInsets.right;
            // Add the border margins and panel margin twice (for both left and right margins)
            if (pParent instanceof Panel) {
                Panel aPanel = (Panel)pParent;
                naturalWidth += 2*aPanel.getMargin();

                // TF:02/03/2010:Compensate the locations by the difference between the real locations and the virtual locations
                //naturalWidth += actualLoc.x - virtualLoc.x;
            }
        }

        switch (widthPolicy) {
        case Constants.SP_NATURAL:
            minWidth = width = naturalWidth;
            break;

        case Constants.SP_TO_PARENT:
            // To parent size: our minimum is our border insets, but we can go up to the parent size
          // TF:26/07/2009:The minimum size of the panel is larger of the natural width and the borders
          // This condition about the tab panel is an issue for DET-103, but may just be eratic behaviour in Forte
            width = borderInsets.left + borderInsets.right;
            if (width < naturalWidth && !isMinSizeEnforced) {
              // TF:14/08/2009:This isn't correct in most cases, removed this change.
              //width = naturalWidth;
            }
            minWidth = width;
            if (width < pParent.getWidth()) {
                width = pParent.getWidth();
            }
            break;

        case Constants.SP_FORM:
            // We form a border around the panel the size of the minX component
            width = 2* minX + (maxCurrentX - minX);
            width += borderInsets.left + borderInsets.right;
            minWidth = width;
            if (width < pParent.getWidth()) {
                width = pParent.getWidth();
            }
            break;
           
        case Constants.SP_TO_PARTNER:
          // Our size is the size of the largest minimum size of us or our partners
            JComponent partner = LayoutManagerHelper.getWidthPartner((JComponent)pParent);
            width = minWidth = naturalWidth;
            while (partner != null && partner != pParent && partner.isVisible()) {
              // Need to perform this check to prevent infinite recursion
              if (partner.isMinimumSizeSet()) {
                  Dimension d = LayoutManagerHelper.getMinimumSizeWithoutPartners(partner);
                  if (d.width >width) {
                      width = d.width;
                  }
              }
                partner = LayoutManagerHelper.getWidthPartner(partner);
            }
          break;

        default:
            // We're using explicit, our size cannot change
            width = pParent.getWidth();
            minWidth = width;
        }
       
        // TF:29/04/2008:If we're a folder in a tab pane, we can leave our width wider than
        // normal, if it's already there. Otherwise, a grid which is sized to parent in a panel
        // which has natural size inside a tab folder will be the wrong size (too small)
        if (pParent.getParent() instanceof JTabbedPane) {
          if (pParent.getWidth() > width) {
            width = pParent.getWidth();
          }
        }
       
        // Width can also never shrink smaller than the title width
        int titleWidth = getCaptionWidth(pParent);
        // TF:2/10/07: Added a margin to make the titles look like forte
        if (minWidth < titleWidth + 8) {
            minWidth = titleWidth + 8;
        }
        if (isMinSizeEnforced) {
            // Tab folders have a size of the natural size + the offset of the child
            if (pParent.getParent() instanceof JTabbedPane) {
                naturalWidth += minX;
            }
            if (minWidth < naturalWidth) {
                minWidth = naturalWidth;
            }
        }
        // We can never shrink smaller than the min size
        if (pParent instanceof Panel) {
            int aMinWidth = ((Panel)pParent).getMinWidth();
            if (aMinWidth > width) {
                width = ((Panel)pParent).getMinWidth();
            }
            // TF:18/9/07:Separated this logic out as the width is not always the same as the minWidth
            if (aMinWidth > minWidth) {
                minWidth = aMinWidth;
            }
        }
        // Enforce the minimum width
        if (width < minWidth) {
            width = minWidth;
        }

        // Now repeat with height
        // TF:26/07/2009:Added in Constants.SP_TO_PARENT
        if (heightPolicy == Constants.SP_NATURAL || heightPolicy == Constants.SP_TO_PARTNER || heightPolicy == Constants.SP_TO_PARENT || isMinSizeEnforced) {
            // Our size is the bounding box containing all the children plus the frame size if any plus margins.
            if ((ignoreInvisibleChildren && visibleChildren > 0) || (!ignoreInvisibleChildren && pParent.getComponentCount() > 0)) {
                naturalHeight = maxMinimumY - minY /* + 1 */;
            }
            naturalHeight += borderInsets.top + borderInsets.bottom;
            // Add the border margins and panel margin twice (for both left and right margins)
            if (pParent instanceof Panel) {
                Panel aPanel = (Panel)pParent;
                naturalHeight += 2*aPanel.getMargin();

                // TF:02/03/2010:Compensate the locations by the difference between the real locations and the virtual locations
//                naturalHeight += actualLoc.y - virtualLoc.y;
            }
        }
View Full Code Here

TOP

Related Classes of DisplayProject.controls.Panel

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.