summaryrefslogtreecommitdiff
path: root/java/ImageProcessing/framework/FilePanel.java
blob: f8ffc7dbca8f993b505a4bce1cd3b63d7f611b93 (plain)
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
package imaging.framework;

import java.awt.*;

// Create a panel for all the buttons
class FilePanel extends Panel
{
  FilePanel (ImageApp parent)
  {
    this.parent_ = parent;

    this.setLayout (new GridLayout (2, 1));

    // First create all the buttons
    this.URLDialogButton_ = new URLDialogButton ("Open URL", "Download an image", this.parent_);
    this.saveButton_ = new SaveButton ("Save", "Upload an image", this.parent_);

    // Place the created buttons in the panel
    this.add (this.URLDialogButton_);
    this.add (this.saveButton_);

    // Disable the save button for now
    this.disableSaveButton ();
    this.resize (400, 400);
  }

  public void enableSaveButton ()
  {
    this.saveButton_.enable ();
  }

  public void disableSaveButton ()
  {
    this.saveButton_.disable ();
  }

  // All the created buttons
  private URLDialogButton URLDialogButton_;
  private SaveButton saveButton_;

  private ImageApp parent_;
}

// Create a panel for all the buttons
class ResetPanel extends Panel
{
  ResetPanel (ImageApp parent)
  {
    this.parent_ = parent;

    this.setLayout (new GridLayout (2, 1));

    // First create all the buttons
    this.reloadButton_ = new ReloadButton ("Reload Filters", "Reload all filters", this.parent_);

    // **********************
    // Disable this until it works
    // **********************
    this.reloadButton_.disable();


    this.resetButton_ = new ResetButton ("Reset", "Reset the image", this.parent_);


    // Place the created buttons in the panel
    this.add (this.resetButton_);
    this.add (this.reloadButton_);

    this.resize (400, 400);
  }

  // All the created buttons
  private ReloadButton reloadButton_;
  private ResetButton resetButton_;

  private ImageApp parent_;
}


class ZoomPanel extends Panel
{
  ZoomPanel (ImageApp parent)
  {
    this.parent_ = parent;

    this.setLayout (new GridLayout (2, 1));

    // First create the two zoom buttons
    this.zoomInButton_ = new ZoomInButton ("<< Zoom in", "Zoom into the image", this.parent_);
    this.zoomOutButton_ = new ZoomOutButton ("Zoom out >>", "Zoom out of the image", this.parent_);

    // Now add the buttons to the panel
    this.add (this.zoomInButton_);
    this.add (this.zoomOutButton_);

    this.resize (100, 100);
  }

  private ZoomInButton zoomInButton_;
  private ZoomOutButton zoomOutButton_;

  private ImageApp parent_;
}


class FilterPanel extends Panel
{
  FilterPanel (ImageApp parent)
  {
    this.parent_ = parent;

    this.setLayout (new GridLayout (2, 1));
    this.applyButton_ = new ApplyButton ("Apply", "Apply the selected filter", this.parent_);

    // Set the layout of the Choice Panel. Note that the Choice Panel
    // holds the choice button of filters.
    this.choicePanel_ = new ChoicePanel ("Select filter", this.parent_);

    this.add (this.applyButton_);
    this.add (this.choicePanel_);
    this.resize (200,200);
  }

  public Choice choice ()
  {
    return this.choicePanel_.choice ();
  }

  public void loadFilters ()
  {
    this.choicePanel_.loadFilters ();
  }

  private ChoicePanel choicePanel_;
  private ApplyButton applyButton_;
  private ImageApp parent_;
}

class HelpPanel extends Panel
{
  HelpPanel (ImageApp parent)
  {
    this.parent_ = parent;

    this.setLayout (new GridLayout (2, 1));

    this.aboutButton_ = new AboutButton ("About", "About the applet", this.parent_);
    this.helpButton_ = new HelpButton ("Help", "Help on how to use the applet", this.parent_);

    // Now add the buttons to the panel
    this.add (this.aboutButton_);
    this.add (this.helpButton_);

    this.resize (100, 100);
  }

  private AboutButton aboutButton_;
  private HelpButton helpButton_;

  private ImageApp parent_;
}