Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPictureExplorer.java
More file actions
Latest commit
executable file
·807 lines (697 loc) · 23.4 KB
/
Copy pathPictureExplorer.java
File metadata and controls
executable file
·807 lines (697 loc) · 23.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.awt.image.*;
importjavax.swing.border.*;
/**
* Displays a picture and lets you explore the picture by displaying the row, column, red,
* green, and blue values of the pixel at the cursor when you click a mouse button or
* press and hold a mouse button while moving the cursor. It also lets you zoom in or
* out. You can also type in a row and column value to see the color at that location.
*
* Originally created for the Jython Environment for Students (JES).
* Modified to work with DrJava by Barbara Ericson
* Also modified to show row and columns by Barbara Ericson
*
* @author Keith McDermottt, gte047w@cc.gatech.edu
* @author Barb Ericson ericson@cc.gatech.edu
*/
publicclassPictureExplorerimplementsMouseMotionListener, ActionListener, MouseListener
{
// current indicies
/** row index */
privateintrowIndex = 0;
/** column index */
privateintcolIndex = 0;
// main GUI
/** window to hold GUI */
privateJFramepictureFrame;
/** window that allows the user to scroll to see a large picture */
privateJScrollPanescrollPane;
// GUI components
/** column label */
privateJLabelcolLabel;
/** column previous button */
privateJButtoncolPrevButton;
/** row previous button */
privateJButtonrowPrevButton;
/** column next button */
privateJButtoncolNextButton;
/** row next button */
privateJButtonrowNextButton;
/** row label */
privateJLabelrowLabel;
/** text field to show column index */
privateJTextFieldcolValue;
/** text field to show row index */
privateJTextFieldrowValue;
/** red value label */
privateJLabelrValue;
/** green value label */
privateJLabelgValue;
/** blue value label */
privateJLabelbValue;
/** color swatch label */
privateJLabelcolorLabel;
/** panel to show the color swatch */
privateJPanelcolorPanel;
// menu components
/** menu bar */
privateJMenuBarmenuBar;
/** zoom menu */
privateJMenuzoomMenu;
/** 25% zoom level */
privateJMenuItemtwentyFive;
/** 50% zoom level */
privateJMenuItemfifty;
/** 75% zoom level */
privateJMenuItemseventyFive;
/** 100% zoom level */
privateJMenuItemhundred;
/** 150% zoom level */
privateJMenuItemhundredFifty;
/** 200% zoom level */
privateJMenuItemtwoHundred;
/** 500% zoom level */
privateJMenuItemfiveHundred;
/** The picture being explored */
privateDigitalPicturepicture;
/** The image icon used to display the picture */
privateImageIconscrollImageIcon;
/** The image display */
privateImageDisplayimageDisplay;
/** the zoom factor (amount to zoom) */
privatedoublezoomFactor;
/** the number system to use, 0 means starting at 0, 1 means starting at 1 */
privateintnumberBase=0;
/**
* Public constructor
* @param picture the picture to explore
*/
publicPictureExplorer(DigitalPicturepicture)
{
// set the fields
this.picture=picture;
zoomFactor=1;
// create the window and set things up
createWindow();
}
/**
* Changes the number system to start at one
*/
publicvoidchangeToBaseOne()
{
numberBase=1;
}
/**
* Set the title of the frame
*@param title the title to use in the JFrame
*/
publicvoidsetTitle(Stringtitle)
{
pictureFrame.setTitle(title);
}
/**
* Method to create and initialize the picture frame
*/
privatevoidcreateAndInitPictureFrame()
{
pictureFrame = newJFrame(); // create the JFrame
pictureFrame.setResizable(true); // allow the user to resize it
pictureFrame.getContentPane().setLayout(newBorderLayout()); // use border layout
pictureFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // when close stop
pictureFrame.setTitle(picture.getTitle());
PictureExplorerFocusTraversalPolicynewPolicy = newPictureExplorerFocusTraversalPolicy();
pictureFrame.setFocusTraversalPolicy(newPolicy);
}
/**
* Method to create the menu bar, menus, and menu items
*/
privatevoidsetUpMenuBar()
{
//create menu
menuBar = newJMenuBar();
zoomMenu = newJMenu("Zoom");
twentyFive = newJMenuItem("25%");
fifty = newJMenuItem("50%");
seventyFive = newJMenuItem("75%");
hundred = newJMenuItem("100%");
hundred.setEnabled(false);
hundredFifty = newJMenuItem("150%");
twoHundred = newJMenuItem("200%");
fiveHundred = newJMenuItem("500%");
// add the action listeners
twentyFive.addActionListener(this);
fifty.addActionListener(this);
seventyFive.addActionListener(this);
hundred.addActionListener(this);
hundredFifty.addActionListener(this);
twoHundred.addActionListener(this);
fiveHundred.addActionListener(this);
// add the menu items to the menus
zoomMenu.add(twentyFive);
zoomMenu.add(fifty);
zoomMenu.add(seventyFive);
zoomMenu.add(hundred);
zoomMenu.add(hundredFifty);
zoomMenu.add(twoHundred);
zoomMenu.add(fiveHundred);
menuBar.add(zoomMenu);
// set the menu bar to this menu
pictureFrame.setJMenuBar(menuBar);
}
/**
* Create and initialize the scrolling image
*/
privatevoidcreateAndInitScrollingImage()
{
scrollPane = newJScrollPane();
BufferedImagebimg = picture.getBufferedImage();
imageDisplay = newImageDisplay(bimg);
imageDisplay.addMouseMotionListener(this);
imageDisplay.addMouseListener(this);
imageDisplay.setToolTipText("Click a mouse button on a pixel to see the pixel information");
scrollPane.setViewportView(imageDisplay);
pictureFrame.getContentPane().add(scrollPane, BorderLayout.CENTER);
}
/**
* Creates the JFrame and sets everything up
*/
privatevoidcreateWindow()
{
// create the picture frame and initialize it
createAndInitPictureFrame();
// set up the menu bar
setUpMenuBar();
//create the information panel
createInfoPanel();
//creates the scrollpane for the picture
createAndInitScrollingImage();
// show the picture in the frame at the size it needs to be
pictureFrame.pack();
pictureFrame.setVisible(true);
}
/**
* Method to set up the next and previous buttons for the
* pixel location information
*/
privatevoidsetUpNextAndPreviousButtons()
{
// create the image icons for the buttons
IconprevIcon = newImageIcon(DigitalPicture.class.getResource("leftArrow.gif"),
"previous index");
IconnextIcon = newImageIcon(DigitalPicture.class.getResource("rightArrow.gif"),
"next index");
// create the arrow buttons
colPrevButton = newJButton(prevIcon);
colNextButton = newJButton(nextIcon);
rowPrevButton = newJButton(prevIcon);
rowNextButton = newJButton(nextIcon);
// set the tool tip text
colNextButton.setToolTipText("Click to go to the next column value");
colPrevButton.setToolTipText("Click to go to the previous column value");
rowNextButton.setToolTipText("Click to go to the next row value");
rowPrevButton.setToolTipText("Click to go to the previous row value");
// set the sizes of the buttons
intprevWidth = prevIcon.getIconWidth() + 2;
intnextWidth = nextIcon.getIconWidth() + 2;
intprevHeight = prevIcon.getIconHeight() + 2;
intnextHeight = nextIcon.getIconHeight() + 2;
DimensionprevDimension = newDimension(prevWidth,prevHeight);
DimensionnextDimension = newDimension(nextWidth, nextHeight);
colPrevButton.setPreferredSize(prevDimension);
rowPrevButton.setPreferredSize(prevDimension);
colNextButton.setPreferredSize(nextDimension);
rowNextButton.setPreferredSize(nextDimension);
// handle previous column button press
colPrevButton.addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEventevt) {
colIndex--;
if (colIndex < 0)
colIndex = 0;
displayPixelInformation(colIndex,rowIndex);
}
});
// handle previous row button press
rowPrevButton.addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEventevt) {
rowIndex--;
if (rowIndex < 0)
rowIndex = 0;
displayPixelInformation(colIndex,rowIndex);
}
});
// handle next column button press
colNextButton.addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEventevt) {
colIndex++;
if (colIndex >= picture.getWidth())
colIndex = picture.getWidth() - 1;
displayPixelInformation(colIndex,rowIndex);
}
});
// handle next row button press
rowNextButton.addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEventevt) {
rowIndex++;
if (rowIndex >= picture.getHeight())
rowIndex = picture.getHeight() - 1;
displayPixelInformation(colIndex,rowIndex);
}
});
}
/**
* Create the pixel location panel
* @param labelFont the font for the labels
* @return the location panel
*/
publicJPanelcreateLocationPanel(FontlabelFont) {
// create a location panel
JPanellocationPanel = newJPanel();
locationPanel.setLayout(newFlowLayout());
BoxhBox = Box.createHorizontalBox();
// create the labels
rowLabel = newJLabel("Row:");
colLabel = newJLabel("Column:");
// create the text fields
colValue = newJTextField(Integer.toString(colIndex + numberBase),6);
colValue.addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEvente) {
displayPixelInformation(colValue.getText(),rowValue.getText());
}
});
rowValue = newJTextField(Integer.toString(rowIndex + numberBase),6);
rowValue.addActionListener(newActionListener() {
publicvoidactionPerformed(ActionEvente) {
displayPixelInformation(colValue.getText(),rowValue.getText());
}
});
// set up the next and previous buttons
setUpNextAndPreviousButtons();
// set up the font for the labels
colLabel.setFont(labelFont);
rowLabel.setFont(labelFont);
colValue.setFont(labelFont);
rowValue.setFont(labelFont);
// add the items to the vertical box and the box to the panel
hBox.add(Box.createHorizontalGlue());
hBox.add(rowLabel);
hBox.add(rowPrevButton);
hBox.add(rowValue);
hBox.add(rowNextButton);
hBox.add(Box.createHorizontalStrut(10));
hBox.add(colLabel);
hBox.add(colPrevButton);
hBox.add(colValue);
hBox.add(colNextButton);
locationPanel.add(hBox);
hBox.add(Box.createHorizontalGlue());
returnlocationPanel;
}
/**
* Create the color information panel
* @param labelFont the font to use for labels
* @return the color information panel
*/
privateJPanelcreateColorInfoPanel(FontlabelFont)
{
// create a color info panel
JPanelcolorInfoPanel = newJPanel();
colorInfoPanel.setLayout(newFlowLayout());
// get the pixel at the x and y
Pixelpixel = newPixel(picture,colIndex,rowIndex);
// create the labels
rValue = newJLabel("R: " + pixel.getRed());
gValue = newJLabel("G: " + pixel.getGreen());
bValue = newJLabel("B: " + pixel.getBlue());
// create the sample color panel and label
colorLabel = newJLabel("Color at location: ");
colorPanel = newJPanel();
colorPanel.setBorder(newLineBorder(Color.black,1));
// set the color sample to the pixel color
colorPanel.setBackground(pixel.getColor());
// set the font
rValue.setFont(labelFont);
gValue.setFont(labelFont);
bValue.setFont(labelFont);
colorLabel.setFont(labelFont);
colorPanel.setPreferredSize(newDimension(25,25));
// add items to the color information panel
colorInfoPanel.add(rValue);
colorInfoPanel.add(gValue);
colorInfoPanel.add(bValue);
colorInfoPanel.add(colorLabel);
colorInfoPanel.add(colorPanel);
returncolorInfoPanel;
}
/**
* Creates the North JPanel with all the pixel location
* and color information
*/
privatevoidcreateInfoPanel()
{
// create the info panel and set the layout
JPanelinfoPanel = newJPanel();
infoPanel.setLayout(newBorderLayout());
// create the font
FontlargerFont = newFont(infoPanel.getFont().getName(),
infoPanel.getFont().getStyle(),14);
// create the pixel location panel
JPanellocationPanel = createLocationPanel(largerFont);
// create the color information panel
JPanelcolorInfoPanel = createColorInfoPanel(largerFont);
// add the panels to the info panel
infoPanel.add(BorderLayout.NORTH,locationPanel);
infoPanel.add(BorderLayout.SOUTH,colorInfoPanel);
// add the info panel
pictureFrame.getContentPane().add(BorderLayout.NORTH,infoPanel);
}
/**
* Method to check that the current position is in the viewing area and if
* not scroll to center the current position if possible
*/
publicvoidcheckScroll()
{
// get the x and y position in pixels
intxPos = (int) (colIndex * zoomFactor);
intyPos = (int) (rowIndex * zoomFactor);
// only do this if the image is larger than normal
if (zoomFactor > 1) {
// get the rectangle that defines the current view
JViewportviewport = scrollPane.getViewport();
Rectanglerect = viewport.getViewRect();
intrectMinX = (int) rect.getX();
intrectWidth = (int) rect.getWidth();
intrectMaxX = rectMinX + rectWidth - 1;
intrectMinY = (int) rect.getY();
intrectHeight = (int) rect.getHeight();
intrectMaxY = rectMinY + rectHeight - 1;
// get the maximum possible x and y index
intmacolIndexX = (int) (picture.getWidth() * zoomFactor) - rectWidth - 1;
intmacolIndexY = (int) (picture.getHeight() * zoomFactor) - rectHeight - 1;
// calculate how to position the current position in the middle of the viewing
// area
intviewX = xPos - (int) (rectWidth / 2);
intviewY = yPos - (int) (rectHeight / 2);
// reposition the viewX and viewY if outside allowed values
if (viewX < 0)
viewX = 0;
elseif (viewX > macolIndexX)
viewX = macolIndexX;
if (viewY < 0)
viewY = 0;
elseif (viewY > macolIndexY)
viewY = macolIndexY;
// move the viewport upper left point
viewport.scrollRectToVisible(newRectangle(viewX,viewY,rectWidth,rectHeight));
}
}
/**
* Zooms in the on picture by scaling the image.
* It is extremely memory intensive.
* @param factor the amount to zoom by
*/
publicvoidzoom(doublefactor)
{
// save the current zoom factor
zoomFactor = factor;
// calculate the new width and height and get an image that size
intwidth = (int) (picture.getWidth()*zoomFactor);
intheight = (int) (picture.getHeight()*zoomFactor);
BufferedImagebimg = picture.getBufferedImage();
// set the scroll image icon to the new image
imageDisplay.setImage(bimg.getScaledInstance(width, height, Image.SCALE_DEFAULT));
imageDisplay.setCurrentX((int) (colIndex * zoomFactor));
imageDisplay.setCurrentY((int) (rowIndex * zoomFactor));
imageDisplay.revalidate();
checkScroll(); // check if need to reposition scroll
}
/**
* Repaints the image on the scrollpane.
*/
publicvoidrepaint()
{
pictureFrame.repaint();
}
//****************************************//
// Event Listeners //
//****************************************//
/**
* Called when the mouse is dragged (button held down and moved)
* @param e the mouse event
*/
publicvoidmouseDragged(MouseEvente)
{
displayPixelInformation(e);
}
/**
* Method to check if the given x and y are in the picture
* @param column the horizontal value
* @param row the vertical value
* @return true if the row and column are in the picture
* and false otherwise
*/
privatebooleanisLocationInPicture(intcolumn, introw)
{
booleanresult = false; // the default is false
if (column >= 0 && column < picture.getWidth() &&
row >= 0 && row < picture.getHeight())
result = true;
returnresult;
}
/**
* Method to display the pixel information from the passed x and y but
* also converts x and y from strings
* @param xString the x value as a string from the user
* @param yString the y value as a string from the user
*/
publicvoiddisplayPixelInformation(StringxString, StringyString)
{
intx = -1;
inty = -1;
try {
x = Integer.parseInt(xString);
x = x - numberBase;
y = Integer.parseInt(yString);
y = y - numberBase;
} catch (Exceptionex) {
}
if (x >= 0 && y >= 0) {
displayPixelInformation(x,y);
}
}
/**
* Method to display pixel information for the passed x and y
* @param pictureX the x value in the picture
* @param pictureY the y value in the picture
*/
privatevoiddisplayPixelInformation(intpictureX, intpictureY)
{
// check that this x and y are in range
if (isLocationInPicture(pictureX, pictureY))
{
// save the current x and y index
colIndex = pictureX;
rowIndex = pictureY;
// get the pixel at the x and y
Pixelpixel = newPixel(picture,colIndex,rowIndex);
// set the values based on the pixel
colValue.setText(Integer.toString(colIndex + numberBase));
rowValue.setText(Integer.toString(rowIndex + numberBase));
rValue.setText("R: " + pixel.getRed());
gValue.setText("G: " + pixel.getGreen());
bValue.setText("B: " + pixel.getBlue());
colorPanel.setBackground(newColor(pixel.getRed(), pixel.getGreen(), pixel.getBlue()));
}
else
{
clearInformation();
}
// notify the image display of the current x and y
imageDisplay.setCurrentX((int) (colIndex * zoomFactor));
imageDisplay.setCurrentY((int) (rowIndex * zoomFactor));
}
/**
* Method to display pixel information based on a mouse event
* @param e a mouse event
*/
privatevoiddisplayPixelInformation(MouseEvente)
{
// get the cursor x and y
intcursorX = e.getX();
intcursorY = e.getY();
// get the x and y in the original (not scaled image)
intpictureX = (int) (cursorX / zoomFactor + numberBase);
intpictureY = (int) (cursorY / zoomFactor + numberBase);
// display the information for this x and y
displayPixelInformation(pictureX,pictureY);
}
/**
* Method to clear the labels and current color and reset the
* current index to -1
*/
privatevoidclearInformation()
{
colValue.setText("N/A");
rowValue.setText("N/A");
rValue.setText("R: N/A");
gValue.setText("G: N/A");
bValue.setText("B: N/A");
colorPanel.setBackground(Color.black);
colIndex = -1;
rowIndex = -1;
}
/**
* Method called when the mouse is moved with no buttons down
* @param e the mouse event
*/
publicvoidmouseMoved(MouseEvente)
{}
/**
* Method called when the mouse is clicked
* @param e the mouse event
*/
publicvoidmouseClicked(MouseEvente)
{
displayPixelInformation(e);
}
/**
* Method called when the mouse button is pushed down
* @param e the mouse event
*/
publicvoidmousePressed(MouseEvente)
{
displayPixelInformation(e);
}
/**
* Method called when the mouse button is released
* @param e the mouse event
*/
publicvoidmouseReleased(MouseEvente)
{
}
/**
* Method called when the component is entered (mouse moves over it)
* @param e the mouse event
*/
publicvoidmouseEntered(MouseEvente)
{
}
/**
* Method called when the mouse moves over the component
* @param e the mouse event
*/
publicvoidmouseExited(MouseEvente)
{
}
/**
* Method to enable all menu commands
*/
privatevoidenableZoomItems()
{
twentyFive.setEnabled(true);
fifty.setEnabled(true);
seventyFive.setEnabled(true);
hundred.setEnabled(true);
hundredFifty.setEnabled(true);
twoHundred.setEnabled(true);
fiveHundred.setEnabled(true);
}
/**
* Controls the zoom menu bar
*
* @param a the ActionEvent
*/
publicvoidactionPerformed(ActionEventa)
{
if(a.getActionCommand().equals("Update"))
{
this.repaint();
}
if(a.getActionCommand().equals("25%"))
{
this.zoom(.25);
enableZoomItems();
twentyFive.setEnabled(false);
}
if(a.getActionCommand().equals("50%"))
{
this.zoom(.50);
enableZoomItems();
fifty.setEnabled(false);
}
if(a.getActionCommand().equals("75%"))
{
this.zoom(.75);
enableZoomItems();
seventyFive.setEnabled(false);
}
if(a.getActionCommand().equals("100%"))
{
this.zoom(1.0);
enableZoomItems();
hundred.setEnabled(false);
}
if(a.getActionCommand().equals("150%"))
{
this.zoom(1.5);
enableZoomItems();
hundredFifty.setEnabled(false);
}
if(a.getActionCommand().equals("200%"))
{
this.zoom(2.0);
enableZoomItems();
twoHundred.setEnabled(false);
}
if(a.getActionCommand().equals("500%"))
{
this.zoom(5.0);
enableZoomItems();
fiveHundred.setEnabled(false);
}
}
/**
* Class for establishing the focus for the textfields
*/
privateclassPictureExplorerFocusTraversalPolicy
extendsFocusTraversalPolicy {
/**
* Method to get the next component for focus
*/
publicComponentgetComponentAfter(ContainerfocusCycleRoot,
ComponentaComponent) {
if (aComponent.equals(colValue))
returnrowValue;
else
returncolValue;
}
/**
* Method to get the previous component for focus
*/
publicComponentgetComponentBefore(ContainerfocusCycleRoot,
ComponentaComponent) {
if (aComponent.equals(colValue))
returnrowValue;
else
returncolValue;
}
publicComponentgetDefaultComponent(ContainerfocusCycleRoot) {
returncolValue;
}
publicComponentgetLastComponent(ContainerfocusCycleRoot) {
returnrowValue;
}
publicComponentgetFirstComponent(ContainerfocusCycleRoot) {
returncolValue;
}
}
/**
* Test Main. It will explore the beach
*/
publicstaticvoidmain( Stringargs[])
{
Picturepix = newPicture("beach.jpg");
pix.explore();
}
}