Function bodies 149 total
Algorithm method · java · L28-L31 (4 LOC)app/src/main/java/byrne/fractal/Algorithm.java
Algorithm(int i,int b) {
native_integer = i;
bailout = b;
}getInt method · java · L33-L35 (3 LOC)app/src/main/java/byrne/fractal/Algorithm.java
int getInt() {
return native_integer;
}getBailout method · java · L37-L39 (3 LOC)app/src/main/java/byrne/fractal/Algorithm.java
int getBailout() {
return bailout;
}ComplexEquation method · java · L39-L42 (4 LOC)app/src/main/java/byrne/fractal/ComplexEquation.java
ComplexEquation(int i, int p) {
native_integer = i;
power = p;
}getInt method · java · L45-L47 (3 LOC)app/src/main/java/byrne/fractal/ComplexEquation.java
int getInt() {
return native_integer;
}getPower method · java · L50-L52 (3 LOC)app/src/main/java/byrne/fractal/ComplexEquation.java
int getPower() {
return power;
}Eula class · java · L35-L111 (77 LOC)app/src/main/java/byrne/fractal/Eula.java
class Eula {
private static final String PREFERENCE_EULA_ACCEPTED = "eula.accepted";
private static final String PREFERENCES_EULA = "eula";
/**
* Displays the EULA if necessary. This method should be called from the onCreate()
* method of your main Activity.
*
* @param activity The Activity to finish if the user rejects the EULA.
*/
static void showEula(final Activity activity) {
final SharedPreferences preferences = activity.getSharedPreferences(PREFERENCES_EULA,
Activity.MODE_PRIVATE);
if (!preferences.getBoolean(PREFERENCE_EULA_ACCEPTED, false)) {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.eula_title);
builder.setCancelable(true);
builder.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
aRepobility · open methodology · https://repobility.com/research/
showEula method · java · L45-L71 (27 LOC)app/src/main/java/byrne/fractal/Eula.java
static void showEula(final Activity activity) {
final SharedPreferences preferences = activity.getSharedPreferences(PREFERENCES_EULA,
Activity.MODE_PRIVATE);
if (!preferences.getBoolean(PREFERENCE_EULA_ACCEPTED, false)) {
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.eula_title);
builder.setCancelable(true);
builder.setPositiveButton(R.string.eula_accept, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
accept(preferences);
}
});
builder.setNegativeButton(R.string.eula_refuse, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
refuse(activity);
}
});
builder.setOnCancelListener(new DialogInterface.OnCancelListenonClick method · java · L53-L55 (3 LOC)app/src/main/java/byrne/fractal/Eula.java
public void onClick(DialogInterface dialog, int which) {
accept(preferences);
}onClick method · java · L58-L60 (3 LOC)app/src/main/java/byrne/fractal/Eula.java
public void onClick(DialogInterface dialog, int which) {
refuse(activity);
}onCancel method · java · L63-L65 (3 LOC)app/src/main/java/byrne/fractal/Eula.java
public void onCancel(DialogInterface dialog) {
refuse(activity);
}accept method · java · L73-L75 (3 LOC)app/src/main/java/byrne/fractal/Eula.java
private static void accept(SharedPreferences preferences) {
preferences.edit().putBoolean(PREFERENCE_EULA_ACCEPTED, true).commit();
}refuse method · java · L77-L79 (3 LOC)app/src/main/java/byrne/fractal/Eula.java
private static void refuse(Activity activity) {
activity.finish();
}readFile method · java · L81-L95 (15 LOC)app/src/main/java/byrne/fractal/Eula.java
private static CharSequence readFile(Activity activity, int id) {
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(
activity.getResources().openRawResource(id)));
String line;
StringBuilder buffer = new StringBuilder();
while ((line = in.readLine()) != null) buffer.append(line).append('\n');
return buffer;
} catch (IOException e) {
return "";
} finally {
closeStream(in);
}
}closeStream method · java · L102-L110 (9 LOC)app/src/main/java/byrne/fractal/Eula.java
private static void closeStream(Closeable stream) {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
// Ignore
}
}
}About: code-quality intelligence by Repobility · https://repobility.com
FractalType method · java · L26-L28 (3 LOC)app/src/main/java/byrne/fractal/FractalType.java
FractalType(int i) {
native_integer = i;
}getInt method · java · L29-L31 (3 LOC)app/src/main/java/byrne/fractal/FractalType.java
public int getInt() {
return native_integer;
}FractalView method · java · L58-L63 (6 LOC)app/src/main/java/byrne/fractal/FractalView.java
public FractalView(Context context, AttributeSet attrs) {
super(context, attrs);
res = context.getResources();
multiTouchController = new MultiTouchController<FractalView.Img>(this);
this.setEquation(ComplexEquation.SECOND_ORDER);
}setFractoid method · java · L65-L67 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setFractoid(Fractoid f) {
mFractoid = f;
}quadColorScheme method · java · L69-L96 (28 LOC)app/src/main/java/byrne/fractal/FractalView.java
private void quadColorScheme(int numberOfColors,int[] color1,int[] color2,int[] color3,int[] color4) {
for (int x = 0; x < numberOfColors; x++) {
int value = (x%1020);
int color;
if (value <= 255) {
colorIntegers[x] = Color.rgb((int)((double)((color2[0]-color1[0])/255.0)*value + color1[0]),
(int)((double)((color2[1]-color1[1])/255.0)*value + color1[1]),
(int)((double)((color2[2]-color1[2])/255.0)*value + color1[2])
);
} else if (value <= 510) {
colorIntegers[x] = Color.rgb((int)((double)((color3[0]-color2[0])/255.0)*(value-255) + color2[0]),
(int)((double)((color3[1]-color2[1])/255.0)*(value-255) + color2[1]),
(int)((double)((color3[2]-color2[2])/255.0)*(value-255) + color2[2])
);
} else if (value <= 765) {
calculateColors method · java · L99-L199 (101 LOC)app/src/main/java/byrne/fractal/FractalView.java
private void calculateColors(int numberOfColors) {
int[] color1,color2,color3,color4;
double red, green, blue;
colorIntegers = new int[numberOfColors];
switch (colorSet) {
case RAINBOW:
for (int x = 0; x < numberOfColors; x++) {
double data = x;
data = 2*Math.PI*(data/1020);
red = Math.sin(data + Math.PI*shiftFactor);
green = Math.cos(data + Math.PI*shiftFactor);
blue = -((red + green)*.707);
red = (red*127.0) + 127.0;
green = (green*127.0) + 127.0;
blue = (blue*127.0) + 127.0;
colorIntegers[x] = Color.rgb((int)red, (int)green, (int)blue);
}
break;
case WINTER:
for (int x = 0; x < numberOfColors; x++) {
int value = (x%1020)/2;
int color;
if (value <= 255)
color = value;
else
color = 255-(value-255);
colorIntegers[x] = Color.rgb(255-color,255-csetColorSet method · java · L202-L206 (5 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setColorSet(ColorSet cs) {
colorSet = cs;
calculateColors(1021);
startFractalTask(false);
}setAlgorithm method · java · L208-L211 (4 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setAlgorithm(Algorithm alg) {
mNativeLib.setAlgorithm(alg.getInt(),alg.getBailout());
startFractalTask(true);
}Repobility · code-quality intelligence · https://repobility.com
setTrapFactor method · java · L213-L217 (5 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setTrapFactor(int tf) {
mNativeLib.setTrapFactor(tf);
trapFactor = tf;
startFractalTask(true);
}getTrapFactor method · java · L219-L221 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public int getTrapFactor() {
return trapFactor;
}getColorSet method · java · L223-L225 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public int[] getColorSet() {
return colorIntegers;
}getEquation method · java · L227-L229 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public ComplexEquation getEquation() {
return equation;
}setEquation method · java · L231-L234 (4 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setEquation(ComplexEquation e) {
equation = e;
mNativeLib.setEquation(e.getInt(),e.getPower());
}setZoom method · java · L236-L238 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setZoom(boolean z) {
zoom = z;
}getMaxIterations method · java · L240-L242 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public int getMaxIterations() {
return maxIterations;
}setMaxIterations method · java · L244-L248 (5 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setMaxIterations(int i) {
mNativeLib.setMaxIterations(i);
maxIterations = i;
startFractalTask(true);
}All rows above produced by Repobility · https://repobility.com
recalculate method · java · L250-L295 (46 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void recalculate() {
double imagmin = mNativeLib.getImagMin();
double imagmax = mNativeLib.getImagMax();
double realmin = mNativeLib.getRealMin();
double realmax = mNativeLib.getRealMax();
double realRange = Math.abs(realmax-realmin);
double imagRange = Math.abs(imagmax-imagmin);
double half_irange = imagRange/2;
double half_rrange = realRange/2;
double centerX = (double)fractalBitmap.getCenterX();
double centerY = (double)fractalBitmap.getCenterY();
double scale = (double)fractalBitmap.getScale();
double xres = (double)mNativeLib.getXRes();
double yres = (double)mNativeLib.getYRes();
double offsetX = realmin + half_rrange;
double offsetY = imagmin + half_irange;
realmin = realmin - offsetX;
realmax = realmax - offsetX;
imagmin = imagmin - offsetY;
imagmax = imagmax - offsetY;
double image_y_center = (imagmin + (centerY/yres)*imagRange)/scale;
double image_x_center = (realgetType method · java · L297-L299 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public FractalType getType() {
return fractalType;
}setProgress method · java · L301-L303 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setProgress(float p) {
progress = p;
}getFractal method · java · L305-L307 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public Bitmap getFractal() {
return fractalBitmap.getDrawable().getBitmap();
}turnCalibrateButtonOn method · java · L309-L311 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void turnCalibrateButtonOn() {
mFractoid.setCalibrateButtonEnabled(true,relative);
}stopFractalTask method · java · L313-L318 (6 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void stopFractalTask() {
if (mGenerateFractalTask != null && mGenerateFractalTask.getStatus() == Status.RUNNING) {
mGenerateFractalTask.cancel(true);
}
}startFractalTask method · java · L320-L339 (20 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void startFractalTask(boolean reset) {
setFull = true;
progress = 0;
calculationTime = null;
stopFractalTask();
if (reset) {
mNativeLib.resetValues();
relative = false;
}
mNativeLib.resetCurrentRow();
mFractoid.setCalibrateButtonEnabled(false,relative);
calculateColors(1021);
mGenerateFractalTask = new GenerateFractalTask(this,relative);
System.out.println("Starting new fractal");
mGenerateFractalTask.execute();
}setRelative method · java · L343-L345 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setRelative(boolean r) {
relative = r;
}Repobility · open methodology · https://repobility.com/research/
setFractal method · java · L347-L356 (10 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setFractal(Bitmap fa) {
BitmapDrawable bd = new BitmapDrawable(res, fa);
if (setFull) {
fractalBitmap = new Img(bd, res);
fractalBitmap.setFullScreen();
setFull = false;
} else {
fractalBitmap.setDrawable(bd);
}
}setTime method · java · L358-L371 (14 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void setTime(long t) {
long time = t / 1000;
String seconds = Integer.toString((int)(time % 60));
String minutes = Integer.toString((int)(time / 60));
for (int i = 0; i < 2; i++) {
if (seconds.length() < 2) {
seconds = "0" + seconds;
}
if (minutes.length() < 2) {
minutes = "0" + minutes;
}
}
calculationTime = "Time: "+minutes+":"+seconds;
}resetCoords method · java · L373-L413 (41 LOC)app/src/main/java/byrne/fractal/FractalView.java
protected void resetCoords() {
double imagmax, imagmin;
if (equation == ComplexEquation.BURNING_SHIP) {
//This equation needs a special range to be centered
imagmax = 2.1;
imagmin = -0.7;
} else {
imagmax = 1.4;
imagmin = -1.4;
}
double r_y = Math.abs(imagmax - imagmin);
double realmax = ((double)mNativeLib.getXRes()/mNativeLib.getYRes())*r_y/2;
double realmin = ((double)mNativeLib.getXRes()/mNativeLib.getYRes())*r_y/2*-1;
shiftFactor = Math.random()*2;
mNativeLib.setCoords(realmin,realmax,imagmin,imagmax);
if (equation == ComplexEquation.PHOENIX) {
/*
The mandelbrot fractal for this equation is ugly so
we only allow the user to explore the Julia version
*/
mNativeLib.setFractalType(FractalType.JULIA.getInt());
fractalType = FractalType.JULIA;
mNativeLib.setCValue(0.56666667,-0.5); //magic number for the best julia set
mNativeLib.setMaxIteratioclearBackground method · java · L460-L462 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void clearBackground() {
backgroundBitmap = null;
}mergeBitmaps method · java · L464-L477 (14 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void mergeBitmaps() {
Bitmap composite = Bitmap.createBitmap(mNativeLib.getXRes(), mNativeLib.getYRes(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(composite);
if (backgroundBitmap != null) {
backgroundBitmap.draw(canvas);
clearBackground();
}
fractalBitmap.draw(canvas);
BitmapDrawable bd = new BitmapDrawable(res, composite);
fractalBitmap.setDrawable(bd);
fractalBitmap.setFullScreen();
}getDraggableObjectAtPoint method · java · L480-L489 (10 LOC)app/src/main/java/byrne/fractal/FractalView.java
public Img getDraggableObjectAtPoint(PointInfo pt) {
if (mGenerateFractalTask != null && mGenerateFractalTask.getStatus() == Status.RUNNING) {
mGenerateFractalTask.cancel(true);
}
mergeBitmaps();
return fractalBitmap;
}selectObject method · java · L495-L502 (8 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void selectObject(Img img, PointInfo touchPoint) {
if (img == null) {
System.out.println("fractalBitmap="+fractalBitmap.toString());
backgroundBitmap = fractalBitmap;
recalculate();
}
invalidate();
}getPositionAndScale method · java · L505-L508 (4 LOC)app/src/main/java/byrne/fractal/FractalView.java
public void getPositionAndScale(Img img, PositionAndScale objPosAndScaleOut) {
objPosAndScaleOut.set(img.getCenterX(), img.getCenterY(),true, img.getScale(),
false, 0.0f, 0.0f, false, 0.0f);
}About: code-quality intelligence by Repobility · https://repobility.com
setPositionAndScale method · java · L511-L519 (9 LOC)app/src/main/java/byrne/fractal/FractalView.java
public boolean setPositionAndScale(Img img, PositionAndScale newImgPosAndScale, PointInfo touchPoint) {
float x = newImgPosAndScale.getXOff();
float y = newImgPosAndScale.getYOff();
float scale = newImgPosAndScale.getScale();
boolean ok = img.setPos(x, y, scale);
if (ok)
invalidate();
return ok;
}Img class · java · L571-L658 (88 LOC)app/src/main/java/byrne/fractal/FractalView.java
class Img {
private BitmapDrawable drawable;
private int width, height, displayWidth, displayHeight;
private float centerX, centerY, scale;
private float minX, maxX, minY, maxY;
private static final float SCREEN_MARGIN = 100;
public Img(BitmapDrawable bd, Resources res) {
this.drawable = bd;
}
public void setFullScreen() {
width = mNativeLib.getXRes();
height = mNativeLib.getYRes();
displayHeight = mNativeLib.getYRes();
displayWidth = mNativeLib.getXRes();
setPos(mNativeLib.getXRes()/2.0f, mNativeLib.getYRes()/2.0f, 1.0f);
}
/** Set the position and scale of an image in screen coordinates */
private boolean setPos(float centerX, float centerY, float scale) {
float ws = (width / 2) * scale, hs = (height / 2) * scale;
float newMinX = centerX - ws, newMinY = centerY - hs, newMaxX = centerX + ws, newMaxY = centerY + hs;
if (newMinX > displayWidth - SCREEN_MARGIN || newMaxX < SCImg method · java · L579-L581 (3 LOC)app/src/main/java/byrne/fractal/FractalView.java
public Img(BitmapDrawable bd, Resources res) {
this.drawable = bd;
}page 1 / 3next ›