/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
enum DitherMethod {
};
@SuppressWarnings("serial")
ditherTest.init();
f.pack();
f.setVisible(true);
ditherTest.start();
}
public void init() {
int xvals[] = new int[2];
int yvals[] = new int[2];
try {
} catch (NullPointerException ignored) {
//only occurs if run as application
}
xspec = "red";
}
yspec = "blue";
}
setLayout(new BorderLayout());
xmethod, false);
ymethod, true);
}
if (s == null) {
s = "";
}
method = m;
}
}
return method;
}
int begval = 0;
int endval = 255;
try {
if (dash < 0) {
} else {
}
} catch (NumberFormatException ignored) {
}
if (begval < 0) {
begval = 0;
} else if (begval > 255) {
begval = 255;
}
if (endval < 0) {
endval = 0;
} else if (endval > 255) {
endval = 255;
}
return method;
}
/**
* Calculates and returns the image. Halts the calculation and returns
* null if the Applet is stopped during the calculation.
*/
int xvals[] = new int[2];
int yvals[] = new int[2];
int c[] = new int[4]; //temporarily holds R,G,B,A information
int index = 0;
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
c[0] = c[1] = c[2] = 0;
c[3] = 255;
} else {
}
| c[2]);
}
// Poll once per row to see if we've been told to stop.
return null;
}
}
}
return;
}
? vals[0]
switch (method) {
case RED:
c[0] = val;
break;
case GREEN:
c[1] = val;
break;
case BLUE:
c[2] = val;
break;
case ALPHA:
c[3] = val;
break;
case SATURATION:
if (c[0] == 0) {
c[0] = min;
}
if (c[1] == 0) {
c[1] = min;
}
if (c[2] == 0) {
c[2] = min;
}
break;
}
}
public void start() {
}
public void run() {
}
}
public void stop() {
}
public void destroy() {
}
return "An interactive demonstration of dithering.";
}
{ "xaxis", "{RED, GREEN, BLUE, ALPHA, SATURATION}",
"The color of the Y axis. Default is RED." },
{ "yaxis", "{RED, GREEN, BLUE, ALPHA, SATURATION}",
"The color of the X axis. Default is BLUE." }
};
return info;
}
}
@SuppressWarnings("serial")
super.paint(g);
int y = h / 2;
g.drawString(calcString, x, y);
} else {
}
}
paint(g);
}
}
}
return img;
}
repaint();
}
}
@SuppressWarnings("serial")
10, 5);
boolean vertical) {
}
}
/* puts on the button */
public void addRenderButton() {
button.addActionListener(this);
}
/* retrieves data from the user input fields */
try {
} catch (NumberFormatException nfe) {
}
try {
} catch (NumberFormatException nfe) {
}
return choice.getSelectedIndex();
}
/* fits the number between 0 and 255 inclusive */
if (number < 0) {
number = 0;
} else if (number > 255) {
number = 255;
}
return number;
}
/* called when user clicks the button */
}
}
}
@SuppressWarnings("serial")
}
// Consume non-digit KeyTyped events
// Note that processTextEvent kind of eliminates the need for this
// function, but this is neater, since ideally, it would prevent
// the text from appearing at all. Sigh. See bugid 4100317/4114565.
//
super.processEvent(evt);
return;
}
char c = kevt.getKeyChar();
// Digits, backspace, and delete are okay
// Note that the minus sign is not allowed (neither is decimal)
super.processEvent(evt);
return;
}
}
// Should consume TextEvents for non-integer Strings
// Store away the text in the tf for every TextEvent
// so we can revert to it on a TextEvent (paste, or
// legal key in the wrong location) with bad text
//
// Note: it would be easy to extend this to an eight-bit
// TextField (range 0-255), but I'll leave it as-is.
//
// The empty string is okay, too
super.processTextEvent(te);
return;
}
}
// Returns true for Cardinal (non-negative) numbers
// Note that the empty string is not allowed
try {
} catch (NumberFormatException nfe) {
return false;
}
}
}