/** * Sets if the content should be stretched vertically to fill all available verticalAlignment * space (minus the top and bottom insets). * * @param verticalStretch new verticalAlignment stretch value */ public void setFillVertical(boolean verticalStretch) { boolean old = this.isFillVertical(); this.fillVertical = verticalStretch; setDirty(true); firePropertyChange("fillVertical", old, isFillVertical()); }
/** * Sets if the content should be stretched vertically to fill all available verticalAlignment * space (minus the top and bottom insets). * * @param verticalStretch new verticalAlignment stretch value */ public void setFillVertical(boolean verticalStretch) { boolean old = this.isFillVertical(); this.fillVertical = verticalStretch; setDirty(true); firePropertyChange("fillVertical", old, isFillVertical()); }
/** * Sets if the content should be stretched vertically to fill all available verticalAlignment * space (minus the top and bottom insets). * * @param verticalStretch new verticalAlignment stretch value */ public void setFillVertical(boolean verticalStretch) { boolean old = this.isFillVertical(); this.fillVertical = verticalStretch; setDirty(true); firePropertyChange("fillVertical", old, isFillVertical()); }
/** * Sets if the content should be stretched vertically to fill all available verticalAlignment * space (minus the top and bottom insets). * * @param verticalStretch new verticalAlignment stretch value */ public void setFillVertical(boolean verticalStretch) { boolean old = this.isFillVertical(); this.fillVertical = verticalStretch; setDirty(true); firePropertyChange("fillVertical", old, isFillVertical()); }
/** * Sets if the content should be stretched vertically to fill all available verticalAlignment * space (minus the top and bottom insets). * * * @param verticalStretch new verticalAlignment stretch value */ public void setFillVertical(boolean verticalStretch) { boolean old = this.isFillVertical(); this.fillVertical = verticalStretch; setDirty(true); firePropertyChange("verticalStretch",old,this.fillVertical); }
/** * A protected method used by subclasses to calculate the final position of the * content. This will position the content using the fillHorizontal, fillVertical * horizontalAlignment, and verticalAlignment properties. This method * is typically called by subclasses in their doPaint() methods. * * @param contentWidth The width of the content to be painted * @param contentHeight The height of the content to be painted * @param width the width of the area that the content will be positioned in * @param height the height of the area that the content will be positioned in * @return the rectangle for the content to be painted in */ protected Rectangle calculateLayout(final int contentWidth, final int contentHeight, final int width, final int height) { Rectangle rect = new Rectangle(); rect.width = contentWidth; rect.height = contentHeight; if (isFillHorizontal()) { rect.width = width - insets.left - insets.right; } if (isFillVertical()) { rect.height = height - insets.top - insets.bottom; } rect.x = calculateX(rect.width, width); rect.y = calculateY(rect.height, height); return rect; }
/** * A protected method used by subclasses to calculate the final position of the * content. This will position the content using the fillHorizontal, fillVertical * horizontalAlignment, and verticalAlignment properties. This method * is typically called by subclasses in their doPaint() methods. * * @param contentWidth The width of the content to be painted * @param contentHeight The height of the content to be painted * @param width the width of the area that the content will be positioned in * @param height the height of the area that the content will be positioned in * @return the rectangle for the content to be painted in */ protected final Rectangle calculateLayout(final int contentWidth, final int contentHeight, final int width, final int height) { Rectangle rect = new Rectangle(); rect.width = contentWidth; rect.height = contentHeight; if(isFillHorizontal()) { rect.width = width - insets.left - insets.right; } if(isFillVertical()) { rect.height = height - insets.top - insets.bottom; } rect.x = calculateX(rect.width, width); rect.y = calculateY(rect.height, height); return rect; }
/** * A protected method used by subclasses to calculate the final position of the * content. This will position the content using the fillHorizontal, fillVertical * horizontalAlignment, and verticalAlignment properties. This method * is typically called by subclasses in their doPaint() methods. * * @param contentWidth The width of the content to be painted * @param contentHeight The height of the content to be painted * @param width the width of the area that the content will be positioned in * @param height the height of the area that the content will be positioned in * @return the rectangle for the content to be painted in */ protected final Rectangle calculateLayout(final int contentWidth, final int contentHeight, final int width, final int height) { Rectangle rect = new Rectangle(); rect.width = contentWidth; rect.height = contentHeight; if(isFillHorizontal()) { rect.width = width - insets.left - insets.right; } if(isFillVertical()) { rect.height = height - insets.top - insets.bottom; } rect.x = calculateX(rect.width, width); rect.y = calculateY(rect.height, height); return rect; }
/** * A protected method used by subclasses to calculate the final position of the * content. This will position the content using the fillHorizontal, fillVertical * horizontalAlignment, and verticalAlignment properties. This method * is typically called by subclasses in their doPaint() methods. * * @param contentWidth The width of the content to be painted * @param contentHeight The height of the content to be painted * @param width the width of the area that the content will be positioned in * @param height the height of the area that the content will be positioned in * @return the rectangle for the content to be painted in */ protected final Rectangle calculateLayout(final int contentWidth, final int contentHeight, final int width, final int height) { Rectangle rect = new Rectangle(); rect.width = contentWidth; rect.height = contentHeight; if(isFillHorizontal()) { rect.width = width - insets.left - insets.right; } if(isFillVertical()) { rect.height = height - insets.top - insets.bottom; } rect.x = calculateX(rect.width, width); rect.y = calculateY(rect.height, height); return rect; }
/** * A protected method used by subclasses to calculate the final position of the * content. This will position the content using the fillHorizontal, fillVertical * horizontalAlignment, and verticalAlignment properties. This method * is typically called by subclasses in their doPaint() methods. * * @param contentWidth The width of the content to be painted * @param contentHeight The height of the content to be painted * @param width the width of the area that the content will be positioned in * @param height the height of the area that the content will be positioned in * @return the rectangle for the content to be painted in */ protected final Rectangle calculateLayout(final int contentWidth, final int contentHeight, final int width, final int height) { Rectangle rect = new Rectangle(); rect.width = contentWidth; rect.height = contentHeight; if(isFillHorizontal()) { rect.width = width - insets.left - insets.right; } if(isFillVertical()) { rect.height = height - insets.top - insets.bottom; } rect.x = calculateX(rect.width, width); rect.y = calculateY(rect.height, height); return rect; }
@Test @Override public void testDefaults() { super.testDefaults(); AbstractLayoutPainter alp = (AbstractLayoutPainter) p; assertThat(alp.getHorizontalAlignment(), is(AbstractLayoutPainter.HorizontalAlignment.CENTER)); assertThat(alp.getInsets(), is(new Insets(0, 0, 0, 0))); assertThat(alp.getVerticalAlignment(), is(AbstractLayoutPainter.VerticalAlignment.CENTER)); assertThat(alp.isFillHorizontal(), is(false)); assertThat(alp.isFillVertical(), is(false)); } }
assertThat(alp.getVerticalAlignment(), is(AbstractLayoutPainter.VerticalAlignment.CENTER)); assertThat(alp.isFillHorizontal(), is(true)); assertThat(alp.isFillVertical(), is(true));
assertThat(alp.getVerticalAlignment(), is(AbstractLayoutPainter.VerticalAlignment.CENTER)); assertThat(alp.isFillHorizontal(), is(false)); assertThat(alp.isFillVertical(), is(false));