import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo;
/**
* <p>
* @VERSION@
* @since 3.0
*/
-public class GridLayout extends AbstractLayout {
+public class GridLayout extends AbstractLayout implements
+ Layout.AlignmentHandler, Layout.SpacingHandler {
/**
* Initial grid columns.
*/
private Map componentToAlignment = new HashMap();
- /**
- * Contained component should be aligned horizontally to the left.
- */
- public static final int ALIGNMENT_LEFT = AlignmentInfo.ALIGNMENT_LEFT;
-
- /**
- * Contained component should be aligned horizontally to the right.
- */
- public static final int ALIGNMENT_RIGHT = AlignmentInfo.ALIGNMENT_RIGHT;
-
- /**
- * Contained component should be aligned vertically to the top.
- */
- public static final int ALIGNMENT_TOP = AlignmentInfo.ALIGNMENT_TOP;
-
- /**
- * Contained component should be aligned vertically to the bottom.
- */
- public static final int ALIGNMENT_BOTTOM = AlignmentInfo.ALIGNMENT_BOTTOM;
-
- /**
- * Contained component should be horizontally aligned to center.
- */
- public static final int ALIGNMENT_HORIZONTAL_CENTER = AlignmentInfo.ALIGNMENT_HORIZONTAL_CENTER;
-
- /**
- * Contained component should be vertically aligned to center.
- */
- public static final int ALIGNMENT_VERTICAL_CENTER = AlignmentInfo.ALIGNMENT_VERTICAL_CENTER;
-
- private static final int ALIGNMENT_DEFAULT = ALIGNMENT_TOP + ALIGNMENT_LEFT;
-
/**
* Is spacing between contained components enabled. Defaults to false.
*/
private boolean spacing = false;
+ private static final int ALIGNMENT_DEFAULT = ALIGNMENT_TOP + ALIGNMENT_LEFT;
+
/**
* Constructor for grid of given size (number of cells). Note that grid's
* final size depends on the items that are added into the grid. Grid grows
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.itmill.toolkit.ui.Layout.AlignmentHandler#getComponentAlignment(com.itmill.toolkit.ui.Component)
+ */
public int getComponentAlignment(Component childComponent) {
final Integer bitMask = (Integer) componentToAlignment
.get(childComponent);
cursorY = 0;
}
- /**
- * Set alignment for one contained component in this layout.
+ /*
+ * (non-Javadoc)
*
- * @param childComponent
- * the component to align within it's layout cell.
- * @param horizontalAlignment
- * the horizontal alignment for the child component (left,
- * center, right).
- * @param verticalAlignment
- * the vertical alignment for the child component (top,
- * center, bottom).
+ * @see com.itmill.toolkit.ui.Layout.AlignmentHandler#setComponentAlignment(com.itmill.toolkit.ui.Component,
+ * int, int)
*/
public void setComponentAlignment(Component childComponent,
int horizontalAlignment, int verticalAlignment) {
horizontalAlignment + verticalAlignment));
}
- /**
- * Enable spacing between child components within this layout.
- *
- * <p>
- * <strong>NOTE:</strong> This will only affect spaces between components,
- * not also all around spacing of the layout (i.e. do not mix this with HTML
- * Table elements cellspacing-attribute). Use {@link #setMargin(boolean)} to
- * add extra space around the layout.
- * </p>
+ /*
+ * (non-Javadoc)
*
- * @param enabled
+ * @see com.itmill.toolkit.ui.Layout.SpacingHandler#setSpacing(boolean)
*/
public void setSpacing(boolean enabled) {
spacing = enabled;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.itmill.toolkit.ui.Layout.SpacingHandler#isSpacingEnabled()
+ */
+ public boolean isSpacingEnabled() {
+ return spacing;
+ }
+
}
package com.itmill.toolkit.ui;
+import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo;
/**
* Extension to the {@link ComponentContainer} interface which adds the
public void setMargin(boolean top, boolean right, boolean bottom,
boolean left);
+ /**
+ * TODO make javadocs, remove from implementing classes
+ */
+ public interface AlignmentHandler extends Layout {
+
+ /**
+ * Contained component should be aligned horizontally to the left.
+ */
+ public static final int ALIGNMENT_LEFT = AlignmentInfo.ALIGNMENT_LEFT;
+
+ /**
+ * Contained component should be aligned horizontally to the right.
+ */
+ public static final int ALIGNMENT_RIGHT = AlignmentInfo.ALIGNMENT_RIGHT;
+
+ /**
+ * Contained component should be aligned vertically to the top.
+ */
+ public static final int ALIGNMENT_TOP = AlignmentInfo.ALIGNMENT_TOP;
+
+ /**
+ * Contained component should be aligned vertically to the bottom.
+ */
+ public static final int ALIGNMENT_BOTTOM = AlignmentInfo.ALIGNMENT_BOTTOM;
+
+ /**
+ * Contained component should be horizontally aligned to center.
+ */
+ public static final int ALIGNMENT_HORIZONTAL_CENTER = AlignmentInfo.ALIGNMENT_HORIZONTAL_CENTER;
+
+ /**
+ * Contained component should be vertically aligned to center.
+ */
+ public static final int ALIGNMENT_VERTICAL_CENTER = AlignmentInfo.ALIGNMENT_VERTICAL_CENTER;
+
+ /**
+ * Set alignment for one contained component in this layout. Alignment
+ * is calculated as a bit mask of the two passed values.
+ *
+ * @param childComponent
+ * the component to align within it's layout cell.
+ * @param horizontalAlignment
+ * the horizontal alignment for the child component
+ * (left, center, right). Use ALIGNMENT constants.
+ * @param verticalAlignment
+ * the vertical alignment for the child component (top,
+ * center, bottom). Use ALIGNMENT constants.
+ */
+ public void setComponentAlignment(Component childComponent,
+ int horizontalAlignment, int verticalAlignment);
+
+ /**
+ *
+ * @param childComponent
+ * @return
+ */
+ public int getComponentAlignment(Component childComponent);
+
+ }
+
+ /**
+ * This type of layout can set spacing between its components on of off.
+ *
+ * TODO refine javadocs
+ */
+ public interface SpacingHandler extends Layout {
+ /**
+ * Enable spacing between child components within this layout.
+ *
+ * <p>
+ * <strong>NOTE:</strong> This will only affect spaces between
+ * components, not also all around spacing of the layout (i.e. do not
+ * mix this with HTML Table elements cellspacing-attribute). Use
+ * {@link #setMargin(boolean)} to add extra space around the layout.
+ * </p>
+ *
+ * @param enabled
+ */
+ public void setSpacing(boolean enabled);
+
+ /**
+ *
+ * @return true if spacing, layout leaves space between components
+ */
+ public boolean isSpacingEnabled();
+ }
+
}
import com.itmill.toolkit.terminal.PaintException;
import com.itmill.toolkit.terminal.PaintTarget;
-import com.itmill.toolkit.terminal.gwt.client.ui.AlignmentInfo;
/**
* Ordered layout.
* @VERSION@
* @since 3.0
*/
-public class OrderedLayout extends AbstractLayout {
+public class OrderedLayout extends AbstractLayout implements
+ Layout.AlignmentHandler, Layout.SpacingHandler {
/* Predefined orientations ***************************************** */
*/
public static int ORIENTATION_HORIZONTAL = 1;
+ private static final int ALIGNMENT_DEFAULT = ALIGNMENT_TOP + ALIGNMENT_LEFT;
+
/**
* Custom layout slots containing the components.
*/
*/
private final Map componentToAlignment = new HashMap();
- /**
- * Contained component should be aligned horizontally to the left.
- */
- public static final int ALIGNMENT_LEFT = AlignmentInfo.ALIGNMENT_LEFT;
-
- /**
- * Contained component should be aligned horizontally to the right.
- */
- public static final int ALIGNMENT_RIGHT = AlignmentInfo.ALIGNMENT_RIGHT;
-
- /**
- * Contained component should be aligned vertically to the top.
- */
- public static final int ALIGNMENT_TOP = AlignmentInfo.ALIGNMENT_TOP;
-
- /**
- * Contained component should be aligned vertically to the bottom.
- */
- public static final int ALIGNMENT_BOTTOM = AlignmentInfo.ALIGNMENT_BOTTOM;
-
- /**
- * Contained component should be horizontally aligned to center.
- */
- public static final int ALIGNMENT_HORIZONTAL_CENTER = AlignmentInfo.ALIGNMENT_HORIZONTAL_CENTER;
-
- /**
- * Contained component should be vertically aligned to center.
- */
- public static final int ALIGNMENT_VERTICAL_CENTER = AlignmentInfo.ALIGNMENT_VERTICAL_CENTER;
-
- private static final int ALIGNMENT_DEFAULT = ALIGNMENT_TOP + ALIGNMENT_LEFT;
-
/**
* Orientation of the layout.
*/
}
}
- /**
- * Set alignment for one contained component in this layout. Alignment is
- * calculated as a bit mask of the two passed values.
+ /*
+ * (non-Javadoc)
*
- * @param childComponent
- * the component to align within it's layout cell.
- * @param horizontalAlignment
- * the horizontal alignment for the child component (left,
- * center, right).
- * @param verticalAlignment
- * the vertical alignment for the child component (top,
- * center, bottom).
+ * @see com.itmill.toolkit.ui.Layout.AlignmentHandler#setComponentAlignment(com.itmill.toolkit.ui.Component,
+ * int, int)
*/
public void setComponentAlignment(Component childComponent,
int horizontalAlignment, int verticalAlignment) {
requestRepaint();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.itmill.toolkit.ui.Layout.AlignmentHandler#getComponentAlignment(com.itmill.toolkit.ui.Component)
+ */
public int getComponentAlignment(Component childComponent) {
final Integer bitMask = (Integer) componentToAlignment
.get(childComponent);
}
}
- /**
- * Enable spacing between child components within this layout.
- *
- * <p>
- * <strong>NOTE:</strong> This will only affect spaces between components,
- * not also all around spacing of the layout (i.e. do not mix this with HTML
- * Table elements cellspacing-attribute). Use {@link #setMargin(boolean)} to
- * add extra space around the layout.
- * </p>
+ /*
+ * (non-Javadoc)
*
- * @param enabled
+ * @see com.itmill.toolkit.ui.Layout.SpacingHandler#setSpacing(boolean)
*/
public void setSpacing(boolean enabled) {
spacing = enabled;
requestRepaint();
}
- /**
+ /*
+ * (non-Javadoc)
*
- * @return true if spacing, layout leaves space between components
+ * @see com.itmill.toolkit.ui.Layout.SpacingHandler#isSpacingEnabled()
*/
public boolean isSpacingEnabled() {
return spacing;