diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.pagedesigner/src')
31 files changed, 372 insertions, 165 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockBox.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockBox.java index 7c635a59c..d20bc7a9e 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockBox.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockBox.java @@ -59,11 +59,11 @@ public class BlockBox extends CompositeBox { + box._height); } - public int getInternalContentWidth() { + int getInternalContentWidth() { return _internalContentWidth; } - public int getInternalContentHeight() { + int getInternalContentHeight() { return _internalContentHeight; } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlow.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlow.java index 35eb4c7c2..d7b8b0b09 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlow.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlow.java @@ -27,7 +27,7 @@ import org.eclipse.draw2d.PositionConstants; * <P> * Only {@link FlowFigure}s can be added to a BlockFlow. */ -public class BlockFlow extends FlowFigure { +/*package*/ class BlockFlow extends FlowFigure { final BlockBox _blockBox; @@ -46,7 +46,8 @@ public class BlockFlow extends FlowFigure { } /** - * @see org.eclipse.jst.pagedesigner.css2.layout.FlowFigure#createDefaultFlowLayout() + * @return the default flow layout + * */ protected FlowFigureLayout createDefaultFlowLayout() { return new BlockFlowLayout(this); diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlowContext.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlowContext.java index 7cb5efdf4..44c43c8b0 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlowContext.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlowContext.java @@ -24,18 +24,19 @@ import org.eclipse.jst.pagedesigner.css2.value.Length; * @version 1.5 */ public class BlockFlowContext implements FlowContext { - protected LineBox _currentLine; + private LineBox _currentLine; private LineBox _previousLine = null; - protected BlockBox _blockBox; + BlockBox _blockBox; - protected FlowContext _originalContext; + private final FlowContext _originalContext; - protected ICSSStyle _style; + private final ICSSStyle _style; /** - * + * @param originalContext + * @param style */ public BlockFlowContext(FlowContext originalContext, ICSSStyle style) { this._originalContext = originalContext; @@ -53,7 +54,10 @@ public class BlockFlowContext implements FlowContext { return _originalContext.getContainerWidth(); } - public void setup() { + /** + * Initialize the object + */ + private void setup() { _blockBox = new BlockBox(); _blockBox.setRecommendedWidth(getRecommendedWidth()); _currentLine = this.getCurrentLine(); @@ -136,7 +140,7 @@ public class BlockFlowContext implements FlowContext { createNewLine(); } - protected void createNewLine() { + private void createNewLine() { _currentLine = new LineBox(); setupLine(_currentLine, Integer.MIN_VALUE); } @@ -146,13 +150,14 @@ public class BlockFlowContext implements FlowContext { * * @param line * the LineBox to set up + * @param topMargin */ protected void setupLine(LineBox line, int topMargin) { line.clear(); // the caller of getCurrentLine() may add leftMargin and leftPadding and // leftBorder to line.x - line._x = _blockBox._borderInsets.left + _blockBox._paddingInsets.left; + line._x = _blockBox.getBorderInsets().left + _blockBox.getPaddingInsets().left; // FIXME: here should check the floating boxes, and minus the width of // them from @@ -166,14 +171,14 @@ public class BlockFlowContext implements FlowContext { // space. // line.setRecommendedWidth(_blockBox.getRecommendedContentWidth()); if (_previousLine == null) { - line._y = _blockBox._borderInsets.top - + _blockBox._paddingInsets.top; + line._y = _blockBox.getBorderInsets().top + + _blockBox.getPaddingInsets().top; if (topMargin != Integer.MIN_VALUE) line._y += topMargin; } else { if (topMargin == Integer.MIN_VALUE) line._y = _previousLine._y + _previousLine.getHeight() - + getLinePadding() + _previousLine._marginInsets.bottom; // XXX: + + getLinePadding() + _previousLine.getMarginInsets().bottom; // XXX: // should // add // previous @@ -183,7 +188,7 @@ public class BlockFlowContext implements FlowContext { line._y = _previousLine._y + _previousLine.getHeight() + Math.max(topMargin, - _previousLine._marginInsets.bottom); + _previousLine.getMarginInsets().bottom); } // line.validate(); } @@ -219,7 +224,7 @@ public class BlockFlowContext implements FlowContext { FlowBox box = (FlowBox) _currentLine.getFragments().get( _currentLine.getFragments().size() - 1); if (box != null) { - return box._marginInsets.right; + return box.getMarginInsets().right; } return 0; } @@ -273,7 +278,7 @@ public class BlockFlowContext implements FlowContext { _blockBox.add(_currentLine); } - public void endBlock() { + void endBlock() { endLine(); } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlowLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlowLayout.java index f50ee6093..05bf6c454 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlowLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BlockFlowLayout.java @@ -62,6 +62,7 @@ public class BlockFlowLayout extends FlowContainerLayout { * * @param line * the LineBox to set up + * @param topMargin */ protected void setupLine(LineBox line, int topMargin) { line.clear(); @@ -82,7 +83,7 @@ public class BlockFlowLayout extends FlowContainerLayout { } else { if (topMargin == Integer.MIN_VALUE) { line._y = _previousLine._y + _previousLine.getHeight() - + getLinePadding() + _previousLine._marginInsets.bottom; // XXX: + + getLinePadding() + _previousLine.getMarginInsets().bottom; // XXX: // should // add // previous @@ -92,7 +93,7 @@ public class BlockFlowLayout extends FlowContainerLayout { line._y = _previousLine._y + _previousLine.getHeight() + Math.max(topMargin, - _previousLine._marginInsets.bottom); + _previousLine.getMarginInsets().bottom); } } // line.validate(); diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BoxUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BoxUtil.java index 54978d145..b91e30ee1 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BoxUtil.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/BoxUtil.java @@ -26,9 +26,9 @@ public class BoxUtil { * @param style */ public static void setupBorderPaddingMargin(FlowBox box, ICSSStyle style) { - box._marginInsets = new Insets(style.getMarginInsets()); - box._borderInsets = new Insets(style.getBorderInsets()); - box._paddingInsets = new Insets(style.getPaddingInsets()); + box.setMarginInsets(new Insets(style.getMarginInsets())); + box.setBorderInsets(new Insets(style.getBorderInsets())); + box.setPaddingInsets(new Insets(style.getPaddingInsets())); if (box.getBorderPaddingHeight() > box.getHeight()) { box.setHeight(box.getBorderPaddingHeight()); diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSBlockFlowLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSBlockFlowLayout.java index c3dd62516..dd02b490d 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSBlockFlowLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSBlockFlowLayout.java @@ -237,7 +237,7 @@ public class CSSBlockFlowLayout extends CSSLayout implements ICSSPainter2 { _blockBox.setRecommendedHeight(h); } } - _blockBox._marginInsets = new Insets(style.getMarginInsets()); + _blockBox.setMarginInsets(new Insets(style.getMarginInsets())); if (handlingBorderForBlock()) { BoxUtil.setupBorderPaddingMargin(_blockBox, getCSSStyle()); } @@ -394,7 +394,7 @@ public class CSSBlockFlowLayout extends CSSLayout implements ICSSPainter2 { && _blockBox.getInternalContentHeight() >= 0 && _userSpecifiedHeight < _blockBox .getInternalContentHeight() - + _blockBox._paddingInsets.getHeight() + + _blockBox.getPaddingInsets().getHeight() + BorderUtil.SCROLL_WIDTH) { _needVScroll = true; } @@ -404,7 +404,7 @@ public class CSSBlockFlowLayout extends CSSLayout implements ICSSPainter2 { && _blockBox.getInternalContentWidth() >= 0 && _userSpecifiedWidth < _blockBox .getInternalContentWidth() - + _blockBox._paddingInsets.getWidth() + + _blockBox.getPaddingInsets().getWidth() + BorderUtil.SCROLL_WIDTH) { _needHScroll = true; } @@ -421,7 +421,7 @@ public class CSSBlockFlowLayout extends CSSLayout implements ICSSPainter2 { if (getFlowContext().isCurrentLineOccupied() && getFlowContext().getCurrentLine().getAvailableWidth() < _blockBox._width - + _blockBox._marginInsets.getWidth()) { + + _blockBox.getMarginInsets().getWidth()) { getFlowContext().endLine(); } if (!isInlineBlock()) { @@ -435,7 +435,7 @@ public class CSSBlockFlowLayout extends CSSLayout implements ICSSPainter2 { } else { getFlowContext().addToCurrentLine(_blockBox); } - getFlowContext().getCurrentLine()._marginInsets.bottom = getCSSStyle() + getFlowContext().getCurrentLine().getMarginInsets().bottom = getCSSStyle() .getMarginInsets().bottom; if (!isInlineBlock()) { @@ -572,7 +572,7 @@ public class CSSBlockFlowLayout extends CSSLayout implements ICSSPainter2 { } else { if (topMargin == Integer.MIN_VALUE) { line._y = _previousLine._y + _previousLine.getHeight() - + getLinePadding() + _previousLine._marginInsets.bottom; // XXX: + + getLinePadding() + _previousLine.getMarginInsets().bottom; // XXX: // should // add // previous @@ -582,7 +582,7 @@ public class CSSBlockFlowLayout extends CSSLayout implements ICSSPainter2 { line._y = _previousLine._y + _previousLine.getHeight() + Math.max(topMargin, - _previousLine._marginInsets.bottom); + _previousLine.getMarginInsets().bottom); } } setFontinfoForLine(line); @@ -726,7 +726,7 @@ public class CSSBlockFlowLayout extends CSSLayout implements ICSSPainter2 { Rectangle rect = new Rectangle(0, 0, _blockBox.getWidth(), _blockBox.getHeight()); - rect.crop(_blockBox._borderInsets); + rect.crop(_blockBox.getBorderInsets()); if (this._needHScroll && this._needVScroll) { BorderUtil.drawScrollBar(g, BorderUtil.SCROLL_WIDTH, diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSFigure.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSFigure.java index 79012d99e..a6c5289e0 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSFigure.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSFigure.java @@ -44,24 +44,25 @@ public class CSSFigure extends FlowFigure implements ICSSFigure { private static final Rectangle PRIVATE_RECT = new Rectangle(); - ICSSStyle _style; - - // NOTE: here keep the element is only for debug use. CSSFigure shouldn't - // require an element. - // Element _element; + private ICSSStyle _style; // if this field is set, then regetLayout() will still return this layout, // without going through the CSS resolution - CSSLayout _fixedLayout; + private CSSLayout _fixedLayout; + /** + * Default constructor + * Equivalent to CSSFigure(DefaultStyle.getInstance()) + */ public CSSFigure() { - _style = DefaultStyle.getInstance(); - invalidateCSS(); + this(DefaultStyle.getInstance()); } + /** + * @param style + */ public CSSFigure(ICSSStyle style) { _style = style; - // _element = element; invalidateCSS(); } @@ -69,6 +70,9 @@ public class CSSFigure extends FlowFigure implements ICSSFigure { return _style; } + /** + * @param style + */ public void setCSSStyle(ICSSStyle style) { _style = style; invalidateCSS(); @@ -91,6 +95,9 @@ public class CSSFigure extends FlowFigure implements ICSSFigure { this.setLayoutManager(layout); } + /** + * @param layout + */ public void setFixedLayoutManager(CSSLayout layout) { this._fixedLayout = layout; this.setLayoutManager(regetLayout(getLayoutManager())); @@ -128,6 +135,10 @@ public class CSSFigure extends FlowFigure implements ICSSFigure { super.setLayoutManager(manager); } + /** + * @param old + * @return the layout + */ protected CSSLayout regetLayout(LayoutManager old) { if (_fixedLayout != null) { return _fixedLayout; @@ -177,7 +188,7 @@ public class CSSFigure extends FlowFigure implements ICSSFigure { /** * this method is a shortcut to getFragmentsForRead * - * @return + * @return fragment bounds */ public Rectangle[] getFragmentsBounds() { List list = getFragmentsForRead(); @@ -382,8 +393,8 @@ public class CSSFigure extends FlowFigure implements ICSSFigure { if (Debug.DEBUG_BOX) { CSSLayout csslayout = (CSSLayout) this.getLayoutManager(); - if (csslayout._absoluteContext != null) { - BlockBox blockbox = csslayout._absoluteContext._blockBox; + if (csslayout.getAbsoluteContext() != null) { + BlockBox blockbox = csslayout.getAbsoluteContext()._blockBox; g.setLineWidth(1); g.setForegroundColor(ColorConstants.green); g.drawRectangle(blockbox._x, blockbox._y, blockbox.getWidth(), @@ -394,7 +405,7 @@ public class CSSFigure extends FlowFigure implements ICSSFigure { /** * Paints this Figure's client area. The client area is typically defined as - * the anything inside the Figure's {@link Border} or {@link Insets}, and + * the anything inside the Figure's {@link org.eclipse.draw2d.Border} or {@link org.eclipse.draw2d.geometry.Insets}, and * by default includes the children of this Figure. On return, this method * must leave the given Graphics in its initial state. * diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSInlineFlowLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSInlineFlowLayout.java index 97f4571c0..39ddf89b4 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSInlineFlowLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSInlineFlowLayout.java @@ -142,7 +142,7 @@ public class CSSInlineFlowLayout extends CSSLayout { } if (_currentLine != null /* && _currentLine.isOccupied() */) { - _currentLine._marginInsets.right = getCSSStyle().getMarginInsets().right; + _currentLine.getMarginInsets().right = getCSSStyle().getMarginInsets().right; getFlowContext().addToCurrentLine(_currentLine); } @@ -192,6 +192,7 @@ public class CSSInlineFlowLayout extends CSSLayout { * * @param line * The LineBox to initialize. + * @param firstline */ protected void setupLine(LineBox line, boolean firstline) { LineBox parent = getFlowContext().getCurrentLine(); diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSLayout.java index 99081a798..9683a34f6 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSLayout.java @@ -30,7 +30,7 @@ import org.eclipse.jst.pagedesigner.css2.value.Length; * @author mengbo */ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext { - protected BlockFlowContext _absoluteContext; + private BlockFlowContext _absoluteContext; // when doing absolute layout, and if top/left are both "auto", it will be // relating to the normaly flow position. The following two fields try to @@ -47,6 +47,7 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext private boolean _calculatingMaxWidth = false; /** + * @param flowFigure * @see org.eclipse.jst.pagedesigner.css2.layout.FlowFigureLayout#FlowFigureLayout(FlowFigure) */ protected CSSLayout(CSSFigure flowFigure) { @@ -56,13 +57,20 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext /** * a shortcut method to get the style associated with the figure. * - * @return + * @return the css style */ public ICSSStyle getCSSStyle() { return getCSSFigure().getCSSStyle(); } /** + * @return the absolute context + */ + protected final BlockFlowContext getAbsoluteContext() { + return _absoluteContext; + } + + /** * @see org.eclipse.jst.pagedesigner.css2.layout.FlowContext#addToCurrentLine(FlowBox) */ public void addToCurrentLine(FlowBox block) { @@ -129,7 +137,10 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext cleanup(); } - protected boolean isAbsolutePosition() { + /** + * @return true if is absolute position + */ + protected final boolean isAbsolutePosition() { ICSSStyle style = getCSSStyle(); // FIXME: Some layout don't support absolute, need check here @@ -146,7 +157,7 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext /** * Child class could override this method. * - * @return + * @return true if supports absolute position */ protected boolean supportAbsolutePosition() { if (findContainingPositionedFigure() == null) { @@ -155,10 +166,8 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext return true; } - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.pagedesigner.css2.layout.FlowContainerLayout#preLayout() + /** + * Perform a prelayout */ protected void preLayout() { ICSSStyle style = this.getCSSStyle(); @@ -192,11 +201,14 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext return getOriginalFlowContext(); } - public FlowContext getParentFigureContext() { + /** + * @return the flow context + */ + private FlowContext getParentFigureContext() { return super.getFlowContext(); } - public void postValidateForAbsolute() { + final void postValidateForAbsolute() { if (_absoluteContext != null) { ICSSStyle style = this.getCSSStyle(); @@ -358,15 +370,21 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext FlowBox box = (FlowBox) _currentLine.getFragments().get( _currentLine.getFragments().size() - 1); if (box != null) { - return box._marginInsets.right; + return box.getMarginInsets().right; } return 0; } + /** + * @param c + */ public void setCalculatingMaxWidth(boolean c) { _calculatingMaxWidth = c; } + /** + * @return the calculated maximum width + */ public boolean getCalcuatingMaxWidth() { return _calculatingMaxWidth; } @@ -399,13 +417,16 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext // ------------------------------------------------------------------------------------ - public CSSFigure getCSSFigure() { + /** + * @return the css figure + */ + protected final CSSFigure getCSSFigure() { return (CSSFigure) getFlowFigure(); } /** * - * @return + * @return the fragments for read */ public abstract List getFragmentsForRead(); @@ -429,9 +450,9 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext /** * Child class can override this. Normally block figure will return true. * - * @return + * @return true if should use local coordinates */ - public boolean useLocalCoordinates() { + protected boolean useLocalCoordinates() { return false; } @@ -440,9 +461,9 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext * method will return true, else return false, for example,the input file * will return false. * - * @return + * @return true if handling border block */ - public boolean handlingBorderForBlock() { + protected boolean handlingBorderForBlock() { return true; } @@ -450,7 +471,7 @@ public abstract class CSSLayout extends FlowFigureLayout implements FlowContext * This method is called when the corresponding figure is revalidated. * */ - public void figureRevalidate() { + protected void figureRevalidate() { // child class can override. } } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSListItemLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSListItemLayout.java index a3608ddad..a8400f406 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSListItemLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSListItemLayout.java @@ -135,7 +135,7 @@ public class CSSListItemLayout extends CSSBlockFlowLayout implements List list = _blockBox.getFragments(); Rectangle box = _blockBox.toRectangle().getCopy().expand( _blockBox.getBorderPaddingInsets().getAdded( - _blockBox._marginInsets)); + _blockBox.getMarginInsets())); if (list != null && !list.isEmpty()) { LineBox line = (LineBox) list.get(0); y = line.getBaseline() - CIRCLE_DIAMETER; @@ -156,7 +156,7 @@ public class CSSListItemLayout extends CSSBlockFlowLayout implements Rectangle box = _blockBox.toRectangle().getCopy().expand( _blockBox.getBorderPaddingInsets().getAdded( - _blockBox._marginInsets)); + _blockBox.getMarginInsets())); x = box.x - FigureUtilities.getTextWidth(displayString, font); x = x diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSPageFlowLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSPageFlowLayout.java index c74963a58..8662bc25b 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSPageFlowLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSPageFlowLayout.java @@ -33,7 +33,6 @@ public class CSSPageFlowLayout extends CSSBlockFlowLayout { private Dimension _pageSizeCacheValues[] = new Dimension[4]; - private Dimension _cacheMaxWidthSize = null; /** * @param cssfigure @@ -53,7 +52,6 @@ public class CSSPageFlowLayout extends CSSBlockFlowLayout { _pageSizeCacheValues = new Dimension[4]; _pageSize = new Dimension(); _recommendedWidth = 0; - _cacheMaxWidthSize = null; } protected void endBlock() { @@ -96,7 +94,7 @@ public class CSSPageFlowLayout extends CSSBlockFlowLayout { _blockBox._x = 0; } - public int getRecommendedWidth() { + private int getRecommendedWidth() { return _recommendedWidth; } @@ -161,26 +159,4 @@ public class CSSPageFlowLayout extends CSSBlockFlowLayout { } return _pageSizeCacheValues[0]; } - - public Dimension getMaxContentWidthSize(IFigure container) { - if (this._cacheMaxWidthSize == null) { - boolean b = getCalcuatingMaxWidth(); - setCalculatingMaxWidth(true); - - // Flowpage must temporarily layout to determine its preferred size - int oldWidth = getRecommendedWidth(); - setRecommendedWidth(Integer.MAX_VALUE); - container.validate(); - _cacheMaxWidthSize = _pageSize.getExpanded(container.getInsets() - .getWidth(), container.getInsets().getHeight()); - - if (0 != oldWidth) { - setRecommendedWidth(oldWidth); - container.getUpdateManager().addInvalidFigure(container); - } - - setCalculatingMaxWidth(b); - } - return _cacheMaxWidthSize; - } } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSTextFigure.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSTextFigure.java index 9994cbbe5..afb0f46c6 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSTextFigure.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSTextFigure.java @@ -36,6 +36,9 @@ public class CSSTextFigure extends FlowFigure implements ICSSFigure { private List _fragments = new ArrayList(1); + /** + * @param provider + */ public CSSTextFigure(ICSSTextProvider provider) { _provider = provider; this.setLayoutManager(createDefaultFlowLayout()); @@ -69,7 +72,8 @@ public class CSSTextFigure extends FlowFigure implements ICSSFigure { } /** - * @see FlowFigure#createDefaultFlowLayout() + * @return the default flow layout + * */ protected FlowFigureLayout createDefaultFlowLayout() { return new CSSTextLayout(this); @@ -93,6 +97,9 @@ public class CSSTextFigure extends FlowFigure implements ICSSFigure { return getFragments(); } + /** + * @return the text + */ public String getText() { return _provider.getTextData(); } @@ -179,7 +186,7 @@ public class CSSTextFigure extends FlowFigure implements ICSSFigure { * which has closer x coordinate. * * @param relative - * @return + * @return return the offset */ // TODO: refactoring? public int getNewInsertionOffset(Point relative) { @@ -246,6 +253,10 @@ public class CSSTextFigure extends FlowFigure implements ICSSFigure { return -1; } + /** + * @param relative + * @return the insertion offset + */ public int getInsertionOffset(Point relative) { for (int i = 0, n = _fragments.size(); i < n; i++) { TextFragmentBox box = (TextFragmentBox) _fragments.get(i); @@ -264,7 +275,7 @@ public class CSSTextFigure extends FlowFigure implements ICSSFigure { * the returned rectangle will be relative to this text figure. * * @param offset - * @return + * @return the caret position */ public Rectangle calculateCaretPosition(int offset) { // search reverse order, find the latest box that has _offset small than diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSTextLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSTextLayout.java index d452e0dc2..b01c97d71 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSTextLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSTextLayout.java @@ -42,6 +42,9 @@ public class CSSTextLayout extends FlowFigureLayout { // public static final int WORD_WRAP_TRUNCATE = 2; private int _wrappingStyle = WORD_WRAP_HARD; + /** + * @param textfigure + */ public CSSTextLayout(CSSTextFigure textfigure) { super(textfigure); } @@ -149,7 +152,11 @@ public class CSSTextLayout extends FlowFigureLayout { } } - // XXX: maybe should move to TextSupport later. + /** + * @param context + * @return true if should trim leading whitespace + */ + // XXX: maybe should move to TextSupport later. public boolean shouldTrimLeadingWhitespace(FlowContext context) { if (!context.isCurrentLineOccupied()) { return true; diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSWidgetLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSWidgetLayout.java index ef573ee78..8e50123d3 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSWidgetLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CSSWidgetLayout.java @@ -27,6 +27,7 @@ public class CSSWidgetLayout extends CSSBlockFlowLayout implements ICSSPainter { /** * @param flowfigure + * @param provider */ public CSSWidgetLayout(CSSFigure flowfigure, ICSSWidgetProvider provider) { super(flowfigure); @@ -42,6 +43,9 @@ public class CSSWidgetLayout extends CSSBlockFlowLayout implements ICSSPainter { _provider = provider; } + /** + * @return the provider + */ public ICSSWidgetProvider getProvider() { // return ((CSSWidgetFigure)this.getFlowFigure()).getProvider(); return _provider; diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CompositeBox.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CompositeBox.java index 6cce9545a..75d6a0e9f 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CompositeBox.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/CompositeBox.java @@ -80,20 +80,6 @@ public abstract class CompositeBox extends FlowBox { } /** - * Returns the recommended height for this compositebox. - * - * @return - */ - public int getRecommendedHeight() { - return _recommendedHeight; - } - - // public int getInnerTop() { - // validate(); - // return y; - // } - - /** * resets fields before unioning the data from the fragments. */ protected void resetInfo() { @@ -110,6 +96,9 @@ public abstract class CompositeBox extends FlowBox { _recommendedWidth = w; } + /** + * @param h + */ public void setRecommendedHeight(int h) { _recommendedHeight = h; } @@ -129,14 +118,23 @@ public abstract class CompositeBox extends FlowBox { _height = bottom - _y; } + /** + * @return the content width + */ public int getContentWidth() { return getWidth() - getBorderPaddingWidth(); } + /** + * @return the content height + */ public int getContentHeight() { return getHeight() - getBorderPaddingHeight(); } + /** + * @return the recommended content width + */ public int getRecommendedContentWidth() { return Math.max(0, getRecommendedWidth() - getBorderPaddingWidth()); } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/Debug.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/Debug.java index c15f21da0..f83e9017a 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/Debug.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/Debug.java @@ -18,11 +18,23 @@ package org.eclipse.jst.pagedesigner.css2.layout; * @version 1.5 */ public class Debug { + /** + * Debug flag + */ public static final boolean DEBUG_BASELINE = false; + /** + * Debug flag + */ public static final boolean DEBUG_BOX = false; + /** + * Debug flag + */ public static final boolean DEBUG_BORDERPADDING = false; + /** + * Debug flag + */ public static final boolean DEBUG_TEXTBORDER = false; } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/DisplayToLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/DisplayToLayout.java index d67849b11..cefb4de03 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/DisplayToLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/DisplayToLayout.java @@ -24,12 +24,12 @@ import org.eclipse.jst.pagedesigner.css2.property.PositionMeta; /** * @author mengbo */ -public class DisplayToLayout { +public final class DisplayToLayout { /** * @param figure * @param display * @param old - * @return + * @return the layout */ public static CSSLayout displayToLayout(CSSFigure figure, String display, LayoutManager old) { @@ -75,10 +75,8 @@ public class DisplayToLayout { } /** - * @param figure - * @param display - * @param old - * @return + * @param display + * @return true if is inline */ public static boolean isInline(String display) { return "inline".equalsIgnoreCase(display) //$NON-NLS-1$ @@ -87,7 +85,7 @@ public class DisplayToLayout { /** * @param style - * @return + * @return true if is positioned */ public static boolean isPositioned(ICSSStyle style) { Object position = style.getStyleProperty(ICSSPropertyID.ATTR_POSITION); @@ -96,4 +94,9 @@ public class DisplayToLayout { } return true; } + + private DisplayToLayout() + { + // util class, no instantiation + } } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FigureUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FigureUtil.java index 60e3f6fcb..56d775cb9 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FigureUtil.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FigureUtil.java @@ -18,9 +18,13 @@ import org.eclipse.draw2d.geometry.Translatable; * @author mengbo * @version 1.5 */ -public class FigureUtil { - // XXX: - // seemed Figure.translateToRelative is bug? +public final class FigureUtil { + /** + * @param figure + * @param t + */ + // XXX: + // seemed Figure.translateToRelative is bug? public static final void translateToRelative(IFigure figure, Translatable t) { if (figure.getParent() != null) { translateToRelative(figure.getParent(), t); @@ -29,8 +33,12 @@ public class FigureUtil { } } - // XXX: - // seemed Figure.translateToAbsolute is bug? + /** + * @param figure + * @param t + */ + // XXX: + // seemed Figure.translateToAbsolute is bug? public static final void translateToAbsolute(IFigure figure, Translatable t) { if (figure.getParent() != null) { figure.translateToParent(t); @@ -39,4 +47,9 @@ public class FigureUtil { } } + + private FigureUtil() + { + // util class. No instantiation + } } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowBox.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowBox.java index 149fbd9a4..52b376589 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowBox.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowBox.java @@ -17,7 +17,8 @@ import org.eclipse.draw2d.geometry.Rectangle; /** * This class represents the CSS box model. See chapter 8 of CSS2 spec. * - * @see http://www.w3.org/TR/REC-CSS2/box.html + * see http://www.w3.org/TR/REC-CSS2/box.html + * */ public class FlowBox { private Object _verticalAlignData = null; @@ -25,22 +26,22 @@ public class FlowBox { /** * The x location */ - public int _x; + protected int _x; /** * The y location */ - public int _y; + protected int _y; int _width; int _height; - public Insets _marginInsets = new Insets(); + private Insets _marginInsets = new Insets(); - public Insets _borderInsets = new Insets(); + private Insets _borderInsets = new Insets(); - public Insets _paddingInsets = new Insets(); + private Insets _paddingInsets = new Insets(); /** * This method must be called on a block that is completely positioned and @@ -67,6 +68,7 @@ public class FlowBox { return getHeight(); } + /** * By default, a simple FlowBox is all ascent, and no descent. Zero is * returned. @@ -95,10 +97,16 @@ public class FlowBox { return _width; } + /** + * @param w + */ public void setWidth(int w) { _width = w; } + /** + * @param h + */ public void setHeight(int h) { _height = h; } @@ -113,25 +121,31 @@ public class FlowBox { _y = (value - getAscent()); } + /** + * @return the border padding width + */ public int getBorderPaddingWidth() { return _borderInsets.getWidth() + _paddingInsets.getWidth(); } /** - * @return + * @return the border padding height */ public int getBorderPaddingHeight() { return _borderInsets.getHeight() + _paddingInsets.getHeight(); } /** - * @return + * @return the border padding insets */ public Insets getBorderPaddingInsets() { Insets temp = new Insets(_borderInsets); return temp.add(_paddingInsets); } + /** + * @param rect + */ public void setXYWidthHeight(Rectangle rect) { this._x = rect.x; this._y = rect.y; @@ -154,8 +168,63 @@ public class FlowBox { _verticalAlignData = alignData; } + /** + * @return a copy of the rectangle + * TODO: use getCopy() ? + */ public Rectangle getRectangle() { return new Rectangle(this._x, this._y, this.getWidth(), this .getHeight()); } + + /** + * @return the x coordinate + */ + public final int getX() { + return _x; + } + + /** + * @return the y coordinate + */ + public final int getY() { + return _y; + } + + /** + * @param y + */ + protected void setY(int y) + { + _y = y; + } + + /** + * @return the margin insets + */ + public final Insets getMarginInsets() { + return _marginInsets; + } + + final void setMarginInsets(Insets marginInsets) { + _marginInsets = marginInsets; + } + + final Insets getBorderInsets() { + return _borderInsets; + } + + final void setBorderInsets(Insets borderInsets) + { + _borderInsets = borderInsets; + } + + final Insets getPaddingInsets() { + return _paddingInsets; + } + + final void setPaddingInsets(Insets paddingInsets) + { + _paddingInsets = paddingInsets; + } } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowContainerLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowContainerLayout.java index aa17d120a..ca4335365 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowContainerLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowContainerLayout.java @@ -32,7 +32,7 @@ public abstract class FlowContainerLayout extends FlowFigureLayout implements */ protected LineBox _currentLine; - private boolean _calculatingMaxWidth = false; + private boolean _calculatingMaxWidth; /** * @see org.eclipse.jst.pagedesigner.css2.layout.FlowFigureLayout#FlowFigureLayout(FlowFigure) @@ -131,19 +131,11 @@ public abstract class FlowContainerLayout extends FlowFigureLayout implements FlowBox box = (FlowBox) _currentLine.getFragments().get( _currentLine.getFragments().size() - 1); if (box != null) { - return box._marginInsets.right; + return box.getMarginInsets().right; } return 0; } - public void setCalculatingMaxWidth(boolean c) { - _calculatingMaxWidth = c; - } - - public boolean getCalcuatingMaxWidth() { - return _calculatingMaxWidth; - } - /* * (non-Javadoc) * diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowContext.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowContext.java index dbca0dd53..bdd4e5168 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowContext.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowContext.java @@ -49,7 +49,7 @@ public interface FlowContext { * considering the new element's left margin. * * @param topMargin - * @return + * @return the current line */ LineBox getCurrentLine(int topMargin); @@ -66,7 +66,7 @@ public interface FlowContext { boolean isCurrentLineOccupied(); /** - * @return + * @return the last margin right coord */ int getLastMarginRight(); @@ -77,14 +77,14 @@ public interface FlowContext { * block element we don't set the block element's size to be recommended * width. Please see CSSBlockFlowLayout * - * @return + * @return true if is calculating max width */ boolean isCalculatingMaxWidth(); /** * when calculating percentage width, we need the container width * - * @return + * @return container width */ int getContainerWidth(); } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowFigure.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowFigure.java index c610eb8f0..6a910d8ab 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowFigure.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowFigure.java @@ -109,10 +109,6 @@ public abstract class FlowFigure extends Figure { .setOriginalFlowContext(flowContext); } - public void setDisplayString(String s) { - _displayString = s; - } - public String toString() { if (_displayString == null) { @@ -121,10 +117,10 @@ public abstract class FlowFigure extends Figure { return _displayString + " " + getClass().getName(); } - String _displayString; // for debug + private String _displayString; // for debug /** - * @return + * @return the flow context */ public FlowContext getFlowContext() { return ((FlowFigureLayout) getLayoutManager()).getFlowContext(); diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowFigureLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowFigureLayout.java index 3f80478cf..4a7759715 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowFigureLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowFigureLayout.java @@ -15,6 +15,10 @@ import org.eclipse.draw2d.AbstractLayout; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Dimension; +/** + * Layout for flow figures + * + */ public abstract class FlowFigureLayout extends AbstractLayout { /** @@ -94,14 +98,17 @@ public abstract class FlowFigureLayout extends AbstractLayout { _context = flowContext; } - public FlowContext getOriginalFlowContext() { + /** + * @return the original flow context + */ + protected final FlowContext getOriginalFlowContext() { return _context; } /** * get flow context. * - * @return + * @return the flow context */ public FlowContext getFlowContext() { return _context; @@ -112,5 +119,8 @@ public abstract class FlowFigureLayout extends AbstractLayout { return _flowFigure.toString(); } + /** + * Called to dispose the layout + */ abstract public void dispose(); } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowUtilities.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowUtilities.java index 5ebde828b..6cd9e194d 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowUtilities.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/FlowUtilities.java @@ -22,7 +22,7 @@ import org.eclipse.swt.graphics.FontMetrics; * Utility class for FlowFigures. * */ -public class FlowUtilities extends FigureUtilities { +public final class FlowUtilities extends FigureUtilities { /** * Returns the number of characters from the specified String that will fit * in the available amount of space. An average character width can be @@ -61,7 +61,7 @@ public class FlowUtilities extends FigureUtilities { * @param availableWidth * @param avg * @param wrapping - * @return + * @return how much text can fit into */ public static int getTextForSpace(String string, Font font, int availableWidth, float avg, int wrapping) { @@ -205,6 +205,13 @@ public class FlowUtilities extends FigureUtilities { return result; } + /** + * @param string + * @param font + * @param availableWidth + * @param avg + * @return the text width + */ public static int getTextInWidth(String string, Font font, int availableWidth, float avg) { if (string.length() == 0) { @@ -229,7 +236,7 @@ public class FlowUtilities extends FigureUtilities { * * @param s * @param f - * @return + * @return the dimension */ public static Dimension getStringExtents2(String s, Font f) { return new Dimension(getStringDimension(s, f)); @@ -257,4 +264,8 @@ public class FlowUtilities extends FigureUtilities { frag.setWidth(d.width); } + private FlowUtilities() + { + // no instantiation + } } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/ICSSFigure.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/ICSSFigure.java index b0a193562..cecf650e5 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/ICSSFigure.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/ICSSFigure.java @@ -25,14 +25,14 @@ public interface ICSSFigure extends IFigure { * Note, this method is for read only, caller should not change the returned * list and items in the returned list. * - * @return + * @return the list of fragments */ public List getFragmentsForRead(); /** * get the CSSStyle of this CSS figure. * - * @return + * @return the css style */ public ICSSStyle getCSSStyle(); } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/ICSSLayout.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/ICSSLayout.java index 1320103f3..f17c54aa8 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/ICSSLayout.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/ICSSLayout.java @@ -26,7 +26,7 @@ public interface ICSSLayout extends LayoutManager { /** * Each ICSSLayout is dedicated to a single CSSFigure. * - * @return + * @return the figure */ public ICSSFigure getICSSFigure(); diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/LineBox.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/LineBox.java index 5ab842f2f..fcfe8b44b 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/LineBox.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/LineBox.java @@ -18,7 +18,7 @@ import org.eclipse.swt.graphics.FontMetrics; /** * A composite box representing a single line. LineBox calculates its ascent and * descent from the child boxes it contains. Clients can call - * {@link #getAscent()}or {@link#getHeight()}at any time and expect valid + * {@link #getAscent()} at any time and expect valid * values. The child boxes that are added to a line have unspecied locations * until {@link #commit()}is called, at which time the child boxes are layed * out in left-to-right order, and their baselines are all aligned vertically. @@ -78,8 +78,8 @@ public class LineBox extends CompositeBox { int xLocation = _x; for (int i = 0; i < _fragments.size(); i++) { FlowBox block = (FlowBox) _fragments.get(i); - block._x = xLocation + block._marginInsets.left; - xLocation = block._x + block._width + block._marginInsets.right; + block._x = xLocation + block.getMarginInsets().left; + xLocation = block._x + block._width + block.getMarginInsets().right; if (_fragments.size() > 1 && block instanceof TextFragmentBox) { TextFragmentBox textBox = (TextFragmentBox) block; @@ -131,7 +131,7 @@ public class LineBox extends CompositeBox { } } - protected int getVerticalAlignType(FlowBox box) { + private int getVerticalAlignType(FlowBox box) { Object data = box.getVerticalAlignData(); if (data != null) { @@ -278,7 +278,7 @@ public class LineBox extends CompositeBox { } _accumlatedWidth += blockInfo._width - + blockInfo._marginInsets.getWidth(); + + blockInfo.getMarginInsets().getWidth(); if (_accumlatedWidth > _width) { _width = _accumlatedWidth; } @@ -300,6 +300,7 @@ public class LineBox extends CompositeBox { } /** + * @return true if is occupied * @see org.eclipse.draw2d.geometry.Rectangle#isEmpty() */ public boolean isOccupied() { @@ -328,6 +329,9 @@ public class LineBox extends CompositeBox { return true; } + /** + * @return true if is empty string line + */ public boolean isEmptyStringLine() { // if(this.getWidth() == 0) // { @@ -411,4 +415,10 @@ public class LineBox extends CompositeBox { public void setHtmlInitData(Object htmlInitData) { this._htmlInitData = htmlInitData; } + + @Override + public void setY(int y) { + // make set y public + super.setY(y); + } } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/MultiLineLabel.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/MultiLineLabel.java index 4ea41d981..e49872c23 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/MultiLineLabel.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/MultiLineLabel.java @@ -19,6 +19,10 @@ import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; +/** + * A multi-line label + * + */ public class MultiLineLabel extends Label { private static String ELLIPSIS = "..."; //$NON-NLS-1$ @@ -63,7 +67,11 @@ public class MultiLineLabel extends Label { return lines; } - public String getSubStringText(String text) { + /** + * @param text + * @return the substring text + */ + private String getSubStringText(String text) { String subStringText = text; Font currentFont = getFont(); diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/TextFragmentBox.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/TextFragmentBox.java index 80907513f..58776e430 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/TextFragmentBox.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/TextFragmentBox.java @@ -26,7 +26,7 @@ public class TextFragmentBox extends FlowBox { // boolean _truncated; - public boolean _isLastCharWhitespace = false; + /*package*/ boolean _isLastCharWhitespace = false; private String _textData; @@ -76,10 +76,16 @@ public class TextFragmentBox extends FlowBox { _width = w; } + /** + * @return the text data + */ public String getTextData() { return _textData; } + /** + * @param txt + */ public void setTextData(String txt) { _textData = txt; } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/TextLayoutSupport.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/TextLayoutSupport.java index 0a4a35200..65ca4c106 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/TextLayoutSupport.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/TextLayoutSupport.java @@ -73,6 +73,12 @@ public class TextLayoutSupport { /** * this method will create a set of TextFragment. Each fragment will offset * to the original text (whole text for the text figure). + * @param context + * @param text + * @param fragments + * @param font + * @param wrappingStyle + * @param trimLeading */ public static void layoutNormal(FlowContext context, String text, List fragments, Font font, int wrappingStyle, boolean trimLeading) { @@ -147,6 +153,12 @@ public class TextLayoutSupport { } } + /** + * @param context + * @param text + * @param fragments + * @param font + */ public static void layoutNoWrap(FlowContext context, String text, List fragments, Font font) { TextFragmentBox fragment; @@ -187,11 +199,22 @@ public class TextLayoutSupport { return result; } + /** + * @param g + * @param fragments + * @param font + * @param textDecoration + */ public static void paintTextFigure(Graphics g, List fragments, Font font, int textDecoration) { paintTextFigure(g, fragments, font, null, textDecoration); } + /** + * @param g + * @param rect + * @param textDecoration + */ public static void paintTextDecoration(Graphics g, Rectangle rect, int textDecoration) { if ((textDecoration & TextDecorationMeta.UNDERLINE) != 0) { @@ -207,6 +230,13 @@ public class TextLayoutSupport { } } + /** + * @param g + * @param fragments + * @param font + * @param color + * @param textDecoration + */ public static void paintTextFigure(Graphics g, List fragments, Font font, Color color, int textDecoration) { // FIXME: It happens there is problem in this method's parameters. what @@ -359,6 +389,12 @@ public class TextLayoutSupport { } } + /** + * @param textAlign + * @param rect + * @param textWidth + * @return the x value + */ public static int getBeginX(Object textAlign, Rectangle rect, int textWidth) { int x = rect.x; if (textAlign != null) { @@ -383,4 +419,9 @@ public class TextLayoutSupport { } return x; } + + private TextLayoutSupport() + { + // no instantiation + } } diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/WidgetBox.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/WidgetBox.java index 5be873bb9..220d61c5a 100644 --- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/WidgetBox.java +++ b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/css2/layout/WidgetBox.java @@ -27,12 +27,12 @@ public class WidgetBox extends FlowBox { return _ascent; } - public void setAscent(int ascent) { + /*package*/ void setAscent(int ascent) { _ascent = ascent; } /** - * @return + * @return true if supports ascent */ public boolean supportAscent() { return _ascent > 0; |