aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2013-08-05 08:56:37 (EDT)
committercbrun2013-09-20 04:12:37 (EDT)
commit6bf060c5d4c8e1f589bec89a148af64133c6e22a (patch)
tree4b0d61dab0c3e26bd88438a0afffaf81acc9d05e
parentf3d3b362649cb3333ede6087dcdc4069a32b2409 (diff)
downloadorg.eclipse.nebula-6bf060c5d4c8e1f589bec89a148af64133c6e22a.zip
org.eclipse.nebula-6bf060c5d4c8e1f589bec89a148af64133c6e22a.tar.gz
org.eclipse.nebula-6bf060c5d4c8e1f589bec89a148af64133c6e22a.tar.bz2
[294940] Move package-vis. classes to internal
The Tycho tests were failling because the tests themselves are doing illegal instantiations of instances using a constructor which is not visible. In particular : LayerEntry and GridCell This commit - introduce internal packages - isolates the classes which had a "package" visibility into these internal packages - set x-internal export of these internal packages - enables PDE tooling
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/.project6
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/.settings/org.eclipse.pde.api.tools.prefs97
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/META-INF/MANIFEST.MF6
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/pom.xml2
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntry.java137
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntryIterator.java14
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerPrint.java134
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/RotatePrint.java1
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/SidewaysPrint.java1
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderPrint.java1
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/internal/BorderIterator.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderIterator.java)14
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/internal/BorderPiece.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderPiece.java)9
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridLook.java1
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridCell.java210
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridPrint.java13
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/DefaultGridLookPainter.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridLookPainter.java)52
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/DefaultGridMargins.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridMargins.java)3
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridCellImpl.java159
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridCellIterator.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridCellIterator.java)33
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridIterator.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridIterator.java)136
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridLookPainterPiece.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridLookPainterPiece.java)4
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerEntryImpl.java95
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerEntryIteratorImpl.java48
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerIterator.java125
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/RotatePiece.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/RotatePiece.java)8
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/StyledTextPrint.java1
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPrint.java1
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/internal/TextPiece.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPiece.java)7
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/internal/TextPrintPiece.java (renamed from widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPrintPiece.java)4
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.tests/META-INF/MANIFEST.MF2
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/LayerEntryTest.java18
-rw-r--r--widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/grid/GridCellTest.java14
32 files changed, 841 insertions, 515 deletions
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/.project b/widgets/paperclips/org.eclipse.nebula.paperclips.core/.project
index 925e91e..1bcac1b 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/.project
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/.project
@@ -20,9 +20,15 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/.settings/org.eclipse.pde.api.tools.prefs b/widgets/paperclips/org.eclipse.nebula.paperclips.core/.settings/org.eclipse.pde.api.tools.prefs
new file mode 100644
index 0000000..ddaf320
--- /dev/null
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/.settings/org.eclipse.pde.api.tools.prefs
@@ -0,0 +1,97 @@
+ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error
+ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error
+API_USE_SCAN_FIELD_SEVERITY=Error
+API_USE_SCAN_METHOD_SEVERITY=Error
+API_USE_SCAN_TYPE_SEVERITY=Error
+CLASS_ELEMENT_TYPE_ADDED_METHOD=Error
+CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
+CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error
+CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error
+CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error
+CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error
+CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
+CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error
+ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error
+ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error
+ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+FIELD_ELEMENT_TYPE_ADDED_VALUE=Error
+FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error
+FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
+FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
+FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error
+FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error
+FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error
+FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error
+ILLEGAL_EXTEND=Warning
+ILLEGAL_IMPLEMENT=Warning
+ILLEGAL_INSTANTIATE=Warning
+ILLEGAL_OVERRIDE=Warning
+ILLEGAL_REFERENCE=Warning
+INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error
+INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error
+INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error
+INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+INVALID_JAVADOC_TAG=Ignore
+INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Ignore
+LEAK_EXTEND=Error
+LEAK_FIELD_DECL=Error
+LEAK_IMPLEMENT=Error
+LEAK_METHOD_PARAM=Error
+LEAK_METHOD_RETURN_TYPE=Error
+METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
+METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
+METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
+METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error
+METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+MISSING_EE_DESCRIPTIONS=Warning
+TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
+UNUSED_PROBLEM_FILTERS=Warning
+automatically_removed_unused_problem_filters=false
+eclipse.preferences.version=1
+incompatible_api_component_version=Error
+incompatible_api_component_version_include_major_without_breaking_change=Disabled
+incompatible_api_component_version_include_minor_without_api_change=Disabled
+invalid_since_tag_version=Error
+malformed_since_tag=Error
+missing_since_tag=Error
+report_api_breakage_when_major_version_incremented=Disabled
+report_resolution_errors_api_component=Warning
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/META-INF/MANIFEST.MF b/widgets/paperclips/org.eclipse.nebula.paperclips.core/META-INF/MANIFEST.MF
index 2447fb7..3e169fc 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/META-INF/MANIFEST.MF
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/META-INF/MANIFEST.MF
@@ -2,13 +2,15 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PaperClips Core Plug-in
Bundle-SymbolicName: org.eclipse.nebula.paperclips.core
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Vendor: Matthew Hall and others
Require-Bundle: org.eclipse.swt;bundle-version="[3.2.0,4.0.0)"
Export-Package: org.eclipse.nebula.paperclips.core,
org.eclipse.nebula.paperclips.core.border,
org.eclipse.nebula.paperclips.core.grid,
- org.eclipse.nebula.paperclips.core.internal.util;x-friends:="org.eclipse.nebula.paperclips.tests",
+ org.eclipse.nebula.paperclips.core.grid.internal;x-internal:=true,
+ org.eclipse.nebula.paperclips.core.internal;x-internal:=true,
+ org.eclipse.nebula.paperclips.core.internal.util;x-internal:=true,
org.eclipse.nebula.paperclips.core.page,
org.eclipse.nebula.paperclips.core.text
Bundle-ClassPath: .
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/pom.xml b/widgets/paperclips/org.eclipse.nebula.paperclips.core/pom.xml
index e74f803..0292214 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/pom.xml
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/pom.xml
@@ -13,7 +13,7 @@
<groupId>org.eclipse.nebula</groupId>
<artifactId>org.eclipse.nebula.paperclips.core</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>2.1.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntry.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntry.java
index 7446289..476f7ac 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntry.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntry.java
@@ -1,95 +1,44 @@
-/*
- * Copyright (c) 2007 Matthew Hall 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:
- * Matthew Hall - initial API and implementation
- */
-package org.eclipse.nebula.paperclips.core;
-
-import org.eclipse.nebula.paperclips.core.internal.util.PaperClipsUtil;
-import org.eclipse.nebula.paperclips.core.internal.util.Util;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Device;
-import org.eclipse.swt.graphics.GC;
-
-/**
- * Instances in this class represent an entry in a LayerPrint.
- *
- * @author Matthew Hall
- */
-public class LayerEntry {
- final Print target;
- final int align;
-
- LayerEntry(Print target, int align) {
- Util.notNull(target);
- this.target = target;
- this.align = checkAlign(align);
- }
-
- LayerEntry(LayerEntry that) {
- this.target = that.target;
- this.align = that.align;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + align;
- result = prime * result + ((target == null) ? 0 : target.hashCode());
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- LayerEntry other = (LayerEntry) obj;
- if (align != other.align)
- return false;
- if (target == null) {
- if (other.target != null)
- return false;
- } else if (!target.equals(other.target))
- return false;
- return true;
- }
-
- /**
- * Returns the target print of this entry.
- *
- * @return the target print of this entry.
- */
- public Print getTarget() {
- return target;
- }
-
- /**
- * Returns the horizontal alignment applied to the target.
- *
- * @return the horizontal alignment applied to the target.
- */
- public int getHorizontalAlignment() {
- return align;
- }
-
- private static int checkAlign(int align) {
- return PaperClipsUtil.firstMatch(align, new int[] { SWT.LEFT,
- SWT.CENTER, SWT.RIGHT }, SWT.LEFT);
- }
-
- LayerEntry copy() {
- return new LayerEntry(this);
- }
-
- LayerEntryIterator iterator(Device device, GC gc) {
- return new LayerEntryIterator(this, device, gc);
- }
+/*
+ * Copyright (c) 2006 Matthew Hall 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:
+ * Matthew Hall - initial API and implementation
+ */
+package org.eclipse.nebula.paperclips.core;
+
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.GC;
+
+/**
+ * Instances implementing this interface are representing an entry in a
+ * LayerPrint.
+ *
+ * @author Matthew Hall
+ */
+public interface LayerEntry {
+
+ /**
+ * Returns the target print of this entry.
+ *
+ * @return the target print of this entry.
+ */
+ Print getTarget();
+
+ /**
+ * Returns the horizontal alignment applied to the target.
+ *
+ * @return the horizontal alignment applied to the target.
+ */
+ int getHorizontalAlignment();
+
+ /**
+ * @param device
+ * @param gc
+ * @return
+ */
+ LayerEntryIterator iterator(Device device, GC gc);
} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntryIterator.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntryIterator.java
new file mode 100644
index 0000000..cc8ae65
--- /dev/null
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerEntryIterator.java
@@ -0,0 +1,14 @@
+package org.eclipse.nebula.paperclips.core;
+
+/**
+ *
+ *
+ */
+public interface LayerEntryIterator {
+
+ PrintIterator getTarget();
+
+ int getAlignment();
+
+ LayerEntryIterator copy();
+} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerPrint.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerPrint.java
index 85ff9f5..f5ebb35 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerPrint.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/LayerPrint.java
@@ -11,14 +11,13 @@
package org.eclipse.nebula.paperclips.core;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-import org.eclipse.nebula.paperclips.core.internal.util.PrintSizeStrategy;
+import org.eclipse.nebula.paperclips.core.internal.LayerEntryImpl;
+import org.eclipse.nebula.paperclips.core.internal.LayerIterator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
/**
* A Print which displays its child Prints on top each other.
@@ -48,7 +47,7 @@ public class LayerPrint implements Print {
* @see #DEFAULT_ALIGN
*/
public void add(Print print) {
- entries.add(new LayerEntry(print, DEFAULT_ALIGN));
+ entries.add(new LayerEntryImpl(print, DEFAULT_ALIGN));
}
/**
@@ -61,7 +60,7 @@ public class LayerPrint implements Print {
* SWT.CENTER, or SWT.RIGHT.
*/
public void add(Print print, int align) {
- entries.add(new LayerEntry(print, align));
+ entries.add(new LayerEntryImpl(print, align));
}
public int hashCode() {
@@ -100,128 +99,3 @@ public class LayerPrint implements Print {
return new LayerIterator(this, device, gc);
}
}
-
-class LayerEntryIterator {
- final PrintIterator target;
- final int alignment;
-
- LayerEntryIterator(LayerEntry entry, Device device, GC gc) {
- this.target = entry.target.iterator(device, gc);
- this.alignment = entry.getHorizontalAlignment();
- }
-
- LayerEntryIterator(LayerEntryIterator that) {
- this.target = that.target.copy();
- this.alignment = that.alignment;
- }
-
- LayerEntryIterator copy() {
- return new LayerEntryIterator(this);
- }
-}
-
-class LayerIterator implements PrintIterator {
- LayerEntryIterator[] entries;
-
- LayerIterator(LayerPrint print, Device device, GC gc) {
- entries = new LayerEntryIterator[print.entries.size()];
- LayerEntry[] e = print.getEntries();
- for (int i = 0; i < entries.length; i++) {
- entries[i] = e[i].iterator(device, gc);
- }
- }
-
- LayerIterator(LayerIterator that) {
- this.entries = (LayerEntryIterator[]) that.entries.clone();
- for (int i = 0; i < entries.length; i++)
- if (entries[i].target.hasNext())
- entries[i] = entries[i].copy();
- }
-
- public boolean hasNext() {
- for (int i = 0; i < entries.length; i++)
- if (entries[i].target.hasNext())
- return true;
- return false;
- }
-
- public PrintPiece next(int width, int height) {
- if (!hasNext())
- PaperClips.error("No more content"); //$NON-NLS-1$
-
- PrintPiece[] pieces = nextPieces(width, height);
- if (pieces == null)
- return null;
-
- CompositeEntry[] entries = new CompositeEntry[pieces.length];
- for (int i = 0; i < entries.length; i++) {
- PrintPiece piece = pieces[i];
- int offset = getHorzAlignmentOffset(this.entries[i].alignment,
- piece.getSize().x, width);
- entries[i] = new CompositeEntry(piece, new Point(offset, 0));
- }
- return new CompositePiece(entries);
- }
-
- private PrintPiece[] nextPieces(int width, int height) {
- LayerEntryIterator[] entries = (LayerEntryIterator[]) this.entries
- .clone();
-
- List pieces = new ArrayList();
- for (int i = 0; i < entries.length; i++) {
- LayerEntryIterator entry = entries[i];
- if (entry.target.hasNext()) {
- PrintPiece piece = PaperClips.next(entry.target, width, height);
-
- if (piece == null) {
- for (Iterator iter = pieces.iterator(); iter.hasNext();)
- ((PrintPiece) iter.next()).dispose();
- return null;
- }
- pieces.add(piece);
- }
- }
-
- // Replace instance entries with the entries that were just consumed.
- this.entries = entries;
-
- return (PrintPiece[]) pieces.toArray(new PrintPiece[pieces.size()]);
- }
-
- private int getHorzAlignmentOffset(int alignment, int pieceWidth,
- int totalWidth) {
- int offset = 0;
- switch (alignment) {
- case SWT.CENTER:
- offset = (totalWidth - pieceWidth) / 2;
- break;
- case SWT.RIGHT:
- offset = totalWidth - pieceWidth;
- break;
- }
- return offset;
- }
-
- Point computeSize(PrintSizeStrategy strategy) {
- Point size = new Point(0, 0);
- for (int i = 0; i < entries.length; i++) {
- LayerEntryIterator entry = entries[i];
- Point entrySize = strategy.computeSize(entry.target);
- size.x = Math.max(size.x, entrySize.x);
- size.y = Math.max(size.y, entrySize.y);
- }
- return size;
- }
-
- public Point minimumSize() {
- return computeSize(PrintSizeStrategy.MINIMUM);
- }
-
- public Point preferredSize() {
- return computeSize(PrintSizeStrategy.PREFERRED);
- }
-
- public PrintIterator copy() {
- return new LayerIterator(this);
- }
-} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/RotatePrint.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/RotatePrint.java
index 283f357..11d642f 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/RotatePrint.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/RotatePrint.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.nebula.paperclips.core;
+import org.eclipse.nebula.paperclips.core.internal.RotatePiece;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/SidewaysPrint.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/SidewaysPrint.java
index 0b89ba1..e193cab 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/SidewaysPrint.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/SidewaysPrint.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.nebula.paperclips.core;
+import org.eclipse.nebula.paperclips.core.internal.RotatePiece;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderPrint.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderPrint.java
index 34a0276..1a3ed60 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderPrint.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderPrint.java
@@ -12,6 +12,7 @@ package org.eclipse.nebula.paperclips.core.border;
import org.eclipse.nebula.paperclips.core.Print;
import org.eclipse.nebula.paperclips.core.PrintIterator;
+import org.eclipse.nebula.paperclips.core.border.internal.BorderIterator;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderIterator.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/internal/BorderIterator.java
index 4d80e3c..5dbab9d 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderIterator.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/internal/BorderIterator.java
@@ -9,29 +9,31 @@
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.border;
+package org.eclipse.nebula.paperclips.core.border.internal;
import org.eclipse.nebula.paperclips.core.PaperClips;
import org.eclipse.nebula.paperclips.core.PrintIterator;
import org.eclipse.nebula.paperclips.core.PrintPiece;
+import org.eclipse.nebula.paperclips.core.border.BorderPainter;
+import org.eclipse.nebula.paperclips.core.border.BorderPrint;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
-class BorderIterator implements PrintIterator {
+public class BorderIterator implements PrintIterator {
private final BorderPainter border;
private PrintIterator target;
private boolean opened;
- BorderIterator(BorderPrint print, Device device, GC gc) {
- this.border = print.border.createPainter(device, gc);
+ public BorderIterator(BorderPrint print, Device device, GC gc) {
+ this.border = print.getBorder().createPainter(device, gc);
- this.target = print.target.iterator(device, gc);
+ this.target = print.getTarget().iterator(device, gc);
this.opened = false;
}
- BorderIterator(BorderIterator that) {
+ public BorderIterator(BorderIterator that) {
this.border = that.border;
this.target = that.target.copy();
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderPiece.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/internal/BorderPiece.java
index 581ba3b..20f189e 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/BorderPiece.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/border/internal/BorderPiece.java
@@ -9,14 +9,15 @@
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.border;
+package org.eclipse.nebula.paperclips.core.border.internal;
import org.eclipse.nebula.paperclips.core.PrintPiece;
+import org.eclipse.nebula.paperclips.core.border.BorderPainter;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
-class BorderPiece implements PrintPiece {
+public class BorderPiece implements PrintPiece {
private final PrintPiece target;
private final BorderPainter border;
@@ -27,8 +28,8 @@ class BorderPiece implements PrintPiece {
private final Point size;
- BorderPiece(PrintPiece target, BorderPainter border, boolean topOpen,
- boolean bottomOpen) {
+ public BorderPiece(PrintPiece target, BorderPainter border,
+ boolean topOpen, boolean bottomOpen) {
Util.notNull(target, border);
this.target = target;
this.border = border;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridLook.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridLook.java
index 6e8a249..6b721c3 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridLook.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridLook.java
@@ -12,6 +12,7 @@ package org.eclipse.nebula.paperclips.core.grid;
import org.eclipse.nebula.paperclips.core.border.Border;
import org.eclipse.nebula.paperclips.core.border.GapBorder;
+import org.eclipse.nebula.paperclips.core.grid.internal.DefaultGridLookPainter;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridCell.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridCell.java
index 05409c5..6041679 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridCell.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridCell.java
@@ -1,152 +1,60 @@
-/*
- * Copyright (c) 2007 Matthew Hall 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:
- * Matthew Hall - initial API and implementation
- */
-package org.eclipse.nebula.paperclips.core.grid;
-
-import org.eclipse.nebula.paperclips.core.PaperClips;
-import org.eclipse.nebula.paperclips.core.Print;
-import org.eclipse.nebula.paperclips.core.internal.util.PaperClipsUtil;
-import org.eclipse.nebula.paperclips.core.internal.util.Util;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Device;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * Instances of this class represent a single cell in a GridPrint.
- *
- * @author Matthew Hall
- */
-public class GridCell {
- final int hAlignment;
- final int vAlignment;
- final Print target;
- final int colspan;
-
- GridCell(int hAlignment, int vAlignment, Print target, int colspan) {
- Util.notNull(target);
- this.hAlignment = checkHorizontalAlignment(hAlignment);
- this.vAlignment = checkVerticalAlignment(vAlignment);
- this.target = target;
- this.colspan = checkColspan(colspan);
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + colspan;
- result = prime * result + hAlignment;
- result = prime * result + ((target == null) ? 0 : target.hashCode());
- result = prime * result + vAlignment;
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- GridCell other = (GridCell) obj;
- if (colspan != other.colspan)
- return false;
- if (hAlignment != other.hAlignment)
- return false;
- if (target == null) {
- if (other.target != null)
- return false;
- } else if (!target.equals(other.target))
- return false;
- if (vAlignment != other.vAlignment)
- return false;
- return true;
- }
-
- /**
- * Returns a Point representing the horizontal and vertical alignment
- * applied to the cell's content.
- *
- * @return a Point representing the horizontal and vertical alignment
- * applied to the cell's content.
- */
- public Point getAlignment() {
- return new Point(hAlignment, vAlignment);
- }
-
- /**
- * Returns the horizontal alignment applied to the cell content.
- *
- * @return the horizontal alignment applied to the cell content.
- */
- public int getHorizontalAlignment() {
- return hAlignment;
- }
-
- /**
- * Returns the vertical alignment applied to the cell content.
- *
- * @return the vertical alignment applied to the cell content.
- */
- public int getVerticalAlignment() {
- return vAlignment;
- }
-
- /**
- * Returns the content print of the cell.
- *
- * @return the content print of the cell.
- */
- public Print getContent() {
- return target;
- }
-
- /**
- * Returns the number of columns this cell spans across.
- *
- * @return the number of columns this cell spans across.
- */
- public int getColSpan() {
- return colspan;
- }
-
- private static int checkHorizontalAlignment(int hAlignment) {
- hAlignment = PaperClipsUtil.firstMatch(hAlignment, new int[] {
- SWT.DEFAULT, SWT.LEFT, SWT.CENTER, SWT.RIGHT }, 0);
- if (hAlignment == 0)
- PaperClips
- .error(
- SWT.ERROR_INVALID_ARGUMENT,
- "Alignment argument must be one of SWT.LEFT, SWT.CENTER, SWT.RIGHT, or SWT.DEFAULT"); //$NON-NLS-1$
- return hAlignment;
- }
-
- private static int checkVerticalAlignment(int vAlignment) {
- vAlignment = PaperClipsUtil.firstMatch(vAlignment, new int[] {
- SWT.DEFAULT, SWT.TOP, SWT.CENTER, SWT.BOTTOM, SWT.FILL }, 0);
- if (vAlignment == 0)
- PaperClips
- .error(
- SWT.ERROR_INVALID_ARGUMENT,
- "Alignment argument must be one of SWT.TOP, SWT.CENTER, SWT.BOTTOM, SWT.DEFAULT, or SWT.FILL"); //$NON-NLS-1$
- return vAlignment;
- }
-
- private int checkColspan(int colspan) {
- if (colspan <= 0 && colspan != GridPrint.REMAINDER)
- PaperClips.error(SWT.ERROR_INVALID_ARGUMENT,
- "colspan must be a positive number or GridPrint.REMAINDER"); //$NON-NLS-1$
- return colspan;
- }
-
- GridCellIterator iterator(Device device, GC gc) {
- return new GridCellIterator(this, device, gc);
- }
+/*
+ * Copyright (c) 2006 Matthew Hall 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:
+ * Matthew Hall - initial API and implementation
+ */
+package org.eclipse.nebula.paperclips.core.grid;
+
+import org.eclipse.nebula.paperclips.core.Print;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * Instances of this interface represent a single cell in a GridPrint.
+ *
+ * @author Matthew Hall
+ */
+public interface GridCell {
+
+ /**
+ * Returns a Point representing the horizontal and vertical alignment
+ * applied to the cell's content.
+ *
+ * @return a Point representing the horizontal and vertical alignment
+ * applied to the cell's content.
+ */
+ Point getAlignment();
+
+ /**
+ * Returns the horizontal alignment applied to the cell content.
+ *
+ * @return the horizontal alignment applied to the cell content.
+ */
+ int getHorizontalAlignment();
+
+ /**
+ * Returns the vertical alignment applied to the cell content.
+ *
+ * @return the vertical alignment applied to the cell content.
+ */
+ int getVerticalAlignment();
+
+ /**
+ * Returns the content print of the cell.
+ *
+ * @return the content print of the cell.
+ */
+ Print getContent();
+
+ /**
+ * Returns the number of columns this cell spans across.
+ *
+ * @return the number of columns this cell spans across.
+ */
+ int getColSpan();
+
} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridPrint.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridPrint.java
index b9a185a..0cd8130 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridPrint.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridPrint.java
@@ -17,6 +17,8 @@ import java.util.List;
import org.eclipse.nebula.paperclips.core.PaperClips;
import org.eclipse.nebula.paperclips.core.Print;
import org.eclipse.nebula.paperclips.core.PrintIterator;
+import org.eclipse.nebula.paperclips.core.grid.internal.GridCellImpl;
+import org.eclipse.nebula.paperclips.core.grid.internal.GridIterator;
import org.eclipse.nebula.paperclips.core.internal.util.PaperClipsUtil;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
import org.eclipse.swt.SWT;
@@ -442,7 +444,7 @@ public final class GridPrint implements Print {
int col = 0;
for (int cellI = 0; cellI < row.size(); cellI++) {
GridCell cell = (GridCell) row.get(cellI);
- col += cell.colspan;
+ col += cell.getColSpan();
// Adjust the cell which extends through the insert point, or
// whose right side touches the insert
@@ -455,9 +457,10 @@ public final class GridPrint implements Print {
// right side touches insert point but is not the final cell.
(col == index && (rowI + 1 < rows.size() || cellI + 1 < row
.size()))) {
- row
- .set(cellI, new GridCell(cell.hAlignment,
- cell.vAlignment, cell.target, cell.colspan
+ row.set(cellI,
+ new GridCellImpl(cell.getHorizontalAlignment(),
+ cell.getVerticalAlignment(), cell
+ .getContent(), cell.getColSpan()
+ count));
break;
}
@@ -892,7 +895,7 @@ public final class GridPrint implements Print {
List row = getOpenRow(rows, startColumn);
colspan = convertRemainderToExplicitColSpan(startColumn, colspan);
- GridCell cell = new GridCell(hAlignment, vAlignment, cellContents,
+ GridCell cell = new GridCellImpl(hAlignment, vAlignment, cellContents,
colspan);
row.add(cell);
startColumn += colspan;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridLookPainter.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/DefaultGridLookPainter.java
index a4906e2..e210d7d 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridLookPainter.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/DefaultGridLookPainter.java
@@ -9,9 +9,13 @@
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.grid;
+package org.eclipse.nebula.paperclips.core.grid.internal;
import org.eclipse.nebula.paperclips.core.border.BorderPainter;
+import org.eclipse.nebula.paperclips.core.grid.BasicGridLookPainter;
+import org.eclipse.nebula.paperclips.core.grid.CellBackgroundProvider;
+import org.eclipse.nebula.paperclips.core.grid.DefaultGridLook;
+import org.eclipse.nebula.paperclips.core.grid.GridMargins;
import org.eclipse.nebula.paperclips.core.internal.util.ResourcePool;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
@@ -20,7 +24,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
-class DefaultGridLookPainter extends BasicGridLookPainter {
+public class DefaultGridLookPainter extends BasicGridLookPainter {
private final Rectangle cellPadding;
private final BorderPainter border;
@@ -33,52 +37,52 @@ class DefaultGridLookPainter extends BasicGridLookPainter {
private final ResourcePool resources;
- DefaultGridLookPainter(DefaultGridLook look, Device device, GC gc) {
+ public DefaultGridLookPainter(DefaultGridLook look, Device device, GC gc) {
super(device);
Point dpi = device.getDPI();
- this.border = look.cellBorder.createPainter(device, gc);
+ this.border = look.getCellBorder().createPainter(device, gc);
this.cellPadding = calculateCellPadding(look, dpi);
this.margins = calculateGridMargins(look, dpi);
- this.bodyBackground = look.bodyBackgroundProvider;
- this.headerBackground = look.headerBackgroundProvider;
- this.footerBackground = look.footerBackgroundProvider;
+ this.bodyBackground = look.getBodyBackgroundProvider();
+ this.headerBackground = look.getHeaderBackgroundProvider();
+ this.footerBackground = look.getFooterBackgroundProvider();
this.resources = ResourcePool.forDevice(device);
}
private Rectangle calculateCellPadding(DefaultGridLook look, Point dpi) {
- Rectangle cellPadding = new Rectangle(look.cellPadding.x * dpi.x / 72,
- look.cellPadding.y * dpi.y / 72, look.cellPadding.width * dpi.x
- / 72, look.cellPadding.height * dpi.y / 72);
+ Rectangle cellPadding = new Rectangle(look.getCellPadding().x * dpi.x
+ / 72, look.getCellPadding().y * dpi.y / 72,
+ look.getCellPadding().width * dpi.x / 72,
+ look.getCellPadding().height * dpi.y / 72);
return cellPadding;
}
private GridMargins calculateGridMargins(DefaultGridLook look, Point dpi) {
final Point cellSpacing = new Point(
border.getWidth()
- + (look.cellSpacing.x == DefaultGridLook.BORDER_OVERLAP ? -border
- .getOverlap().x
- : dpi.x * look.cellSpacing.x / 72),
+ + (look.getCellSpacing().x == DefaultGridLook.BORDER_OVERLAP ? -border.getOverlap().x
+ : dpi.x * look.getCellSpacing().x / 72),
border.getHeight(false, false)
- + (look.cellSpacing.y == DefaultGridLook.BORDER_OVERLAP ? -border
- .getOverlap().y
- : dpi.y * look.cellSpacing.y / 72));
+ + (look.getCellSpacing().y == DefaultGridLook.BORDER_OVERLAP ? -border
+ .getOverlap().y : dpi.y
+ * look.getCellSpacing().y / 72));
final int headerClosedSpacing = border.getHeight(false, false)
- + (look.headerGap == DefaultGridLook.BORDER_OVERLAP ? -border
- .getOverlap().y : dpi.y * look.headerGap / 72);
+ + (look.getHeaderGap() == DefaultGridLook.BORDER_OVERLAP ? -border
+ .getOverlap().y : dpi.y * look.getHeaderGap() / 72);
final int headerOpenSpacing = border.getHeight(true, false)
- + (look.headerGap == DefaultGridLook.BORDER_OVERLAP ? dpi.y / 72
- : dpi.y * look.headerGap / 72);
+ + (look.getHeaderGap() == DefaultGridLook.BORDER_OVERLAP ? dpi.y / 72
+ : dpi.y * look.getHeaderGap() / 72);
final int footerClosedSpacing = border.getHeight(false, false)
- + (look.footerGap == DefaultGridLook.BORDER_OVERLAP ? -border
- .getOverlap().y : dpi.y * look.footerGap / 72);
+ + (look.getFooterGap() == DefaultGridLook.BORDER_OVERLAP ? -border
+ .getOverlap().y : dpi.y * look.getFooterGap() / 72);
final int footerOpenSpacing = border.getHeight(false, true)
- + (look.footerGap == DefaultGridLook.BORDER_OVERLAP ? dpi.y / 72
- : dpi.y * look.footerGap / 72);
+ + (look.getFooterGap() == DefaultGridLook.BORDER_OVERLAP ? dpi.y / 72
+ : dpi.y * look.getFooterGap() / 72);
return new DefaultGridMargins(border, cellSpacing, cellPadding,
headerClosedSpacing, headerOpenSpacing, footerClosedSpacing,
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridMargins.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/DefaultGridMargins.java
index c2a44e9..20b9fe5 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/DefaultGridMargins.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/DefaultGridMargins.java
@@ -9,9 +9,10 @@
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.grid;
+package org.eclipse.nebula.paperclips.core.grid.internal;
import org.eclipse.nebula.paperclips.core.border.BorderPainter;
+import org.eclipse.nebula.paperclips.core.grid.GridMargins;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridCellImpl.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridCellImpl.java
new file mode 100644
index 0000000..77d4794
--- /dev/null
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridCellImpl.java
@@ -0,0 +1,159 @@
+package org.eclipse.nebula.paperclips.core.grid.internal;
+
+import org.eclipse.nebula.paperclips.core.PaperClips;
+import org.eclipse.nebula.paperclips.core.Print;
+import org.eclipse.nebula.paperclips.core.grid.GridCell;
+import org.eclipse.nebula.paperclips.core.grid.GridPrint;
+import org.eclipse.nebula.paperclips.core.internal.util.PaperClipsUtil;
+import org.eclipse.nebula.paperclips.core.internal.util.Util;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * Instances of this class represent a single cell in a GridPrint.
+ *
+ * @author Matthew Hall
+ */
+public class GridCellImpl implements GridCell {
+
+ private final int hAlignment;
+ private final int vAlignment;
+ private final Print target;
+ private final int colspan;
+
+ /**
+ * This constructor is only here for compatibility reasons and is not
+ * intented to be used by clients.
+ *
+ * @param hAlignment
+ * the horizontal alignment.
+ * @param vAlignment
+ * the vertical alignment.
+ * @param target
+ * the target of the cell.
+ * @param colspan
+ * the number of columns this cell spans across.
+ */
+
+ public GridCellImpl(int hAlignment, int vAlignment, Print target,
+ int colspan) {
+ Util.notNull(target);
+ this.hAlignment = checkHorizontalAlignment(hAlignment);
+ this.vAlignment = checkVerticalAlignment(vAlignment);
+ this.target = target;
+ this.colspan = checkColspan(colspan);
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + colspan;
+ result = prime * result + hAlignment;
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ result = prime * result + vAlignment;
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ GridCell other = (GridCell) obj;
+ if (colspan != other.getColSpan())
+ return false;
+ if (hAlignment != other.getHorizontalAlignment())
+ return false;
+ if (target == null) {
+ if (other.getContent() != null)
+ return false;
+ } else if (!target.equals(other.getContent()))
+ return false;
+ if (vAlignment != other.getVerticalAlignment())
+ return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.nebula.paperclips.core.grid.GridCell#getAlignment()
+ */
+ public Point getAlignment() {
+ return new Point(hAlignment, vAlignment);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.nebula.paperclips.core.grid.GridCell#getHorizontalAlignment()
+ */
+ public int getHorizontalAlignment() {
+ return hAlignment;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.nebula.paperclips.core.grid.GridCell#getVerticalAlignment()
+ */
+ public int getVerticalAlignment() {
+ return vAlignment;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.nebula.paperclips.core.grid.GridCell#getContent()
+ */
+ public Print getContent() {
+ return target;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.nebula.paperclips.core.grid.GridCell#getColSpan()
+ */
+ public int getColSpan() {
+ return colspan;
+ }
+
+ private static int checkHorizontalAlignment(int hAlignment) {
+ hAlignment = PaperClipsUtil.firstMatch(hAlignment, new int[] {
+ SWT.DEFAULT, SWT.LEFT, SWT.CENTER, SWT.RIGHT }, 0);
+ if (hAlignment == 0)
+ PaperClips
+ .error(SWT.ERROR_INVALID_ARGUMENT,
+ "Alignment argument must be one of SWT.LEFT, SWT.CENTER, SWT.RIGHT, or SWT.DEFAULT"); //$NON-NLS-1$
+ return hAlignment;
+ }
+
+ private static int checkVerticalAlignment(int vAlignment) {
+ vAlignment = PaperClipsUtil.firstMatch(vAlignment, new int[] {
+ SWT.DEFAULT, SWT.TOP, SWT.CENTER, SWT.BOTTOM, SWT.FILL }, 0);
+ if (vAlignment == 0)
+ PaperClips
+ .error(SWT.ERROR_INVALID_ARGUMENT,
+ "Alignment argument must be one of SWT.TOP, SWT.CENTER, SWT.BOTTOM, SWT.DEFAULT, or SWT.FILL"); //$NON-NLS-1$
+ return vAlignment;
+ }
+
+ private int checkColspan(int colspan) {
+ if (colspan <= 0 && colspan != GridPrint.REMAINDER)
+ PaperClips.error(SWT.ERROR_INVALID_ARGUMENT,
+ "colspan must be a positive number or GridPrint.REMAINDER"); //$NON-NLS-1$
+ return colspan;
+ }
+
+ public GridCellIterator iterator(Device device, GC gc) {
+ return new GridCellIterator(this, device, gc);
+ }
+
+} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridCellIterator.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridCellIterator.java
index 9cd6dc1..6c6ecf0 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridCellIterator.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridCellIterator.java
@@ -8,23 +8,24 @@
* Contributors:
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.grid;
+package org.eclipse.nebula.paperclips.core.grid.internal;
import org.eclipse.nebula.paperclips.core.PrintIterator;
+import org.eclipse.nebula.paperclips.core.grid.GridCell;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
-class GridCellIterator {
+public class GridCellIterator {
final int hAlignment;
final int vAlignment;
final PrintIterator target;
final int colspan;
- GridCellIterator(GridCell cell, Device device, GC gc) {
- this.hAlignment = cell.hAlignment;
- this.vAlignment = cell.vAlignment;
- this.target = cell.target.iterator(device, gc);
- this.colspan = cell.colspan;
+ public GridCellIterator(GridCell cell, Device device, GC gc) {
+ this.hAlignment = cell.getHorizontalAlignment();
+ this.vAlignment = cell.getVerticalAlignment();
+ this.target = cell.getContent().iterator(device, gc);
+ this.colspan = cell.getColSpan();
}
private GridCellIterator(GridCellIterator that) {
@@ -34,7 +35,23 @@ class GridCellIterator {
this.colspan = that.colspan;
}
- GridCellIterator copy() {
+ public int getHorizontalAlignment() {
+ return hAlignment;
+ }
+
+ public int getVerticalAlignment() {
+ return vAlignment;
+ }
+
+ public PrintIterator getTarget() {
+ return target;
+ }
+
+ public int getColspan() {
+ return colspan;
+ }
+
+ public GridCellIterator copy() {
return new GridCellIterator(this);
}
} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridIterator.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridIterator.java
index 896abc8..fd20360 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridIterator.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridIterator.java
@@ -8,7 +8,7 @@
* Contributors:
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.grid;
+package org.eclipse.nebula.paperclips.core.grid.internal;
import java.util.ArrayList;
import java.util.Iterator;
@@ -19,6 +19,11 @@ import org.eclipse.nebula.paperclips.core.CompositePiece;
import org.eclipse.nebula.paperclips.core.PaperClips;
import org.eclipse.nebula.paperclips.core.PrintIterator;
import org.eclipse.nebula.paperclips.core.PrintPiece;
+import org.eclipse.nebula.paperclips.core.grid.GridCell;
+import org.eclipse.nebula.paperclips.core.grid.GridColumn;
+import org.eclipse.nebula.paperclips.core.grid.GridLookPainter;
+import org.eclipse.nebula.paperclips.core.grid.GridMargins;
+import org.eclipse.nebula.paperclips.core.grid.GridPrint;
import org.eclipse.nebula.paperclips.core.internal.util.PaperClipsUtil;
import org.eclipse.nebula.paperclips.core.internal.util.PrintSizeStrategy;
import org.eclipse.swt.SWT;
@@ -26,7 +31,7 @@ import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
-class GridIterator implements PrintIterator {
+public class GridIterator implements PrintIterator {
final Device device;
final Point dpi;
@@ -54,19 +59,19 @@ class GridIterator implements PrintIterator {
// current row.
private boolean rowStarted;
- GridIterator(GridPrint grid, Device device, GC gc) {
+ public GridIterator(GridPrint grid, Device device, GC gc) {
this.device = device;
this.dpi = device.getDPI();
-
- this.columns = (GridColumn[]) grid.columns
- .toArray(new GridColumn[grid.columns.size()]);
+ this.columns = new GridColumn[grid.getColumns().length];
+ System.arraycopy(grid.getColumns(), 0, this.columns, 0,
+ grid.getColumns().length);
this.columnGroups = grid.getColumnGroups();
- this.header = createGridCellIterators(grid.header, device, gc);
- this.body = createGridCellIterators(grid.body, device, gc);
- this.footer = createGridCellIterators(grid.footer, device, gc);
+ this.header = createGridCellIterators(grid.getHeaderCells(), device, gc);
+ this.body = createGridCellIterators(grid.getBodyCells(), device, gc);
+ this.footer = createGridCellIterators(grid.getFooterCells(), device, gc);
- this.cellClippingEnabled = grid.cellClippingEnabled;
+ this.cellClippingEnabled = grid.isCellClippingEnabled();
this.look = grid.getLook().getPainter(device, gc);
@@ -82,20 +87,20 @@ class GridIterator implements PrintIterator {
rowStarted = false;
}
- private static GridCellIterator[][] createGridCellIterators(List gridCells,
- Device device, GC gc) {
- GridCellIterator[][] result = new GridCellIterator[gridCells.size()][];
+ private static GridCellIterator[][] createGridCellIterators(
+ GridCell[][] gridCells, Device device, GC gc) {
+ GridCellIterator[][] result = new GridCellIterator[gridCells.length][];
for (int rowIndex = 0; rowIndex < result.length; rowIndex++)
- result[rowIndex] = createRowCellIterators((List) gridCells
- .get(rowIndex), device, gc);
+ result[rowIndex] = createRowCellIterators(gridCells[rowIndex],
+ device, gc);
return result;
}
- private static GridCellIterator[] createRowCellIterators(List rowCells,
- Device device, GC gc) {
- GridCellIterator[] result = new GridCellIterator[rowCells.size()];
- for (int cellIndex = 0; cellIndex < rowCells.size(); cellIndex++)
- result[cellIndex] = ((GridCell) rowCells.get(cellIndex)).iterator(
+ private static GridCellIterator[] createRowCellIterators(
+ GridCell[] rowCells, Device device, GC gc) {
+ GridCellIterator[] result = new GridCellIterator[rowCells.length];
+ for (int cellIndex = 0; cellIndex < rowCells.length; cellIndex++)
+ result[cellIndex] = ((GridCellImpl) rowCells[cellIndex]).iterator(
device, gc);
return result;
}
@@ -148,9 +153,9 @@ class GridIterator implements PrintIterator {
private int computeCellWidth(GridCellIterator entry, GridColumn col,
PrintSizeStrategy strategy) {
if (col.size == SWT.DEFAULT)
- return strategy.computeSize(entry.target).x;
+ return strategy.computeSize(entry.getTarget()).x;
if (col.size == GridPrint.PREFERRED)
- return entry.target.preferredSize().x;
+ return entry.getTarget().preferredSize().x;
return Math.round(col.size * device.getDPI().x / 72f);
}
@@ -235,14 +240,14 @@ class GridIterator implements PrintIterator {
int columnIndex = 0;
for (int cellIndex = 0; cellIndex < row.length; cellIndex++) {
GridCellIterator entry = row[cellIndex];
- int colspan = entry.colspan;
+ int colspan = entry.getColspan();
if (colspan > 1) {
int currentWidth = PaperClipsUtil.sum(colSizes,
columnIndex, colspan);
// Subtract column spacing so the weighted distribution of
// extra width stays proportional.
- int minimumWidth = strategy.computeSize(entry.target).x
+ int minimumWidth = strategy.computeSize(entry.getTarget()).x
- horizontalSpacing * (colspan - 1);
if (currentWidth < minimumWidth) {
@@ -305,11 +310,11 @@ class GridIterator implements PrintIterator {
GridCellIterator entry = row[cellIndex];
// ignore explicitly sized cols
- if (entry.colspan == 1 && !isExplicitSize(columns[col])) {
- colSizes[col] = Math.max(colSizes[col], computeCellWidth(
- entry, columns[col], strategy));
+ if (entry.getColspan() == 1 && !isExplicitSize(columns[col])) {
+ colSizes[col] = Math.max(colSizes[col],
+ computeCellWidth(entry, columns[col], strategy));
}
- col += entry.colspan;
+ col += entry.getColspan();
}
}
}
@@ -433,16 +438,16 @@ class GridIterator implements PrintIterator {
if (header.length > 0)
height += computeHeaderHeight(margins, strategy);
else
- height += Math.max(margins.getBodyTop(false, true), margins
- .getBodyTop(false, false));
+ height += Math.max(margins.getBodyTop(false, true),
+ margins.getBodyTop(false, false));
height += computeMaxBodyRowHeight(strategy);
if (footer.length > 0)
height += computeFooterHeight(strategy, margins);
else
- height += Math.max(margins.getBodyBottom(false, false), margins
- .getBodyBottom(false, true));
+ height += Math.max(margins.getBodyBottom(false, false),
+ margins.getBodyBottom(false, true));
return new Point(width, height);
}
@@ -452,8 +457,8 @@ class GridIterator implements PrintIterator {
int headerHeight = margins.getHeaderTop()
+ margins.getHeaderVerticalSpacing()
* (header.length - 1)
- + Math.max(margins.getBodyTop(true, true), margins.getBodyTop(
- true, false));
+ + Math.max(margins.getBodyTop(true, true),
+ margins.getBodyTop(true, false));
for (int rowIndex = 0; rowIndex < header.length; rowIndex++) {
GridCellIterator[] row = header[rowIndex];
int col = 0;
@@ -461,9 +466,9 @@ class GridIterator implements PrintIterator {
for (int cellIndex = 0; cellIndex < row.length; cellIndex++) {
GridCellIterator entry = row[cellIndex];
// Find tallest cell in row.
- rowHeight = Math.max(rowHeight, strategy
- .computeSize(entry.target).y);
- col += entry.colspan;
+ rowHeight = Math.max(rowHeight,
+ strategy.computeSize(entry.getTarget()).y);
+ col += entry.getColspan();
}
headerHeight += rowHeight;
}
@@ -478,9 +483,9 @@ class GridIterator implements PrintIterator {
for (int cellIndex = 0; cellIndex < row.length; cellIndex++) {
GridCellIterator entry = row[cellIndex];
// Find the greatest height of all cells' calculated sizes.
- maxBodyRowHeight = Math.max(maxBodyRowHeight, strategy
- .computeSize(entry.target).y);
- col += entry.colspan;
+ maxBodyRowHeight = Math.max(maxBodyRowHeight,
+ strategy.computeSize(entry.getTarget()).y);
+ col += entry.getColspan();
}
}
return maxBodyRowHeight;
@@ -488,8 +493,8 @@ class GridIterator implements PrintIterator {
private int computeFooterHeight(PrintSizeStrategy strategy,
final GridMargins margins) {
- int footerHeight = Math.max(margins.getBodyBottom(true, false), margins
- .getBodyBottom(true, true))
+ int footerHeight = Math.max(margins.getBodyBottom(true, false),
+ margins.getBodyBottom(true, true))
+ margins.getFooterVerticalSpacing()
* (footer.length - 1)
+ margins.getFooterBottom();
@@ -500,9 +505,9 @@ class GridIterator implements PrintIterator {
for (int cellIndex = 0; cellIndex < row.length; cellIndex++) {
GridCellIterator entry = row[cellIndex];
// Find tallest cell in row.
- rowHeight = Math.max(rowHeight, strategy
- .computeSize(entry.target).y);
- col += entry.colspan;
+ rowHeight = Math.max(rowHeight,
+ strategy.computeSize(entry.getTarget()).y);
+ col += entry.getColspan();
}
footerHeight += rowHeight;
}
@@ -676,7 +681,7 @@ class GridIterator implements PrintIterator {
private static boolean rowContainsNonDefaultVertAlignment(
final GridCellIterator[] cells) {
for (int i = 0; i < cells.length; i++)
- if (!isDefaultVerticalAlignment(cells[i].vAlignment))
+ if (!isDefaultVerticalAlignment(cells[i].getVerticalAlignment()))
return true;
return false;
}
@@ -691,7 +696,7 @@ class GridIterator implements PrintIterator {
final int horzSpacing = look.getMargins().getHorizontalSpacing();
int col = 0;
for (int cellIndex = 0; cellIndex < cells.length; cellIndex++) {
- int colspan = cells[cellIndex].colspan;
+ int colspan = cells[cellIndex].getColspan();
result[cellIndex] = (colspan - 1) * horzSpacing
+ PaperClipsUtil.sum(columnWidths, col, colspan);
col += colspan;
@@ -705,11 +710,11 @@ class GridIterator implements PrintIterator {
final PrintPiece[] pieces = new PrintPiece[cells.length];
for (int cellIndex = 0; cellIndex < cells.length; cellIndex++) {
final GridCellIterator cell = cells[cellIndex];
- final PrintIterator iter = cell.target;
+ final PrintIterator iter = cell.getTarget();
final int cellWidth = cellWidths[cellIndex];
- if (iter.hasNext() && cell.vAlignment != SWT.FILL) {
+ if (iter.hasNext() && cell.getVerticalAlignment() != SWT.FILL) {
PrintPiece piece = pieces[cellIndex] = PaperClips.next(iter,
cellWidth, height);
if ((piece == null) || (iter.hasNext() && !bottomOpen)) {
@@ -726,8 +731,9 @@ class GridIterator implements PrintIterator {
int maxHeight = 0;
for (int cellIndex = 0; cellIndex < cells.length; cellIndex++) {
GridCellIterator cell = cells[cellIndex];
- if (cell.vAlignment == SWT.FILL)
- maxHeight = Math.max(maxHeight, cell.target.minimumSize().y);
+ if (cell.getVerticalAlignment() == SWT.FILL)
+ maxHeight = Math.max(maxHeight,
+ cell.getTarget().minimumSize().y);
else if (cellPieces[cellIndex] != null)
maxHeight = Math.max(maxHeight,
cellPieces[cellIndex].getSize().y);
@@ -740,9 +746,9 @@ class GridIterator implements PrintIterator {
final int[] cellWidths, final PrintPiece[] cellPieces) {
for (int cellIndex = 0; cellIndex < cells.length; cellIndex++) {
GridCellIterator cell = cells[cellIndex];
- PrintIterator iter = cell.target;
+ PrintIterator iter = cell.getTarget();
- if (cell.vAlignment == SWT.FILL) {
+ if (cell.getVerticalAlignment() == SWT.FILL) {
PrintPiece piece = cellPieces[cellIndex] = PaperClips.next(
iter, cellWidths[cellIndex], height);
if (piece == null || iter.hasNext()) {
@@ -769,16 +775,16 @@ class GridIterator implements PrintIterator {
PrintPiece piece = pieces[cellIndex];
if (piece != null) {
Point size = piece.getSize();
- int hAlignment = resolveHorzAlignment(cell.hAlignment,
- columns[col].align);
+ int hAlignment = resolveHorzAlignment(
+ cell.getHorizontalAlignment(), columns[col].align);
xOffsets[cellIndex] += getHorzAlignmentOffset(hAlignment,
size.x, cellWidths[cellIndex]);
- yOffsets[cellIndex] += getVertAlignmentOffset(cell.vAlignment,
- size.y, rowHeight);
+ yOffsets[cellIndex] += getVertAlignmentOffset(
+ cell.getVerticalAlignment(), size.y, rowHeight);
}
x += cellWidths[cellIndex] + horzSpacing;
- col += cell.colspan;
+ col += cell.getColspan();
}
}
@@ -819,7 +825,7 @@ class GridIterator implements PrintIterator {
private static boolean hasNext(GridCellIterator[] cells) {
for (int i = 0; i < cells.length; i++)
- if (cells[i].target.hasNext())
+ if (cells[i].getTarget().hasNext())
return true;
return false;
}
@@ -873,10 +879,10 @@ class GridIterator implements PrintIterator {
final boolean bottomOpen = rowStarted;
return createResult(colSizes, headerPiece, headerHeights,
- headerColSpans, firstRow, topOpen, bodyPiece, PaperClipsUtil
- .toIntArray(bodyRows), PaperClipsUtil
- .toIntIntArray(bodyColSpans), bottomOpen, footerPiece,
- footerHeights, footerColSpans);
+ headerColSpans, firstRow, topOpen, bodyPiece,
+ PaperClipsUtil.toIntArray(bodyRows),
+ PaperClipsUtil.toIntIntArray(bodyColSpans), bottomOpen,
+ footerPiece, footerHeights, footerColSpans);
}
private PrintPiece nextHeaderPiece(final int[] colSizes, final int height,
@@ -901,7 +907,7 @@ class GridIterator implements PrintIterator {
colSpans[rowIndex] = new int[row.length];
for (int cellIndex = 0; cellIndex < row.length; cellIndex++)
- colSpans[rowIndex][cellIndex] = row[cellIndex].colspan;
+ colSpans[rowIndex][cellIndex] = row[cellIndex].getColspan();
PrintPiece rowPiece = nextRow(row, colSizes, height - y, false);
boolean hasNext = hasNext(row);
@@ -958,7 +964,7 @@ class GridIterator implements PrintIterator {
final int[] rowColSpans = new int[thisRow.length];
for (int cellIndex = 0; cellIndex < rowColSpans.length; cellIndex++)
- rowColSpans[cellIndex] = thisRow[cellIndex].colspan;
+ rowColSpans[cellIndex] = thisRow[cellIndex].getColspan();
colSpans.add(rowColSpans);
final int rowHeight = rowPiece.getSize().y;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridLookPainterPiece.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridLookPainterPiece.java
index 46aa643..02a7006 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/GridLookPainterPiece.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/grid/internal/GridLookPainterPiece.java
@@ -8,9 +8,11 @@
* Contributors:
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.grid;
+package org.eclipse.nebula.paperclips.core.grid.internal;
import org.eclipse.nebula.paperclips.core.PrintPiece;
+import org.eclipse.nebula.paperclips.core.grid.GridLookPainter;
+import org.eclipse.nebula.paperclips.core.grid.GridMargins;
import org.eclipse.nebula.paperclips.core.internal.util.PaperClipsUtil;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
import org.eclipse.swt.graphics.GC;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerEntryImpl.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerEntryImpl.java
new file mode 100644
index 0000000..7c910b6
--- /dev/null
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerEntryImpl.java
@@ -0,0 +1,95 @@
+package org.eclipse.nebula.paperclips.core.internal;
+
+import org.eclipse.nebula.paperclips.core.LayerEntry;
+import org.eclipse.nebula.paperclips.core.LayerEntryIterator;
+import org.eclipse.nebula.paperclips.core.Print;
+import org.eclipse.nebula.paperclips.core.internal.util.PaperClipsUtil;
+import org.eclipse.nebula.paperclips.core.internal.util.Util;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.GC;
+
+/**
+ * Instances in this class represent an entry in a LayerPrint.
+ *
+ * @author Matthew Hall
+ */
+public class LayerEntryImpl implements LayerEntry {
+
+ private final Print target;
+ private final int align;
+
+ /**
+ * Create a new layer entry.
+ *
+ * @param target
+ * the target print of this entry.
+ * @param align
+ * the horizontal alignment applied to the target.
+ */
+ public LayerEntryImpl(Print target, int align) {
+ Util.notNull(target);
+ this.target = target;
+ this.align = checkAlign(align);
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + align;
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ LayerEntry other = (LayerEntry) obj;
+ if (align != other.getHorizontalAlignment())
+ return false;
+ if (target == null) {
+ if (other.getTarget() != null)
+ return false;
+ } else if (!target.equals(other.getTarget()))
+ return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.nebula.paperclips.core.internal.LayerEntry#getTarget()
+ */
+ public Print getTarget() {
+ return target;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.nebula.paperclips.core.internal.LayerEntry#getHorizontalAlignment
+ * ()
+ */
+ public int getHorizontalAlignment() {
+ return align;
+ }
+
+ private static int checkAlign(int align) {
+ return PaperClipsUtil.firstMatch(align, new int[] { SWT.LEFT,
+ SWT.CENTER, SWT.RIGHT }, SWT.LEFT);
+ }
+
+ /**
+ * @param device
+ * @param gc
+ * @return
+ */
+ public LayerEntryIterator iterator(Device device, GC gc) {
+ return new LayerEntryIteratorImpl(this, device, gc);
+ }
+} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerEntryIteratorImpl.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerEntryIteratorImpl.java
new file mode 100644
index 0000000..3331ffe
--- /dev/null
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerEntryIteratorImpl.java
@@ -0,0 +1,48 @@
+package org.eclipse.nebula.paperclips.core.internal;
+
+import org.eclipse.nebula.paperclips.core.LayerEntry;
+import org.eclipse.nebula.paperclips.core.LayerEntryIterator;
+import org.eclipse.nebula.paperclips.core.PrintIterator;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.GC;
+
+public class LayerEntryIteratorImpl implements LayerEntryIterator {
+ final PrintIterator target;
+ final int alignment;
+
+ public LayerEntryIteratorImpl(LayerEntry entry, Device device, GC gc) {
+ this.target = entry.getTarget().iterator(device, gc);
+ this.alignment = entry.getHorizontalAlignment();
+ }
+
+ public LayerEntryIteratorImpl(LayerEntryIterator that) {
+ this.target = that.getTarget().copy();
+ this.alignment = that.getAlignment();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.nebula.paperclips.core.internal.LayerEntryIterator#getTarget
+ * ()
+ */
+ public PrintIterator getTarget() {
+ return target;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.nebula.paperclips.core.internal.LayerEntryIterator#getAlignment
+ * ()
+ */
+ public int getAlignment() {
+ return alignment;
+ }
+
+ public LayerEntryIterator copy() {
+ return new LayerEntryIteratorImpl(this);
+ }
+} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerIterator.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerIterator.java
new file mode 100644
index 0000000..d3536f7
--- /dev/null
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/LayerIterator.java
@@ -0,0 +1,125 @@
+package org.eclipse.nebula.paperclips.core.internal;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.nebula.paperclips.core.CompositeEntry;
+import org.eclipse.nebula.paperclips.core.CompositePiece;
+import org.eclipse.nebula.paperclips.core.LayerEntry;
+import org.eclipse.nebula.paperclips.core.LayerEntryIterator;
+import org.eclipse.nebula.paperclips.core.LayerPrint;
+import org.eclipse.nebula.paperclips.core.PaperClips;
+import org.eclipse.nebula.paperclips.core.PrintIterator;
+import org.eclipse.nebula.paperclips.core.PrintPiece;
+import org.eclipse.nebula.paperclips.core.internal.util.PrintSizeStrategy;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+
+public class LayerIterator implements PrintIterator {
+ LayerEntryIterator[] entries;
+
+ public LayerIterator(LayerPrint print, Device device, GC gc) {
+ entries = new LayerEntryIteratorImpl[print.getEntries().length];
+ LayerEntry[] e = print.getEntries();
+ for (int i = 0; i < entries.length; i++) {
+ entries[i] = e[i].iterator(device, gc);
+ }
+ }
+
+ public LayerIterator(LayerIterator that) {
+ this.entries = (LayerEntryIterator[]) that.entries.clone();
+ for (int i = 0; i < entries.length; i++)
+ if (entries[i].getTarget().hasNext())
+ entries[i] = entries[i].copy();
+ }
+
+ public boolean hasNext() {
+ for (int i = 0; i < entries.length; i++)
+ if (entries[i].getTarget().hasNext())
+ return true;
+ return false;
+ }
+
+ public PrintPiece next(int width, int height) {
+ if (!hasNext())
+ PaperClips.error("No more content"); //$NON-NLS-1$
+
+ PrintPiece[] pieces = nextPieces(width, height);
+ if (pieces == null)
+ return null;
+
+ CompositeEntry[] entries = new CompositeEntry[pieces.length];
+ for (int i = 0; i < entries.length; i++) {
+ PrintPiece piece = pieces[i];
+ int offset = getHorzAlignmentOffset(this.entries[i].getAlignment(),
+ piece.getSize().x, width);
+ entries[i] = new CompositeEntry(piece, new Point(offset, 0));
+ }
+ return new CompositePiece(entries);
+ }
+
+ private PrintPiece[] nextPieces(int width, int height) {
+ LayerEntryIteratorImpl[] entries = (LayerEntryIteratorImpl[]) this.entries
+ .clone();
+
+ List pieces = new ArrayList();
+ for (int i = 0; i < entries.length; i++) {
+ LayerEntryIteratorImpl entry = entries[i];
+ if (entry.target.hasNext()) {
+ PrintPiece piece = PaperClips.next(entry.target, width, height);
+
+ if (piece == null) {
+ for (Iterator iter = pieces.iterator(); iter.hasNext();)
+ ((PrintPiece) iter.next()).dispose();
+ return null;
+ }
+ pieces.add(piece);
+ }
+ }
+
+ // Replace instance entries with the entries that were just consumed.
+ this.entries = entries;
+
+ return (PrintPiece[]) pieces.toArray(new PrintPiece[pieces.size()]);
+ }
+
+ private int getHorzAlignmentOffset(int alignment, int pieceWidth,
+ int totalWidth) {
+ int offset = 0;
+ switch (alignment) {
+ case SWT.CENTER:
+ offset = (totalWidth - pieceWidth) / 2;
+ break;
+ case SWT.RIGHT:
+ offset = totalWidth - pieceWidth;
+ break;
+ }
+ return offset;
+ }
+
+ Point computeSize(PrintSizeStrategy strategy) {
+ Point size = new Point(0, 0);
+ for (int i = 0; i < entries.length; i++) {
+ LayerEntryIterator entry = entries[i];
+ Point entrySize = strategy.computeSize(entry.getTarget());
+ size.x = Math.max(size.x, entrySize.x);
+ size.y = Math.max(size.y, entrySize.y);
+ }
+ return size;
+ }
+
+ public Point minimumSize() {
+ return computeSize(PrintSizeStrategy.MINIMUM);
+ }
+
+ public Point preferredSize() {
+ return computeSize(PrintSizeStrategy.PREFERRED);
+ }
+
+ public PrintIterator copy() {
+ return new LayerIterator(this);
+ }
+} \ No newline at end of file
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/RotatePiece.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/RotatePiece.java
index 18e821b..477a55e 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/RotatePiece.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/internal/RotatePiece.java
@@ -9,8 +9,10 @@
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core;
+package org.eclipse.nebula.paperclips.core.internal;
+import org.eclipse.nebula.paperclips.core.PaperClips;
+import org.eclipse.nebula.paperclips.core.PrintPiece;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
@@ -18,7 +20,7 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Transform;
-final class RotatePiece implements PrintPiece {
+public final class RotatePiece implements PrintPiece {
private final Device device;
private final PrintPiece target;
private final int angle;
@@ -27,7 +29,7 @@ final class RotatePiece implements PrintPiece {
private Transform oldTransform;
private Transform transform;
- RotatePiece(Device device, PrintPiece target, int angle, Point size) {
+ public RotatePiece(Device device, PrintPiece target, int angle, Point size) {
Util.notNull(device, target, size);
this.device = device;
this.target = target;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/StyledTextPrint.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/StyledTextPrint.java
index 03a7b09..d911613 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/StyledTextPrint.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/StyledTextPrint.java
@@ -21,6 +21,7 @@ import org.eclipse.nebula.paperclips.core.PrintIterator;
import org.eclipse.nebula.paperclips.core.PrintPiece;
import org.eclipse.nebula.paperclips.core.internal.util.PrintSizeStrategy;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
+import org.eclipse.nebula.paperclips.core.text.internal.TextPrintPiece;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPrint.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPrint.java
index f66eb3b..4952440 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPrint.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPrint.java
@@ -19,6 +19,7 @@ import org.eclipse.nebula.paperclips.core.PrintIterator;
import org.eclipse.nebula.paperclips.core.PrintPiece;
import org.eclipse.nebula.paperclips.core.internal.util.ResourcePool;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
+import org.eclipse.nebula.paperclips.core.text.internal.TextPiece;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Font;
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPiece.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/internal/TextPiece.java
index 82780b6..8715fd3 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPiece.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/internal/TextPiece.java
@@ -8,10 +8,11 @@
* Contributors:
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.text;
+package org.eclipse.nebula.paperclips.core.text.internal;
import org.eclipse.nebula.paperclips.core.internal.util.ResourcePool;
import org.eclipse.nebula.paperclips.core.internal.util.Util;
+import org.eclipse.nebula.paperclips.core.text.TextStyle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
@@ -20,7 +21,7 @@ import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
-class TextPiece implements TextPrintPiece {
+public class TextPiece implements TextPrintPiece {
private final Point size;
private final String[] lines;
private final TextStyle style;
@@ -28,7 +29,7 @@ class TextPiece implements TextPrintPiece {
private final ResourcePool resources;
- TextPiece(Device device, TextStyle style, String[] text, Point size,
+ public TextPiece(Device device, TextStyle style, String[] text, Point size,
int ascent) {
Util.notNull(device, size, style);
Util.noNulls(text);
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPrintPiece.java b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/internal/TextPrintPiece.java
index 9a822fc..08890ad 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/TextPrintPiece.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.core/src/org/eclipse/nebula/paperclips/core/text/internal/TextPrintPiece.java
@@ -8,11 +8,11 @@
* Contributors:
* Matthew Hall - initial API and implementation
*/
-package org.eclipse.nebula.paperclips.core.text;
+package org.eclipse.nebula.paperclips.core.text.internal;
import org.eclipse.nebula.paperclips.core.PrintPiece;
-interface TextPrintPiece extends PrintPiece {
+public interface TextPrintPiece extends PrintPiece {
/**
* Returns the ascent of the first line of text, in pixels.
*
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.tests/META-INF/MANIFEST.MF b/widgets/paperclips/org.eclipse.nebula.paperclips.tests/META-INF/MANIFEST.MF
index 0326013..dffbb1c 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.tests/META-INF/MANIFEST.MF
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.tests/META-INF/MANIFEST.MF
@@ -7,6 +7,6 @@ Require-Bundle: org.eclipse.nebula.paperclips.core;bundle-version="[2.0.0,3.0.0)
org.eclipse.nebula.paperclips.snippets;bundle-version="[2.0.0,3.0.0)",
org.eclipse.nebula.paperclips.widgets;bundle-version="[2.0.0,3.0.0)",
org.eclipse.swt;bundle-version="[3.2.0,4.0.0)",
- org.junit;bundle-version="[3.8.2,4.0.0)"
+ org.junit;bundle-version="[3.8.2,5.0.0)"
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Export-Package: org.eclipse.nebula.paperclips.tests.benchmark
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/LayerEntryTest.java b/widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/LayerEntryTest.java
index df4aac7..6179f30 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/LayerEntryTest.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/LayerEntryTest.java
@@ -12,24 +12,28 @@ package org.eclipse.nebula.paperclips.core;
import junit.framework.TestCase;
-import org.eclipse.nebula.paperclips.core.LayerEntry;
+import org.eclipse.nebula.paperclips.core.internal.LayerEntryImpl;
+import org.eclipse.nebula.paperclips.core.internal.LayerEntryImpl;
import org.eclipse.swt.SWT;
public class LayerEntryTest extends TestCase {
public void testConstructor_invalidArguments() {
try {
- new LayerEntry(null, SWT.LEFT);
+ new LayerEntryImpl(null, SWT.LEFT);
fail();
} catch (IllegalArgumentException expected) {
}
- assertEquals(SWT.LEFT, new LayerEntry(new PrintStub(), 0).align);
+ assertEquals(SWT.LEFT,
+ new LayerEntryImpl(new PrintStub(), 0).getHorizontalAlignment());
}
public void testEquals() {
- LayerEntry entry = new LayerEntry(new PrintStub(0), SWT.LEFT);
- assertEquals(entry, new LayerEntry(new PrintStub(0), SWT.LEFT));
- assertFalse(entry.equals(new LayerEntry(new PrintStub(1), SWT.LEFT)));
- assertFalse(entry.equals(new LayerEntry(new PrintStub(0), SWT.CENTER)));
+ LayerEntry entry = new LayerEntryImpl(new PrintStub(0), SWT.LEFT);
+ assertEquals(entry, new LayerEntryImpl(new PrintStub(0), SWT.LEFT));
+ assertFalse(entry
+ .equals(new LayerEntryImpl(new PrintStub(1), SWT.LEFT)));
+ assertFalse(entry.equals(new LayerEntryImpl(new PrintStub(0),
+ SWT.CENTER)));
}
}
diff --git a/widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/grid/GridCellTest.java b/widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/grid/GridCellTest.java
index 6fc99cc..3ecd49f 100644
--- a/widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/grid/GridCellTest.java
+++ b/widgets/paperclips/org.eclipse.nebula.paperclips.tests/src/org/eclipse/nebula/paperclips/core/grid/GridCellTest.java
@@ -13,22 +13,22 @@ package org.eclipse.nebula.paperclips.core.grid;
import junit.framework.TestCase;
import org.eclipse.nebula.paperclips.core.PrintStub;
-import org.eclipse.nebula.paperclips.core.grid.GridCell;
+import org.eclipse.nebula.paperclips.core.grid.internal.GridCellImpl;
import org.eclipse.swt.SWT;
public class GridCellTest extends TestCase {
public void testEquals() {
- GridCell cell = new GridCell(SWT.DEFAULT, SWT.DEFAULT,
+ GridCell cell = new GridCellImpl(SWT.DEFAULT, SWT.DEFAULT,
new PrintStub(0), 1);
- assertTrue(cell.equals(new GridCell(SWT.DEFAULT, SWT.DEFAULT,
+ assertTrue(cell.equals(new GridCellImpl(SWT.DEFAULT, SWT.DEFAULT,
new PrintStub(0), 1)));
- assertFalse(cell.equals(new GridCell(SWT.CENTER, SWT.DEFAULT,
+ assertFalse(cell.equals(new GridCellImpl(SWT.CENTER, SWT.DEFAULT,
new PrintStub(0), 1)));
- assertFalse(cell.equals(new GridCell(SWT.DEFAULT, SWT.CENTER,
+ assertFalse(cell.equals(new GridCellImpl(SWT.DEFAULT, SWT.CENTER,
new PrintStub(0), 1)));
- assertFalse(cell.equals(new GridCell(SWT.DEFAULT, SWT.DEFAULT,
+ assertFalse(cell.equals(new GridCellImpl(SWT.DEFAULT, SWT.DEFAULT,
new PrintStub(1), 1)));
- assertFalse(cell.equals(new GridCell(SWT.DEFAULT, SWT.DEFAULT,
+ assertFalse(cell.equals(new GridCellImpl(SWT.DEFAULT, SWT.DEFAULT,
new PrintStub(0), 2)));
}
}