KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > edit > provider > ComposedImage


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: ComposedImage.java,v 1.2 2005/06/08 06:17:05 nickb Exp $
16  */

17 package org.eclipse.emf.edit.provider;
18
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.Collection JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24
25
26 /**
27  * This implements a wrapper that can be used to specify how a composed image should look.
28  */

29 public class ComposedImage
30 {
31   public static class Point
32   {
33     public int x;
34     public int y;
35   }
36
37   public static class Size
38   {
39     public int width;
40     public int height;
41   }
42
43   protected List JavaDoc images;
44   protected List JavaDoc imageSizes;
45
46   /**
47    * This creates an empty instance.
48    */

49   public ComposedImage(Collection JavaDoc images)
50   {
51     this.images = new ArrayList JavaDoc(images);
52   }
53
54   public boolean equals(Object JavaDoc that)
55   {
56     return that instanceof ComposedImage && ((ComposedImage)that).getImages().equals(images);
57   }
58
59   public int hashCode()
60   {
61     return images.hashCode();
62   }
63
64   public List JavaDoc getImages()
65   {
66     return images;
67   }
68
69   public Size getSize(Collection JavaDoc imageSizes)
70   {
71     this.imageSizes = new ArrayList JavaDoc(imageSizes);
72     Size result = new Size();
73     for (Iterator JavaDoc sizes = imageSizes.iterator(); sizes.hasNext(); )
74     {
75       Size size = (Size)sizes.next();
76       result.width = Math.max(result.width, size.width);
77       result.height = Math.max(result.height, size.height);
78     }
79     return result;
80   }
81
82   public List JavaDoc getDrawPoints(Size size)
83   {
84     List JavaDoc results = new ArrayList JavaDoc();
85     for (int i = imageSizes.size(); i > 0; --i)
86     {
87       Point result = new Point();
88       results.add(result);
89     }
90     return results;
91   }
92 }
93
Popular Tags