_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q6200 | Orientation.imageOrientationsOf | train | private static Set<String> imageOrientationsOf(ImageMetadata metadata) {
String exifIFD0DirName = new ExifIFD0Directory().getName();
Tag[] tags = Arrays.stream(metadata.getDirectories())
.filter(dir -> dir.getName().equals(exifIFD0DirName))
.findFirst()
.map(Directory::getTags)
.orElseGet(() -> new Tag[0]);
return Arrays.stream(tags)
.filter(tag -> tag.getType() == 274)
.map(Tag::getRawValue)
.collect(Collectors.toSet());
} | java | {
"resource": ""
} |
q6201 | Noise.noise1 | train | public static float noise1(float x) {
int bx0, bx1;
float rx0, rx1, sx, t, u, v;
if (start) {
start = false;
init();
}
t = x + N;
bx0 = ((int)t) & BM;
bx1 = (bx0+1) & BM;
rx0 = t - (int)t;
rx1 = rx0 - 1.0f;
sx = sCurve(rx0);
u = rx0 * g1[p[bx0]];
v = rx1 * g1[p[bx1]];
return 2.3f*lerp(sx, u, v);
} | java | {
"resource": ""
} |
q6202 | Noise.noise2 | train | public static float noise2(float x, float y) {
int bx0, bx1, by0, by1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, q[], sx, sy, a, b, t, u, v;
int i, j;
if (start) {
start = false;
init();
}
t = x + N;
bx0 = ((int)t) & BM;
bx1 = (bx0+1) & BM;
rx0 = t - (int)t;
rx1 = rx0 - 1.0f;
t = y + N;
by0 = ((int)t) & BM;
by1 = (by0+1) & BM;
ry0 = t - (int)t;
ry1 = ry0 - 1.0f;
i = p[bx0];
j = p[bx1];
b00 = p[i + by0];
b10 = p[j + by0];
b01 = p[i + by1];
b11 = p[j + by1];
sx = sCurve(rx0);
sy = sCurve(ry0);
q = g2[b00]; u = rx0 * q[0] + ry0 * q[1];
q = g2[b10]; v = rx1 * q[0] + ry0 * q[1];
a = lerp(sx, u, v);
q = g2[b01]; u = rx0 * q[0] + ry1 * q[1];
q = g2[b11]; v = rx1 * q[0] + ry1 * q[1];
b = lerp(sx, u, v);
return 1.5f*lerp(sy, a, b);
} | java | {
"resource": ""
} |
q6203 | LinearSubpixelInterpolator.integerPixelCoordinatesAndWeights | train | private List<Pair<Integer, Double>> integerPixelCoordinatesAndWeights(double d, int numPixels) {
if (d <= 0.5) return Collections.singletonList(new Pair<>(0, 1.0));
else if (d >= numPixels - 0.5) return Collections.singletonList(new Pair<>(numPixels - 1, 1.0));
else {
double shifted = d - 0.5;
double floor = Math.floor(shifted);
double floorWeight = 1 - (shifted - floor);
double ceil = Math.ceil(shifted);
double ceilWeight = 1 - floorWeight;
assert (floorWeight + ceilWeight == 1);
return Arrays.asList(new Pair<>((int) floor, floorWeight), new Pair<>((int) ceil, ceilWeight));
}
} | java | {
"resource": ""
} |
q6204 | ImageUtils.createImage | train | public static BufferedImage createImage(ImageProducer producer) {
PixelGrabber pg = new PixelGrabber(producer, 0, 0, -1, -1, null, 0, 0);
try {
pg.grabPixels();
} catch (InterruptedException e) {
throw new RuntimeException("Image fetch interrupted");
}
if ((pg.status() & ImageObserver.ABORT) != 0)
throw new RuntimeException("Image fetch aborted");
if ((pg.status() & ImageObserver.ERROR) != 0)
throw new RuntimeException("Image fetch error");
BufferedImage p = new BufferedImage(pg.getWidth(), pg.getHeight(), BufferedImage.TYPE_INT_ARGB);
p.setRGB(0, 0, pg.getWidth(), pg.getHeight(), (int[])pg.getPixels(), 0, pg.getWidth());
return p;
} | java | {
"resource": ""
} |
q6205 | ImageUtils.convertImageToARGB | train | public static BufferedImage convertImageToARGB( Image image ) {
if ( image instanceof BufferedImage && ((BufferedImage)image).getType() == BufferedImage.TYPE_INT_ARGB )
return (BufferedImage)image;
BufferedImage p = new BufferedImage( image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = p.createGraphics();
g.drawImage( image, 0, 0, null );
g.dispose();
return p;
} | java | {
"resource": ""
} |
q6206 | ImageUtils.cloneImage | train | public static BufferedImage cloneImage( BufferedImage image ) {
BufferedImage newImage = new BufferedImage( image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB );
Graphics2D g = newImage.createGraphics();
g.drawRenderedImage( image, null );
g.dispose();
return newImage;
} | java | {
"resource": ""
} |
q6207 | ImageUtils.paintCheckedBackground | train | public static void paintCheckedBackground(Component c, Graphics g, int x, int y, int width, int height) {
if ( backgroundImage == null ) {
backgroundImage = new BufferedImage( 64, 64, BufferedImage.TYPE_INT_ARGB );
Graphics bg = backgroundImage.createGraphics();
for ( int by = 0; by < 64; by += 8 ) {
for ( int bx = 0; bx < 64; bx += 8 ) {
bg.setColor( ((bx^by) & 8) != 0 ? Color.lightGray : Color.white );
bg.fillRect( bx, by, 8, 8 );
}
}
bg.dispose();
}
if ( backgroundImage != null ) {
Shape saveClip = g.getClip();
Rectangle r = g.getClipBounds();
if (r == null)
r = new Rectangle(c.getSize());
r = r.intersection(new Rectangle(x, y, width, height));
g.setClip(r);
int w = backgroundImage.getWidth();
int h = backgroundImage.getHeight();
if (w != -1 && h != -1) {
int x1 = (r.x / w) * w;
int y1 = (r.y / h) * h;
int x2 = ((r.x + r.width + w - 1) / w) * w;
int y2 = ((r.y + r.height + h - 1) / h) * h;
for (y = y1; y < y2; y += h)
for (x = x1; x < x2; x += w)
g.drawImage(backgroundImage, x, y, c);
}
g.setClip(saveClip);
}
} | java | {
"resource": ""
} |
q6208 | ImageUtils.getSelectedBounds | train | public static Rectangle getSelectedBounds(BufferedImage p) {
int width = p.getWidth();
int height = p.getHeight();
int maxX = 0, maxY = 0, minX = width, minY = height;
boolean anySelected = false;
int y1;
int [] pixels = null;
for (y1 = height-1; y1 >= 0; y1--) {
pixels = getRGB( p, 0, y1, width, 1, pixels );
for (int x = 0; x < minX; x++) {
if ((pixels[x] & 0xff000000) != 0) {
minX = x;
maxY = y1;
anySelected = true;
break;
}
}
for (int x = width-1; x >= maxX; x--) {
if ((pixels[x] & 0xff000000) != 0) {
maxX = x;
maxY = y1;
anySelected = true;
break;
}
}
if ( anySelected )
break;
}
pixels = null;
for (int y = 0; y < y1; y++) {
pixels = getRGB( p, 0, y, width, 1, pixels );
for (int x = 0; x < minX; x++) {
if ((pixels[x] & 0xff000000) != 0) {
minX = x;
if ( y < minY )
minY = y;
anySelected = true;
break;
}
}
for (int x = width-1; x >= maxX; x--) {
if ((pixels[x] & 0xff000000) != 0) {
maxX = x;
if ( y < minY )
minY = y;
anySelected = true;
break;
}
}
}
if ( anySelected )
return new Rectangle( minX, minY, maxX-minX+1, maxY-minY+1 );
return null;
} | java | {
"resource": ""
} |
q6209 | ImageUtils.composeThroughMask | train | public static void composeThroughMask(Raster src, WritableRaster dst, Raster sel) {
int x = src.getMinX();
int y = src.getMinY();
int w = src.getWidth();
int h = src.getHeight();
int srcRGB[] = null;
int selRGB[] = null;
int dstRGB[] = null;
for ( int i = 0; i < h; i++ ) {
srcRGB = src.getPixels(x, y, w, 1, srcRGB);
selRGB = sel.getPixels(x, y, w, 1, selRGB);
dstRGB = dst.getPixels(x, y, w, 1, dstRGB);
int k = x;
for ( int j = 0; j < w; j++ ) {
int sr = srcRGB[k];
int dir = dstRGB[k];
int sg = srcRGB[k+1];
int dig = dstRGB[k+1];
int sb = srcRGB[k+2];
int dib = dstRGB[k+2];
int sa = srcRGB[k+3];
int dia = dstRGB[k+3];
float a = selRGB[k+3]/255f;
float ac = 1-a;
dstRGB[k] = (int)(a*sr + ac*dir);
dstRGB[k+1] = (int)(a*sg + ac*dig);
dstRGB[k+2] = (int)(a*sb + ac*dib);
dstRGB[k+3] = (int)(a*sa + ac*dia);
k += 4;
}
dst.setPixels(x, y, w, 1, dstRGB);
y++;
}
} | java | {
"resource": ""
} |
q6210 | DiffusionFilter.setMatrix | train | public void setMatrix(int[] matrix) {
this.matrix = matrix;
sum = 0;
for (int i = 0; i < matrix.length; i++)
sum += matrix[i];
} | java | {
"resource": ""
} |
q6211 | ImageMath.gain | train | public static float gain(float a, float b) {
/*
float p = (float)Math.log(1.0 - b) / (float)Math.log(0.5);
if (a < .001)
return 0.0f;
else if (a > .999)
return 1.0f;
if (a < 0.5)
return (float)Math.pow(2 * a, p) / 2;
else
return 1.0f - (float)Math.pow(2 * (1. - a), p) / 2;
*/
float c = (1.0f/b-2.0f) * (1.0f-2.0f*a);
if (a < 0.5)
return a/(c+1.0f);
else
return (c-a)/(c-1.0f);
} | java | {
"resource": ""
} |
q6212 | ImageMath.smoothPulse | train | public static float smoothPulse(float a1, float a2, float b1, float b2, float x) {
if (x < a1 || x >= b2)
return 0;
if (x >= a2) {
if (x < b1)
return 1.0f;
x = (x - b1) / (b2 - b1);
return 1.0f - (x*x * (3.0f - 2.0f*x));
}
x = (x - a1) / (a2 - a1);
return x*x * (3.0f - 2.0f*x);
} | java | {
"resource": ""
} |
q6213 | ImageMath.smoothStep | train | public static float smoothStep(float a, float b, float x) {
if (x < a)
return 0;
if (x >= b)
return 1;
x = (x - a) / (b - a);
return x*x * (3 - 2*x);
} | java | {
"resource": ""
} |
q6214 | ImageMath.mixColors | train | public static int mixColors(float t, int rgb1, int rgb2) {
int a1 = (rgb1 >> 24) & 0xff;
int r1 = (rgb1 >> 16) & 0xff;
int g1 = (rgb1 >> 8) & 0xff;
int b1 = rgb1 & 0xff;
int a2 = (rgb2 >> 24) & 0xff;
int r2 = (rgb2 >> 16) & 0xff;
int g2 = (rgb2 >> 8) & 0xff;
int b2 = rgb2 & 0xff;
a1 = lerp(t, a1, a2);
r1 = lerp(t, r1, r2);
g1 = lerp(t, g1, g2);
b1 = lerp(t, b1, b2);
return (a1 << 24) | (r1 << 16) | (g1 << 8) | b1;
} | java | {
"resource": ""
} |
q6215 | ImageMath.bilinearInterpolate | train | public static int bilinearInterpolate(float x, float y, int nw, int ne, int sw, int se) {
float m0, m1;
int a0 = (nw >> 24) & 0xff;
int r0 = (nw >> 16) & 0xff;
int g0 = (nw >> 8) & 0xff;
int b0 = nw & 0xff;
int a1 = (ne >> 24) & 0xff;
int r1 = (ne >> 16) & 0xff;
int g1 = (ne >> 8) & 0xff;
int b1 = ne & 0xff;
int a2 = (sw >> 24) & 0xff;
int r2 = (sw >> 16) & 0xff;
int g2 = (sw >> 8) & 0xff;
int b2 = sw & 0xff;
int a3 = (se >> 24) & 0xff;
int r3 = (se >> 16) & 0xff;
int g3 = (se >> 8) & 0xff;
int b3 = se & 0xff;
float cx = 1.0f-x;
float cy = 1.0f-y;
m0 = cx * a0 + x * a1;
m1 = cx * a2 + x * a3;
int a = (int)(cy * m0 + y * m1);
m0 = cx * r0 + x * r1;
m1 = cx * r2 + x * r3;
int r = (int)(cy * m0 + y * m1);
m0 = cx * g0 + x * g1;
m1 = cx * g2 + x * g3;
int g = (int)(cy * m0 + y * m1);
m0 = cx * b0 + x * b1;
m1 = cx * b2 + x * b3;
int b = (int)(cy * m0 + y * m1);
return (a << 24) | (r << 16) | (g << 8) | b;
} | java | {
"resource": ""
} |
q6216 | ImageMath.brightnessNTSC | train | public static int brightnessNTSC(int rgb) {
int r = (rgb >> 16) & 0xff;
int g = (rgb >> 8) & 0xff;
int b = rgb & 0xff;
return (int)(r*0.299f + g*0.587f + b*0.114f);
} | java | {
"resource": ""
} |
q6217 | ImageMath.colorSpline | train | public static int colorSpline(int x, int numKnots, int[] xknots, int[] yknots) {
int span;
int numSpans = numKnots - 3;
float k0, k1, k2, k3;
float c0, c1, c2, c3;
if (numSpans < 1)
throw new IllegalArgumentException("Too few knots in spline");
for (span = 0; span < numSpans; span++)
if (xknots[span+1] > x)
break;
if (span > numKnots-3)
span = numKnots-3;
float t = (float)(x-xknots[span]) / (xknots[span+1]-xknots[span]);
span--;
if (span < 0) {
span = 0;
t = 0;
}
int v = 0;
for (int i = 0; i < 4; i++) {
int shift = i * 8;
k0 = (yknots[span] >> shift) & 0xff;
k1 = (yknots[span+1] >> shift) & 0xff;
k2 = (yknots[span+2] >> shift) & 0xff;
k3 = (yknots[span+3] >> shift) & 0xff;
c3 = m00*k0 + m01*k1 + m02*k2 + m03*k3;
c2 = m10*k0 + m11*k1 + m12*k2 + m13*k3;
c1 = m20*k0 + m21*k1 + m22*k2 + m23*k3;
c0 = m30*k0 + m31*k1 + m32*k2 + m33*k3;
int n = (int)(((c3*t + c2)*t + c1)*t + c0);
if (n < 0)
n = 0;
else if (n > 255)
n = 255;
v |= n << shift;
}
return v;
} | java | {
"resource": ""
} |
q6218 | Gradient.copyTo | train | public void copyTo(Gradient g) {
g.numKnots = numKnots;
g.map = (int[])map.clone();
g.xKnots = (int[])xKnots.clone();
g.yKnots = (int[])yKnots.clone();
g.knotTypes = (byte[])knotTypes.clone();
} | java | {
"resource": ""
} |
q6219 | Gradient.setColor | train | public void setColor(int n, int color) {
int firstColor = map[0];
int lastColor = map[256-1];
if (n > 0)
for (int i = 0; i < n; i++)
map[i] = ImageMath.mixColors((float)i/n, firstColor, color);
if (n < 256-1)
for (int i = n; i < 256; i++)
map[i] = ImageMath.mixColors((float)(i-n)/(256-n), color, lastColor);
} | java | {
"resource": ""
} |
q6220 | Gradient.setKnotType | train | public void setKnotType(int n, int type) {
knotTypes[n] = (byte)((knotTypes[n] & ~COLOR_MASK) | type);
rebuildGradient();
} | java | {
"resource": ""
} |
q6221 | Gradient.setKnotBlend | train | public void setKnotBlend(int n, int type) {
knotTypes[n] = (byte)((knotTypes[n] & ~BLEND_MASK) | type);
rebuildGradient();
} | java | {
"resource": ""
} |
q6222 | Gradient.setKnots | train | public void setKnots(int[] x, int[] rgb, byte[] types) {
numKnots = rgb.length+2;
xKnots = new int[numKnots];
yKnots = new int[numKnots];
knotTypes = new byte[numKnots];
if (x != null)
System.arraycopy(x, 0, xKnots, 1, numKnots-2);
else
for (int i = 1; i > numKnots-1; i++)
xKnots[i] = 255*i/(numKnots-2);
System.arraycopy(rgb, 0, yKnots, 1, numKnots-2);
if (types != null)
System.arraycopy(types, 0, knotTypes, 1, numKnots-2);
else
for (int i = 0; i > numKnots; i++)
knotTypes[i] = RGB|SPLINE;
sortKnots();
rebuildGradient();
} | java | {
"resource": ""
} |
q6223 | Gradient.setKnots | train | public void setKnots(int[] x, int[] y, byte[] types, int offset, int count) {
numKnots = count;
xKnots = new int[numKnots];
yKnots = new int[numKnots];
knotTypes = new byte[numKnots];
System.arraycopy(x, offset, xKnots, 0, numKnots);
System.arraycopy(y, offset, yKnots, 0, numKnots);
System.arraycopy(types, offset, knotTypes, 0, numKnots);
sortKnots();
rebuildGradient();
} | java | {
"resource": ""
} |
q6224 | Gradient.splitSpan | train | public void splitSpan(int n) {
int x = (xKnots[n] + xKnots[n+1])/2;
addKnot(x, getColor(x/256.0f), knotTypes[n]);
rebuildGradient();
} | java | {
"resource": ""
} |
q6225 | Gradient.knotAt | train | public int knotAt(int x) {
for (int i = 1; i < numKnots-1; i++)
if (xKnots[i+1] > x)
return i;
return 1;
} | java | {
"resource": ""
} |
q6226 | Gradient.randomize | train | public void randomize() {
numKnots = 4 + (int)(6*Math.random());
xKnots = new int[numKnots];
yKnots = new int[numKnots];
knotTypes = new byte[numKnots];
for (int i = 0; i < numKnots; i++) {
xKnots[i] = (int)(255 * Math.random());
yKnots[i] = 0xff000000 | ((int)(255 * Math.random()) << 16) | ((int)(255 * Math.random()) << 8) | (int)(255 * Math.random());
knotTypes[i] = RGB|SPLINE;
}
xKnots[0] = -1;
xKnots[1] = 0;
xKnots[numKnots-2] = 255;
xKnots[numKnots-1] = 256;
sortKnots();
rebuildGradient();
} | java | {
"resource": ""
} |
q6227 | Gradient.mutate | train | public void mutate(float amount) {
for (int i = 0; i < numKnots; i++) {
int rgb = yKnots[i];
int r = ((rgb >> 16) & 0xff);
int g = ((rgb >> 8) & 0xff);
int b = (rgb & 0xff);
r = PixelUtils.clamp( (int)(r + amount * 255 * (Math.random()-0.5)) );
g = PixelUtils.clamp( (int)(g + amount * 255 * (Math.random()-0.5)) );
b = PixelUtils.clamp( (int)(b + amount * 255 * (Math.random()-0.5)) );
yKnots[i] = 0xff000000 | (r << 16) | (g << 8) | b;
knotTypes[i] = RGB|SPLINE;
}
sortKnots();
rebuildGradient();
} | java | {
"resource": ""
} |
q6228 | MarvinImage.setBufferedImage | train | public void setBufferedImage(BufferedImage img) {
image = img;
width = img.getWidth();
height = img.getHeight();
updateColorArray();
} | java | {
"resource": ""
} |
q6229 | MarvinImage.getNewImageInstance | train | public BufferedImage getNewImageInstance() {
BufferedImage buf = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
buf.setData(image.getData());
return buf;
} | java | {
"resource": ""
} |
q6230 | MarvinImage.getBufferedImage | train | public BufferedImage getBufferedImage(int width, int height) {
// using the new approach of Java 2D API
BufferedImage buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = (Graphics2D) buf.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2d.drawImage(image, 0, 0, width, height, null);
g2d.dispose();
return (buf);
} | java | {
"resource": ""
} |
q6231 | MarvinImage.resize | train | public void resize(int w, int h) {
// using the new approach of Java 2D API
BufferedImage buf = new BufferedImage(w, h, image.getType());
Graphics2D g2d = (Graphics2D) buf.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2d.drawImage(image, 0, 0, w, h, null);
g2d.dispose();
image = buf;
width = w;
height = h;
updateColorArray();
} | java | {
"resource": ""
} |
q6232 | MarvinImage.multi8p | train | public double multi8p(int x, int y, double masc) {
int aR = getIntComponent0(x - 1, y - 1);
int bR = getIntComponent0(x - 1, y);
int cR = getIntComponent0(x - 1, y + 1);
int aG = getIntComponent1(x - 1, y - 1);
int bG = getIntComponent1(x - 1, y);
int cG = getIntComponent1(x - 1, y + 1);
int aB = getIntComponent1(x - 1, y - 1);
int bB = getIntComponent1(x - 1, y);
int cB = getIntComponent1(x - 1, y + 1);
int dR = getIntComponent0(x, y - 1);
int eR = getIntComponent0(x, y);
int fR = getIntComponent0(x, y + 1);
int dG = getIntComponent1(x, y - 1);
int eG = getIntComponent1(x, y);
int fG = getIntComponent1(x, y + 1);
int dB = getIntComponent1(x, y - 1);
int eB = getIntComponent1(x, y);
int fB = getIntComponent1(x, y + 1);
int gR = getIntComponent0(x + 1, y - 1);
int hR = getIntComponent0(x + 1, y);
int iR = getIntComponent0(x + 1, y + 1);
int gG = getIntComponent1(x + 1, y - 1);
int hG = getIntComponent1(x + 1, y);
int iG = getIntComponent1(x + 1, y + 1);
int gB = getIntComponent1(x + 1, y - 1);
int hB = getIntComponent1(x + 1, y);
int iB = getIntComponent1(x + 1, y + 1);
double rgb = 0;
rgb = ((aR * masc) + (bR * masc) + (cR * masc) +
(dR * masc) + (eR * masc) + (fR * masc) +
(gR * masc) + (hR * masc) + (iR * masc));
return (rgb);
} | java | {
"resource": ""
} |
q6233 | MarvinImage.fillRect | train | public void fillRect(int x, int y, int w, int h, Color c) {
int color = c.getRGB();
for (int i = x; i < x + w; i++) {
for (int j = y; j < y + h; j++) {
setIntColor(i, j, color);
}
}
} | java | {
"resource": ""
} |
q6234 | TransitionFilter.prepareFilter | train | public void prepareFilter( float transition ) {
try {
method.invoke( filter, new Object[] { new Float( transition ) } );
}
catch ( Exception e ) {
throw new IllegalArgumentException("Error setting value for property: "+property);
}
} | java | {
"resource": ""
} |
q6235 | MarvinColorModelConverter.rgbToBinary | train | public static MarvinImage rgbToBinary(MarvinImage img, int threshold) {
MarvinImage resultImage = new MarvinImage(img.getWidth(), img.getHeight(), MarvinImage.COLOR_MODEL_BINARY);
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int gray = (int) ((img.getIntComponent0(x, y) * 0.3) + (img.getIntComponent1(x, y) * 0.59) + (img.getIntComponent2(x, y) * 0.11));
if (gray <= threshold) {
resultImage.setBinaryColor(x, y, true);
} else {
resultImage.setBinaryColor(x, y, false);
}
}
}
return resultImage;
} | java | {
"resource": ""
} |
q6236 | MarvinColorModelConverter.binaryToRgb | train | public static MarvinImage binaryToRgb(MarvinImage img) {
MarvinImage resultImage = new MarvinImage(img.getWidth(), img.getHeight(), MarvinImage.COLOR_MODEL_RGB);
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
if (img.getBinaryColor(x, y)) {
resultImage.setIntColor(x, y, 0, 0, 0);
} else {
resultImage.setIntColor(x, y, 255, 255, 255);
}
}
}
return resultImage;
} | java | {
"resource": ""
} |
q6237 | MarvinColorModelConverter.binaryToRgb | train | public static int[] binaryToRgb(boolean[] binaryArray) {
int[] rgbArray = new int[binaryArray.length];
for (int i = 0; i < binaryArray.length; i++) {
if (binaryArray[i]) {
rgbArray[i] = 0x00000000;
} else {
rgbArray[i] = 0x00FFFFFF;
}
}
return rgbArray;
} | java | {
"resource": ""
} |
q6238 | SwimFilter.setAngle | train | public void setAngle(float angle) {
this.angle = angle;
float cos = (float) Math.cos(angle);
float sin = (float) Math.sin(angle);
m00 = cos;
m01 = sin;
m10 = -sin;
m11 = cos;
} | java | {
"resource": ""
} |
q6239 | AutocropOps.scanright | train | public static int scanright(Color color, int height, int width, int col, PixelsExtractor f, int tolerance) {
if (col == width || !PixelTools.colorMatches(color, tolerance, f.apply(new Area(col, 0, 1, height))))
return col;
else
return scanright(color, height, width, col + 1, f, tolerance);
} | java | {
"resource": ""
} |
q6240 | MarvinImageMask.clear | train | public void clear() {
if (arrMask != null) {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
arrMask[x][y] = false;
}
}
}
} | java | {
"resource": ""
} |
q6241 | AwtImage.pixels | train | public Pixel[] pixels() {
Pixel[] pixels = new Pixel[count()];
Point[] points = points();
for (int k = 0; k < points.length; k++) {
pixels[k] = pixel(points[k]);
}
return pixels;
} | java | {
"resource": ""
} |
q6242 | AwtImage.forall | train | public boolean forall(PixelPredicate predicate) {
return Arrays.stream(points()).allMatch(p -> predicate.test(p.x, p.y, pixel(p)));
} | java | {
"resource": ""
} |
q6243 | AwtImage.foreach | train | public void foreach(PixelFunction fn) {
Arrays.stream(points()).forEach(p -> fn.apply(p.x, p.y, pixel(p)));
} | java | {
"resource": ""
} |
q6244 | AwtImage.contains | train | public boolean contains(Color color) {
return exists(p -> p.toInt() == color.toPixel().toInt());
} | java | {
"resource": ""
} |
q6245 | AwtImage.argb | train | public int[] argb(int x, int y) {
Pixel p = pixel(x, y);
return new int[]{p.alpha(), p.red(), p.green(), p.blue()};
} | java | {
"resource": ""
} |
q6246 | AwtImage.argb | train | public int[][] argb() {
return Arrays.stream(points()).map(p -> argb(p.x, p.y)).toArray(int[][]::new);
} | java | {
"resource": ""
} |
q6247 | AwtImage.colours | train | public Set<RGBColor> colours() {
return stream().map(Pixel::toColor).collect(Collectors.toSet());
} | java | {
"resource": ""
} |
q6248 | AwtImage.toNewBufferedImage | train | public BufferedImage toNewBufferedImage(int type) {
BufferedImage target = new BufferedImage(width, height, type);
Graphics2D g2 = (Graphics2D) target.getGraphics();
g2.drawImage(awt, 0, 0, null);
g2.dispose();
return target;
} | java | {
"resource": ""
} |
q6249 | DimensionTools.dimensionsToFit | train | public static Dimension dimensionsToFit(Dimension target, Dimension source) {
// if target width/height is zero then we have no preference for that, so set it to the original value,
// since it cannot be any larger
int maxWidth;
if (target.getX() == 0) {
maxWidth = source.getX();
} else {
maxWidth = target.getX();
}
int maxHeight;
if (target.getY() == 0) {
maxHeight = source.getY();
} else {
maxHeight = target.getY();
}
double wscale = maxWidth / (double) source.getX();
double hscale = maxHeight / (double) source.getY();
if (wscale < hscale)
return new Dimension((int) (source.getX() * wscale), (int) (source.getY() * wscale));
else
return new Dimension((int) (source.getX() * hscale), (int) (source.getY() * hscale));
} | java | {
"resource": ""
} |
q6250 | GammaFilter.setGamma | train | public void setGamma(float rGamma, float gGamma, float bGamma) {
this.rGamma = rGamma;
this.gGamma = gGamma;
this.bGamma = bGamma;
initialized = false;
} | java | {
"resource": ""
} |
q6251 | ArrayColormap.setColorInterpolated | train | public void setColorInterpolated(int index, int firstIndex, int lastIndex, int color) {
int firstColor = map[firstIndex];
int lastColor = map[lastIndex];
for (int i = firstIndex; i <= index; i++)
map[i] = ImageMath.mixColors((float)(i-firstIndex)/(index-firstIndex), firstColor, color);
for (int i = index; i < lastIndex; i++)
map[i] = ImageMath.mixColors((float)(i-index)/(lastIndex-index), color, lastColor);
} | java | {
"resource": ""
} |
q6252 | ArrayColormap.setColorRange | train | public void setColorRange(int firstIndex, int lastIndex, int color1, int color2) {
for (int i = firstIndex; i <= lastIndex; i++)
map[i] = ImageMath.mixColors((float)(i-firstIndex)/(lastIndex-firstIndex), color1, color2);
} | java | {
"resource": ""
} |
q6253 | ArrayColormap.setColorRange | train | public void setColorRange(int firstIndex, int lastIndex, int color) {
for (int i = firstIndex; i <= lastIndex; i++)
map[i] = color;
} | java | {
"resource": ""
} |
q6254 | MainActivity.buttonClick | train | public void buttonClick(View v) {
switch (v.getId()) {
case R.id.show:
showAppMsg();
break;
case R.id.cancel_all:
AppMsg.cancelAll(this);
break;
default:
return;
}
} | java | {
"resource": ""
} |
q6255 | AppMsg.getLayoutParams | train | public LayoutParams getLayoutParams() {
if (mLayoutParams == null) {
mLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
}
return mLayoutParams;
} | java | {
"resource": ""
} |
q6256 | AppMsg.setLayoutGravity | train | public AppMsg setLayoutGravity(int gravity) {
mLayoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, gravity);
return this;
} | java | {
"resource": ""
} |
q6257 | StrategyUtils.getPercentage | train | public static int getPercentage(String percentage) {
if (isNotEmpty(percentage) && isNumeric(percentage)) {
int p = Integer.parseInt(percentage);
return p;
} else {
return 0;
}
} | java | {
"resource": ""
} |
q6258 | App.named | train | public App named(String name) {
App newApp = copy();
newApp.name = name;
return newApp;
} | java | {
"resource": ""
} |
q6259 | App.on | train | public App on(Heroku.Stack stack) {
App newApp = copy();
newApp.stack = new App.Stack(stack);
return newApp;
} | java | {
"resource": ""
} |
q6260 | HerokuAPI.listApps | train | public Range<App> listApps(String range) {
return connection.execute(new AppList(range), apiKey);
} | java | {
"resource": ""
} |
q6261 | HerokuAPI.renameApp | train | public String renameApp(String appName, String newName) {
return connection.execute(new AppRename(appName, newName), apiKey).getName();
} | java | {
"resource": ""
} |
q6262 | HerokuAPI.addAddon | train | public AddonChange addAddon(String appName, String addonName) {
return connection.execute(new AddonInstall(appName, addonName), apiKey);
} | java | {
"resource": ""
} |
q6263 | HerokuAPI.listAppAddons | train | public List<Addon> listAppAddons(String appName) {
return connection.execute(new AppAddonsList(appName), apiKey);
} | java | {
"resource": ""
} |
q6264 | HerokuAPI.removeAddon | train | public AddonChange removeAddon(String appName, String addonName) {
return connection.execute(new AddonRemove(appName, addonName), apiKey);
} | java | {
"resource": ""
} |
q6265 | HerokuAPI.listReleases | train | public List<Release> listReleases(String appName) {
return connection.execute(new ReleaseList(appName), apiKey);
} | java | {
"resource": ""
} |
q6266 | HerokuAPI.rollback | train | public Release rollback(String appName, String releaseUuid) {
return connection.execute(new Rollback(appName, releaseUuid), apiKey);
} | java | {
"resource": ""
} |
q6267 | HerokuAPI.getReleaseInfo | train | public Release getReleaseInfo(String appName, String releaseName) {
return connection.execute(new ReleaseInfo(appName, releaseName), apiKey);
} | java | {
"resource": ""
} |
q6268 | HerokuAPI.listCollaborators | train | public List<Collaborator> listCollaborators(String appName) {
return connection.execute(new CollabList(appName), apiKey);
} | java | {
"resource": ""
} |
q6269 | HerokuAPI.addCollaborator | train | public void addCollaborator(String appName, String collaborator) {
connection.execute(new SharingAdd(appName, collaborator), apiKey);
} | java | {
"resource": ""
} |
q6270 | HerokuAPI.removeCollaborator | train | public void removeCollaborator(String appName, String collaborator) {
connection.execute(new SharingRemove(appName, collaborator), apiKey);
} | java | {
"resource": ""
} |
q6271 | HerokuAPI.updateConfig | train | public void updateConfig(String appName, Map<String, String> config) {
connection.execute(new ConfigUpdate(appName, config), apiKey);
} | java | {
"resource": ""
} |
q6272 | HerokuAPI.listConfig | train | public Map<String, String> listConfig(String appName) {
return connection.execute(new ConfigList(appName), apiKey);
} | java | {
"resource": ""
} |
q6273 | HerokuAPI.transferApp | train | public void transferApp(String appName, String to) {
connection.execute(new SharingTransfer(appName, to), apiKey);
} | java | {
"resource": ""
} |
q6274 | HerokuAPI.getLogs | train | public LogStreamResponse getLogs(String appName, Boolean tail) {
return connection.execute(new Log(appName, tail), apiKey);
} | java | {
"resource": ""
} |
q6275 | HerokuAPI.getLogs | train | public LogStreamResponse getLogs(Log.LogRequestBuilder logRequest) {
return connection.execute(new Log(logRequest), apiKey);
} | java | {
"resource": ""
} |
q6276 | HerokuAPI.isMaintenanceModeEnabled | train | public boolean isMaintenanceModeEnabled(String appName) {
App app = connection.execute(new AppInfo(appName), apiKey);
return app.isMaintenance();
} | java | {
"resource": ""
} |
q6277 | HerokuAPI.setMaintenanceMode | train | public void setMaintenanceMode(String appName, boolean enable) {
connection.execute(new AppUpdate(appName, enable), apiKey);
} | java | {
"resource": ""
} |
q6278 | HerokuAPI.createBuild | train | public Build createBuild(String appName, Build build) {
return connection.execute(new BuildCreate(appName, build), apiKey);
} | java | {
"resource": ""
} |
q6279 | HerokuAPI.getBuildInfo | train | public Build getBuildInfo(String appName, String buildId) {
return connection.execute(new BuildInfo(appName, buildId), apiKey);
} | java | {
"resource": ""
} |
q6280 | HerokuAPI.listDynos | train | public Range<Dyno> listDynos(String appName) {
return connection.execute(new DynoList(appName), apiKey);
} | java | {
"resource": ""
} |
q6281 | HerokuAPI.restartDyno | train | public void restartDyno(String appName, String dynoId) {
connection.execute(new DynoRestart(appName, dynoId), apiKey);
} | java | {
"resource": ""
} |
q6282 | HerokuAPI.scale | train | public Formation scale(String appName, String processType, int quantity) {
return connection.execute(new FormationUpdate(appName, processType, quantity), apiKey);
} | java | {
"resource": ""
} |
q6283 | HerokuAPI.listFormation | train | public List<Formation> listFormation(String appName) {
return connection.execute(new FormationList(appName), apiKey);
} | java | {
"resource": ""
} |
q6284 | HerokuAPI.listBuildpackInstallations | train | public List<BuildpackInstallation> listBuildpackInstallations(String appName) {
return connection.execute(new BuildpackInstallationList(appName), apiKey);
} | java | {
"resource": ""
} |
q6285 | HerokuAPI.updateBuildpackInstallations | train | public void updateBuildpackInstallations(String appName, List<String> buildpacks) {
connection.execute(new BuildpackInstallationUpdate(appName, buildpacks), apiKey);
} | java | {
"resource": ""
} |
q6286 | Analyzer.resolveConstrained | train | static Artifact resolveConstrained(MavenProject project, String gav, Pattern versionRegex,
ArtifactResolver resolver)
throws VersionRangeResolutionException, ArtifactResolutionException {
boolean latest = gav.endsWith(":LATEST");
if (latest || gav.endsWith(":RELEASE")) {
Artifact a = new DefaultArtifact(gav);
if (latest) {
versionRegex = versionRegex == null ? ANY : versionRegex;
} else {
versionRegex = versionRegex == null ? ANY_NON_SNAPSHOT : versionRegex;
}
String upTo = project.getGroupId().equals(a.getGroupId()) && project.getArtifactId().equals(a.getArtifactId())
? project.getVersion()
: null;
return resolver.resolveNewestMatching(gav, upTo, versionRegex, latest, latest);
} else {
String projectGav = getProjectArtifactCoordinates(project, null);
Artifact ret = null;
if (projectGav.equals(gav)) {
ret = findProjectArtifact(project);
}
return ret == null ? resolver.resolveArtifact(gav) : ret;
}
} | java | {
"resource": ""
} |
q6287 | ServiceTypeLoader.load | train | public static <X> ServiceTypeLoader<X> load(Class<X> serviceType) {
return load(serviceType, Thread.currentThread().getContextClassLoader());
} | java | {
"resource": ""
} |
q6288 | JSONUtil.stringifyJavascriptObject | train | public static String stringifyJavascriptObject(Object object) {
StringBuilder bld = new StringBuilder();
stringify(object, bld);
return bld.toString();
} | java | {
"resource": ""
} |
q6289 | CheckBase.popIfActive | train | @Nullable
@SuppressWarnings("unchecked")
protected <T extends JavaElement> ActiveElements<T> popIfActive() {
return (ActiveElements<T>) (!activations.isEmpty() && activations.peek().depth == depth ? activations.pop() :
null);
} | java | {
"resource": ""
} |
q6290 | AnalysisContext.builder | train | @Nonnull
public static Builder builder(Revapi revapi) {
List<String> knownExtensionIds = new ArrayList<>();
addExtensionIds(revapi.getPipelineConfiguration().getApiAnalyzerTypes(), knownExtensionIds);
addExtensionIds(revapi.getPipelineConfiguration().getTransformTypes(), knownExtensionIds);
addExtensionIds(revapi.getPipelineConfiguration().getFilterTypes(), knownExtensionIds);
addExtensionIds(revapi.getPipelineConfiguration().getReporterTypes(), knownExtensionIds);
return new Builder(knownExtensionIds);
} | java | {
"resource": ""
} |
q6291 | AnalysisContext.copyWithConfiguration | train | public AnalysisContext copyWithConfiguration(ModelNode configuration) {
return new AnalysisContext(this.locale, configuration, this.oldApi, this.newApi, this.data);
} | java | {
"resource": ""
} |
q6292 | PipelineConfiguration.parse | train | public static PipelineConfiguration.Builder parse(ModelNode json) {
ModelNode analyzerIncludeNode = json.get("analyzers").get("include");
ModelNode analyzerExcludeNode = json.get("analyzers").get("exclude");
ModelNode filterIncludeNode = json.get("filters").get("include");
ModelNode filterExcludeNode = json.get("filters").get("exclude");
ModelNode transformIncludeNode = json.get("transforms").get("include");
ModelNode transformExcludeNode = json.get("transforms").get("exclude");
ModelNode reporterIncludeNode = json.get("reporters").get("include");
ModelNode reporterExcludeNode = json.get("reporters").get("exclude");
return builder()
.withTransformationBlocks(json.get("transformBlocks"))
.withAnalyzerExtensionIdsInclude(asStringList(analyzerIncludeNode))
.withAnalyzerExtensionIdsExclude(asStringList(analyzerExcludeNode))
.withFilterExtensionIdsInclude(asStringList(filterIncludeNode))
.withFilterExtensionIdsExclude(asStringList(filterExcludeNode))
.withTransformExtensionIdsInclude(asStringList(transformIncludeNode))
.withTransformExtensionIdsExclude(asStringList(transformExcludeNode))
.withReporterExtensionIdsInclude(asStringList(reporterIncludeNode))
.withReporterExtensionIdsExclude(asStringList(reporterExcludeNode));
} | java | {
"resource": ""
} |
q6293 | Util.firstDotConstellation | train | private static void firstDotConstellation(int[] dollarPositions, int[] dotPositions, int nestingLevel) {
int i = 0;
int unassigned = dotPositions.length - nestingLevel;
for (; i < unassigned; ++i) {
dotPositions[i] = -1;
}
for (; i < dotPositions.length; ++i) {
dotPositions[i] = dollarPositions[i];
}
} | java | {
"resource": ""
} |
q6294 | AnalysisResult.fakeSuccess | train | public static AnalysisResult fakeSuccess() {
return new AnalysisResult(null, new Extensions(Collections.emptyMap(), Collections.emptyMap(),
Collections.emptyMap(), Collections.emptyMap()));
} | java | {
"resource": ""
} |
q6295 | SchemaDrivenJSONToXmlConverter.convert | train | static PlexusConfiguration convert(ModelNode configuration, ModelNode jsonSchema, String extensionId, String id) {
ConversionContext ctx = new ConversionContext();
ctx.currentSchema = jsonSchema;
ctx.rootSchema = jsonSchema;
ctx.pushTag(extensionId);
ctx.id = id;
return convert(configuration, ctx);
} | java | {
"resource": ""
} |
q6296 | TypeDescriptor.getAnnotation | train | @SuppressWarnings("unchecked")
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
for (Annotation annotation : this.annotations) {
if (annotation.annotationType().equals(annotationType)) {
return (T) annotation;
}
}
for (Annotation metaAnn : this.annotations) {
T ann = metaAnn.annotationType().getAnnotation(annotationType);
if (ann != null) {
return ann;
}
}
return null;
} | java | {
"resource": ""
} |
q6297 | UriUtils.encodeScheme | train | public static String encodeScheme(String scheme, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(scheme, encoding, HierarchicalUriComponents.Type.SCHEME);
} | java | {
"resource": ""
} |
q6298 | UriUtils.encodeAuthority | train | public static String encodeAuthority(String authority, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(authority, encoding, HierarchicalUriComponents.Type.AUTHORITY);
} | java | {
"resource": ""
} |
q6299 | UriUtils.encodeUserInfo | train | public static String encodeUserInfo(String userInfo, String encoding) throws UnsupportedEncodingException {
return HierarchicalUriComponents.encodeUriComponent(userInfo, encoding, HierarchicalUriComponents.Type.USER_INFO);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.