Back to index

moin  1.9.0~rc2
Public Member Functions | Private Attributes
CH.ifa.draw.util.PaletteLayout Class Reference

A custom layout manager for the palette. More...

Collaboration diagram for CH.ifa.draw.util.PaletteLayout:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PaletteLayout (int gap)
 Initializes the palette layout.
 PaletteLayout (int gap, Point border)
 PaletteLayout (int gap, Point border, boolean vertical)
void addLayoutComponent (String name, Component comp)
void removeLayoutComponent (Component comp)
Dimension preferredLayoutSize (Container target)
Dimension minimumLayoutSize (Container target)
void layoutContainer (Container target)

Private Attributes

int fGap
Point fBorder
boolean fVerticalLayout

Detailed Description

A custom layout manager for the palette.

See also:
PaletteButton

Definition at line 15 of file PaletteLayout.java.


Constructor & Destructor Documentation

Initializes the palette layout.

Parameters:
gapthe gap between palette entries.

Definition at line 26 of file PaletteLayout.java.

                                  {
        this(gap, new Point(0,0), true);
    }
CH.ifa.draw.util.PaletteLayout.PaletteLayout ( int  gap,
Point  border 
) [inline]

Definition at line 30 of file PaletteLayout.java.

                                                {
        this(gap, border, true);
    }
CH.ifa.draw.util.PaletteLayout.PaletteLayout ( int  gap,
Point  border,
boolean  vertical 
) [inline]

Definition at line 34 of file PaletteLayout.java.

                                                                  {
        fGap = gap;
        fBorder = border;
        fVerticalLayout = vertical;
    }

Member Function Documentation

void CH.ifa.draw.util.PaletteLayout.addLayoutComponent ( String  name,
Component  comp 
) [inline]

Definition at line 40 of file PaletteLayout.java.

                                                                {
    }
void CH.ifa.draw.util.PaletteLayout.layoutContainer ( Container  target) [inline]

Definition at line 80 of file PaletteLayout.java.

                                                  {
           Insets insets = target.getInsets();
           int nmembers = target.getComponentCount();
           int x = insets.left + fBorder.x;
           int y = insets.top + fBorder.y;

           for (int i = 0 ; i < nmembers ; i++) {
               Component m = target.getComponent(i);
               if (m.isVisible()) {
                      Dimension d = m.getMinimumSize();
                      m.setBounds(x, y, d.width, d.height);
                      if (fVerticalLayout) {
                          y += d.height;
                          y += fGap;
                      } else {
                          x += d.width;
                          x += fGap;
                      }
                  }
           }
    }
Dimension CH.ifa.draw.util.PaletteLayout.minimumLayoutSize ( Container  target) [inline]

Definition at line 50 of file PaletteLayout.java.

                                                         {
           Dimension dim = new Dimension(0, 0);
           int nmembers = target.getComponentCount();

           for (int i = 0 ; i < nmembers ; i++) {
               Component m = target.getComponent(i);
               if (m.isVisible()) {
                      Dimension d = m.getMinimumSize();
                      if (fVerticalLayout) {
                          dim.width = Math.max(dim.width, d.width);
                          if (i > 0)
                              dim.height += fGap;
                          dim.height += d.height;
                      } else {
                          dim.height = Math.max(dim.height, d.height);
                          if (i > 0)
                              dim.width += fGap;
                          dim.width += d.width;
                   }
               }
           }

           Insets insets = target.getInsets();
           dim.width += insets.left + insets.right;
           dim.width += 2 * fBorder.x;
           dim.height += insets.top + insets.bottom;
           dim.height += 2 * fBorder.y;
           return dim;
    }

Here is the caller graph for this function:

Dimension CH.ifa.draw.util.PaletteLayout.preferredLayoutSize ( Container  target) [inline]

Definition at line 46 of file PaletteLayout.java.

                                                           {
        return minimumLayoutSize(target);
    }

Here is the call graph for this function:

void CH.ifa.draw.util.PaletteLayout.removeLayoutComponent ( Component  comp) [inline]

Definition at line 43 of file PaletteLayout.java.

                                                      {
    }

Member Data Documentation

Definition at line 19 of file PaletteLayout.java.

Definition at line 18 of file PaletteLayout.java.

Definition at line 20 of file PaletteLayout.java.


The documentation for this class was generated from the following file: