KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > chart2d > VerticalTextListArea


1 /**
2  * Chart2D, a java library for drawing two dimensional charts.
3  * Copyright (C) 2001 Jason J. Simas
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * The author of this library may be contacted at:
19  * E-mail: jjsimas@users.sourceforge.net
20  * Street Address: J J Simas, 887 Tico Road, Ojai, CA 93023-3555 USA
21  */

22
23
24 package net.sourceforge.chart2d;
25
26
27 import java.awt.*;
28
29
30 /**
31  * A set of text labels layed out vertially with bullets on either the left or
32  * right of the labels. The bullets can be layed out so that they are aligned
33  * with the center of each label, or aligned with the middle of the space
34  * between each label (vertically). It
35  * was designed to be used as a legend and for making a y axis in a chart
36  * program. Adjustments include
37  * bullets/no bullets, labels/no labels, bullet sizes, bullet colors, labels
38  * font color, size, style, and type; plus it allows for all the functionality
39  * of the the bordered area class including borders, spacing within borders,
40  * auto horizontal and vertical justification, auto sizing, and auto growing and
41  * shrinking of components.<br>
42  * Note: This class does not accept null values. Pass zero length arrays or
43  * empty strings instead.
44  */

45 class VerticalTextListArea extends TextListArea {
46
47
48   private boolean labelsExistence = true;
49   private TextArea[] labels;
50   private String JavaDoc[] labelStrings;
51
52   private boolean bulletsExistence = true;
53   private Rectangle[] bullets;
54   private Dimension bulletsSizeModel;
55   private int bulletsAlignment;
56   private int bulletsRelation;
57   private Color[] bulletColors;
58   private boolean bulletsOutline;
59   private Color bulletsOutlineColor;
60
61   private boolean betweenLabelsGapExistence;
62   private int betweenLabelsGapThicknessModel;
63   private boolean betweenBulletsGapExistence;
64   private int betweenBulletsGapThicknessModel;
65   private boolean betweenBulletsAndLabelsGapExistence;
66   private int betweenBulletsAndLabelsGapThicknessModel;
67   private boolean customizeSpaceMinHeight;
68   private int customSpaceMinHeight;
69
70   private boolean allowSelfSize;
71   private boolean needsUpdate;
72
73
74   /**
75    * Constructs a new vertical text list area with default values. */

76   VerticalTextListArea() {
77
78     labelStrings = new String JavaDoc[0];
79     labels = new TextArea[0];
80     bullets = new Rectangle[0];
81     bulletColors = new Color[0];
82
83     setBulletsSizeModel (new Dimension (9, 9));
84     setBulletsOutline (true);
85     setBulletsOutlineColor (Color.black);
86     setBetweenLabelsGapExistence (true);
87     setBetweenLabelsGapThicknessModel (3);
88     setBetweenBulletsGapExistence (true);
89     setBetweenBulletsGapThicknessModel (3);
90     setBetweenBulletsAndLabelsGapExistence (true);
91     setBetweenBulletsAndLabelsGapThicknessModel (3);
92     setBulletsAlignment (CENTERED);
93     setBulletsRelation (LEFT);
94     setAllowSelfSize (true);
95     resetVerticalTextListAreaModel (true);
96     needsUpdate = true;
97     customizeSpaceMinHeight = false;
98   }
99
100
101   /**
102    * Allows this text list area to determine its minimum size and reset its own
103    * size. This is useful when you want the component to be able to figure out
104    * its minimum size, but not always to set itself to that miniumum size.
105    * @param allow If true, then the component can reset its own minimum size.
106    * This is only relevant when auto minimum sizing is enabled.
107    */

108   final void setAllowSelfSize (boolean allow) {
109
110     needsUpdate = true;
111     allowSelfSize = allow;
112   }
113
114
115   /**
116    * Specifies the text for the labels. This value cannot be null; however,
117    * a zero or greater length array is fine.
118    * @param labels An array of the strings to be used for the labels.
119    */

120   final void setLabels (String JavaDoc[] labels) {
121
122     needsUpdate = true;
123     labelStrings = labels;
124   }
125
126
127   /**
128    * Allows for outside specification of the size of the text list.
129    * This method was introduced as an afterthought.
130    * It's used by LLChartArea for feeding back the size of the graph area.
131    * @param customize True if you want to customize the space height.
132    * @param height The custom space height (if the boolean is true).
133    */

134   final void setCustomSpaceMinHeight (boolean customize, int height) {
135
136     needsUpdate = true;
137     customizeSpaceMinHeight = customize;
138     customSpaceMinHeight = height;
139   }
140
141
142   /**
143    * Specifies the model size (width and height) of the bullets. A ratio based
144    * on maximum size / model size will be applied to this to find the actual
145    * bullet size -- when auto sizing the model maximum size is disabled.
146    * Otherwise, the actual size will be this size.
147    * @param model The model size of a bullet.
148    */

149   final void setBulletsSizeModel (Dimension model) {
150
151     needsUpdate = true;
152     bulletsSizeModel = model;
153   }
154
155
156   /**
157    * The horizontal alignment of the bullets respective to the labels. The
158    * bullets can either be place in line with each label, or in in line with
159    * the middle of the space between each label. That is, bullets can be
160    * centered in the middle of the label, or placed between each label.
161    * @param alignment The alignment for the bullets.
162    * Possible values are CENTERED and BETWEEN.
163    */

164   final void setBulletsAlignment (int alignment) {
165
166     needsUpdate = true;
167     bulletsAlignment = alignment;
168   }
169
170
171   /**
172    * Specifies the horizontal relation of the bullets to the labels.
173    * The bullets
174    * can either be placed along the left of the labels or along the right.
175    * @param relation The horizontal relation of the bullets.
176    * Possible values are LEFT and RIGHT.
177    */

178   final void setBulletsRelation (int relation) {
179
180     needsUpdate = true;
181     bulletsRelation = relation;
182   }
183
184
185   /**
186    * Specifies the colors of the bullets. Each bullet can have a different
187    * color so an array must be passed. The number of colors must be equal to
188    * the number of bullets. If the bullets alignment is between the labels and
189    * the lables do exist, then there should be one bullet less than the number
190    * of labels. If the bullets alignment is centered and the labels do exist,
191    * then there should be the same number of bullets as labels. Otherwise,
192    * choose any number of bullets. Number of bullets is set by setting the
193    * bullet colors. The number of bullets always equals the number of colors.
194    * @param colors An array filled with a color for each bullet. The first
195    * bullet from left to right gets the lowest order color in the array.
196    */

197   final void setBulletColors (Color[] colors) {
198
199     needsUpdate = true;
200     bulletColors = colors;
201   }
202
203
204   /**
205    * Specifies whether the bullets should have a small outline.
206    * Outline is 1 pixel on all sides, at all times, and is black.
207    * Outline is included in size of bullet.
208    * @param outline If true, then the outline will exist.
209    */

210   final void setBulletsOutline (boolean outline) {
211
212     needsUpdate = true;
213     bulletsOutline = outline;
214   }
215
216
217   /**
218    * Specifies the color of the bullets outline.
219    * @param color The outline color.
220    */

221   final void setBulletsOutlineColor (Color color) {
222
223     bulletsOutlineColor = color;
224   }
225
226
227   /**
228    * Specifies whether the <b>minimum</b> amount of space between each label,
229    * the gap, shall be enforced. If the gap does not exist, then it will
230    * not be included in calculations.
231    * @param existence The existence of the gap. If true, then it exists.
232    */

233   final void setBetweenLabelsGapExistence (boolean existence) {
234
235     needsUpdate = true;
236     betweenLabelsGapExistence = existence;
237   }
238
239
240   /**
241    * Specifies the model <b>minimum</b> thickness of the gap between the labels.
242    * @param model The model minimum thickness of the gap. Note: The gap may end
243    * up being more depending on sizing properties.
244    */

245   final void setBetweenLabelsGapThicknessModel (int model) {
246
247     needsUpdate = true;
248     betweenLabelsGapThicknessModel = model;
249   }
250
251
252   /**
253    * Specifies the existence of a minimum gap between each bullets. If the gap
254    * doesn't exist, then it will not be included in calculations.
255    * @param existence The existence of the minimum gap. If true, then the gap
256    * does exist.
257    */

258   final void setBetweenBulletsGapExistence (boolean existence) {
259
260     needsUpdate = true;
261     betweenBulletsGapExistence = existence;
262   }
263
264
265   /**
266    * Specifies the model <b>minimum</b> thickness of the gap between each
267    * bullet.
268    * @param model The model minimum thickness of the gap.
269    * Note: The gap may end up being more depending on sizing properties.
270    */

271   final void setBetweenBulletsGapThicknessModel (int model) {
272
273     needsUpdate = true;
274     betweenBulletsGapThicknessModel = model;
275   }
276
277
278   /**
279    * Specifies the existence of a minimum gap between the labels and the
280    * bullets. If the gap doesn't exist, then it will not be included in
281    * calculations.
282    * @param existence The existence of the minimum gap. If true, then the gap
283    * does exist.
284    */

285   final void setBetweenBulletsAndLabelsGapExistence (boolean existence) {
286
287     needsUpdate = true;
288     betweenBulletsAndLabelsGapExistence = existence;
289   }
290
291
292   /**
293    * Specifies the model <b>minimum</b> thickness of the gap between the labels
294    * and the bullets.
295    * @param model The model minimum thickness of the gap.
296    * Note: The gap may end up being more depending on sizing properties.
297    */

298   final void setBetweenBulletsAndLabelsGapThicknessModel (int model) {
299
300     needsUpdate = true;
301     betweenBulletsAndLabelsGapThicknessModel = model;
302   }
303
304
305   /**
306    * Returns the label strings of this text list.
307    * @return The label strings.
308    */

309   final String JavaDoc[] getLabelStrings() {
310
311     return labelStrings;
312   }
313
314
315   /**
316    * Returns the model thickness of the minimum gap between bullets.
317    * @return The model thickness.
318    */

319   final int getBetweenBulletsGapThicknessModel() {
320
321     return betweenBulletsGapThicknessModel;
322   }
323
324
325   /**
326    * Returns the model thickness of the minimum gap between labels.
327    * @return The model thickness.
328    */

329   final int getBetweenLabelsGapThicknessModel() {
330
331     return betweenLabelsGapThicknessModel;
332   }
333
334
335   /**
336    * Returns the model <b>minimum</b> thickness of the gap between the labels
337    * and the bullets.
338    * @return The model minimum thickness of the gap.
339    */

340   final int getBetweenBulletsAndLabelsGapThicknessModel() {
341
342     return betweenBulletsAndLabelsGapThicknessModel;
343   }
344
345
346   /**
347    * Returns the bounds for each bullet. This is useful if other components
348    * need to be aligned exactly with the bullet's location or should be the
349    * exact same size.
350    * @param g2D The graphics context used for calculations.
351    * @return The array of rectangles which bound each bullet.
352    */

353   final Rectangle[] getBullets (Graphics2D g2D) {
354
355     updateVerticalTextListArea (g2D);
356     return bullets;
357   }
358
359
360   /**
361    * Returns the number of bullets this text list has. Calculates it each time.
362    * @return The number of bullets of this text list.
363    */

364   final int getNumBullets() {
365     int numBullets = bulletsExistence && labelsExistence ?
366       (bulletsAlignment == CENTERED ?
367       labelStrings.length : labelStrings.length - 1) : 0;
368     return (numBullets > 0 ? numBullets : 0);
369   }
370
371
372   /**
373    * Returns the model size (width and height) of the bullets.
374    * @return The model size of a bullet.
375    */

376   final Dimension getBulletsSizeModel() {
377
378     return bulletsSizeModel;
379   }
380
381
382   /**
383    * Returns the colors of the bullets. Each bullet can have a different
384    * color so an array must be passed. The number of colors must be equal to
385    * the number of bullets. If the bullets alignment is between the labels and
386    * the lables do exist, then there should be one bullet less than the number
387    * of labels. If the bullets alignment is centered and the labels do exist,
388    * then there should be the same number of bullets as labels. Otherwise,
389    * choose any number of bullets. Number of bullets is set by setting the
390    * bullet colors. The number of bullets always equals the number of colors.
391    * @return Color[] An array filled with a color for each bullet. The first
392    * bullet from left to right gets the lowest order color in the array.
393    */

394   final Color[] getBulletColors() {
395     return bulletColors;
396   }
397
398
399   /**
400    * Returns the vertical alignment of the bullets respective to the labels.
401    * The bullets can either be place in line with each label, or in in line with
402    * the middle of the space between each label. That is, bullets can be
403    * centered in the middle of the label, or placed between each label.
404    * Possible values are CENTERED and BETWEEN.
405    * @return int The alignment for the bullets [CENTERED or BETWEEN].
406    */

407   final int getBulletsAlignment() {
408
409     return bulletsAlignment;
410   }
411
412
413   /**
414    * Specifies whether the bullets should have a small outline.
415    * Outline is 1 pixel on all sides, at all times, and is black.
416    * Outline is included in size of bullet.
417    * @return outline If true, then the outline will exist.
418    */

419   final boolean getBulletsOutline() {
420
421     return bulletsOutline;
422   }
423
424
425   /**
426    * Specifies the color of the bullets outline.
427    * @return color The outline color.
428    */

429   final Color getBulletsOutlineColor() {
430
431     return bulletsOutlineColor;
432   }
433
434
435   /**
436    * Returns the labels. This is useful if other components
437    * need to be aligned exactly with the label's location or should be the
438    * exact same size.
439    * @param g2D The graphics context used for calculations.
440    * @return The array of TextArea's which are the labels.
441    */

442   final TextArea[] getLabels (Graphics2D g2D) {
443
444     updateVerticalTextListArea (g2D);
445     return labels;
446   }
447
448
449   /**
450    * Resets the model for this class. The model is used for shrinking and
451    * growing of its components based on the maximum size of this class. If this
452    * method is called, then the next time the maximum size is set, this classes
453    * model maximum size will be made equal to the new maximum size. Effectively
454    * what this does is ensure that whenever this objects maximum size is equal
455    * to the one given, then all of the components will take on their default
456    * model sizes. Note: This is only useful when auto model max sizing is
457    * disabled.
458    * @param reset True causes the max model size to be set upon the next max
459    * sizing.
460    */

461   final void resetVerticalTextListAreaModel (boolean reset) {
462
463     needsUpdate = true;
464     resetFontAreaModel (reset);
465   }
466
467
468   /**
469    * Indicates whether some property of this class has changed.
470    * @return True if some property has changed.
471    */

472   final boolean getVerticalTextListAreaNeedsUpdate() {
473
474     return (needsUpdate || getFontAreaNeedsUpdate());
475   }
476
477
478   /**
479    * Updates all variables. First updates the variables of its parent class,
480    * then updates its own variables.
481    * @param g2D The graphics context used for calculations.
482    */

483   final void updateVerticalTextListArea (Graphics2D g2D) {
484
485     if (getVerticalTextListAreaNeedsUpdate()) {
486       updateFontArea ();
487       update (g2D);
488     }
489     needsUpdate = false;
490   }
491
492
493   /**
494    * Paints all the components of this class. First all variables are updated.
495    * @param g2D The graphics context for calculations and painting.
496    */

497   void paintComponent (Graphics2D g2D) {
498
499     updateVerticalTextListArea (g2D);
500     super.paintComponent (g2D);
501
502     Color oldColor = g2D.getColor();
503
504     int num = labelsExistence ? labels.length : 0;
505     for (int i = 0; i < num; ++i) {
506       labels[i].paintComponent (g2D);
507     }
508
509     num = bulletsExistence ? bullets.length : 0;
510     for (int i = 0; i < num; ++i) {
511
512       g2D.setColor (bulletColors[i]);
513       g2D.fill (bullets[i]);
514
515       if (bulletsOutline) {
516         g2D.setColor (bulletsOutlineColor);
517         g2D.draw (bullets[i]);
518       }
519     }
520
521     g2D.setColor (oldColor);
522   }
523
524
525   private void update (Graphics2D g2D) {
526
527     int numLabels = labelsExistence ? labelStrings.length : 0;
528     labels = new TextArea[numLabels];
529     int numBullets = getNumBullets();
530     bullets = new Rectangle[numBullets];
531
532     int numBulletGaps = bulletsAlignment == CENTERED ?
533       (numBullets - 1) : (numBullets + 1);
534     int requiredNumBulletsForGaps = bulletsAlignment == CENTERED ? 2 : 1;
535     int requiredNumBulletsForSpacing = bulletsAlignment == CENTERED ?
536       numBullets : (numBullets + 1);
537
538     int betweenBulletsAndLabelsGapThickness = 0;
539     int availableWidth = getSpaceSize (MAX).width;
540     if (betweenBulletsAndLabelsGapExistence && labelsExistence) {
541       betweenBulletsAndLabelsGapThickness = applyRatio (
542         betweenBulletsAndLabelsGapThicknessModel, getRatio (WIDTH));
543       betweenBulletsAndLabelsGapThickness =
544         betweenBulletsAndLabelsGapThickness <= availableWidth ?
545         betweenBulletsAndLabelsGapThickness : availableWidth;
546       availableWidth -= betweenBulletsAndLabelsGapThickness;
547     }
548
549     int availableHeightForLabels = getSpaceSize (MAX).height;
550     int availableHeightForBullets = getSpaceSize (MAX).height;
551     int betweenLabelsGapThickness = 0;
552     int betweenBulletsGapThickness = 0;
553     if (betweenLabelsGapExistence && numLabels > 1) {
554       betweenLabelsGapThickness =
555        applyRatio (betweenLabelsGapThicknessModel, getRatio (HEIGHT));
556       betweenLabelsGapThickness = betweenLabelsGapThickness <=
557         (availableHeightForLabels / (numLabels - 1)) ?
558         betweenLabelsGapThickness :
559         (availableHeightForLabels / (numLabels - 1));
560       availableHeightForLabels -=
561         ((numLabels - 1) * betweenLabelsGapThickness);
562     }
563     if (betweenBulletsGapExistence && numBullets >= requiredNumBulletsForGaps) {
564       betweenBulletsGapThickness =
565         applyRatio (betweenBulletsGapThicknessModel, getRatio (HEIGHT));
566       betweenBulletsGapThickness = betweenBulletsGapThickness <=
567         (availableHeightForBullets / numBulletGaps) ?
568         betweenBulletsGapThickness :
569         (availableHeightForBullets / numBulletGaps);
570       availableHeightForBullets -=
571         (numBulletGaps * betweenBulletsGapThickness);
572     }
573
574     int bulletsWidth = 0;
575     int bulletsHeight = 0;
576     if (bulletsExistence) {
577       if (numBullets > 0) {
578         bulletsWidth = applyRatio (bulletsSizeModel.width, getRatio (WIDTH));
579         bulletsWidth =
580           bulletsWidth <= availableWidth ? bulletsWidth : availableWidth;
581         bulletsHeight = applyRatio (bulletsSizeModel.height, getRatio (HEIGHT));
582         bulletsHeight = bulletsHeight <=
583           (availableHeightForBullets / requiredNumBulletsForSpacing) ?
584           bulletsHeight :
585           (availableHeightForBullets / requiredNumBulletsForSpacing);
586       }
587       if (bulletsWidth <= 0 || bulletsHeight <= 0) {
588         bulletsWidth = 0;
589         bulletsHeight = 0;
590       }
591       else {
592         availableWidth -= bulletsWidth;
593       }
594     }
595
596     int labelsWidth = 0;
597     int labelsHeight = 0;
598     if (labelsExistence && numLabels > 0) {
599       labelsWidth = availableWidth;
600       labelsHeight = availableHeightForLabels / numLabels;
601     }
602
603     for (int i = 0; i < numLabels; ++i) {
604       labels[i] = new TextArea();
605       labels[i].setCustomRatio (WIDTH, true, getRatio (WIDTH));
606       labels[i].setCustomRatio (HEIGHT, true, getRatio (HEIGHT));
607       labels[i].setAutoSizes (true, false);
608       labels[i].setSize (MAX, new Dimension (labelsWidth, labelsHeight));
609       labels[i].setBorderExistence (false);
610       labels[i].setGapExistence (false);
611       labels[i].setBackgroundExistence (false);
612       labels[i].setText (labelStrings[i]);
613       labels[i].setFontName(getFontName());
614       labels[i].setFontStyle(getFontStyle());
615       labels[i].setFontPointModel(getFontPointModel());
616       labels[i].setFontColor(getFontColor());
617     }
618
619     int greatestLabelWidth = 0;
620     int smallestLabelWidth = Integer.MAX_VALUE;
621     int greatestLabelHeight = 0;
622     for (int i = 0; i < numLabels; ++i) {
623       labels[i].updateTextArea (g2D);
624       int thisLabelWidth = labels[i].getSize (MIN).width;
625       greatestLabelWidth = thisLabelWidth > greatestLabelWidth ?
626         thisLabelWidth : greatestLabelWidth;
627       smallestLabelWidth = thisLabelWidth < smallestLabelWidth ?
628         thisLabelWidth : smallestLabelWidth;
629       int thisLabelHeight = labels[i].getSize (MIN).height;
630       greatestLabelHeight = thisLabelHeight > greatestLabelHeight ?
631         thisLabelHeight : greatestLabelHeight;
632     }
633
634     if (smallestLabelWidth > 0) {
635       labelsWidth = greatestLabelWidth;
636       labelsHeight = greatestLabelHeight;
637     }
638     else {
639       labelsWidth = 0;
640       labelsHeight = 0;
641       betweenLabelsGapThickness = 0;
642       for (int i = 0; i < numLabels; ++i) {
643         labels[i].setSize (MAX, new Dimension());
644       }
645
646       betweenBulletsAndLabelsGapThickness = 0;
647       availableWidth = getSpaceSize (MAX).width;
648       bulletsWidth = 0;
649       bulletsHeight = 0;
650       if (bulletsExistence && numBullets > 0) {
651         bulletsWidth = applyRatio (bulletsSizeModel.width, getRatio (WIDTH));
652         bulletsWidth =
653           bulletsWidth <= availableWidth ? bulletsWidth : availableWidth;
654         bulletsHeight = applyRatio (bulletsSizeModel.height, getRatio (HEIGHT));
655         bulletsHeight = bulletsHeight <=
656           (availableHeightForBullets / requiredNumBulletsForSpacing) ?
657           bulletsHeight :
658           (availableHeightForBullets / requiredNumBulletsForSpacing);
659       }
660       if (bulletsWidth <= 0 || bulletsHeight <= 0) {
661         bulletsWidth = 0;
662         bulletsHeight = 0;
663         betweenBulletsGapThickness = 0;
664       }
665     }
666
667     if (!getAutoSize (MIN) && allowSelfSize) {
668       int minSpaceWidth =
669         bulletsWidth + betweenBulletsAndLabelsGapThickness + labelsWidth;
670       int possibleMinSpaceHeightLabels =
671         numLabels * labelsHeight + (numLabels - 1) * betweenLabelsGapThickness;
672       int possibleMinSpaceHeightBullets =
673         requiredNumBulletsForSpacing * bulletsHeight +
674         numBulletGaps * betweenBulletsGapThickness;
675       int minSpaceHeight =
676         possibleMinSpaceHeightLabels > possibleMinSpaceHeightBullets ?
677         possibleMinSpaceHeightLabels : possibleMinSpaceHeightBullets;
678       minSpaceHeight =
679         customizeSpaceMinHeight && customSpaceMinHeight > minSpaceHeight ?
680         customSpaceMinHeight : minSpaceHeight;
681       setSpaceSize (MIN,
682         new Dimension (minSpaceWidth, minSpaceHeight));
683     }
684
685     int numComps = numLabels;
686     float compHeight = getSpaceSize (MIN).height / (float)numComps;
687     int x = getSpaceSizeLocation (MIN).x;
688     int y = getSpaceSizeLocation (MIN).y;
689     int labelsX = 0, labelsY = 0, bulletsX = 0, bulletsY = 0;
690     for (int i = 0; i < numComps; ++i) {
691
692       labels[i].setAutoJustifys (false, false);
693       if (bulletsRelation == LEFT) {
694         labelsX = x + bulletsWidth + betweenBulletsAndLabelsGapThickness;
695         bulletsX = x;
696       }
697       else {
698         labelsX = x + labelsWidth - labels[i].getSpaceSize(MIN).width;
699         bulletsX = x + labelsWidth + betweenBulletsAndLabelsGapThickness;
700       }
701       labelsY = (int)(y + i * compHeight +
702         (compHeight - labels[i].getSpaceSize (MIN).height) / 2f);
703       labels[i].setSpaceSizeLocation (MIN, new Point (labelsX, labelsY));
704       if (i < numBullets) {
705         if (bulletsAlignment == CENTERED) {
706           bulletsY =
707             (int)(y + i * compHeight + (compHeight - bulletsHeight) / 2f);
708         }
709         else {
710           bulletsY =
711             (int)(y + (i + 1) * compHeight - bulletsHeight / 2f);
712         }
713         bullets[i] = new Rectangle();
714         bullets[i].setLocation (bulletsX, bulletsY);
715         bullets[i].setSize (bulletsWidth, bulletsHeight);
716       }
717     }
718   }
719 }
Popular Tags