KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > custom > EditorImages


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * Project author: Daniel Mazurek <Daniel.Mazurek [at] nightlabs [dot] org> *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin St, Fifth Floor, *
20  * Boston, MA 02110-1301 USA *
21  * *
22  * Or get it online : *
23  * http://www.gnu.org/copyleft/lesser.html *
24  * *
25  * *
26  ******************************************************************************/

27
28 package org.nightlabs.editor2d.custom;
29
30 import org.eclipse.draw2d.PositionConstants;
31 import org.eclipse.jface.resource.ImageDescriptor;
32 import org.eclipse.swt.graphics.Image;
33
34 import org.nightlabs.base.resource.SharedImages;
35 import org.nightlabs.editor2d.EditorPlugin;
36
37 public class EditorImages
38 {
39   public EditorImages()
40   {
41     super();
42   }
43
44 // private static ImageDescriptor createDescriptor(String filename)
45
// {
46
// return ImageDescriptor.createFromFile(EditorPlugin.class, filename);
47
// }
48

49   public static final ImageDescriptor ROTATE_NW_16;
50   public static final ImageDescriptor ROTATE_SW_16;
51   public static final ImageDescriptor ROTATE_NE_16;
52   public static final ImageDescriptor ROTATE_SE_16;
53      
54   static
55   {
56 // ROTATE_NW_16 = createDescriptor("icons/rotateNW16.gif"); //$NON-NLS-1$
57
// ROTATE_NE_16 = createDescriptor("icons/rotateNE16.gif"); //$NON-NLS-2$
58
// ROTATE_SE_16 = createDescriptor("icons/rotateSE16.gif"); //$NON-NLS-3$
59
// ROTATE_SW_16 = createDescriptor("icons/rotateSW16.gif"); //$NON-NLS-4$
60
ROTATE_NW_16 = SharedImages.getSharedImageDescriptor(EditorPlugin.getDefault(),
61             EditorImages.class, "RotateNW");
62     ROTATE_NE_16 = SharedImages.getSharedImageDescriptor(EditorPlugin.getDefault(),
63             EditorImages.class, "RotateNE");
64     ROTATE_SE_16 = SharedImages.getSharedImageDescriptor(EditorPlugin.getDefault(),
65             EditorImages.class, "RotateSE");
66     ROTATE_SW_16 = SharedImages.getSharedImageDescriptor(EditorPlugin.getDefault(),
67             EditorImages.class, "RotateSW");
68   }
69   
70   /**
71    * Returns the RotationImage or ShearImage corresponding to the given direction, defined in
72    * {@link PositionConstants}.
73    * @param direction The relative direction of the desired Rotate/Shear Image
74    * @return The appropriate directional Rotate/Shear Image
75    */

76   public static Image getDirectionalRotationImage(int direction)
77   {
78     switch (direction)
79     {
80 // case PositionConstants.NORTH :
81
// return SHEAR_HORIZONTAL_16.createImage();
82
// case PositionConstants.SOUTH:
83
// return SHEAR_HORIZONTAL_16.createImage();
84
// case PositionConstants.EAST :
85
// return SHEAR_VERTICAL_16.createImage();
86
// case PositionConstants.WEST:
87
// return SHEAR_VERTICAL_16.createImage();
88
case PositionConstants.SOUTH_EAST:
89         return ROTATE_SE_16.createImage();
90       case PositionConstants.SOUTH_WEST:
91         return ROTATE_SW_16.createImage();
92       case PositionConstants.NORTH_EAST:
93         return ROTATE_NE_16.createImage();
94       case PositionConstants.NORTH_WEST:
95         return ROTATE_NW_16.createImage();
96       default:
97         break;
98     }
99     return null;
100   }
101 }
102
Popular Tags