Package net.helipilot50.stocktrade.displayproject.controls

Examples of net.helipilot50.stocktrade.displayproject.controls.Panel


   *            the <code>Panel</code> and its border relative to its parent
   *            widget. Y is measured in mils from top to bottom.
   * @return The created <code>Panel</code>
   */
  public static Panel newPanel(int frameWeight, Container parent, int x, int y) {
    Panel jp = newPanel((String) null);
    FrameWeight.set(jp, frameWeight);
    Parent.set(jp, parent);
    jp.setLocation(UIutils.milsToPixels(x), UIutils.milsToPixels(y));
    jp.setBackground(null);
    return jp;
  }
View Full Code Here


   * @param widthPolicy
   *       The width policy of the panel. This should be one of the SP_ constants
   * @return The created <code>Panel</code>
   */
  public static Panel newPanel(String caption, int heightPolicy, String name, int widthPolicy) {
    Panel panel = newPanel(name);
    HeightPolicy.set(panel, heightPolicy);
    WidthPolicy.set(panel, widthPolicy);
    Caption.set(panel, caption);
    return panel;
  }
View Full Code Here

   * @param widthPolicy
   *       The width policy of the panel. This should be one of the SP_ constants
   * @return The created <code>Panel</code>
   */
  public static Panel newPanel(TextData caption, int heightPolicy, String name, int widthPolicy) {
    Panel panel = newPanel(name);
    HeightPolicy.set(panel, heightPolicy);
    WidthPolicy.set(panel, widthPolicy);
    Caption.set(panel, caption);
    return panel;
  }
View Full Code Here

   * @param widthPolicy
   *       The width policy of the panel. This should be one of the SP_ constants
   * @return The created <code>Panel</code>
   */
  public static Panel newPanel(String caption, int heightPolicy, TextData name, int widthPolicy) {
    Panel panel = newPanel(name);
    HeightPolicy.set(panel, heightPolicy);
    WidthPolicy.set(panel, widthPolicy);
    Caption.set(panel, caption);
    return panel;
  }
View Full Code Here

   * @param widthPolicy
   *       The width policy of the panel. This should be one of the SP_ constants
   * @return The created <code>Panel</code>
   */
  public static Panel newPanel(TextData caption, int heightPolicy, TextData name, int widthPolicy) {
    Panel panel = newPanel(name);
    HeightPolicy.set(panel, heightPolicy);
    WidthPolicy.set(panel, widthPolicy);
    Caption.set(panel, caption);
    return panel;
  }
View Full Code Here

   * @param name
   *            Name of the Panel
   * @return The created <code>Panel</code>
   */
  public static Panel newPanel(String name) {
    Panel panel = new Panel();
    int size = UIutils.milsToPixels(5000);
    panel.setSize(size, size);
    // panel.setMinimumSize(panel.getSize());
    panel.setName(name);
    panel.setFocusable(false);
    panel.setOpaque(true);
    panel.setLayout(new PanelLayoutManager());
    panel.setBackground(null);
    return panel;
  }
View Full Code Here

   *            The margin parameter (int) defines a margin, in mils, between
   *            a panel�s boundaries and its child widgets as a group.
   * @return The created <code>Panel</code>
   */
  public static Panel newPanel(String name, int margin) {
    Panel gf = newPanel(name);
    int gap = UIutils.milsToPixels(margin);
    gf.getInsets().left = gap;
    gf.getInsets().right = gap;
    gf.getInsets().top = gap;
    gf.getInsets().bottom = gap;
    gf.setBackground(null);
    return gf;
  }
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

     * @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

TOP

Related Classes of net.helipilot50.stocktrade.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.