Skip to content

Package: AbstractGridCell

AbstractGridCell

nameinstructionbranchcomplexitylinemethod
AbstractGridCell(int, int, AbstractRenderer)
M: 0 C: 33
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 12
100%
M: 0 C: 1
100%
equals(Object)
M: 15 C: 29
66%
M: 8 C: 6
43%
M: 7 C: 1
13%
M: 7 C: 8
53%
M: 0 C: 1
100%
getColumn()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getHorizontalAlignment()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getHorizontalSpan()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRenderer()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRow()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getVerticalAlignment()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 0 C: 26
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
isHorizontalFill()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isHorizontalGrab()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isVerticalFill()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isVerticalGrab()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setHorizontalAlignment(AbstractGridCell.Alignment)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setHorizontalFill(boolean)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setHorizontalGrab(boolean)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setHorizontalSpan(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setRenderer(AbstractRenderer)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setVerticalAlignment(AbstractGridCell.Alignment)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setVerticalFill(boolean)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setVerticalGrab(boolean)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: * Lucas Köhler - Refactoring
14: ******************************************************************************/
15: package org.eclipse.emf.ecp.view.model.common;
16:
17: /**
18: * A {@link AbstractGridCell} has a row, a column and a renderer it is rendered by a renderer.
19: *
20: * @author Eugen Neufeld
21: * @author Lucas Köhler
22: * @param <RENDERER> the renderer type (e.g. SWT or JavaFX renderer)
23: */
24: public abstract class AbstractGridCell<RENDERER extends AbstractRenderer<?>> {
25:
26:         private final int row;
27:         private final int column;
28:         private RENDERER renderer;
29:
30:         private int horizontalSpan = 1;
31:         private boolean verticalGrab = true;
32:         private boolean verticalFill = true;
33:         private boolean horizontalGrab = true;
34:         private boolean horizontalFill = true;
35:         private Alignment horizontalAlignment = Alignment.BEGINNING;
36:         private Alignment verticalAlignment = Alignment.CENTER;
37:
38:         /**
39:          * Either horizontal or vertical alignment within the cell.
40:          * For filling the complete horizontal or vertical space, use {@link AbstractGridCell#setHorizontalFill(boolean)} or
41:          * {@link AbstractGridCell#setVerticalFill(boolean)} respectively.
42:          *
43:          * @author Martin Fleck
44:          * @since 1.9
45:          *
46:          */
47:         public enum Alignment {
48:                 /**
49:                  * Align cell at the horizontal (left) or vertical (top) beginning.
50:                  */
51:                 BEGINNING,
52:                 /**
53:                  * Align cell at the horizontal or vertical center.
54:                  */
55:                 CENTER,
56:                 /**
57:                  * Align cell at the horizontal (right) or vertical (bottom) end.
58:                  */
59:                 END
60:         }
61:
62:         /**
63:          * Default constructor to create a grid cell.
64:          *
65:          * @param row the row of the cell
66:          * @param column the column of the cell
67:          * @param renderer the {@link AbstractRenderer} that renderes the cell
68:          */
69:         public AbstractGridCell(int row, int column, RENDERER renderer) {
70:                 super();
71:                 this.row = row;
72:                 this.column = column;
73:                 this.renderer = renderer;
74:         }
75:
76:         /**
77:          * The id of the row.
78:          *
79:          * @return the row
80:          */
81:         public int getRow() {
82:                 return row;
83:         }
84:
85:         /**
86:          * The id of the column.
87:          *
88:          * @return the column
89:          */
90:         public int getColumn() {
91:                 return column;
92:         }
93:
94:         /**
95:          * @return the renderer
96:          */
97:         public RENDERER getRenderer() {
98:                 return renderer;
99:         }
100:
101:         /**
102:          * @param renderer the renderer to set
103:          */
104:         public void setRenderer(RENDERER renderer) {
105:                 this.renderer = renderer;
106:         }
107:
108:         /**
109:          * Return the horizontalSpan of this control. Default is 1.
110:          *
111:          * @return the horizontalSpan
112:          */
113:         public int getHorizontalSpan() {
114:                 return horizontalSpan;
115:         }
116:
117:         /**
118:          * Set the horizontal span of this cell.
119:          *
120:          * @param horizontalSpan the horizontalSpan to set
121:          */
122:         public void setHorizontalSpan(int horizontalSpan) {
123:                 this.horizontalSpan = horizontalSpan;
124:         }
125:
126:         /**
127:          * Returns whether this cell will take all available vertical space.
128:          *
129:          * @return the verticalGrab
130:          */
131:         public boolean isVerticalGrab() {
132:                 return verticalGrab;
133:         }
134:
135:         /**
136:          * True if all available vertical space should be taken.
137:          *
138:          * @param verticalGrab the verticalGrab to set
139:          */
140:         public void setVerticalGrab(boolean verticalGrab) {
141:                 this.verticalGrab = verticalGrab;
142:         }
143:
144:         /**
145:          * Returns whether the control should fill the available vertical space.
146:          *
147:          * @return the verticalFill
148:          */
149:         public boolean isVerticalFill() {
150:                 return verticalFill;
151:         }
152:
153:         /**
154:          * True if the available vertical space should be filled.
155:          *
156:          * @param verticalFill the verticalFill to set
157:          */
158:         public void setVerticalFill(boolean verticalFill) {
159:                 this.verticalFill = verticalFill;
160:         }
161:
162:         /**
163:          * Returns whether this cell will take all available horizontal space.
164:          *
165:          * @return the horizontalGrab
166:          */
167:         public boolean isHorizontalGrab() {
168:                 return horizontalGrab;
169:         }
170:
171:         /**
172:          * True if all available horizontal space should be taken.
173:          *
174:          * @param horizontalGrab the horizontalGrab to set
175:          */
176:         public void setHorizontalGrab(boolean horizontalGrab) {
177:                 this.horizontalGrab = horizontalGrab;
178:         }
179:
180:         /**
181:          * Returns whether the control should fill the available horizontal space.
182:          *
183:          * @return the horizontalFill
184:          */
185:         public boolean isHorizontalFill() {
186:                 return horizontalFill;
187:         }
188:
189:         /**
190:          * True if the available horizontal space should be filled.
191:          *
192:          * @param horizontalFill the horizontalFill to set
193:          */
194:         public void setHorizontalFill(boolean horizontalFill) {
195:                 this.horizontalFill = horizontalFill;
196:         }
197:
198:         /**
199:          * Returns the horizontal alignment of the control that is used if horizontal fill is set to false. Default is
200:          * {@link Alignment#BEGINNING}.
201:          *
202:          * @return the horizontalAlignment
203:          * @since 1.9
204:          */
205:         public Alignment getHorizontalAlignment() {
206:                 return horizontalAlignment;
207:         }
208:
209:         /**
210:          * Set the horizontal alignment. This alignment is only considered if horizontal fill is set to false.
211:          *
212:          * @param horizontalAlignment the horizontalAlignment to set
213:          * @since 1.9
214:          */
215:         public void setHorizontalAlignment(Alignment horizontalAlignment) {
216:                 this.horizontalAlignment = horizontalAlignment;
217:         }
218:
219:         /**
220:          * Returns the vertical alignment of the control that is used if vertical fill is set to false. Default is
221:          * {@link Alignment#CENTER}.
222:          *
223:          * @return the verticalAlignment
224:          * @since 1.9
225:          */
226:         public Alignment getVerticalAlignment() {
227:                 return verticalAlignment;
228:         }
229:
230:         /**
231:          * Set the vertical alignment. This alignment is only considered if vertical fill is set to false.
232:          *
233:          * @param verticalAlignment the verticalAlignment to set
234:          * @since 1.9
235:          */
236:         public void setVerticalAlignment(Alignment verticalAlignment) {
237:                 this.verticalAlignment = verticalAlignment;
238:         }
239:
240:         /**
241:          * {@inheritDoc}
242:          *
243:          * @see java.lang.Object#hashCode()
244:          */
245:         @Override
246:         public int hashCode() {
247:                 final int prime = 31;
248:                 int result = 1;
249:                 result = prime * result + column;
250:•                result = prime * result + (renderer == null ? 0 : renderer.hashCode());
251:                 return result;
252:         }
253:
254:         /**
255:          * {@inheritDoc}
256:          *
257:          * @see java.lang.Object#equals(java.lang.Object)
258:          */
259:         @Override
260:         public boolean equals(Object obj) {
261:•                if (this == obj) {
262:                         return true;
263:                 }
264:•                if (obj == null) {
265:                         return false;
266:                 }
267:•                if (getClass() != obj.getClass()) {
268:                         return false;
269:                 }
270:                 @SuppressWarnings("unchecked")
271:                 final AbstractGridCell<RENDERER> other = (AbstractGridCell<RENDERER>) obj;
272:•                if (column != other.column) {
273:                         return false;
274:                 }
275:•                if (renderer == null) {
276:•                        if (other.renderer != null) {
277:                                 return false;
278:                         }
279:•                } else if (!renderer.equals(other.renderer)) {
280:                         return false;
281:                 }
282:                 return true;
283:         }
284:
285: }