diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts')
3 files changed, 0 insertions, 574 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/ContainerLayout.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/ContainerLayout.java deleted file mode 100644 index 6209800b93..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/ContainerLayout.java +++ /dev/null @@ -1,219 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.design.layouts; - -import java.util.List; - -import org.eclipse.draw2d.AbstractLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.wst.xsd.ui.internal.design.figures.SpacingFigure; - - -public class ContainerLayout extends AbstractLayout -{ - protected boolean isHorizontal; - protected int spacing = 0; - protected int border = 0; - - public ContainerLayout() - { - this(true, 0); - } - - public ContainerLayout(boolean isHorizontal, int spacing) - { - this.isHorizontal = isHorizontal; - this.spacing = spacing; - } - - public void setHorizontal(boolean isHorizontal) - { - this.isHorizontal = isHorizontal; - } - - public void setSpacing(int spacing) - { - this.spacing = spacing; - } - - public void setBorder(int border) - { - this.border = border; - } - - protected int alignFigure(IFigure parent, IFigure child) - { - return -1; - } - - /** - * Calculates and returns the preferred size of the container - * given as input. - * - * @param figure Figure whose preferred size is required. - * @return The preferred size of the passed Figure. - * @since 2.0 - */ - protected Dimension calculatePreferredSizeHelper(IFigure parent) - { - Dimension preferred = new Dimension(); - List children = parent.getChildren(); - - for (int i=0; i < children.size(); i++) - { - IFigure child = (IFigure)children.get(i); - - Dimension childSize = child.getPreferredSize(); - - if (isHorizontal) - { - preferred.width += childSize.width; - preferred.height = Math.max(preferred.height, childSize.height); - } - else - { - preferred.height += childSize.height; - preferred.width = Math.max(preferred.width, childSize.width); - } - } - - int childrenSize = children.size(); - if (childrenSize > 1) - { - if (isHorizontal) - { - preferred.width += spacing * (childrenSize - 1); - } - else - { - preferred.height += spacing * (childrenSize - 1); - } - } - - preferred.width += border * 2; - preferred.height += border * 2; - preferred.width += parent.getInsets().getWidth(); - preferred.height += parent.getInsets().getHeight(); - - return preferred; - } - - protected Dimension calculatePreferredSize(IFigure parent, int width, int height) - { - Dimension preferred = null; - - // Here we ensure that an unexpanded container is given a size of (0,0) - // -// if (parent instanceof IExpandable) -// { -// IExpandable expandableFigure = (IExpandable)parent; -// if (!expandableFigure.isExpanded()) -// { -// preferred = new Dimension(); -// } -// } - - if (preferred == null) - { - preferred = calculatePreferredSizeHelper(parent); - } - - return preferred; - } - - - protected void adjustLayoutLocation(IFigure parent, Dimension dimension) - { - } - - public void layout(IFigure parent) - { - List children = parent.getChildren(); - - int rx = 0; - Dimension dimension = new Dimension(); - - - for (int i=0; i < children.size(); i++) - { - IFigure child = (IFigure)children.get(i); - Dimension childSize = child.getPreferredSize(); - if (isHorizontal) - { - dimension.height = Math.max(dimension.height, childSize.height); - rx += childSize.width; - } - else - { - dimension.width = Math.max(dimension.width, childSize.width); - } - } - - //dimension.width += parent.getInsets().left; - //dimension.height += parent.getInsets().top; - - if (isHorizontal) - { - dimension.height += border*2; - dimension.width += border; - } - else - { - dimension.width += border*2; - dimension.height += border; - } - adjustLayoutLocation(parent, dimension); - - for (int i=0; i < children.size(); i++) - { - IFigure child = (IFigure)children.get(i); - Dimension childSize = child.getPreferredSize(); - - if (isHorizontal) - { - int y = -1; - - y = alignFigure(parent, child); - - if (y == -1) - { - y = (dimension.height - childSize.height) / 2; - } - - Rectangle rectangle = new Rectangle(dimension.width, y, childSize.width, childSize.height); - rectangle.translate(parent.getClientArea().getLocation()); - - - child.setBounds(rectangle); - dimension.width += childSize.width; - dimension.width += spacing; - - if (child instanceof SpacingFigure) - { - int availableHorizontalSpace = parent.getClientArea().width - rx; - dimension.width += availableHorizontalSpace; - } - } - else - { - Rectangle rectangle = new Rectangle(0, dimension.height, childSize.width, childSize.height); - rectangle.translate(parent.getClientArea().getLocation()); - - - child.setBounds(rectangle); - dimension.height += childSize.height; - dimension.height += spacing; - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/FillLayout.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/FillLayout.java deleted file mode 100644 index 14fe8e5b3d..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/FillLayout.java +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.design.layouts; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.AbstractLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Rectangle; - -public class FillLayout extends AbstractLayout -{ - protected boolean isHorizontal = false; - protected int spacing = 0; - public Dimension min; - - public FillLayout() - { - } - - public FillLayout(int spacing) - { - this.spacing = spacing; - } - - public void setHorizontal(boolean isHorizontal) - { - this.isHorizontal = isHorizontal; - } - - /** - * Calculates and returns the preferred size of the input container. This is - * the size of the largest child of the container, as all other children fit - * into this size. - * - * @param figure - * Container figure for which preferred size is required. - * @return The preferred size of the input figure. - */ - - protected Dimension calculatePreferredSize(IFigure figure, int width, int height) - { - Dimension d = calculatePreferredClientAreaSize(figure); - d.expand(figure.getInsets().getWidth(), figure.getInsets().getHeight()); - d.union(getBorderPreferredSize(figure)); - return d; - } - - protected Dimension calculatePreferredClientAreaSize(IFigure figure) - { - Dimension d = new Dimension(); - List children = figure.getChildren(); - - for (Iterator i = children.iterator(); i.hasNext();) - { - IFigure child = (IFigure) i.next(); - Dimension childSize = child.getPreferredSize(); - - if (isHorizontal) - { - d.width += childSize.width; - d.height = Math.max(childSize.height, d.height); - } - else - { - d.height += childSize.height; - d.width = Math.max(childSize.width, d.width); - } - } - - int childrenSize = children.size(); - if (childrenSize > 0) - { - if (isHorizontal) - { - d.width += spacing * (childrenSize - 1); - } - else - { - d.height += spacing * (childrenSize - 1); - } - } - - if (min != null) - { - d.width = Math.max(d.width, min.width); - d.height = Math.max(d.height, min.height); - } - return d; - } - - /* - * Returns the minimum size required by the input container. This is the size - * of the largest child of the container, as all other children fit into this - * size. - */ - public Dimension getMinimumSize(IFigure figure, int width, int height) - { - Dimension d = new Dimension(); - List children = figure.getChildren(); - IFigure child; - - for (int i = 0; i < children.size(); i++) - { - child = (IFigure) children.get(i); - d.union(child.getMinimumSize()); - } - d.expand(figure.getInsets().getWidth(), figure.getInsets().getHeight()); - return d; - } - - public Dimension getPreferredSize(IFigure figure, int width, int height) - { - return calculatePreferredSize(figure, width, height); - } - - /* - * Lays out the children on top of each other with their sizes equal to that - * of the available paintable area of the input container figure. - */ - public void layout(IFigure figure) - { - Dimension preferredSize = calculatePreferredClientAreaSize(figure); - Rectangle r = figure.getClientArea().getCopy(); - List children = figure.getChildren(); - - int nChildren = children.size(); - int extraHorizontalSpace = r.width - preferredSize.width; - - for (Iterator i = children.iterator(); i.hasNext();) - { - IFigure child = (IFigure) i.next(); - Dimension preferredChildSize = child.getPreferredSize(); - - if (isHorizontal) - { - int w = preferredChildSize.width + (extraHorizontalSpace / nChildren); - child.setBounds(new Rectangle(r.x, r.y, w, Math.max(preferredSize.height, r.height))); - r.x += w + spacing; - } - else - { - child.setBounds(new Rectangle(r.x, r.y, Math.max(preferredSize.width, r.width), preferredChildSize.height)); - r.y += preferredChildSize.height + spacing; - } - } - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/ModelGroupLayout.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/ModelGroupLayout.java deleted file mode 100644 index 69f7b79e9d..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/layouts/ModelGroupLayout.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.design.layouts; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.AbstractLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.wst.xsd.ui.internal.design.figures.ModelGroupFigure; -import org.eclipse.wst.xsd.ui.internal.design.figures.SpacingFigure; - -public class ModelGroupLayout extends AbstractLayout -{ - protected boolean isHorizontal; - protected int spacing = 10; - protected int border = 0; - - public ModelGroupLayout() - { - this(0); - } - - public ModelGroupLayout(boolean isHorizontal) - { - this.isHorizontal = isHorizontal; - } - - public ModelGroupLayout(boolean isHorizontal, int spacing) - { - this.isHorizontal = isHorizontal; - this.spacing = spacing; - } - - public ModelGroupLayout(int spacing) - { - super(); - this.spacing = spacing; - } - - protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) - { - Dimension preferred = new Dimension(); - List children = container.getChildren(); - - for (int i = 0; i < children.size(); i++) - { - IFigure child = (IFigure) children.get(i); - - Dimension childSize = child.getPreferredSize(); - - if (isHorizontal) - { - preferred.width += childSize.width; - preferred.height = Math.max(preferred.height, childSize.height); - } - else - { - preferred.height += childSize.height; - preferred.width = Math.max(preferred.width, childSize.width); - } - } - - int childrenSize = children.size(); - if (childrenSize > 1) - { - if (isHorizontal) - { - preferred.width += spacing * (childrenSize - 1); - } - else - { - preferred.height += spacing * (childrenSize - 1); - } - } - - preferred.width += border * 2; - preferred.height += border * 2; - preferred.width += container.getInsets().getWidth(); - preferred.height += container.getInsets().getHeight(); - - return preferred; - } - - public void layout(IFigure container) - { - List children = container.getChildren(); - - int rx = 0; - Dimension dimension = new Dimension(); - - for (int i = 0; i < children.size(); i++) - { - IFigure child = (IFigure) children.get(i); - Dimension childSize = child.getPreferredSize(); - if (isHorizontal) - { - dimension.height = Math.max(dimension.height, childSize.height); - rx += childSize.width; - } - else - { - dimension.width = Math.max(dimension.width, childSize.width); - } - } - - if (isHorizontal) - { - dimension.height += border * 2; - dimension.width += border; - } - else - { - dimension.width += border * 2; - dimension.height += border; - } - - Rectangle r = container.getClientArea(); - dimension = new Dimension(r.width, r.height); - Point p = new Point(0, 0); - - for (Iterator i = children.iterator(); i.hasNext();) - { - IFigure child = (IFigure) i.next(); - Dimension childSize = child.getPreferredSize(); - - if (isHorizontal) - { - Rectangle rectangle = new Rectangle(p.x, 0, childSize.width, childSize.height); - - // last child - if (!i.hasNext()) - { - rectangle.width = dimension.width - rectangle.x; - } - - if (p.x == 0) - { - rectangle.y = r.height / 2 - childSize.height / 2; - } - else - { - rectangle.y = r.height / 2 - childSize.height / 2; - } - - rectangle.translate(container.getClientArea().getLocation()); - child.setBounds(rectangle); - p.x += childSize.width; - p.x += spacing; - - } - else - { - Rectangle rectangle = new Rectangle(0, p.y, childSize.width, childSize.height); - - if (child instanceof SpacingFigure) - { - rectangle.x = dimension.width + 6; - } - else if (child instanceof ModelGroupFigure) - { - rectangle.width = dimension.width - rectangle.x; - } - else - { - rectangle.width = dimension.width - rectangle.x; - } - - rectangle.translate(container.getClientArea().getLocation()); - child.setBounds(rectangle); - p.y += childSize.height; - p.y += spacing; - } - } - } - - public void setSpacing(int spacing) - { - this.spacing = spacing; - } - - protected int alignFigure(IFigure parent, IFigure child) - { - return -1; - } -} |