619N/A/*
2362N/A * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
619N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
619N/A *
619N/A * This code is free software; you can redistribute it and/or modify it
619N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
619N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
619N/A *
619N/A * This code is distributed in the hope that it will be useful, but WITHOUT
619N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
619N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
619N/A * version 2 for more details (a copy is included in the LICENSE file that
619N/A * accompanied this code).
619N/A *
619N/A * You should have received a copy of the GNU General Public License version
619N/A * 2 along with this work; if not, write to the Free Software Foundation,
619N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
619N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
619N/A */
619N/A
619N/Apackage sun.swing;
619N/A
619N/Aimport static sun.swing.SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET;
619N/A
619N/Aimport javax.swing.*;
619N/Aimport javax.swing.plaf.basic.BasicHTML;
619N/Aimport javax.swing.text.View;
619N/Aimport java.awt.*;
619N/Aimport java.awt.event.KeyEvent;
619N/Aimport java.util.Map;
619N/Aimport java.util.HashMap;
619N/A
619N/A/**
619N/A * Calculates preferred size and layouts menu items.
619N/A */
619N/Apublic class MenuItemLayoutHelper {
619N/A
619N/A /* Client Property keys for calculation of maximal widths */
619N/A public static final StringUIClientPropertyKey MAX_ARROW_WIDTH =
619N/A new StringUIClientPropertyKey("maxArrowWidth");
619N/A public static final StringUIClientPropertyKey MAX_CHECK_WIDTH =
619N/A new StringUIClientPropertyKey("maxCheckWidth");
619N/A public static final StringUIClientPropertyKey MAX_ICON_WIDTH =
619N/A new StringUIClientPropertyKey("maxIconWidth");
619N/A public static final StringUIClientPropertyKey MAX_TEXT_WIDTH =
619N/A new StringUIClientPropertyKey("maxTextWidth");
619N/A public static final StringUIClientPropertyKey MAX_ACC_WIDTH =
619N/A new StringUIClientPropertyKey("maxAccWidth");
619N/A public static final StringUIClientPropertyKey MAX_LABEL_WIDTH =
619N/A new StringUIClientPropertyKey("maxLabelWidth");
619N/A
619N/A private JMenuItem mi;
619N/A private JComponent miParent;
619N/A
619N/A private Font font;
619N/A private Font accFont;
619N/A private FontMetrics fm;
619N/A private FontMetrics accFm;
619N/A
619N/A private Icon icon;
619N/A private Icon checkIcon;
619N/A private Icon arrowIcon;
619N/A private String text;
619N/A private String accText;
619N/A
619N/A private boolean isColumnLayout;
619N/A private boolean useCheckAndArrow;
619N/A private boolean isLeftToRight;
619N/A private boolean isTopLevelMenu;
619N/A private View htmlView;
619N/A
619N/A private int verticalAlignment;
619N/A private int horizontalAlignment;
619N/A private int verticalTextPosition;
619N/A private int horizontalTextPosition;
619N/A private int gap;
619N/A private int leadingGap;
619N/A private int afterCheckIconGap;
619N/A private int minTextOffset;
619N/A
624N/A private int leftTextExtraWidth;
624N/A
619N/A private Rectangle viewRect;
619N/A
619N/A private RectSize iconSize;
619N/A private RectSize textSize;
619N/A private RectSize accSize;
619N/A private RectSize checkSize;
619N/A private RectSize arrowSize;
619N/A private RectSize labelSize;
619N/A
619N/A /**
619N/A * The empty protected constructor is necessary for derived classes.
619N/A */
619N/A protected MenuItemLayoutHelper() {
619N/A }
619N/A
619N/A public MenuItemLayoutHelper(JMenuItem mi, Icon checkIcon, Icon arrowIcon,
619N/A Rectangle viewRect, int gap, String accDelimiter,
619N/A boolean isLeftToRight, Font font, Font accFont,
619N/A boolean useCheckAndArrow, String propertyPrefix) {
619N/A reset(mi, checkIcon, arrowIcon, viewRect, gap, accDelimiter,
619N/A isLeftToRight, font, accFont, useCheckAndArrow, propertyPrefix);
619N/A }
619N/A
619N/A protected void reset(JMenuItem mi, Icon checkIcon, Icon arrowIcon,
619N/A Rectangle viewRect, int gap, String accDelimiter,
619N/A boolean isLeftToRight, Font font, Font accFont,
619N/A boolean useCheckAndArrow, String propertyPrefix) {
619N/A this.mi = mi;
619N/A this.miParent = getMenuItemParent(mi);
619N/A this.accText = getAccText(accDelimiter);
619N/A this.verticalAlignment = mi.getVerticalAlignment();
619N/A this.horizontalAlignment = mi.getHorizontalAlignment();
619N/A this.verticalTextPosition = mi.getVerticalTextPosition();
619N/A this.horizontalTextPosition = mi.getHorizontalTextPosition();
619N/A this.useCheckAndArrow = useCheckAndArrow;
619N/A this.font = font;
619N/A this.accFont = accFont;
619N/A this.fm = mi.getFontMetrics(font);
619N/A this.accFm = mi.getFontMetrics(accFont);
619N/A this.isLeftToRight = isLeftToRight;
619N/A this.isColumnLayout = isColumnLayout(isLeftToRight,
619N/A horizontalAlignment, horizontalTextPosition,
619N/A verticalTextPosition);
619N/A this.isTopLevelMenu = (this.miParent == null) ? true : false;
619N/A this.checkIcon = checkIcon;
619N/A this.icon = getIcon(propertyPrefix);
619N/A this.arrowIcon = arrowIcon;
619N/A this.text = mi.getText();
619N/A this.gap = gap;
619N/A this.afterCheckIconGap = getAfterCheckIconGap(propertyPrefix);
619N/A this.minTextOffset = getMinTextOffset(propertyPrefix);
619N/A this.htmlView = (View) mi.getClientProperty(BasicHTML.propertyKey);
619N/A this.viewRect = viewRect;
619N/A
619N/A this.iconSize = new RectSize();
619N/A this.textSize = new RectSize();
619N/A this.accSize = new RectSize();
619N/A this.checkSize = new RectSize();
619N/A this.arrowSize = new RectSize();
619N/A this.labelSize = new RectSize();
624N/A calcExtraWidths();
619N/A calcWidthsAndHeights();
619N/A setOriginalWidths();
619N/A calcMaxWidths();
619N/A
619N/A this.leadingGap = getLeadingGap(propertyPrefix);
619N/A calcMaxTextOffset(viewRect);
619N/A }
619N/A
624N/A private void calcExtraWidths() {
624N/A leftTextExtraWidth = getLeftExtraWidth(text);
624N/A }
624N/A
624N/A private int getLeftExtraWidth(String str) {
624N/A int lsb = SwingUtilities2.getLeftSideBearing(mi, fm, str);
624N/A if (lsb < 0) {
624N/A return -lsb;
624N/A } else {
624N/A return 0;
624N/A }
624N/A }
624N/A
619N/A private void setOriginalWidths() {
619N/A iconSize.origWidth = iconSize.width;
619N/A textSize.origWidth = textSize.width;
619N/A accSize.origWidth = accSize.width;
619N/A checkSize.origWidth = checkSize.width;
619N/A arrowSize.origWidth = arrowSize.width;
619N/A }
619N/A
619N/A private String getAccText(String acceleratorDelimiter) {
619N/A String accText = "";
619N/A KeyStroke accelerator = mi.getAccelerator();
619N/A if (accelerator != null) {
619N/A int modifiers = accelerator.getModifiers();
619N/A if (modifiers > 0) {
619N/A accText = KeyEvent.getKeyModifiersText(modifiers);
619N/A accText += acceleratorDelimiter;
619N/A }
619N/A int keyCode = accelerator.getKeyCode();
619N/A if (keyCode != 0) {
619N/A accText += KeyEvent.getKeyText(keyCode);
619N/A } else {
619N/A accText += accelerator.getKeyChar();
619N/A }
619N/A }
619N/A return accText;
619N/A }
619N/A
619N/A private Icon getIcon(String propertyPrefix) {
619N/A // In case of column layout, .checkIconFactory is defined for this UI,
619N/A // the icon is compatible with it and useCheckAndArrow() is true,
619N/A // then the icon is handled by the checkIcon.
619N/A Icon icon = null;
619N/A MenuItemCheckIconFactory iconFactory =
619N/A (MenuItemCheckIconFactory) UIManager.get(propertyPrefix
619N/A + ".checkIconFactory");
619N/A if (!isColumnLayout || !useCheckAndArrow || iconFactory == null
619N/A || !iconFactory.isCompatible(checkIcon, propertyPrefix)) {
619N/A icon = mi.getIcon();
619N/A }
619N/A return icon;
619N/A }
619N/A
619N/A private int getMinTextOffset(String propertyPrefix) {
619N/A int minimumTextOffset = 0;
619N/A Object minimumTextOffsetObject =
619N/A UIManager.get(propertyPrefix + ".minimumTextOffset");
619N/A if (minimumTextOffsetObject instanceof Integer) {
619N/A minimumTextOffset = (Integer) minimumTextOffsetObject;
619N/A }
619N/A return minimumTextOffset;
619N/A }
619N/A
619N/A private int getAfterCheckIconGap(String propertyPrefix) {
619N/A int afterCheckIconGap = gap;
619N/A Object afterCheckIconGapObject =
619N/A UIManager.get(propertyPrefix + ".afterCheckIconGap");
619N/A if (afterCheckIconGapObject instanceof Integer) {
619N/A afterCheckIconGap = (Integer) afterCheckIconGapObject;
619N/A }
619N/A return afterCheckIconGap;
619N/A }
619N/A
619N/A private int getLeadingGap(String propertyPrefix) {
619N/A if (checkSize.getMaxWidth() > 0) {
619N/A return getCheckOffset(propertyPrefix);
619N/A } else {
619N/A return gap; // There is no any check icon
619N/A }
619N/A }
619N/A
619N/A private int getCheckOffset(String propertyPrefix) {
619N/A int checkIconOffset = gap;
619N/A Object checkIconOffsetObject =
619N/A UIManager.get(propertyPrefix + ".checkIconOffset");
619N/A if (checkIconOffsetObject instanceof Integer) {
619N/A checkIconOffset = (Integer) checkIconOffsetObject;
619N/A }
619N/A return checkIconOffset;
619N/A }
619N/A
619N/A protected void calcWidthsAndHeights() {
619N/A // iconRect
619N/A if (icon != null) {
619N/A iconSize.width = icon.getIconWidth();
619N/A iconSize.height = icon.getIconHeight();
619N/A }
619N/A
619N/A // accRect
619N/A if (!accText.equals("")) {
619N/A accSize.width = SwingUtilities2.stringWidth(mi, accFm, accText);
619N/A accSize.height = accFm.getHeight();
619N/A }
619N/A
619N/A // textRect
619N/A if (text == null) {
619N/A text = "";
619N/A } else if (!text.equals("")) {
619N/A if (htmlView != null) {
619N/A // Text is HTML
619N/A textSize.width =
619N/A (int) htmlView.getPreferredSpan(View.X_AXIS);
619N/A textSize.height =
619N/A (int) htmlView.getPreferredSpan(View.Y_AXIS);
619N/A } else {
619N/A // Text isn't HTML
619N/A textSize.width = SwingUtilities2.stringWidth(mi, fm, text);
619N/A textSize.height = fm.getHeight();
619N/A }
619N/A }
619N/A
619N/A if (useCheckAndArrow) {
619N/A // checkIcon
619N/A if (checkIcon != null) {
619N/A checkSize.width = checkIcon.getIconWidth();
619N/A checkSize.height = checkIcon.getIconHeight();
619N/A }
619N/A // arrowRect
619N/A if (arrowIcon != null) {
619N/A arrowSize.width = arrowIcon.getIconWidth();
619N/A arrowSize.height = arrowIcon.getIconHeight();
619N/A }
619N/A }
619N/A
619N/A // labelRect
619N/A if (isColumnLayout) {
619N/A labelSize.width = iconSize.width + textSize.width + gap;
619N/A labelSize.height = max(checkSize.height, iconSize.height,
619N/A textSize.height, accSize.height, arrowSize.height);
619N/A } else {
619N/A Rectangle textRect = new Rectangle();
619N/A Rectangle iconRect = new Rectangle();
619N/A SwingUtilities.layoutCompoundLabel(mi, fm, text, icon,
619N/A verticalAlignment, horizontalAlignment,
619N/A verticalTextPosition, horizontalTextPosition,
619N/A viewRect, iconRect, textRect, gap);
1637N/A textRect.width += leftTextExtraWidth;
619N/A Rectangle labelRect = iconRect.union(textRect);
619N/A labelSize.height = labelRect.height;
619N/A labelSize.width = labelRect.width;
619N/A }
619N/A }
619N/A
619N/A protected void calcMaxWidths() {
619N/A calcMaxWidth(checkSize, MAX_CHECK_WIDTH);
619N/A calcMaxWidth(arrowSize, MAX_ARROW_WIDTH);
619N/A calcMaxWidth(accSize, MAX_ACC_WIDTH);
619N/A
619N/A if (isColumnLayout) {
619N/A calcMaxWidth(iconSize, MAX_ICON_WIDTH);
619N/A calcMaxWidth(textSize, MAX_TEXT_WIDTH);
619N/A int curGap = gap;
619N/A if ((iconSize.getMaxWidth() == 0)
619N/A || (textSize.getMaxWidth() == 0)) {
619N/A curGap = 0;
619N/A }
619N/A labelSize.maxWidth =
619N/A calcMaxValue(MAX_LABEL_WIDTH, iconSize.maxWidth
619N/A + textSize.maxWidth + curGap);
619N/A } else {
619N/A // We shouldn't use current icon and text widths
619N/A // in maximal widths calculation for complex layout.
619N/A iconSize.maxWidth = getParentIntProperty(MAX_ICON_WIDTH);
619N/A calcMaxWidth(labelSize, MAX_LABEL_WIDTH);
619N/A // If maxLabelWidth is wider
619N/A // than the widest icon + the widest text + gap,
619N/A // we should update the maximal text witdh
619N/A int candidateTextWidth = labelSize.maxWidth - iconSize.maxWidth;
619N/A if (iconSize.maxWidth > 0) {
619N/A candidateTextWidth -= gap;
619N/A }
619N/A textSize.maxWidth = calcMaxValue(MAX_TEXT_WIDTH, candidateTextWidth);
619N/A }
619N/A }
619N/A
619N/A protected void calcMaxWidth(RectSize rs, Object key) {
619N/A rs.maxWidth = calcMaxValue(key, rs.width);
619N/A }
619N/A
619N/A /**
619N/A * Calculates and returns maximal value through specified parent component
619N/A * client property.
619N/A *
619N/A * @param propertyName name of the property, which stores the maximal value.
619N/A * @param value a value which pretends to be maximal
619N/A * @return maximal value among the parent property and the value.
619N/A */
619N/A protected int calcMaxValue(Object propertyName, int value) {
619N/A // Get maximal value from parent client property
619N/A int maxValue = getParentIntProperty(propertyName);
619N/A // Store new maximal width in parent client property
619N/A if (value > maxValue) {
619N/A if (miParent != null) {
619N/A miParent.putClientProperty(propertyName, value);
619N/A }
619N/A return value;
619N/A } else {
619N/A return maxValue;
619N/A }
619N/A }
619N/A
619N/A /**
619N/A * Returns parent client property as int.
619N/A * @param propertyName name of the parent property.
619N/A * @return value of the property as int.
619N/A */
619N/A protected int getParentIntProperty(Object propertyName) {
619N/A Object value = null;
619N/A if (miParent != null) {
619N/A value = miParent.getClientProperty(propertyName);
619N/A }
619N/A if ((value == null) || !(value instanceof Integer)) {
619N/A value = 0;
619N/A }
619N/A return (Integer) value;
619N/A }
619N/A
619N/A public static boolean isColumnLayout(boolean isLeftToRight,
619N/A JMenuItem mi) {
619N/A assert(mi != null);
619N/A return isColumnLayout(isLeftToRight, mi.getHorizontalAlignment(),
619N/A mi.getHorizontalTextPosition(), mi.getVerticalTextPosition());
619N/A }
619N/A
619N/A /**
619N/A * Answers should we do column layout for a menu item or not.
619N/A * We do it when a user doesn't set any alignments
619N/A * and text positions manually, except the vertical alignment.
619N/A */
619N/A public static boolean isColumnLayout(boolean isLeftToRight,
619N/A int horizontalAlignment,
619N/A int horizontalTextPosition,
619N/A int verticalTextPosition) {
619N/A if (verticalTextPosition != SwingConstants.CENTER) {
619N/A return false;
619N/A }
619N/A if (isLeftToRight) {
619N/A if (horizontalAlignment != SwingConstants.LEADING
619N/A && horizontalAlignment != SwingConstants.LEFT) {
619N/A return false;
619N/A }
619N/A if (horizontalTextPosition != SwingConstants.TRAILING
619N/A && horizontalTextPosition != SwingConstants.RIGHT) {
619N/A return false;
619N/A }
619N/A } else {
619N/A if (horizontalAlignment != SwingConstants.LEADING
619N/A && horizontalAlignment != SwingConstants.RIGHT) {
619N/A return false;
619N/A }
619N/A if (horizontalTextPosition != SwingConstants.TRAILING
619N/A && horizontalTextPosition != SwingConstants.LEFT) {
619N/A return false;
619N/A }
619N/A }
619N/A return true;
619N/A }
619N/A
619N/A /**
619N/A * Calculates maximal text offset.
619N/A * It is required for some L&Fs (ex: Vista L&F).
619N/A * The offset is meaningful only for L2R column layout.
619N/A *
619N/A * @param viewRect the rectangle, the maximal text offset
619N/A * will be calculated for.
619N/A */
619N/A private void calcMaxTextOffset(Rectangle viewRect) {
619N/A if (!isColumnLayout || !isLeftToRight) {
619N/A return;
619N/A }
619N/A
619N/A // Calculate the current text offset
619N/A int offset = viewRect.x + leadingGap + checkSize.maxWidth
619N/A + afterCheckIconGap + iconSize.maxWidth + gap;
619N/A if (checkSize.maxWidth == 0) {
619N/A offset -= afterCheckIconGap;
619N/A }
619N/A if (iconSize.maxWidth == 0) {
619N/A offset -= gap;
619N/A }
619N/A
619N/A // maximal text offset shouldn't be less than minimal text offset;
619N/A if (offset < minTextOffset) {
619N/A offset = minTextOffset;
619N/A }
619N/A
619N/A // Calculate and store the maximal text offset
619N/A calcMaxValue(SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET, offset);
619N/A }
619N/A
619N/A /**
619N/A * Layout icon, text, check icon, accelerator text and arrow icon
619N/A * in the viewRect and return their positions.
619N/A *
619N/A * If horizontalAlignment, verticalTextPosition and horizontalTextPosition
619N/A * are default (user doesn't set any manually) the layouting algorithm is:
619N/A * Elements are layouted in the five columns:
619N/A * check icon + icon + text + accelerator text + arrow icon
619N/A *
619N/A * In the other case elements are layouted in the four columns:
619N/A * check icon + label + accelerator text + arrow icon
619N/A * Label is union of icon and text.
619N/A *
619N/A * The order of columns can be reversed.
619N/A * It depends on the menu item orientation.
619N/A */
619N/A public LayoutResult layoutMenuItem() {
619N/A LayoutResult lr = createLayoutResult();
619N/A prepareForLayout(lr);
619N/A
619N/A if (isColumnLayout()) {
619N/A if (isLeftToRight()) {
619N/A doLTRColumnLayout(lr, getLTRColumnAlignment());
619N/A } else {
619N/A doRTLColumnLayout(lr, getRTLColumnAlignment());
619N/A }
619N/A } else {
619N/A if (isLeftToRight()) {
619N/A doLTRComplexLayout(lr, getLTRColumnAlignment());
619N/A } else {
619N/A doRTLComplexLayout(lr, getRTLColumnAlignment());
619N/A }
619N/A }
619N/A
619N/A alignAccCheckAndArrowVertically(lr);
619N/A return lr;
619N/A }
619N/A
619N/A private LayoutResult createLayoutResult() {
619N/A return new LayoutResult(
619N/A new Rectangle(iconSize.width, iconSize.height),
619N/A new Rectangle(textSize.width, textSize.height),
619N/A new Rectangle(accSize.width, accSize.height),
619N/A new Rectangle(checkSize.width, checkSize.height),
619N/A new Rectangle(arrowSize.width, arrowSize.height),
619N/A new Rectangle(labelSize.width, labelSize.height)
619N/A );
619N/A }
619N/A
619N/A public ColumnAlignment getLTRColumnAlignment() {
619N/A return ColumnAlignment.LEFT_ALIGNMENT;
619N/A }
619N/A
619N/A public ColumnAlignment getRTLColumnAlignment() {
619N/A return ColumnAlignment.RIGHT_ALIGNMENT;
619N/A }
619N/A
619N/A protected void prepareForLayout(LayoutResult lr) {
619N/A lr.checkRect.width = checkSize.maxWidth;
619N/A lr.accRect.width = accSize.maxWidth;
619N/A lr.arrowRect.width = arrowSize.maxWidth;
619N/A }
619N/A
619N/A /**
619N/A * Aligns the accelertor text and the check and arrow icons vertically
619N/A * with the center of the label rect.
619N/A */
619N/A private void alignAccCheckAndArrowVertically(LayoutResult lr) {
619N/A lr.accRect.y = (int)(lr.labelRect.y
619N/A + (float)lr.labelRect.height/2
619N/A - (float)lr.accRect.height/2);
619N/A fixVerticalAlignment(lr, lr.accRect);
619N/A if (useCheckAndArrow) {
619N/A lr.arrowRect.y = (int)(lr.labelRect.y
619N/A + (float)lr.labelRect.height/2
619N/A - (float)lr.arrowRect.height/2);
619N/A lr.checkRect.y = (int)(lr.labelRect.y
619N/A + (float)lr.labelRect.height/2
619N/A - (float)lr.checkRect.height/2);
619N/A fixVerticalAlignment(lr, lr.arrowRect);
619N/A fixVerticalAlignment(lr, lr.checkRect);
619N/A }
619N/A }
619N/A
619N/A /**
619N/A * Fixes vertical alignment of all menu item elements if rect.y
619N/A * or (rect.y + rect.height) is out of viewRect bounds
619N/A */
619N/A private void fixVerticalAlignment(LayoutResult lr, Rectangle r) {
619N/A int delta = 0;
619N/A if (r.y < viewRect.y) {
619N/A delta = viewRect.y - r.y;
619N/A } else if (r.y + r.height > viewRect.y + viewRect.height) {
619N/A delta = viewRect.y + viewRect.height - r.y - r.height;
619N/A }
619N/A if (delta != 0) {
619N/A lr.checkRect.y += delta;
619N/A lr.iconRect.y += delta;
619N/A lr.textRect.y += delta;
619N/A lr.accRect.y += delta;
619N/A lr.arrowRect.y += delta;
619N/A lr.labelRect.y += delta;
619N/A }
619N/A }
619N/A
619N/A private void doLTRColumnLayout(LayoutResult lr, ColumnAlignment alignment) {
619N/A // Set maximal width for all the five basic rects
619N/A // (three other ones are already maximal)
619N/A lr.iconRect.width = iconSize.maxWidth;
619N/A lr.textRect.width = textSize.maxWidth;
619N/A
619N/A // Set X coordinates
619N/A // All rects will be aligned at the left side
619N/A calcXPositionsLTR(viewRect.x, leadingGap, gap, lr.checkRect,
619N/A lr.iconRect, lr.textRect);
619N/A
619N/A // Tune afterCheckIconGap
619N/A if (lr.checkRect.width > 0) { // there is the afterCheckIconGap
619N/A lr.iconRect.x += afterCheckIconGap - gap;
619N/A lr.textRect.x += afterCheckIconGap - gap;
619N/A }
619N/A
619N/A calcXPositionsRTL(viewRect.x + viewRect.width, leadingGap, gap,
619N/A lr.arrowRect, lr.accRect);
619N/A
619N/A // Take into account minimal text offset
619N/A int textOffset = lr.textRect.x - viewRect.x;
619N/A if (!isTopLevelMenu && (textOffset < minTextOffset)) {
619N/A lr.textRect.x += minTextOffset - textOffset;
619N/A }
619N/A
619N/A alignRects(lr, alignment);
619N/A
619N/A // Set Y coordinate for text and icon.
619N/A // Y coordinates for other rects
619N/A // will be calculated later in layoutMenuItem.
619N/A calcTextAndIconYPositions(lr);
619N/A
619N/A // Calculate valid X and Y coordinates for labelRect
619N/A lr.setLabelRect(lr.textRect.union(lr.iconRect));
619N/A }
619N/A
619N/A private void doLTRComplexLayout(LayoutResult lr, ColumnAlignment alignment) {
619N/A lr.labelRect.width = labelSize.maxWidth;
619N/A
619N/A // Set X coordinates
619N/A calcXPositionsLTR(viewRect.x, leadingGap, gap, lr.checkRect,
619N/A lr.labelRect);
619N/A
619N/A // Tune afterCheckIconGap
619N/A if (lr.checkRect.width > 0) { // there is the afterCheckIconGap
619N/A lr.labelRect.x += afterCheckIconGap - gap;
619N/A }
619N/A
619N/A calcXPositionsRTL(viewRect.x + viewRect.width,
619N/A leadingGap, gap, lr.arrowRect, lr.accRect);
619N/A
619N/A // Take into account minimal text offset
619N/A int labelOffset = lr.labelRect.x - viewRect.x;
619N/A if (!isTopLevelMenu && (labelOffset < minTextOffset)) {
619N/A lr.labelRect.x += minTextOffset - labelOffset;
619N/A }
619N/A
619N/A alignRects(lr, alignment);
619N/A
619N/A // Center labelRect vertically
619N/A calcLabelYPosition(lr);
619N/A
619N/A layoutIconAndTextInLabelRect(lr);
619N/A }
619N/A
619N/A private void doRTLColumnLayout(LayoutResult lr, ColumnAlignment alignment) {
619N/A // Set maximal width for all the five basic rects
619N/A // (three other ones are already maximal)
619N/A lr.iconRect.width = iconSize.maxWidth;
619N/A lr.textRect.width = textSize.maxWidth;
619N/A
619N/A // Set X coordinates
619N/A calcXPositionsRTL(viewRect.x + viewRect.width, leadingGap, gap,
619N/A lr.checkRect, lr.iconRect, lr.textRect);
619N/A
619N/A // Tune the gap after check icon
619N/A if (lr.checkRect.width > 0) { // there is the gap after check icon
619N/A lr.iconRect.x -= afterCheckIconGap - gap;
619N/A lr.textRect.x -= afterCheckIconGap - gap;
619N/A }
619N/A
619N/A calcXPositionsLTR(viewRect.x, leadingGap, gap, lr.arrowRect,
619N/A lr.accRect);
619N/A
619N/A // Take into account minimal text offset
619N/A int textOffset = (viewRect.x + viewRect.width)
619N/A - (lr.textRect.x + lr.textRect.width);
619N/A if (!isTopLevelMenu && (textOffset < minTextOffset)) {
619N/A lr.textRect.x -= minTextOffset - textOffset;
619N/A }
619N/A
619N/A alignRects(lr, alignment);
619N/A
619N/A // Set Y coordinates for text and icon.
619N/A // Y coordinates for other rects
619N/A // will be calculated later in layoutMenuItem.
619N/A calcTextAndIconYPositions(lr);
619N/A
619N/A // Calculate valid X and Y coordinate for labelRect
619N/A lr.setLabelRect(lr.textRect.union(lr.iconRect));
619N/A }
619N/A
619N/A private void doRTLComplexLayout(LayoutResult lr, ColumnAlignment alignment) {
619N/A lr.labelRect.width = labelSize.maxWidth;
619N/A
619N/A // Set X coordinates
619N/A calcXPositionsRTL(viewRect.x + viewRect.width, leadingGap, gap,
619N/A lr.checkRect, lr.labelRect);
619N/A
619N/A // Tune the gap after check icon
619N/A if (lr.checkRect.width > 0) { // there is the gap after check icon
619N/A lr.labelRect.x -= afterCheckIconGap - gap;
619N/A }
619N/A
619N/A calcXPositionsLTR(viewRect.x, leadingGap, gap, lr.arrowRect, lr.accRect);
619N/A
619N/A // Take into account minimal text offset
619N/A int labelOffset = (viewRect.x + viewRect.width)
619N/A - (lr.labelRect.x + lr.labelRect.width);
619N/A if (!isTopLevelMenu && (labelOffset < minTextOffset)) {
619N/A lr.labelRect.x -= minTextOffset - labelOffset;
619N/A }
619N/A
619N/A alignRects(lr, alignment);
619N/A
619N/A // Center labelRect vertically
619N/A calcLabelYPosition(lr);
619N/A
619N/A layoutIconAndTextInLabelRect(lr);
619N/A }
619N/A
619N/A private void alignRects(LayoutResult lr, ColumnAlignment alignment) {
619N/A alignRect(lr.checkRect, alignment.getCheckAlignment(),
619N/A checkSize.getOrigWidth());
619N/A alignRect(lr.iconRect, alignment.getIconAlignment(),
619N/A iconSize.getOrigWidth());
619N/A alignRect(lr.textRect, alignment.getTextAlignment(),
619N/A textSize.getOrigWidth());
619N/A alignRect(lr.accRect, alignment.getAccAlignment(),
619N/A accSize.getOrigWidth());
619N/A alignRect(lr.arrowRect, alignment.getArrowAlignment(),
619N/A arrowSize.getOrigWidth());
619N/A }
619N/A
619N/A private void alignRect(Rectangle rect, int alignment, int origWidth) {
1450N/A if (alignment == SwingConstants.RIGHT) {
619N/A rect.x = rect.x + rect.width - origWidth;
619N/A }
1450N/A rect.width = origWidth;
619N/A }
619N/A
619N/A protected void layoutIconAndTextInLabelRect(LayoutResult lr) {
619N/A lr.setTextRect(new Rectangle());
619N/A lr.setIconRect(new Rectangle());
619N/A SwingUtilities.layoutCompoundLabel(
619N/A mi, fm, text,icon, verticalAlignment, horizontalAlignment,
619N/A verticalTextPosition, horizontalTextPosition, lr.labelRect,
619N/A lr.iconRect, lr.textRect, gap);
619N/A }
619N/A
619N/A private void calcXPositionsLTR(int startXPos, int leadingGap,
619N/A int gap, Rectangle... rects) {
619N/A int curXPos = startXPos + leadingGap;
619N/A for (Rectangle rect : rects) {
619N/A rect.x = curXPos;
619N/A if (rect.width > 0) {
619N/A curXPos += rect.width + gap;
619N/A }
619N/A }
619N/A }
619N/A
619N/A private void calcXPositionsRTL(int startXPos, int leadingGap,
619N/A int gap, Rectangle... rects) {
619N/A int curXPos = startXPos - leadingGap;
619N/A for (Rectangle rect : rects) {
619N/A rect.x = curXPos - rect.width;
619N/A if (rect.width > 0) {
619N/A curXPos -= rect.width + gap;
619N/A }
619N/A }
619N/A }
619N/A
624N/A /**
619N/A * Sets Y coordinates of text and icon
619N/A * taking into account the vertical alignment
619N/A */
619N/A private void calcTextAndIconYPositions(LayoutResult lr) {
619N/A if (verticalAlignment == SwingUtilities.TOP) {
619N/A lr.textRect.y = (int)(viewRect.y
619N/A + (float)lr.labelRect.height/2
619N/A - (float)lr.textRect.height/2);
619N/A lr.iconRect.y = (int)(viewRect.y
619N/A + (float)lr.labelRect.height/2
619N/A - (float)lr.iconRect.height/2);
619N/A } else if (verticalAlignment == SwingUtilities.CENTER) {
619N/A lr.textRect.y = (int)(viewRect.y
619N/A + (float)viewRect.height/2
619N/A - (float)lr.textRect.height/2);
619N/A lr.iconRect.y = (int)(viewRect.y
619N/A + (float)viewRect.height/2
619N/A - (float)lr.iconRect.height/2);
619N/A }
619N/A else if (verticalAlignment == SwingUtilities.BOTTOM) {
619N/A lr.textRect.y = (int)(viewRect.y
619N/A + viewRect.height
619N/A - (float)lr.labelRect.height/2
619N/A - (float)lr.textRect.height/2);
619N/A lr.iconRect.y = (int)(viewRect.y
619N/A + viewRect.height
619N/A - (float)lr.labelRect.height/2
619N/A - (float)lr.iconRect.height/2);
619N/A }
619N/A }
619N/A
619N/A /**
619N/A * Sets labelRect Y coordinate
619N/A * taking into account the vertical alignment
619N/A */
619N/A private void calcLabelYPosition(LayoutResult lr) {
619N/A if (verticalAlignment == SwingUtilities.TOP) {
619N/A lr.labelRect.y = viewRect.y;
619N/A } else if (verticalAlignment == SwingUtilities.CENTER) {
619N/A lr.labelRect.y = (int)(viewRect.y
619N/A + (float)viewRect.height/2
619N/A - (float)lr.labelRect.height/2);
619N/A } else if (verticalAlignment == SwingUtilities.BOTTOM) {
619N/A lr.labelRect.y = viewRect.y + viewRect.height
619N/A - lr.labelRect.height;
619N/A }
619N/A }
619N/A
619N/A /**
619N/A * Returns parent of this component if it is not a top-level menu
619N/A * Otherwise returns null.
619N/A * @param menuItem the menu item whose parent will be returned.
619N/A * @return parent of this component if it is not a top-level menu
619N/A * Otherwise returns null.
619N/A */
619N/A public static JComponent getMenuItemParent(JMenuItem menuItem) {
619N/A Container parent = menuItem.getParent();
619N/A if ((parent instanceof JComponent) &&
619N/A (!(menuItem instanceof JMenu) ||
619N/A !((JMenu)menuItem).isTopLevelMenu())) {
619N/A return (JComponent) parent;
619N/A } else {
619N/A return null;
619N/A }
619N/A }
619N/A
619N/A public static void clearUsedParentClientProperties(JMenuItem menuItem) {
619N/A clearUsedClientProperties(getMenuItemParent(menuItem));
619N/A }
619N/A
619N/A public static void clearUsedClientProperties(JComponent c) {
619N/A if (c != null) {
619N/A c.putClientProperty(MAX_ARROW_WIDTH, null);
619N/A c.putClientProperty(MAX_CHECK_WIDTH, null);
619N/A c.putClientProperty(MAX_ACC_WIDTH, null);
619N/A c.putClientProperty(MAX_TEXT_WIDTH, null);
619N/A c.putClientProperty(MAX_ICON_WIDTH, null);
619N/A c.putClientProperty(MAX_LABEL_WIDTH, null);
619N/A c.putClientProperty(BASICMENUITEMUI_MAX_TEXT_OFFSET, null);
619N/A }
619N/A }
619N/A
619N/A /**
619N/A * Finds and returns maximal integer value in the given array.
619N/A * @param values array where the search will be performed.
619N/A * @return maximal vaule.
619N/A */
619N/A public static int max(int... values) {
619N/A int maxValue = Integer.MIN_VALUE;
619N/A for (int i : values) {
619N/A if (i > maxValue) {
619N/A maxValue = i;
619N/A }
619N/A }
619N/A return maxValue;
619N/A }
619N/A
619N/A public static Rectangle createMaxRect() {
619N/A return new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
619N/A }
619N/A
619N/A public static void addMaxWidth(RectSize size, int gap, Dimension result) {
619N/A if (size.maxWidth > 0) {
619N/A result.width += size.maxWidth + gap;
619N/A }
619N/A }
619N/A
619N/A public static void addWidth(int width, int gap, Dimension result) {
619N/A if (width > 0) {
619N/A result.width += width + gap;
619N/A }
619N/A }
619N/A
619N/A public JMenuItem getMenuItem() {
619N/A return mi;
619N/A }
619N/A
619N/A public JComponent getMenuItemParent() {
619N/A return miParent;
619N/A }
619N/A
619N/A public Font getFont() {
619N/A return font;
619N/A }
619N/A
619N/A public Font getAccFont() {
619N/A return accFont;
619N/A }
619N/A
619N/A public FontMetrics getFontMetrics() {
619N/A return fm;
619N/A }
619N/A
619N/A public FontMetrics getAccFontMetrics() {
619N/A return accFm;
619N/A }
619N/A
619N/A public Icon getIcon() {
619N/A return icon;
619N/A }
619N/A
619N/A public Icon getCheckIcon() {
619N/A return checkIcon;
619N/A }
619N/A
619N/A public Icon getArrowIcon() {
619N/A return arrowIcon;
619N/A }
619N/A
619N/A public String getText() {
619N/A return text;
619N/A }
619N/A
619N/A public String getAccText() {
619N/A return accText;
619N/A }
619N/A
619N/A public boolean isColumnLayout() {
619N/A return isColumnLayout;
619N/A }
619N/A
619N/A public boolean useCheckAndArrow() {
619N/A return useCheckAndArrow;
619N/A }
619N/A
619N/A public boolean isLeftToRight() {
619N/A return isLeftToRight;
619N/A }
619N/A
619N/A public boolean isTopLevelMenu() {
619N/A return isTopLevelMenu;
619N/A }
619N/A
619N/A public View getHtmlView() {
619N/A return htmlView;
619N/A }
619N/A
619N/A public int getVerticalAlignment() {
619N/A return verticalAlignment;
619N/A }
619N/A
619N/A public int getHorizontalAlignment() {
619N/A return horizontalAlignment;
619N/A }
619N/A
619N/A public int getVerticalTextPosition() {
619N/A return verticalTextPosition;
619N/A }
619N/A
619N/A public int getHorizontalTextPosition() {
619N/A return horizontalTextPosition;
619N/A }
619N/A
619N/A public int getGap() {
619N/A return gap;
619N/A }
619N/A
619N/A public int getLeadingGap() {
619N/A return leadingGap;
619N/A }
619N/A
619N/A public int getAfterCheckIconGap() {
619N/A return afterCheckIconGap;
619N/A }
619N/A
619N/A public int getMinTextOffset() {
619N/A return minTextOffset;
619N/A }
619N/A
619N/A public Rectangle getViewRect() {
619N/A return viewRect;
619N/A }
619N/A
619N/A public RectSize getIconSize() {
619N/A return iconSize;
619N/A }
619N/A
619N/A public RectSize getTextSize() {
619N/A return textSize;
619N/A }
619N/A
619N/A public RectSize getAccSize() {
619N/A return accSize;
619N/A }
619N/A
619N/A public RectSize getCheckSize() {
619N/A return checkSize;
619N/A }
619N/A
619N/A public RectSize getArrowSize() {
619N/A return arrowSize;
619N/A }
619N/A
619N/A public RectSize getLabelSize() {
619N/A return labelSize;
619N/A }
619N/A
619N/A protected void setMenuItem(JMenuItem mi) {
619N/A this.mi = mi;
619N/A }
619N/A
619N/A protected void setMenuItemParent(JComponent miParent) {
619N/A this.miParent = miParent;
619N/A }
619N/A
619N/A protected void setFont(Font font) {
619N/A this.font = font;
619N/A }
619N/A
619N/A protected void setAccFont(Font accFont) {
619N/A this.accFont = accFont;
619N/A }
619N/A
619N/A protected void setFontMetrics(FontMetrics fm) {
619N/A this.fm = fm;
619N/A }
619N/A
619N/A protected void setAccFontMetrics(FontMetrics accFm) {
619N/A this.accFm = accFm;
619N/A }
619N/A
619N/A protected void setIcon(Icon icon) {
619N/A this.icon = icon;
619N/A }
619N/A
619N/A protected void setCheckIcon(Icon checkIcon) {
619N/A this.checkIcon = checkIcon;
619N/A }
619N/A
619N/A protected void setArrowIcon(Icon arrowIcon) {
619N/A this.arrowIcon = arrowIcon;
619N/A }
619N/A
619N/A protected void setText(String text) {
619N/A this.text = text;
619N/A }
619N/A
619N/A protected void setAccText(String accText) {
619N/A this.accText = accText;
619N/A }
619N/A
619N/A protected void setColumnLayout(boolean columnLayout) {
619N/A isColumnLayout = columnLayout;
619N/A }
619N/A
619N/A protected void setUseCheckAndArrow(boolean useCheckAndArrow) {
619N/A this.useCheckAndArrow = useCheckAndArrow;
619N/A }
619N/A
619N/A protected void setLeftToRight(boolean leftToRight) {
619N/A isLeftToRight = leftToRight;
619N/A }
619N/A
619N/A protected void setTopLevelMenu(boolean topLevelMenu) {
619N/A isTopLevelMenu = topLevelMenu;
619N/A }
619N/A
619N/A protected void setHtmlView(View htmlView) {
619N/A this.htmlView = htmlView;
619N/A }
619N/A
619N/A protected void setVerticalAlignment(int verticalAlignment) {
619N/A this.verticalAlignment = verticalAlignment;
619N/A }
619N/A
619N/A protected void setHorizontalAlignment(int horizontalAlignment) {
619N/A this.horizontalAlignment = horizontalAlignment;
619N/A }
619N/A
619N/A protected void setVerticalTextPosition(int verticalTextPosition) {
619N/A this.verticalTextPosition = verticalTextPosition;
619N/A }
619N/A
619N/A protected void setHorizontalTextPosition(int horizontalTextPosition) {
619N/A this.horizontalTextPosition = horizontalTextPosition;
619N/A }
619N/A
619N/A protected void setGap(int gap) {
619N/A this.gap = gap;
619N/A }
619N/A
619N/A protected void setLeadingGap(int leadingGap) {
619N/A this.leadingGap = leadingGap;
619N/A }
619N/A
619N/A protected void setAfterCheckIconGap(int afterCheckIconGap) {
619N/A this.afterCheckIconGap = afterCheckIconGap;
619N/A }
619N/A
619N/A protected void setMinTextOffset(int minTextOffset) {
619N/A this.minTextOffset = minTextOffset;
619N/A }
619N/A
619N/A protected void setViewRect(Rectangle viewRect) {
619N/A this.viewRect = viewRect;
619N/A }
619N/A
619N/A protected void setIconSize(RectSize iconSize) {
619N/A this.iconSize = iconSize;
619N/A }
619N/A
619N/A protected void setTextSize(RectSize textSize) {
619N/A this.textSize = textSize;
619N/A }
619N/A
619N/A protected void setAccSize(RectSize accSize) {
619N/A this.accSize = accSize;
619N/A }
619N/A
619N/A protected void setCheckSize(RectSize checkSize) {
619N/A this.checkSize = checkSize;
619N/A }
619N/A
619N/A protected void setArrowSize(RectSize arrowSize) {
619N/A this.arrowSize = arrowSize;
619N/A }
619N/A
619N/A protected void setLabelSize(RectSize labelSize) {
619N/A this.labelSize = labelSize;
619N/A }
619N/A
624N/A public int getLeftTextExtraWidth() {
624N/A return leftTextExtraWidth;
624N/A }
624N/A
619N/A /**
619N/A * Returns false if the component is a JMenu and it is a top
619N/A * level menu (on the menubar).
619N/A */
619N/A public static boolean useCheckAndArrow(JMenuItem menuItem) {
619N/A boolean b = true;
619N/A if ((menuItem instanceof JMenu) &&
619N/A (((JMenu) menuItem).isTopLevelMenu())) {
619N/A b = false;
619N/A }
619N/A return b;
619N/A }
619N/A
619N/A public static class LayoutResult {
619N/A private Rectangle iconRect;
619N/A private Rectangle textRect;
619N/A private Rectangle accRect;
619N/A private Rectangle checkRect;
619N/A private Rectangle arrowRect;
619N/A private Rectangle labelRect;
619N/A
619N/A public LayoutResult() {
619N/A iconRect = new Rectangle();
619N/A textRect = new Rectangle();
619N/A accRect = new Rectangle();
619N/A checkRect = new Rectangle();
619N/A arrowRect = new Rectangle();
619N/A labelRect = new Rectangle();
619N/A }
619N/A
619N/A public LayoutResult(Rectangle iconRect, Rectangle textRect,
619N/A Rectangle accRect, Rectangle checkRect,
619N/A Rectangle arrowRect, Rectangle labelRect) {
619N/A this.iconRect = iconRect;
619N/A this.textRect = textRect;
619N/A this.accRect = accRect;
619N/A this.checkRect = checkRect;
619N/A this.arrowRect = arrowRect;
619N/A this.labelRect = labelRect;
619N/A }
619N/A
619N/A public Rectangle getIconRect() {
619N/A return iconRect;
619N/A }
619N/A
619N/A public void setIconRect(Rectangle iconRect) {
619N/A this.iconRect = iconRect;
619N/A }
619N/A
619N/A public Rectangle getTextRect() {
619N/A return textRect;
619N/A }
619N/A
619N/A public void setTextRect(Rectangle textRect) {
619N/A this.textRect = textRect;
619N/A }
619N/A
619N/A public Rectangle getAccRect() {
619N/A return accRect;
619N/A }
619N/A
619N/A public void setAccRect(Rectangle accRect) {
619N/A this.accRect = accRect;
619N/A }
619N/A
619N/A public Rectangle getCheckRect() {
619N/A return checkRect;
619N/A }
619N/A
619N/A public void setCheckRect(Rectangle checkRect) {
619N/A this.checkRect = checkRect;
619N/A }
619N/A
619N/A public Rectangle getArrowRect() {
619N/A return arrowRect;
619N/A }
619N/A
619N/A public void setArrowRect(Rectangle arrowRect) {
619N/A this.arrowRect = arrowRect;
619N/A }
619N/A
619N/A public Rectangle getLabelRect() {
619N/A return labelRect;
619N/A }
619N/A
619N/A public void setLabelRect(Rectangle labelRect) {
619N/A this.labelRect = labelRect;
619N/A }
619N/A
619N/A public Map<String, Rectangle> getAllRects() {
619N/A Map<String, Rectangle> result = new HashMap<String, Rectangle>();
619N/A result.put("checkRect", checkRect);
619N/A result.put("iconRect", iconRect);
619N/A result.put("textRect", textRect);
619N/A result.put("accRect", accRect);
619N/A result.put("arrowRect", arrowRect);
619N/A result.put("labelRect", labelRect);
619N/A return result;
619N/A }
619N/A }
619N/A
619N/A public static class ColumnAlignment {
619N/A private int checkAlignment;
619N/A private int iconAlignment;
619N/A private int textAlignment;
619N/A private int accAlignment;
619N/A private int arrowAlignment;
619N/A
619N/A public static final ColumnAlignment LEFT_ALIGNMENT =
619N/A new ColumnAlignment(
619N/A SwingConstants.LEFT,
619N/A SwingConstants.LEFT,
619N/A SwingConstants.LEFT,
619N/A SwingConstants.LEFT,
619N/A SwingConstants.LEFT
619N/A );
619N/A
619N/A public static final ColumnAlignment RIGHT_ALIGNMENT =
619N/A new ColumnAlignment(
619N/A SwingConstants.RIGHT,
619N/A SwingConstants.RIGHT,
619N/A SwingConstants.RIGHT,
619N/A SwingConstants.RIGHT,
619N/A SwingConstants.RIGHT
619N/A );
619N/A
619N/A public ColumnAlignment(int checkAlignment, int iconAlignment,
619N/A int textAlignment, int accAlignment,
619N/A int arrowAlignment) {
619N/A this.checkAlignment = checkAlignment;
619N/A this.iconAlignment = iconAlignment;
619N/A this.textAlignment = textAlignment;
619N/A this.accAlignment = accAlignment;
619N/A this.arrowAlignment = arrowAlignment;
619N/A }
619N/A
619N/A public int getCheckAlignment() {
619N/A return checkAlignment;
619N/A }
619N/A
619N/A public int getIconAlignment() {
619N/A return iconAlignment;
619N/A }
619N/A
619N/A public int getTextAlignment() {
619N/A return textAlignment;
619N/A }
619N/A
619N/A public int getAccAlignment() {
619N/A return accAlignment;
619N/A }
619N/A
619N/A public int getArrowAlignment() {
619N/A return arrowAlignment;
619N/A }
619N/A }
619N/A
619N/A public static class RectSize {
619N/A private int width;
619N/A private int height;
619N/A private int origWidth;
619N/A private int maxWidth;
619N/A
619N/A public RectSize() {
619N/A }
619N/A
619N/A public RectSize(int width, int height, int origWidth, int maxWidth) {
619N/A this.width = width;
619N/A this.height = height;
619N/A this.origWidth = origWidth;
619N/A this.maxWidth = maxWidth;
619N/A }
619N/A
619N/A public int getWidth() {
619N/A return width;
619N/A }
619N/A
619N/A public int getHeight() {
619N/A return height;
619N/A }
619N/A
619N/A public int getOrigWidth() {
619N/A return origWidth;
619N/A }
619N/A
619N/A public int getMaxWidth() {
619N/A return maxWidth;
619N/A }
619N/A
619N/A public void setWidth(int width) {
619N/A this.width = width;
619N/A }
619N/A
619N/A public void setHeight(int height) {
619N/A this.height = height;
619N/A }
619N/A
619N/A public void setOrigWidth(int origWidth) {
619N/A this.origWidth = origWidth;
619N/A }
619N/A
619N/A public void setMaxWidth(int maxWidth) {
619N/A this.maxWidth = maxWidth;
619N/A }
619N/A
619N/A public String toString() {
619N/A return "[w=" + width + ",h=" + height + ",ow="
619N/A + origWidth + ",mw=" + maxWidth + "]";
619N/A }
619N/A }
619N/A}